        :root {
            --accent: #6366f1;
            --accent2: #8b5cf6;
            --success: #10b981;
            --danger: #f43f5e;
            --warning: #f59e0b;
            --bg: #0f1117;
            --surface: #1a1d27;
            --surface2: #21253a;
            --border: rgba(255,255,255,0.07);
            --text: #f1f5f9;
            --text-muted: #64748b;
            --text-dim: #94a3b8;
            --sidebar-w: 72px;
            --glow: 0 0 40px rgba(99,102,241,0.15);
        }
        * { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
        body { font-family:'Inter',sans-serif; background:var(--bg); color:var(--text); display:flex; min-height:100vh; overflow-x:hidden; }

        /* ── Sidebar (desktop) ──────────────────────── */
        .sidebar {
            width:var(--sidebar-w); background:var(--surface); border-right:1px solid var(--border);
            padding:20px 0; display:flex; flex-direction:column; align-items:center;
            position:fixed; top:0; left:0; bottom:0; z-index:200; gap:8px;
        }
        .logo-icon {
            width:42px; height:42px; background:linear-gradient(135deg,var(--accent),var(--accent2));
            border-radius:12px; display:flex; align-items:center; justify-content:center;
            font-size:18px; color:#fff; margin-bottom:16px; box-shadow:0 4px 20px rgba(99,102,241,0.4);
        }
        .nav { display:flex; flex-direction:column; align-items:center; gap:4px; flex:1; width:100%; padding:0 10px; }
        .nav-item {
            width:100%; aspect-ratio:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
            gap:4px; border-radius:12px; color:var(--text-muted); cursor:pointer;
            transition:all .2s; position:relative; font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.5px;
        }
        .nav-item i { font-size:18px; }
        .nav-item:hover { background:var(--surface2); color:var(--text-dim); }
        .nav-item.active { background:linear-gradient(135deg,rgba(99,102,241,.25),rgba(139,92,246,.15)); color:var(--accent); box-shadow:inset 0 0 0 1px rgba(99,102,241,.3); }
        .nav-item.active::before { content:''; position:absolute; left:-10px; top:50%; transform:translateY(-50%); width:3px; height:60%; background:var(--accent); border-radius:0 3px 3px 0; }
        .nav-bottom { padding:0 10px 8px; width:100%; }
        .nav-bottom .nav-item { aspect-ratio:1; }

        /* ── Main ───────────────────────────────────── */
        .main { flex:1; margin-left:var(--sidebar-w); min-width:0; display:flex; flex-direction:column; }

        /* ── Topbar ─────────────────────────────────── */
        .topbar {
            display:flex; align-items:center; justify-content:space-between;
            padding:20px 32px; border-bottom:1px solid var(--border); background:var(--surface);
            position:sticky; top:0; z-index:100;
        }
        .topbar-left { display:flex; align-items:center; gap:16px; }
        .section-title { font-size:20px; font-weight:700; }
        .topbar-right { display:flex; align-items:center; gap:10px; }
        .period-group { display:flex; align-items:center; background:var(--bg); border-radius:10px; padding:3px; border:1px solid var(--border); gap:2px; }
        .period-btn { padding:6px 14px; border-radius:8px; border:none; font-size:12px; font-weight:500; font-family:inherit; background:transparent; color:var(--text-muted); cursor:pointer; transition:all .15s; white-space:nowrap; }
        .period-btn.active { background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; box-shadow:0 2px 10px rgba(99,102,241,.4); }
        .period-sep { width:1px; height:18px; background:var(--border); flex-shrink:0; }
        .drp-wrap { position:relative; }
        .drp-btn { display:flex; align-items:center; gap:7px; padding:6px 12px; border-radius:8px; border:none; font-size:12px; font-weight:500; font-family:inherit; background:transparent; color:var(--text-muted); cursor:pointer; transition:all .15s; white-space:nowrap; }
        .drp-btn:hover { color:var(--text); }
        .drp-btn.active { background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; box-shadow:0 2px 10px rgba(99,102,241,.4); }
        .drp-btn i { font-size:12px; }
        .drp-popup { display:none; position:fixed; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:20px; z-index:600; box-shadow:0 20px 60px rgba(0,0,0,.6); min-width:320px; }
        .drp-popup.open { display:block; }
        .drp-popup h4 { font-size:13px; font-weight:600; margin-bottom:16px; color:var(--text-dim); }
        .drp-presets { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:16px; }
        .drp-preset { padding:5px 11px; border-radius:7px; border:1px solid var(--border); font-size:11px; font-weight:500; font-family:inherit; background:transparent; color:var(--text-muted); cursor:pointer; transition:all .15s; }
        .drp-preset:hover { border-color:var(--accent); color:var(--text); }
        .drp-inputs { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:14px; }
        .drp-field label { display:block; font-size:10px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.5px; margin-bottom:5px; }
        .drp-field input[type=date] { width:100%; padding:9px 11px; background:var(--surface2); border:1px solid var(--border); border-radius:9px; color:var(--text); font-size:13px; font-family:inherit; outline:none; transition:border-color .15s; color-scheme:dark; }
        .drp-field input[type=date]:focus { border-color:var(--accent); }
        .drp-range-display { text-align:center; font-size:12px; color:var(--text-muted); margin-bottom:14px; min-height:18px; }
        .drp-range-display span { color:var(--text); font-weight:600; }
        .drp-apply { width:100%; padding:10px; border-radius:10px; border:none; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; font-size:13px; font-weight:700; font-family:inherit; cursor:pointer; transition:opacity .15s; }
        .drp-apply:hover { opacity:.9; }
        .refresh-btn { width:36px; height:36px; border-radius:9px; background:var(--bg); border:1px solid var(--border); color:var(--text-muted); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:13px; transition:all .2s; }
        .refresh-btn:hover { color:var(--accent); border-color:var(--accent); }
        .refresh-btn.spinning i { animation:spin .7s linear infinite; }
        .meta-chip { padding:6px 12px; background:var(--bg); border:1px solid var(--border); border-radius:8px; font-size:11px; color:var(--text-muted); }

        /* ── User menu ──────────────────────────────── */
        .user-btn { display:flex; align-items:center; gap:10px; padding:6px 10px 6px 6px; background:var(--bg); border:1px solid var(--border); border-radius:10px; cursor:pointer; transition:all .2s; position:relative; }
        .user-btn:hover { border-color:var(--accent); }
        .user-avatar { width:30px; height:30px; border-radius:8px; background:linear-gradient(135deg,var(--accent),var(--accent2)); display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; color:#fff; flex-shrink:0; }
        .user-details { display:flex; flex-direction:column; line-height:1; }
        .user-name { font-size:12px; font-weight:600; }
        .user-role { font-size:10px; color:var(--text-muted); margin-top:2px; }
        .user-caret { font-size:10px; color:var(--text-muted); margin-left:4px; }
        .user-dropdown { position:absolute; top:calc(100% + 8px); right:0; background:var(--surface2); border:1px solid var(--border); border-radius:12px; padding:6px; min-width:180px; display:none; z-index:500; box-shadow:0 16px 48px rgba(0,0,0,.5); }
        .user-dropdown.open { display:block; }
        .dd-item { display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:8px; cursor:pointer; font-size:13px; color:var(--text-dim); transition:all .15s; }
        .dd-item:hover { background:var(--surface); color:var(--text); }
        .dd-item.danger:hover { background:rgba(244,63,94,.1); color:#fb7185; }
        .dd-item i { width:14px; text-align:center; font-size:13px; }
        .dd-sep { height:1px; background:var(--border); margin:4px 0; }

        /* ── Content ────────────────────────────────── */
        .content { padding:28px 32px; flex:1; min-width:0; overflow-x:hidden; }

        /* ── Loader ─────────────────────────────────── */
        .loader { display:flex; flex-direction:column; align-items:center; justify-content:center; height:50vh; gap:16px; color:var(--text-muted); }
        .spinner { width:36px; height:36px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:spin .7s linear infinite; }
        @keyframes spin { to { transform:rotate(360deg); } }

        /* ── KPI Cards ──────────────────────────────── */
        .kpi-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:16px; margin-bottom:24px; }
        .kpi { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:22px; position:relative; overflow:hidden; transition:transform .2s,box-shadow .2s; }
        .kpi:hover { transform:translateY(-3px); box-shadow:var(--glow); }
        .kpi::after { content:''; position:absolute; top:-30px; right:-30px; width:100px; height:100px; border-radius:50%; background:var(--glow-color,rgba(99,102,241,.08)); pointer-events:none; }
        .kpi.blue   { --glow-color:rgba(99,102,241,.12); }
        .kpi.green  { --glow-color:rgba(16,185,129,.12); }
        .kpi.orange { --glow-color:rgba(245,158,11,.12); }
        .kpi.pink   { --glow-color:rgba(244,63,94,.12); }
        .kpi-top { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:16px; }
        .kpi-label { font-size:12px; font-weight:500; color:var(--text-muted); text-transform:uppercase; letter-spacing:.5px; }
        .kpi-icon { width:38px; height:38px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:15px; }
        .kpi.blue   .kpi-icon { background:rgba(99,102,241,.15); color:#818cf8; }
        .kpi.green  .kpi-icon { background:rgba(16,185,129,.15); color:#34d399; }
        .kpi.orange .kpi-icon { background:rgba(245,158,11,.15); color:#fbbf24; }
        .kpi.pink   .kpi-icon { background:rgba(244,63,94,.15); color:#fb7185; }
        .kpi-value { font-size:28px; font-weight:800; letter-spacing:-1px; margin-bottom:6px; }
        .kpi-sub { font-size:12px; color:var(--text-muted); }

        /* ── Panels ─────────────────────────────────── */
        .panel { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:24px; margin-bottom:24px; overflow:hidden; }
        .panel-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; }
        .panel-head h3 { font-size:15px; font-weight:600; }
        .panel-head .sub { font-size:12px; color:var(--text-muted); }

        /* ── Bar chart ──────────────────────────────── */
        .bchart-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; touch-action:pan-x; }
        .bchart-wrap::-webkit-scrollbar { display:none; }
        .bchart { display:inline-flex; align-items:flex-end; gap:4px; height:160px; position:relative; min-width:100%; }
        .bchart::before { content:''; position:absolute; bottom:22px; left:0; right:0; height:1px; background:var(--border); }
        .bc { flex:0 0 auto; width:32px; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; overflow:visible; }
        .bc-bar { width:100%; border-radius:5px 5px 0 0; background:linear-gradient(to top,var(--accent),var(--accent2)); position:relative; cursor:pointer; transition:height .5s cubic-bezier(.34,1.56,.64,1),box-shadow .2s; flex-shrink:0; }
        .bc-bar:hover { box-shadow:0 0 16px rgba(99,102,241,.5); }
        .bc-bar::after { content:attr(data-tip); position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%); background:#1e293b; color:#f1f5f9; padding:4px 8px; border-radius:7px; font-size:11px; white-space:nowrap; pointer-events:none; opacity:0; transition:opacity .15s; border:1px solid var(--border); z-index:10; }
        .bc-bar:hover::after { opacity:1; }
        .bc-lbl { display:block; font-size:10px; color:#fff; white-space:nowrap; line-height:1; text-align:center; margin-top:5px; height:16px; flex-shrink:0; }
        .bchart--many .bc-lbl { font-size:9px; }
        .bc-bar--max { background:linear-gradient(to top,#818cf8,#a78bfa); box-shadow:0 0 12px rgba(167,139,250,.4); }

        /* ── Horiz bar ──────────────────────────────── */
        /* ── ABC badges ─────────────────────────────── */
        .abc-badge { display:inline-block; padding:2px 8px; border-radius:5px; font-size:11px; font-weight:800; }
        .abc-a { background:rgba(52,211,153,.15); color:#34d399; }
        .abc-b { background:rgba(129,140,248,.15); color:#818cf8; }
        .abc-c { background:rgba(148,163,184,.15); color:#94a3b8; }

        .hbar { display:flex; align-items:center; gap:12px; margin-bottom:14px; }
        .hbar:last-child { margin-bottom:0; }
        .hbar-name { font-size:13px; flex:0 0 130px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
        .hbar-track { flex:1; height:8px; background:var(--bg); border-radius:4px; overflow:hidden; }
        .hbar-fill { height:100%; border-radius:4px; background:linear-gradient(to right,var(--accent),var(--accent2)); transition:width .6s ease; }
        .hbar-val { font-size:12px; color:var(--text-dim); flex:0 0 90px; text-align:right; font-weight:500; }

        /* ── Table ──────────────────────────────────── */
        .dt-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
        .dt { width:100%; border-collapse:collapse; min-width:420px; }
        .dt thead tr { border-bottom:1px solid var(--border); }
        .dt th { padding:10px 12px; font-size:10px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.6px; text-align:left; white-space:nowrap; }
        .dt td { padding:12px 12px; font-size:13px; border-bottom:1px solid var(--border); }
        .dt tbody tr:last-child td { border-bottom:none; }
        .dt tbody tr:hover td { background:var(--surface2); }
        .rank { display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:8px; font-size:12px; font-weight:700; }
        .rank.g { background:rgba(251,191,36,.15); color:#fbbf24; }
        .rank.s { background:rgba(148,163,184,.15); color:#94a3b8; }
        .rank.b { background:rgba(251,146,60,.15); color:#fb923c; }
        .rank.n { background:var(--bg); color:var(--text-muted); }

        /* ── Dept cards ─────────────────────────────── */
        .dept-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:16px; margin-bottom:24px; }
        .dept-card { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:20px; position:relative; overflow:hidden; transition:transform .2s; }
        .dept-card:hover { transform:translateY(-2px); }
        .dept-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background:linear-gradient(to right,var(--accent),var(--accent2)); }
        .dept-hd { font-size:14px; font-weight:700; margin-bottom:14px; }
        .dept-row { display:flex; justify-content:space-between; font-size:12px; margin-bottom:7px; }
        .dept-row .lbl { color:var(--text-muted); }
        .dept-row .val { font-weight:600; }
        .dept-track { height:4px; background:var(--bg); border-radius:2px; margin-top:10px; }
        .dept-fill { height:100%; border-radius:2px; background:linear-gradient(to right,var(--accent),var(--accent2)); }

        /* ── Staff ──────────────────────────────────── */
        .staff-bar { display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--border); }
        .staff-bar:last-child { border-bottom:none; }
        .staff-avatar { width:38px; height:38px; border-radius:10px; flex-shrink:0; background:linear-gradient(135deg,var(--accent),var(--accent2)); display:flex; align-items:center; justify-content:center; font-size:14px; font-weight:700; color:#fff; }
        .staff-info { flex:1; min-width:0; }
        .staff-name { font-size:13px; font-weight:600; }
        .staff-sub { font-size:11px; color:var(--text-muted); margin-top:2px; }
        .staff-track { flex:1; height:6px; background:var(--bg); border-radius:3px; min-width:60px; }
        .staff-fill { height:100%; border-radius:3px; background:linear-gradient(to right,var(--accent),var(--accent2)); }
        .staff-rev { font-size:13px; font-weight:700; flex:0 0 100px; text-align:right; }

        /* ── Two-col ────────────────────────────────── */
        .two-col { display:grid; grid-template-columns:1fr 1fr; gap:20px; }

        /* ── Error ──────────────────────────────────── */
        .err { background:rgba(244,63,94,.1); border:1px solid rgba(244,63,94,.3); border-radius:12px; padding:20px; color:#fb7185; font-size:14px; }

        /* ── AI Chat ─────────────────────────────────── */
        .ai-wrap { display:flex; flex-direction:column; height:calc(100vh - 160px); min-height:400px; }
        .ai-messages { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:6px; padding:4px 2px 16px; scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
        .ai-messages::-webkit-scrollbar { width:4px; }
        .ai-messages::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
        .ai-bubble { display:inline-block; max-width:65%; padding:6px 10px; border-radius:12px; font-size:12px; line-height:1.4; }
        .ai-bubble.user { align-self:flex-end; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; border-bottom-right-radius:2px; }
        .ai-bubble.assistant { align-self:flex-start; background:var(--surface2); color:var(--text); border-bottom-left-radius:2px; border:1px solid var(--border); max-width:70%; font-size:11.5px; }
        .ai-bubble.thinking { color:var(--text-muted); font-style:italic; }
        .ai-bubble .ai-sender { display:none; }
        .ai-bubble .ai-tool { display:inline-block; font-size:9px; margin-bottom:3px; }
        .ai-input-row { display:flex; gap:10px; align-items:flex-end; padding-top:12px; border-top:1px solid var(--border); }
        .ai-textarea { flex:1; background:var(--surface2); border:1px solid var(--border); border-radius:12px; padding:12px 14px; color:var(--text); font-size:16px; font-family:inherit; resize:none; outline:none; min-height:44px; max-height:120px; transition:border-color .15s; line-height:1.5; }
        .ai-textarea:focus { border-color:var(--accent); }
        .ai-send-btn { width:44px; height:44px; border-radius:12px; border:none; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; font-size:16px; cursor:pointer; flex-shrink:0; display:flex; align-items:center; justify-content:center; transition:opacity .15s; }
        .ai-send-btn:hover { opacity:.85; }
        .ai-send-btn:disabled { opacity:.4; cursor:not-allowed; }
        /* chips — collapsible */
        .ai-chips-wrap { margin-bottom:10px; }
        .ai-chips-toggle { display:flex; align-items:center; gap:6px; font-size:11px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.5px; background:none; border:none; font-family:inherit; cursor:pointer; padding:4px 0; }
        .ai-chips-toggle i { font-size:10px; transition:transform .2s; }
        .ai-chips-toggle.open i { transform:rotate(180deg); }
        .ai-chips { display:flex; flex-wrap:wrap; gap:7px; margin-top:8px; }
        .ai-chips.hidden { display:none; }
        .ai-chip { padding:6px 13px; border-radius:20px; border:1px solid var(--border); background:var(--bg); color:var(--text-muted); font-size:12px; font-weight:500; font-family:inherit; cursor:pointer; transition:all .15s; white-space:nowrap; }
        .ai-chip:hover { border-color:var(--accent); color:var(--text); }
        .ai-context-bar { display:flex; align-items:center; gap:8px; padding:8px 14px; background:var(--bg); border:1px solid var(--border); border-radius:10px; font-size:12px; color:var(--text-muted); margin-bottom:10px; flex-wrap:wrap; }
        .ai-context-bar i { color:var(--accent); }
        .ai-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; flex:1; gap:12px; color:var(--text-muted); }
        .ai-empty i { font-size:40px; color:var(--border); }
        .ai-empty p { font-size:13px; text-align:center; max-width:260px; line-height:1.6; }
        @media(max-width:640px) {
            /* Чат: высота = весь экран минус topbar, mob-period, mob-nav и отступ снизу под input */
            /* nav H=54, inp H=65 → wrap = 727 - 52 - 50 - 65 - 54 = 506px */
            .ai-wrap {
                height: calc(100dvh - 52px - 50px - 65px - 54px);
                min-height: 200px;
                position: static;
                overflow: hidden;
            }
            /* Убираем padding-bottom контента для AI-раздела */
            .content.section-ai {
                padding-bottom: 65px !important; /* только под input-row */
            }
            /* Input row — фиксирован точно над mob-nav (nav top=673, nav H=54 → bottom=54) */
            .ai-input-row {
                position: fixed;
                bottom: 54px;
                left: 0; right: 0;
                background: var(--surface);
                border-top: 1px solid var(--border);
                padding: 8px 12px 8px;
                z-index: 250;
            }
            .mob-nav.keyboard-open { display: none; }
            .ai-input-row.keyboard-open { bottom: 0; }
            /* Пузыри на мобилке — компактно */
            .ai-messages { padding-bottom: 4px; gap: 3px; }
            .ai-bubble { max-width:60%; font-size:11px; padding:5px 8px; border-radius:10px; line-height:1.35; }
            .ai-bubble.user { max-width:55%; }
            .ai-bubble.assistant { max-width:68%; }
            /* Инпут */
            .ai-textarea { font-size:16px; padding:9px 12px; }
            .ai-send-btn { width:38px; height:38px; font-size:14px; border-radius:10px; }
            /* Шапка чата */
            .ai-context-bar { font-size:11px; padding:6px 10px; margin-bottom:6px; }
            .ai-chips-wrap { margin-bottom:6px; }
            .ai-chips-toggle { font-size:10px; }
            .ai-chip { font-size:11px; padding:5px 10px; }
        }

        /* ── Users panel ────────────────────────────── */
        .users-panel .user-row { display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--border); flex-wrap:wrap; row-gap:8px; }
        .users-panel .user-row:last-child { border-bottom:none; }
        .ur-avatar { width:36px; height:36px; border-radius:9px; flex-shrink:0; background:linear-gradient(135deg,var(--accent),var(--accent2)); display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; color:#fff; }
        .ur-info { flex:1; min-width:0; }
        .ur-name { font-size:13px; font-weight:600; }
        .ur-sub { font-size:11px; color:var(--text-muted); margin-top:2px; }
        .role-tag { padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600; }
        .role-tag.admin   { background:rgba(99,102,241,.15); color:#818cf8; }
        .role-tag.manager { background:rgba(245,158,11,.15); color:#fbbf24; }
        .role-tag.viewer  { background:rgba(148,163,184,.15); color:#94a3b8; }
        .del-btn { width:30px; height:30px; border-radius:8px; background:transparent; border:1px solid var(--border); color:var(--text-muted); cursor:pointer; font-size:12px; display:flex; align-items:center; justify-content:center; transition:all .2s; }
        .del-btn:hover { background:rgba(244,63,94,.1); border-color:rgba(244,63,94,.4); color:#fb7185; }

        /* ══════════════════════════════════════════════
           MOBILE
        ══════════════════════════════════════════════ */

        /* Bottom nav */
        .mob-nav { display:none; position:fixed; bottom:0; left:0; right:0; z-index:300; background:var(--surface); border-top:1px solid var(--border); padding-bottom:env(safe-area-inset-bottom); }
        .mob-nav-inner { display:flex; }
        .mob-nav-item { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; padding:10px 4px; color:var(--text-muted); cursor:pointer; font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.4px; transition:color .15s; border:none; background:none; font-family:inherit; }
        .mob-nav-item i { font-size:19px; }
        .mob-nav-item.active { color:var(--accent); }

        /* Mobile period strip */
        .mob-period { display:none; gap:6px; padding:10px 12px; border-bottom:1px solid var(--border); background:var(--surface); overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; flex-shrink:0; }
        .mob-period::-webkit-scrollbar { display:none; }
        .mob-period .period-btn { padding:7px 14px; border-radius:8px; border:1px solid var(--border); font-size:12px; font-weight:500; font-family:inherit; background:transparent; color:var(--text-muted); cursor:pointer; white-space:nowrap; transition:all .15s; }
        .mob-period .period-btn.active { background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; border-color:transparent; }
        .mob-period .drp-btn { border:1px solid var(--border); border-radius:8px; padding:7px 12px; }

        @media(max-width:900px) { .two-col { grid-template-columns:1fr; } }

        @media(max-width:640px) {
            /* Hide desktop elements */
            .sidebar { display:none; }
            .main { margin-left:0; }
            .topbar { padding:12px 16px; border-bottom:none; }
            .topbar-right .period-group,
            .topbar-right .refresh-btn,
            .topbar-right .meta-chip { display:none; }
            .user-details, .user-caret { display:none; }
            .user-btn { padding:4px; background:transparent; border:none; gap:0; }
            .user-avatar { width:36px; height:36px; font-size:13px; }
            .user-dropdown { right:-8px; min-width:200px; top:calc(100% + 6px); }
            .section-title { font-size:18px; }

            /* Show mobile elements */
            .mob-nav { display:block; }
            .mob-period { display:flex; }

            /* Content */
            .content { padding:12px 12px 90px; }

            /* KPI 2 cols */
            .kpi-grid { grid-template-columns:1fr 1fr; gap:10px; margin-bottom:14px; }
            .kpi { padding:14px; border-radius:14px; }
            .kpi-value { font-size:20px; letter-spacing:-.5px; margin-bottom:4px; }
            .kpi-label { font-size:10px; }
            .kpi-icon { width:30px; height:30px; font-size:12px; border-radius:8px; }
            .kpi-top { margin-bottom:10px; }
            .kpi::after { top:-30px; right:-30px; }

            /* Panels */
            .panel { padding:14px; border-radius:14px; margin-bottom:12px; }
            .panel-head { margin-bottom:14px; }
            .panel-head h3 { font-size:14px; }

            /* Bar chart mobile */
            .bchart { height:140px; }
            .bc { width:24px; }
            .bc-lbl { font-size:9px; }
            .bc-bar::after { display:none; }

            /* Hbar */
            .hbar { gap:8px; margin-bottom:10px; }
            .hbar-name { flex:0 0 90px; font-size:12px; }
            .hbar-val { flex:0 0 70px; font-size:11px; }

            /* Tables scroll */
            .dt th, .dt td { padding:10px 10px; font-size:12px; }

            /* Staff: hide track bar */
            .staff-track { display:none; }
            .staff-rev { flex:0 0 auto; }
            .staff-bar { gap:10px; }

            /* Dept grid 1 col */
            .dept-grid { grid-template-columns:1fr 1fr; gap:10px; }
            .dept-card { padding:14px; }
            .dept-hd { font-size:13px; margin-bottom:10px; }

            /* Modals: bottom sheet */
            .edit-modal-overlay { align-items:flex-end; padding:0; }
            .edit-modal { border-radius:20px 20px 0 0 !important; max-width:100% !important; width:100%; max-height:85vh; overflow-y:auto; padding-bottom:max(24px,env(safe-area-inset-bottom)); }

            /* DRP popup full width — координаты ставит JS */
            .drp-popup { left:8px !important; right:8px !important; bottom:80px !important; top:auto !important; min-width:unset; border-radius:16px; }
        }

        @media(max-width:380px) {
            .kpi-grid { grid-template-columns:1fr; }
            .dept-grid { grid-template-columns:1fr; }
        }

/* ── Finance tabs ─────────────────────────────────────────────────────────── */
.fin-tabs { display:flex; gap:6px; margin-bottom:18px; flex-wrap:wrap; }
.fin-tab {
    background: var(--bg2); border: 1px solid var(--border); color: var(--text-muted);
    border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all .15s;
}
.fin-tab:hover { color: var(--text); border-color: var(--accent); }
.fin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Finance Payment Calendar ─────────────────────────────────────────────── */
.fin-cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:3px; margin-bottom:16px; }
.fin-cal-head { text-align:center; font-size:11px; font-weight:600; color:var(--text-muted); padding:6px 0; }
.fin-cal-cell { min-height:76px; background:var(--bg2); border-radius:7px; padding:6px 5px; position:relative; }
.fin-cal-cell.fin-cal-empty { background:transparent; }
.fin-cal-cell.fin-cal-today { border:1.5px solid var(--accent); }
.fin-cal-day-num { font-size:11px; font-weight:600; color:var(--text-muted); margin-bottom:4px; line-height:1; }
.fin-cal-cell.fin-cal-today .fin-cal-day-num { color:var(--accent); }
.fin-cal-pay { background:var(--bg); border-radius:4px; padding:3px 5px; margin-bottom:3px; cursor:pointer;
    transition:opacity .15s, transform .1s; font-size:11px; position:relative; }
.fin-cal-pay:hover { opacity:.8; transform:scale(1.01); }
.fin-cal-pay.overdue { opacity:.6; }
.fin-cal-pay-name { color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    font-size:11px; display:block; max-width:100%; }
.fin-cal-pay-amt { color:#f87171; font-weight:600; font-size:10px; display:block; }
.fin-cal-day-total { font-size:10px; color:#f87171; font-weight:700; text-align:right; margin-top:2px; }
.fin-cal-popup { background:var(--surface); border:1px solid var(--border); border-radius:10px;
    padding:4px; box-shadow:0 8px 24px rgba(0,0,0,.4); display:flex; flex-direction:column;
    gap:1px; min-width:150px; }
.fin-cal-popup button { background:none; border:none; cursor:pointer; font-size:13px; padding:7px 12px;
    border-radius:7px; text-align:left; display:flex; align-items:center; gap:8px;
    transition:background .1s; width:100%; white-space:nowrap; }
.fin-cal-popup button:hover { background:var(--bg2); }
.fin-cal-popup .rescheduleRow { padding:6px 8px 4px; }
.fin-cal-popup .rescheduleRow input { color-scheme:dark; }
.fin-cal-nav { display:flex; align-items:center; gap:10px; }
.fin-cal-month-title { font-weight:600; font-size:15px; min-width:140px; text-align:center; }
@media(max-width:600px) {
    .fin-cal-cell { min-height:48px; padding:3px; }
    .fin-cal-pay-name { display:none; }
    .fin-cal-day-num { font-size:10px; }
    .fin-cal-pay { padding:2px 4px; margin-bottom:2px; }
}
