@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap");
    :root {
      --bg: #06101d;
      --bg-deep: #030914;
      --panel: rgba(15, 26, 40, 0.86);
      --panel-soft: rgba(255, 255, 255, 0.045);
      --border: rgba(255, 255, 255, 0.09);
      --border-strong: rgba(255, 255, 255, 0.15);
      --text: #f4f7fb;
      --muted: #9ca8ba;
      --muted-2: #728095;
      --blue: #2f7df6;
      --blue-2: #8b1f1f;
      --cyan: #14a7ff;
      --green: #23d36b;
      --purple: #8b5cf6;
      --red: #ff4d4d;
      --orange: #ff7b54;
      --yellow: #ffd166;
      --radius: 18px;
      --radius-sm: 10px;
      --sidebar-width: 300px;
      --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
    }

    body.light {
      --bg: #edf3fb;
      --bg-deep: #f8fbff;
      --panel: rgba(255, 255, 255, 0.88);
      --panel-soft: rgba(6, 16, 29, 0.045);
      --border: rgba(6, 16, 29, 0.11);
      --border-strong: rgba(6, 16, 29, 0.18);
      --text: #071426;
      --muted: #536276;
      --muted-2: #718096;
      --shadow: 0 18px 50px rgba(20, 40, 70, 0.14);
    }

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

    html { scroll-behavior: smooth; }

    body {
      min-height: 100vh;
      font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
      color: var(--text);
      background:
        radial-gradient(circle at 20% 0%, rgba(47, 125, 246, 0.16), transparent 34%),
        radial-gradient(circle at 90% 10%, rgba(139, 92, 246, 0.13), transparent 28%),
        linear-gradient(135deg, var(--bg-deep), var(--bg));
      overflow-x: hidden;
    }

    button, input, select, textarea { font: inherit; }
    button { cursor: pointer; }
    a { color: inherit; text-decoration: none; }

    /* =========================================================
       APP LAYOUT
       Главная сетка: sidebar слева + рабочая зона справа.
    ========================================================= */
    .app {
      display: grid;
      grid-template-columns: var(--sidebar-width) 1fr;
      min-height: 100vh;
    }

    /* =========================================================
       SIDEBAR
       Навигация по всем разделам панели.
    ========================================================= */
    .sidebar {
      position: sticky;
      top: 0;
      height: 100vh;
      padding: 22px 20px;
      background: rgba(3, 9, 20, 0.74);
      border-right: 1px solid var(--border);
      backdrop-filter: blur(22px);
      display: flex;
      flex-direction: column;
      gap: 22px;
      overflow-y: auto;
    }

    .brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px 12px; }
    .brand-logo {
      width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
      background: linear-gradient(145deg, #d94141, #8b1f1f);
      box-shadow: 0 0 26px rgba(217, 65, 65, 0.35);
      font-weight: 900; font-size: 12px;
    }
    .brand-name { font-size: 21px; font-weight: 800; letter-spacing: -0.04em; }
    .version { margin-left: 6px; color: #5b8dff; font-size: 13px; font-weight: 700; }

    .nav { display: flex; flex-direction: column; gap: 6px; }
    .nav-item {
      min-height: 48px;
      border: 1px solid transparent;
      border-radius: 10px;
      color: #d7deea;
      background: transparent;
      display: flex;
      align-items: center;
      gap: 13px;
      padding: 0 16px;
      transition: 0.2s ease;
    }
    .nav-item:hover,
    .nav-item.active {
      background: linear-gradient(135deg, rgba(47, 125, 246, 0.78), rgba(24, 91, 216, 0.72));
      color: white;
      border-color: rgba(255,255,255,.12);
      box-shadow: 0 14px 30px rgba(24, 91, 216, 0.2);
    }
    .nav-icon { width: 22px; text-align: center; opacity: 0.95; }

    .sidebar-status {
      margin-top: auto;
      padding: 18px;
      border: 1px solid var(--border);
      border-radius: 14px;
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
      box-shadow: var(--shadow);
    }
    .status-line { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }
    .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--green); box-shadow: 0 0 18px rgba(35, 211, 107, 0.8); display: inline-block; }
    .dot.red { background: var(--red); box-shadow: 0 0 18px rgba(255, 77, 77, 0.7); }
    .dot.yellow { background: var(--yellow); box-shadow: 0 0 18px rgba(255, 209, 102, 0.7); }
    .mini-row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 14px; margin-top: 14px; }
    .mini-row strong { color: var(--text); font-weight: 700; }
    .sidebar-footer { color: var(--muted); font-size: 13px; line-height: 1.8; }

    /* =========================================================
       MAIN CONTENT
       Все разделы идут друг за другом. В реальном проекте можно
       показывать один раздел по route или через JS-tabs.
    ========================================================= */
    .main { padding: 24px 32px 60px; }
    .section { scroll-margin-top: 24px; margin-bottom: 54px; }

    .topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
    .title h1 { font-size: 29px; line-height: 1.15; letter-spacing: -0.04em; }
    .title p { margin-top: 6px; color: var(--muted); font-size: 16px; }
    .top-actions { display: flex; align-items: center; gap: 12px; }
    .icon-button, .user-button {
      height: 44px; border: 1px solid var(--border); color: var(--text);
      background: rgba(255, 255, 255, 0.045); border-radius: 12px; backdrop-filter: blur(14px);
    }
    .icon-button { width: 44px; }
    .user-button { padding: 0 14px; display: flex; align-items: center; gap: 10px; }

    /* =========================================================
       COMMON UI COMPONENTS
       Карточки, кнопки, формы, таблицы, бейджи.
    ========================================================= */
    .panel,
    .kpi-card {
      border: 1px solid var(--border);
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.028));
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(18px);
    }
    .panel { padding: 24px; }
    .panel-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 18px; }
    .panel-subtitle { color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: -8px; margin-bottom: 18px; }

    .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
    .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
    .grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
    .grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px; }
    .mb-20 { margin-bottom: 20px; }
    .mb-24 { margin-bottom: 24px; }

    .kpi-card { min-height: 126px; padding: 22px; display: flex; align-items: center; gap: 18px; }
    .kpi-icon {
      flex: 0 0 54px; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
      font-size: 28px; background: rgba(47, 125, 246, 0.12); color: var(--cyan);
    }
    .kpi-icon.green { color: var(--green); background: rgba(35, 211, 107, 0.11); }
    .kpi-icon.purple { color: var(--purple); background: rgba(139, 92, 246, 0.13); }
    .kpi-icon.red { color: var(--red); background: rgba(255, 77, 77, 0.12); }
    .kpi-icon.orange { color: var(--orange); background: rgba(255, 123, 84, 0.13); }
    .kpi-label { color: var(--muted); font-size: 14px; margin-bottom: 7px; }
    .kpi-value { font-size: 25px; font-weight: 800; letter-spacing: -0.04em; }
    .kpi-sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
    .success { color: var(--green) !important; }
    .danger { color: var(--red) !important; }
    .warning { color: var(--yellow) !important; }
    .blue { color: #8fbfff !important; }

    .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
    .tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .search, .select, .input, .textarea, .btn {
      min-height: 44px;
      border: 1px solid var(--border-strong);
      background: rgba(3, 9, 20, 0.42);
      color: var(--text);
      border-radius: 10px;
    }
    .search, .input { padding: 0 14px; }
    .search { width: 240px; }
    .select { min-width: 126px; padding: 0 12px; }
    .textarea { width: 100%; min-height: 104px; padding: 14px; resize: vertical; }
    .search::placeholder, .input::placeholder, .textarea::placeholder { color: var(--muted-2); }
    .btn { padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; transition: 0.2s ease; }
    .btn:hover { transform: translateY(-1px); border-color: rgba(255, 255, 255, 0.24); }
    .btn.primary { background: linear-gradient(135deg, #d94141, #1e5be4); border-color: rgba(74, 135, 255, 0.7); box-shadow: 0 14px 34px rgba(47, 125, 246, 0.26); }
    .btn.green { color: #dfffe9; background: rgba(35, 211, 107, 0.14); border-color: rgba(35, 211, 107, 0.32); }
    .btn.warn { color: #ffd2c6; border-color: rgba(255, 123, 84, 0.35); background: rgba(255, 123, 84, 0.13); }
    .btn.danger-btn { color: #ffd4d4; border-color: rgba(255, 77, 77, 0.35); background: rgba(255, 77, 77, 0.12); }

    .table-panel { padding: 0; overflow: hidden; }
    .table-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
    .table-wrap { overflow-x: auto; }
    table { width: 100%; border-collapse: collapse; min-width: 980px; }
    th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; white-space: nowrap; }
    th { color: #c0cada; font-weight: 700; background: rgba(255,255,255,.025); }
    td { color: #e7edf7; }
    tbody tr:hover { background: rgba(255,255,255,.035); }

    .badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 8px; font-weight: 700; font-size: 13px; }
    .badge.online, .badge.good { color: var(--green); background: rgba(35, 211, 107, 0.13); }
    .badge.offline, .badge.neutral { color: #cbd3df; background: rgba(255,255,255,.08); }
    .badge.warn { color: var(--yellow); background: rgba(255, 209, 102, 0.12); }
    .badge.bad { color: var(--red); background: rgba(255, 77, 77, 0.12); }
    .badge.blue-badge { color: #8fbfff; background: rgba(47, 125, 246, 0.13); }
    .action-icons { display: flex; gap: 12px; color: #b7c3d7; }
    .action-icons a, .action-icons button { display: inline-flex; align-items: center; justify-content: center; background: none; border: none; padding: 0; cursor: pointer; color: inherit; }
    .action-icons svg { width: 18px; height: 18px; display: block; }
    .action-icons a:hover, .action-icons button:hover { color: var(--text); }
    .action-icons button.danger:hover { color: var(--red); }
    .action-icons svg { pointer-events: none; }

    .field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
    .field { display: flex; flex-direction: column; gap: 8px; }
    .field label { color: #c8d2e2; font-weight: 700; font-size: 14px; }
    .field small { color: var(--muted); line-height: 1.45; }
    .switch-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); }
    .switch-row:last-child { border-bottom: 0; }
    .switch-title { font-weight: 800; margin-bottom: 4px; }
    .switch-desc { color: var(--muted); font-size: 14px; line-height: 1.45; }
    .toggle { width: 54px; height: 30px; padding: 3px; border-radius: 999px; background: rgba(255,255,255,.12); border: 1px solid var(--border); flex: 0 0 auto; }
    .toggle::before { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: #dce7f7; transition: .2s; }
    .toggle.on { background: rgba(35, 211, 107, .3); border-color: rgba(35, 211, 107, .45); }
    .toggle.on::before { transform: translateX(24px); background: var(--green); }

    .info-list { display: grid; gap: 10px; }
    .info-row { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
    .info-row:last-child { border-bottom: 0; padding-bottom: 0; }
    .info-row strong { color: var(--text); text-align: right; }

    /* =========================================================
       CHART MOCKUPS
       Статичные SVG/ CSS-графики. В backend можно заменить на Chart.js.
    ========================================================= */
    .chart-wrap { height: 245px; position: relative; overflow: hidden; border-radius: 12px; }
    .legend { display: flex; justify-content: center; gap: 22px; color: var(--text); font-size: 14px; margin-bottom: 8px; }
    .legend span::before { content:""; display:inline-block; width:12px; height:8px; border-radius:2px; margin-right:8px; background:var(--blue); }
    .legend span:nth-child(2)::before { background: var(--purple); }
    svg.chart { width: 100%; height: 215px; display: block; }
    .axis-text { fill: var(--muted); font-size: 12px; }
    .grid-line { stroke: rgba(255,255,255,.06); stroke-width: 1; }

    .bar-list { display: grid; gap: 14px; }
    .bar-row { display: grid; grid-template-columns: 140px 1fr 80px; gap: 12px; align-items: center; color: var(--muted); font-size: 14px; }
    .bar-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
    .bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--purple)); }

    /* =========================================================
       DASHBOARD SPECIFIC
    ========================================================= */
    .wg-status-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); }
    .wg-status-item { padding: 15px 2px; border-bottom: 1px solid var(--border); }
    .wg-status-item span { display: block; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
    .wg-status-item strong { font-size: 16px; }

    .bottom-dashboard { display: grid; grid-template-columns: 1fr 420px; gap: 20px; }
    .quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }
    .quick-actions .btn { min-width: 165px; background: rgba(255,255,255,.055); }

    /* =========================================================
       BACKUP CARDS
    ========================================================= */
    .backup-card { display: flex; flex-direction: column; gap: 16px; }
    .backup-icon { width: 54px; height: 54px; border-radius: 16px; display:grid; place-items:center; background: rgba(47,125,246,.13); color:#8fbfff; font-size: 26px; }
    .backup-meta { color: var(--muted); font-size: 14px; line-height: 1.7; }

    /* =========================================================
       RESPONSIVE
    ========================================================= */
    @media (max-width: 1280px) {
      .grid-5 { grid-template-columns: repeat(2, 1fr); }
      .grid-4 { grid-template-columns: repeat(2, 1fr); }
      .grid-3, .grid-2, .bottom-dashboard { grid-template-columns: 1fr; }
    }

    @media (max-width: 920px) {
      .app { grid-template-columns: 1fr; }
      .sidebar { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
      .nav { display: grid; grid-template-columns: repeat(2, 1fr); }
      .main { padding: 22px 16px 44px; }
      .topbar, .table-header, .toolbar { flex-direction: column; align-items: stretch; }
      .grid-5, .grid-4, .grid-3, .grid-2, .field-grid, .wg-status-grid { grid-template-columns: 1fr; }
      .search, .select, .input, .btn { width: 100%; }
    }

/* =========================================================
   LEGACY — поддержка старых классов из первой версии UI
   ========================================================= */

/* Login */
.login-box {
    max-width: 400px;
    margin: 80px auto;
    background: var(--panel);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border);
}
.login-box h1 { font-size: 1.8rem; margin-bottom: 8px; }
.login-box .subtitle { color: var(--muted); margin-bottom: 24px; }

/* Alert */
.alert.error {
    background: rgba(255,77,77,0.12);
    color: #ffd4d4;
    border: 1px solid rgba(255,77,77,0.25);
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 500;
}

/* Button aliases */
.btn-primary {
    background: linear-gradient(135deg, #d94141, #1e5be4) !important;
    border-color: rgba(74, 135, 255, 0.7) !important;
    box-shadow: 0 14px 34px rgba(47, 125, 246, 0.26) !important;
    color: #fff !important;
}
.btn-secondary {
    background: rgba(255,255,255,0.045) !important;
    border-color: var(--border-strong) !important;
    color: var(--text) !important;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.08) !important;
}
.btn-danger {
    color: #ffd4d4 !important;
    border-color: rgba(255, 77, 77, 0.35) !important;
    background: rgba(255, 77, 77, 0.12) !important;
}
.btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* Toggle switch (NAT checkbox) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border-strong);
    border-radius: 26px;
    transition: 0.3s;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px; width: 20px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}
input:checked + .toggle-slider { background: var(--green); }
input:checked + .toggle-slider:before { transform: translateX(22px); }

/* Modal */
.modal {
    position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 420px; width: 90%;
    padding: 24px;
    border: 1px solid var(--border);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.modal-header h3 { font-size: 1.1rem; color: var(--text); }
.modal-body { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
.qr-hint { color: var(--muted); font-size: 0.9rem; text-align: center; }
.qr-image { width: 280px; height: 280px; border-radius: 12px; background: #fff; padding: 12px; object-fit: contain; }
.password-form { width: 100%; display: flex; flex-direction: column; gap: 0; }
.password-form button { margin-top: 8px; width: 100%; }
.password-form label { display: block; text-align: left; margin-bottom: 6px; font-weight: 600; color: var(--muted); }
.password-form input[type="password"] {
    width: 100%; padding: 12px 14px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: rgba(3,9,20,0.42);
    color: var(--text); font-size: 1rem; margin-bottom: 16px; outline: none;
}
.password-form input:focus { border-color: var(--blue); }

/* Conflicts */
.conflicts-hint { color: var(--muted); margin-bottom: 20px; }
.conflicts-actions { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.conflicts-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.conflict-card {
    background: var(--panel); border-radius: var(--radius); padding: 16px;
    border: 1px solid var(--border);
}
.conflict-name { font-weight: 700; font-size: 1.1rem; margin-bottom: 10px; }
.conflict-details { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.conflict-existing, .conflict-imported {
    background: var(--bg-deep); padding: 10px 14px; border-radius: 8px;
    display: flex; flex-direction: column; gap: 4px;
}
.conflict-arrow { font-size: 1.3rem; color: var(--blue); font-weight: 700; }
.conflict-choice { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
.conflict-choice label { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 0.9rem; }

/* Empty state */
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Inline forms */
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input { margin: 0; }
.inline { display: inline; }
.inline form { display: inline; }

/* File input */
.file-input {
    padding: 6px; font-size: 0.85rem; color: var(--muted);
    background: rgba(3,9,20,0.42); border: 1px solid var(--border-strong);
    border-radius: 8px; color: var(--text);
}
.file-input::file-selector-button {
    padding: 6px 12px; border: none; border-radius: 6px;
    background: var(--border-strong); color: var(--text);
    cursor: pointer; margin-right: 8px;
}

/* Section header helpers */
.section-header {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px;
}
.section-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Status dot for client table */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted-2);
}
.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px rgba(35,211,107,0.4);
}
.status-dot.offline {
    background: var(--muted-2);
}

/* Chart axis text */
.axis-text {
    font-size: 12px;
    fill: var(--muted-2);
    font-family: inherit;
}

/* Network form inside panel */
#network-settings form { margin: 0; }
#network-settings .field small select {
    margin-top: 8px;
    min-height: 36px;
    width: 100%;
    border: 1px solid var(--border-strong);
    background: rgba(3,9,20,0.42);
    color: var(--text);
    border-radius: 8px;
    padding: 0 10px;
}

/* =========================================================
   CONNECTION MODE CARDS
   Selectable cards for WireGuard connection modes.
========================================================= */
.mode-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.mode-card {
    position: relative;
    border: 2px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.028));
    border-radius: var(--radius-sm);
    padding: 18px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
}
.mode-card:hover { border-color: var(--border-strong); }
.mode-card.selected {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(47,125,246,0.18);
}
.mode-card .mode-status {
    position: absolute;
    top: 10px; right: 10px;
    font-size: 12px; font-weight: 700;
    padding: 2px 8px; border-radius: 6px;
}
.mode-card .mode-status.active { color: var(--green); background: rgba(35,211,107,0.13); }
.mode-card .mode-status.available { color: #8fbfff; background: rgba(47,125,246,0.13); }
.mode-card .mode-status.planned { color: var(--yellow); background: rgba(255,209,102,0.12); }
.mode-card .mode-status.requires_integration { color: var(--orange); background: rgba(255,123,84,0.13); }
.mode-card .mode-title { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.mode-card .mode-subtitle { color: var(--muted-2); font-size: 13px; margin-bottom: 8px; }
.mode-card .mode-desc { color: var(--muted); font-size: 13px; line-height: 1.4; }
.mode-card input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }

/* Integration warning banner */
.integration-warning {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: 10px;
    background: rgba(255,123,84,0.10); border: 1px solid rgba(255,123,84,0.25);
    color: var(--orange); font-size: 14px; font-weight: 700;
    margin-bottom: 18px;
}

/* Toast notifications */
.toast { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }

/* Dashboard health check panel */
.health-check {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.health-item {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border);
}
.health-item .status {
  font-weight: 700;
  margin-top: 8px;
  font-size: 16px;
}
.health-item .status.success { color: var(--green); }
.health-item .status.danger { color: var(--red); }
.health-item .status.warning { color: var(--yellow); }

/* Client list mini-table */
.client-list-table {
  width: 100%;
  border-collapse: collapse;
}
.client-list-table th,
.client-list-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.client-list-table th {
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-soft);
}
.client-list-table td {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}
.client-list-table tbody tr:hover {
  background: rgba(255,255,255,0.035);
}

/* Responsive health check */
@media (max-width: 920px) {
  .health-check { grid-template-columns: 1fr; }
}

/* Client management styles */
.client-name { font-weight: 700; color: var(--text); text-decoration: none; }
.client-name:hover { color: var(--blue); }

.client-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.client-status-dot.active { background: var(--green); box-shadow: 0 0 8px rgba(35, 211, 107, 0.5); }
.client-status-dot.disabled { background: var(--muted-2); }
.client-status-dot.revoked { background: var(--red); box-shadow: 0 0 8px rgba(255, 77, 77, 0.4); }

.tag-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--panel-soft); color: var(--muted); margin-right: 4px; border: 1px solid var(--border); }

.group-badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; background: rgba(47, 125, 246, 0.15); color: var(--blue); }

.expiry-green { color: var(--green); }
.expiry-yellow { color: var(--yellow); }
.expiry-red { color: var(--red); }

.btn-small { padding: 4px 10px; font-size: 12px; min-height: 28px; border-radius: 6px; }

/* Modal */
.modal { position: fixed; z-index: 1000; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal.show { display: flex; }
.modal-content { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; max-width: 480px; width: 90%; box-shadow: var(--shadow); }

/* Client list table */
.client-list-table { width: 100%; border-collapse: collapse; }
.client-list-table th, .client-list-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.client-list-table th { color: var(--muted); font-weight: 700; background: var(--panel-soft); white-space: nowrap; }
.client-list-table tbody tr:hover { background: rgba(255,255,255,0.035); }

/* Loading indicator */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* Certificate stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; border-radius: var(--radius-sm); background: var(--panel-soft); border: 1px solid var(--border); text-align: center; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Chart container */
.chart-container { position: relative; height: 300px; margin-top: 24px; }

/* Certificate table */
.client-list-table code { font-family: "JetBrains Mono", monospace; font-size: 12px; background: var(--panel-soft); padding: 2px 6px; border-radius: 4px; }

/* Expiry colors */
.expiry-green { color: var(--green); font-weight: 700; }
.expiry-yellow { color: var(--yellow); font-weight: 700; }
.expiry-red { color: var(--red); font-weight: 700; }

/* Responsive stats */
@media (max-width: 920px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Profiles */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.profile-card { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 14px; padding: 20px; transition: 0.2s ease; }
.profile-card:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-1px); }
.profile-card.active { border-color: rgba(35, 211, 107, 0.35); box-shadow: 0 0 0 1px rgba(35, 211, 107, 0.15), 0 10px 30px rgba(0,0,0,0.25); }
.profile-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.profile-name { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.profile-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.meta-row { display: flex; justify-content: space-between; font-size: 14px; }
.meta-label { color: var(--muted); }
.meta-value { color: #e7edf7; font-weight: 600; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-actions .btn { font-size: 13px; min-height: 36px; padding: 0 12px; }
.badge.planned { color: #b7c3d7; background: rgba(255,255,255,.06); border: 1px dashed rgba(255,255,255,.12); }

.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-col { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.form-col label { color: #c8d2e2; font-weight: 700; font-size: 14px; }
.radio-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.radio-group label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.radio-group input[type="radio"] { accent-color: #4a87ff; }
.checkbox-row { align-items: center; }
.checkbox-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.checkbox-row input[type="checkbox"] { accent-color: #4a87ff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.mb-16 { margin-bottom: 16px; }
.mb-18 { margin-bottom: 18px; }

/* Network Settings */
.settings-section { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.settings-section.disabled-section { opacity: 0.5; filter: grayscale(0.4); pointer-events: none; }
.section-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; color: #e7edf7; }
.settings-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-row label { color: #c8d2e2; font-weight: 700; font-size: 14px; }
.toggle-row { display: flex; align-items: center; padding: 8px 0; }
.toggle-row label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: #e7edf7; }
.toggle-row input[type="checkbox"] { accent-color: #4a87ff; width: 18px; height: 18px; }
.route-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.route-row .input { flex: 1; }
.route-row .btn { min-height: 36px; font-size: 13px; padding: 0 12px; }
.field-hint { color: var(--muted); font-size: 13px; margin-top: 2px; }
.field-error { color: var(--red); font-size: 13px; margin-top: 4px; }
.hidden { display: none !important; }
.alert { padding: 12px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.alert.success { color: #dfffe9; background: rgba(35, 211, 107, 0.13); border: 1px solid rgba(35, 211, 107, 0.25); }
.alert.error { color: #ffd4d4; background: rgba(255, 77, 77, 0.12); border: 1px solid rgba(255, 77, 77, 0.25); }
.mb-16 { margin-bottom: 16px; }

/* Firewall */
.firewall-status { padding: 20px; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.status-item { display: flex; flex-direction: column; gap: 6px; }
.status-item .meta-label { font-size: 13px; }
.status-item .meta-value { font-size: 16px; font-weight: 700; }
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.12); border-radius: 26px; transition: 0.3s; }
.toggle-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); }
.ports-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.ports-table th, .ports-table td { padding: 10px 14px; font-size: 14px; }
.rules-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.rules-table th, .rules-table td { padding: 10px 14px; font-size: 14px; }
.system-rule { background: rgba(255,255,255,0.02); color: var(--muted); }
.action-accept { color: var(--green); font-weight: 700; }
.action-drop { color: var(--red); font-weight: 700; }
.action-reject { color: var(--orange); font-weight: 700; }
.mt-16 { margin-top: 16px; }

/* Monitoring */
.monitoring-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.monitoring-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.monitoring-table th, .monitoring-table td { padding: 12px 14px; font-size: 14px; }
.speed-value { color: var(--green); font-weight: 700; }
.routing-pending { color: var(--yellow); }
.stale-warning { background: rgba(255, 209, 102, 0.12); border: 1px solid rgba(255, 209, 102, 0.25); color: #ffd2c6; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.top-clients { display: flex; flex-direction: column; gap: 8px; }
.top-client-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: rgba(255,255,255,0.02); border-radius: 8px; }
.top-rank { font-size: 18px; font-weight: 800; color: var(--muted); min-width: 32px; }
.top-name { flex: 1; font-weight: 600; }
.top-traffic { font-weight: 700; color: #8fbfff; }
.alert.warn { color: #ffd2c6; background: rgba(255, 209, 102, 0.12); border: 1px solid rgba(255, 209, 102, 0.25); }
.mb-24 { margin-bottom: 24px; }

/* Backups */
.storage-bar { background: rgba(255,255,255,0.06); border-radius: 8px; height: 8px; overflow: hidden; margin-top: 8px; }
.storage-bar-fill { height: 100%; background: linear-gradient(90deg, #4a87ff, #23d36b); border-radius: 8px; transition: width 0.5s ease; }
.restore-modal .input { font-family: monospace; }
.password-input { letter-spacing: 2px; }

/* Logs */
.log-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.log-tab { padding: 8px 18px; border-radius: 10px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s; }
.log-tab:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.log-tab.active { background: linear-gradient(135deg, #4a87ff, #23d36b); color: #fff; border-color: transparent; }
.log-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.log-table th, .log-table td { padding: 10px 14px; font-size: 14px; }
.severity-error { color: var(--red); background: rgba(255,77,77,0.12); }
.severity-warning { color: var(--yellow); background: rgba(255,209,102,0.12); }
.severity-info { color: var(--green); background: rgba(35,211,107,0.12); }
.severity-debug { color: var(--muted); background: rgba(255,255,255,0.04); }
.mt-16 { margin-top: 16px; }

/* Polish */
.htmx-loading { opacity: 0.6; pointer-events: none; }
.nav-item.active { box-shadow: 0 0 12px rgba(74,135,255,0.3); }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; animation: toastIn 0.3s ease; }
.toast.success { background: rgba(35,211,107,0.15); border: 1px solid rgba(35,211,107,0.3); color: #dfffe9; }
.toast.error { background: rgba(255,77,77,0.15); border: 1px solid rgba(255,77,77,0.3); color: #ffd4d4; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.empty-state { text-align: center; padding: 40px; color: var(--muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.mobile-toggle { display: none; }

/* Diff view */
.diff-block { font-family: "JetBrains Mono", monospace; font-size: 13px; background: var(--panel-soft); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 8px; white-space: pre-wrap; line-height: 1.6; }
.diff-add { color: var(--green); background: rgba(35,211,107,0.08); }
.diff-remove { color: var(--red); background: rgba(255,77,77,0.08); }
.diff-toggle { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.diff-toggle:hover { text-decoration: underline; }

/* Mobile sidebar toggle */
.mobile-toggle { display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; color: var(--text); font-size: 18px; cursor: pointer; }
@media (max-width: 920px) {
  .mobile-toggle { display: block; position: fixed; top: 12px; left: 12px; z-index: 1000; }
  .sidebar { transform: translateX(-100%); position: fixed; left: 0; top: 0; height: 100vh; width: 260px; z-index: 999; transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { padding-top: 52px; }
}
