:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --ink: #172033;
    --muted: #6a7282;
    --line: #dde2eb;
    --brand: #1167b1;
    --brand-2: #0f9f86;
    --danger: #d04444;
    --warning: #b7791f;
    --ok: #16835f;
    --shadow: 0 12px 28px rgba(19, 34, 66, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--ink);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #e8f3ff, #f7fbf6);
}
.auth-card {
    width: min(430px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-mark {
    width: 46px; height: 46px; border-radius: 8px;
    background: var(--brand);
    color: #fff; display: grid; place-items: center; font-weight: 700;
}
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 7px; }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 11px 12px;
    background: #fff;
}
.field textarea { min-height: 100px; resize: vertical; }
.select2-container .select2-selection--single {
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
    color: var(--ink);
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; }
.btn {
    border: 0;
    border-radius: 7px;
    padding: 11px 14px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
}
.btn.secondary { background: #e8edf5; color: var(--ink); }
.btn.success { background: var(--brand-2); }
.btn.danger { background: var(--danger); }
.btn.full { width: 100%; }
.alert {
    padding: 11px 12px;
    border-radius: 7px;
    margin-bottom: 14px;
    background: #fff2f2;
    color: #9b2525;
    border: 1px solid #ffd3d3;
}
.alert.success {
    background: #ddf8ed;
    color: var(--ok);
    border-color: #bcebd8;
}

.app { min-height: 100vh; display: flex; }
.sidebar {
    width: 260px;
    background: #101827;
    color: #f7fafc;
    padding: 18px 14px;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
}
.sidebar .brand { margin: 0 6px 18px; }
.sidebar .brand-mark { background: var(--brand-2); }
.sidebar p { color: #b7c2d4; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #dbe4f0;
    padding: 11px 12px;
    border-radius: 7px;
    margin-bottom: 5px;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-sub {
    margin: -2px 0 8px 14px;
    padding-left: 8px;
    border-left: 1px solid rgba(255,255,255,.14);
}
.nav-sub a {
    padding: 8px 10px;
    font-size: 13px;
}
.main {
    flex: 1;
    margin-left: 260px;
    min-width: 0;
}
.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 3;
}
.menu-btn { display: none; }
.content { padding: 22px; }
.page-title { margin: 0 0 18px; font-size: 24px; }
.grid { display: grid; gap: 16px; }
.content > .grid + .grid { margin-top: 16px; }
.content > .card + .card { margin-top: 16px; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(19, 34, 66, .04);
    padding: 16px;
}
.stat .num { font-size: 28px; font-weight: 800; margin-top: 8px; }
.muted { color: var(--muted); }
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 99px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 700;
    background: #e8edf5;
}
.badge.ok { background: #ddf8ed; color: var(--ok); }
.badge.warn { background: #fff4db; color: var(--warning); }
.badge.danger { background: #ffe4e4; color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); background: #f9fafc; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.placement-search {
    margin: 0 0 12px;
}
.placement-search input {
    min-width: min(420px, 100%);
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 11px 12px;
}
.placement-actions { margin: 0 0 12px; }
.location-note { margin: 8px 0 14px; }
.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(420px, calc(100vw - 36px));
    background: #172033;
    color: #fff;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: .2s ease;
    z-index: 50;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-weight: 700;
    font-size: 13px;
}
.checkline input { width: auto; }
.mobile-tabs {
    display: none;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.mobile-tabs a {
    white-space: nowrap;
    padding: 9px 12px;
    border-radius: 99px;
    background: #eef2f7;
    font-size: 13px;
}
.mobile-tabs a.active { background: var(--brand); color: #fff; }
.presence-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.presence-tools { margin-top: 12px; }
.photo-preview {
    width: 96px;
    height: 72px;
    object-fit: cover;
    border-radius: 7px;
    border: 1px solid var(--line);
}

@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); transition: .2s ease; z-index: 8; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-btn { display: inline-flex; }
    .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.two, .presence-box { grid-template-columns: 1fr; }
    .mobile-tabs { display: flex; }
}

@media (max-width: 560px) {
    .topbar { padding: 0 14px; height: 58px; }
    .content { padding: 16px; }
    .page-title { font-size: 20px; }
    .grid.cards { grid-template-columns: 1fr; }
    .card { padding: 14px; }
    .btn { width: 100%; }
    .actions .btn { width: auto; flex: 1; }
    table { min-width: 620px; }
}
