    :root {
      --bg: #0d1117;
      --surface: #161b22;
      --surface2: #21262d;
      --border: #30363d;
      --accent: #238636;
      --accent-light: #2ea043;
      --danger: #da3633;
      --warning: #d29922;
      --text: #e6edf3;
      --text-muted: #7d8590;
      --blue: #1f6feb;
      --blue-light: #388bfd;
    }

    /* Split-tunnel / белый список: скрыто тумблером «Дополнительно» в настройках */
    .feature-split-tunnel-ui-hidden {
      display: none !important;
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }

    /* Login */
    #login-screen {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
      background: radial-gradient(ellipse at center, #1a2332 0%, #0d1117 70%);
    }

    .login-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 48px 40px;
      width: 360px;
      text-align: center;
    }

    .login-logo {
      font-size: 48px;
      margin-bottom: 8px;
    }

    .login-card h1 {
      font-size: 22px;
      font-weight: 600;
      margin-bottom: 4px;
    }

    .login-card p {
      color: var(--text-muted);
      font-size: 14px;
      margin-bottom: 32px;
    }

    .form-group {
      text-align: left;
      margin-bottom: 16px;
    }

    .form-group label {
      display: block;
      font-size: 13px;
      font-weight: 500;
      margin-bottom: 6px;
      color: var(--text-muted);
    }

    .form-group input {
      width: 100%;
      padding: 10px 14px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 14px;
      outline: none;
      transition: border-color 0.2s;
    }

    .form-group input:focus { border-color: var(--blue-light); }

    .btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 10px 20px;
      border-radius: 8px;
      border: none;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s;
    }

    .btn-primary {
      background: var(--accent);
      color: white;
      width: 100%;
      justify-content: center;
      padding: 12px;
      font-size: 15px;
    }

    .btn-primary:hover { background: var(--accent-light); }
    .btn-danger { background: var(--danger); color: white; }
    .btn-danger:hover { opacity: 0.85; }
    .btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
    .btn-secondary:hover { background: var(--border); }

    #login-error {
      color: var(--danger);
      font-size: 13px;
      margin-top: 12px;
      display: none;
    }

    /* App Layout */
    #app { display: none; }

    .sidebar {
      position: fixed;
      left: 0;
      top: 0;
      bottom: 0;
      width: 240px;
      background: var(--surface);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      z-index: 100;
    }

    .sidebar-logo {
      padding: 20px 20px 16px;
      border-bottom: 1px solid var(--border);
    }

    .sidebar-logo h2 {
      font-size: 16px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .sidebar-logo span { font-size: 20px; }

    .sidebar-logo p {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .nav-items { flex: 1; padding: 12px 8px; }

    .nav-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 14px;
      color: var(--text-muted);
      transition: all 0.15s;
      margin-bottom: 2px;
    }

    .nav-item:hover { background: var(--surface2); color: var(--text); }
    .nav-item.active { background: #1f2937; color: var(--blue-light); }
    .nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

    .sidebar-footer {
      padding: 16px;
      border-top: 1px solid var(--border);
    }

    .logout-btn {
      width: 100%;
      padding: 8px;
      background: none;
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 13px;
      transition: all 0.15s;
    }

    .logout-btn:hover { border-color: var(--danger); color: var(--danger); }

    .main-content {
      margin-left: 240px;
      padding: 28px;
      min-height: 100vh;
    }

    .page { display: none; }
    .page.active { display: block; }

    .page-header {
      margin-bottom: 24px;
    }

    .page-header h1 {
      font-size: 24px;
      font-weight: 700;
    }

    .page-header p {
      color: var(--text-muted);
      font-size: 14px;
      margin-top: 4px;
    }

    /* Stats Cards */
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
      margin-bottom: 24px;
    }

    .stat-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 20px;
    }

    .stat-label {
      font-size: 12px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 8px;
    }

    .stat-value {
      font-size: 32px;
      font-weight: 700;
      line-height: 1;
    }

    .stat-value.green { color: var(--accent-light); }
    .stat-value.blue { color: var(--blue-light); }
    .stat-value.yellow { color: var(--warning); }

    /* Grid 2 col */
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

    /* Cards */
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
    }

    .card-header {
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .card-header h3 {
      font-size: 15px;
      font-weight: 600;
    }

    .card-body { padding: 0; }

    /* Map */
    #world-map {
      height: 400px;
      width: 100%;
    }

    /* Table */
    .table-wrap { overflow-x: auto; }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
    }

    th {
      padding: 12px 16px;
      text-align: left;
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-muted);
      border-bottom: 1px solid var(--border);
    }

    td {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }

    tr:last-child td { border-bottom: none; }
    tr:hover td { background: rgba(255,255,255,0.02); }

    .url-cell {
      max-width: 300px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .title-cell {
      max-width: 250px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: var(--text-muted);
      font-size: 12px;
    }

    .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 500;
    }

    .badge-green { background: rgba(35, 134, 54, 0.2); color: #3fb950; }
    .badge-red { background: rgba(218, 54, 51, 0.2); color: #f85149; }
    .badge-blue { background: rgba(31, 111, 235, 0.2); color: var(--blue-light); }

    /* Яндекс: вкладки инсайтов (Почта/Музыка/Видео/Мессенджер) */
    .ytab-count {
      display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 2px;
      border-radius: 10px; font-size: 10px; font-weight: 600;
      background: rgba(252, 63, 29, 0.18); color: #fc3f1d; vertical-align: middle;
    }
    .yins-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
    .yins-filters select, .yins-filters input {
      background: var(--card); color: var(--text); border: 1px solid var(--border);
      border-radius: 7px; padding: 6px 10px; font-size: 13px;
    }
    .yins-list { display: flex; flex-direction: column; gap: 8px; }
    .yins-item {
      background: var(--card); border: 1px solid var(--border); border-radius: 10px;
      padding: 10px 14px; display: flex; gap: 12px; align-items: flex-start;
    }
    .yins-item-icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
    .yins-item-body { flex: 1; min-width: 0; }
    .yins-item-title { font-weight: 600; font-size: .92rem; margin-bottom: 2px; word-break: break-word; }
    .yins-item-subtitle { font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }
    .yins-item-preview { font-size: .82rem; color: var(--text-muted); }
    .yins-item-meta { font-size: .75rem; color: var(--text-muted); white-space: nowrap; text-align: right; flex-shrink: 0; }
    .yins-item-account { display: inline-block; margin-top: 4px; font-size: .72rem; padding: 1px 8px; border-radius: 10px; background: rgba(252,63,29,.12); color: #fc3f1d; }

    /* Индикатор онлайн/оффлайн пользователя */
    .online-dot {
      display: inline-block;
      width: 8px; height: 8px;
      border-radius: 50%;
      background: var(--text-muted);
      flex-shrink: 0;
      transition: background 0.4s;
    }
    .online-dot.is-online {
      background: #3fb950;
      box-shadow: 0 0 6px rgba(63, 185, 80, 0.6);
      animation: pulse-green 2s infinite;
    }
    @keyframes pulse-green {
      0%, 100% { box-shadow: 0 0 4px rgba(63, 185, 80, 0.5); }
      50%       { box-shadow: 0 0 10px rgba(63, 185, 80, 0.9); }
    }

    .host-bar {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 16px;
      border-bottom: 1px solid var(--border);
      font-size: 13px;
    }

    .host-bar:last-child { border-bottom: none; }

    .host-name { flex: 1; font-weight: 500; }

    .host-count { color: var(--text-muted); font-size: 12px; min-width: 40px; text-align: right; }

    .host-progress {
      width: 100px;
      height: 4px;
      background: var(--surface2);
      border-radius: 2px;
      overflow: hidden;
    }

    .host-progress-fill {
      height: 100%;
      background: var(--blue-light);
      border-radius: 2px;
    }

    /* Search & Filter */
    .search-bar {
      display: flex;
      gap: 10px;
      margin-bottom: 16px;
    }

    .search-bar input {
      flex: 1;
      padding: 10px 14px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 14px;
      outline: none;
      transition: border-color 0.2s;
    }

    .search-bar input:focus { border-color: var(--blue-light); }

    /* Modal */
    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.6);
      backdrop-filter: blur(4px);
      z-index: 1000;
      align-items: center;
      justify-content: center;
    }

    .modal-overlay.open { display: flex; }

    .modal {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 28px;
      width: 480px;
      max-width: 95vw;
    }

    .modal h2 { font-size: 18px; margin-bottom: 20px; }

    .modal-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      margin-top: 20px;
    }

    /* Config viewer */
    .config-box {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 16px;
      font-family: 'SF Mono', 'Fira Code', monospace;
      font-size: 12px;
      line-height: 1.6;
      white-space: pre-wrap;
      max-height: 300px;
      overflow-y: auto;
      color: #79c0ff;
    }

    /* Pagination */
    .pagination {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 16px;
      justify-content: center;
    }

    .page-btn {
      padding: 6px 12px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text);
      cursor: pointer;
      font-size: 13px;
    }

    .page-btn:hover { border-color: var(--blue-light); }
    .page-btn.active { background: var(--blue); border-color: var(--blue); }
    .page-btn:disabled { opacity: 0.4; cursor: default; }

    .empty-state {
      text-align: center;
      padding: 60px 20px;
      color: var(--text-muted);
    }

    .empty-state .icon { font-size: 48px; margin-bottom: 12px; }

    /* Toast */
    .toast {
      position: fixed;
      bottom: 24px;
      right: 24px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 12px 20px;
      font-size: 14px;
      z-index: 9999;
      transform: translateY(100px);
      opacity: 0;
      transition: all 0.3s;
    }

    .toast.show { transform: translateY(0); opacity: 1; }
    .toast.success { border-color: var(--accent-light); color: var(--accent-light); }
    .toast.error { border-color: var(--danger); color: #f85149; }

    .avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--blue), var(--accent));
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      font-weight: 700;
    }

    .user-row td { vertical-align: middle; }

    .loading {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 40px;
      color: var(--text-muted);
      gap: 10px;
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    .spinner {
      width: 18px;
      height: 18px;
      border: 2px solid var(--border);
      border-top-color: var(--blue-light);
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
    }

    .refresh-btn {
      background: none;
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-muted);
      padding: 4px 10px;
      cursor: pointer;
      font-size: 13px;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .refresh-btn:hover { border-color: var(--text-muted); color: var(--text); }

    .tab-btn {
      flex: 1;
      padding: 7px;
      border: none;
      border-radius: 6px;
      background: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      transition: all 0.15s;
    }

    .tab-btn.active { background: var(--surface); color: var(--text); }
    .tab-btn:hover:not(.active) { color: var(--text); }

    .platform-link {
      display: inline-block;
      padding: 4px 10px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text);
      text-decoration: none;
      font-size: 12px;
      transition: border-color 0.15s;
    }

    .platform-link:hover { border-color: var(--blue-light); }

    .traffic-filters {
      display: flex;
      gap: 10px;
      margin-bottom: 16px;
      align-items: center;
      flex-wrap: wrap;
    }

    .traffic-filters select {
      padding: 10px 14px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 14px;
      outline: none;
      cursor: pointer;
      min-width: 200px;
      transition: border-color 0.2s;
    }

    .traffic-filters select:focus { border-color: var(--blue-light); }

    .traffic-filters input {
      flex: 1;
      padding: 10px 14px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 14px;
      outline: none;
      min-width: 200px;
      transition: border-color 0.2s;
    }

    .traffic-filters input:focus { border-color: var(--blue-light); }

    .toggle-label {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      color: var(--text-muted);
      cursor: pointer;
      white-space: nowrap;
      user-select: none;
    }

    .toggle-label input[type="checkbox"] {
      width: 16px;
      height: 16px;
      accent-color: var(--blue-light);
      cursor: pointer;
    }

    .map-tile-btn {
      padding: 5px 12px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 12px;
      transition: all 0.15s;
    }

    .map-tile-btn:hover { color: var(--text); border-color: var(--text-muted); }
    .map-tile-btn.active { background: var(--blue); border-color: var(--blue); color: white; }

    .settings-grid { display: flex; flex-direction: column; gap: 16px; max-width: 700px; }

    .settings-section {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
    }

    .settings-section-title {
      padding: 14px 20px;
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-muted);
      border-bottom: 1px solid var(--border);
      background: var(--surface2);
    }

    .setting-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      gap: 20px;
    }

    .setting-row:last-child { border-bottom: none; }

    .setting-label { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
    .setting-desc { font-size: 12px; color: var(--text-muted); }

    .setting-select {
      padding: 8px 12px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 13px;
      outline: none;
      cursor: pointer;
      min-width: 200px;
    }

    .toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .toggle-slider {
      position: absolute; cursor: pointer; inset: 0;
      background: var(--surface2); border: 1px solid var(--border);
      border-radius: 24px; transition: 0.2s;
    }
    .toggle-slider:before {
      content: ''; position: absolute;
      width: 18px; height: 18px; left: 2px; top: 2px;
      background: var(--text-muted); border-radius: 50%; transition: 0.2s;
    }
    .toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent-light); }
    .toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); background: white; }

    input[type="date"] {
      padding: 9px 12px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 13px;
      outline: none;
      cursor: pointer;
      color-scheme: dark;
    }

    input[type="date"]:focus { border-color: var(--blue-light); }

    /* ── Mobile Header ─────────────────────────────── */
    .mobile-header {
      display: none;
      position: fixed;
      top: 0; left: 0; right: 0;
      height: 56px;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      align-items: center;
      padding: 0 16px;
      z-index: 200;
      gap: 12px;
    }

    .mobile-header-title {
      font-size: 15px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .hamburger {
      background: none;
      border: none;
      color: var(--text);
      font-size: 22px;
      cursor: pointer;
      padding: 6px 8px;
      border-radius: 6px;
      line-height: 1;
      flex-shrink: 0;
    }

    .hamburger:hover { background: var(--surface2); }

    .sidebar-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.55);
      z-index: 99;
    }

    .sidebar-overlay.open { display: block; }

    /* ── Responsive ────────────────────────────────── */
    @media (max-width: 768px) {
      .mobile-header { display: flex; }

      .sidebar {
        transform: translateX(-260px);
        transition: transform 0.25s ease;
        z-index: 150;
      }

      .sidebar.open { transform: translateX(0); }

      .main-content {
        margin-left: 0;
        padding: 72px 14px 28px;
      }

      .login-card {
        width: calc(100vw - 32px);
        padding: 32px 20px;
      }

      .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
      }

      .stat-value { font-size: 26px; }

      .grid-2 { grid-template-columns: 1fr; }

      .page-header h1 { font-size: 20px; }

      .users-header { flex-wrap: wrap; gap: 10px; }

      /* Traffic filters стек */
      .traffic-filters {
        flex-direction: column;
        align-items: stretch;
      }

      .traffic-filters select,
      .traffic-filters input { min-width: 0; width: 100%; }

      /* Settings rows */
      .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
      }

      .setting-select { min-width: 0; width: 100%; }

      /* Config modal: 2 col → 1 col */
      .config-grid { grid-template-columns: 1fr !important; }

      /* Whitelist форма добавления */
      .whitelist-add-form {
        flex-direction: column;
      }

      .whitelist-add-form input { width: 100%; }

      /* Map */
      #world-map { height: 280px; }
      #route-map { height: 300px; }

      .map-tabs { width: 100% !important; }
      .map-tabs .tab-btn { font-size: 12px; }

      /* Route controls */
      .route-controls { flex-direction: column; align-items: stretch; }
      .route-controls select,
      .route-controls input[type="date"] { min-width: 0; width: 100%; }

      /* Toast - по центру снизу */
      .toast {
        right: 16px;
        left: 16px;
        bottom: 16px;
        text-align: center;
      }

      /* Карта тайлы */
      #map-tiles-btns { justify-content: flex-end; }

      /* Скрываем менее важные колонки таблицы пользователей */
      .users-col-ip { display: none; }
      .users-col-activity { display: none; }

      /* Таблица трафика: скрываем страну и URL */
      .traffic-col-country { display: none; }
      .traffic-col-url { display: none; }

      /* Кнопка добавить - во всю ширину на маленьких */
      .add-user-btn { width: 100%; justify-content: center; margin-top: 4px; }
    }

    @media (max-width: 480px) {
      .stats-grid { grid-template-columns: 1fr; }
      .modal { padding: 20px 16px; }
      .modal h2 { font-size: 16px; }
    }

/* multi-page nav links */
.nav-item { text-decoration: none; }
html:not(.authed) #app, html:not(.authed) .mobile-header { display: none !important; }
html.authed #login-screen { display: none !important; }
html.authed #app { display: block !important; }
.nav-item { text-decoration: none; color: inherit; }
.page { display: none; }
.page.active { display: block; }
