/* ==========================================================================
   Sentinel AI — professional network defence console
   Dark, high-contrast, dense but calm. No external assets (offline friendly).
   ========================================================================== */

:root {
  --bg: #060a12;
  --bg-soft: #0a101c;
  --panel: #0d1524;
  --panel-2: #111c2e;
  --panel-3: #152235;
  --line: rgba(148, 163, 184, 0.13);
  --line-strong: rgba(148, 163, 184, 0.24);
  --text: #e8eefb;
  --text-soft: #c3cfe3;
  --muted: #8b9bb5;
  --muted-2: #64748b;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.12);
  --blue: #3b82f6;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.28);
  --sidebar: 256px;
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 82% -18%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(900px 600px at 4% 110%, rgba(59, 130, 246, 0.10), transparent 55%),
    var(--bg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: #7ee7f7; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }

::selection { background: rgba(34, 211, 238, 0.3); }

/* ------------------------------------------------------------- app shell */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  background: linear-gradient(180deg, #0a111d 0%, #080d17 100%);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(34, 211, 238, 0.22), rgba(59, 130, 246, 0.12));
  border: 1px solid rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.18);
  color: var(--cyan);
  flex: 0 0 auto;
}
.brand-mark svg { width: 23px; height: 23px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
.brand-sub {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-section {
  margin: 18px 10px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 550;
  border: 1px solid transparent;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.nav-link svg { width: 18px; height: 18px; opacity: 0.8; flex: 0 0 auto; }
.nav-link:hover { background: rgba(148, 163, 184, 0.07); color: var(--text); }
.nav-link.active {
  color: #d9fbff;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.17), rgba(34, 211, 238, 0.04));
  border-color: rgba(34, 211, 238, 0.22);
  box-shadow: inset 3px 0 0 var(--cyan);
}
.nav-link.active svg { opacity: 1; color: var(--cyan); }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
}
.nav-badge:empty { display: none; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
}
.sidebar-footer .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.06);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-soft);
}

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 28px;
  background: rgba(6, 10, 18, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-title { font-size: 20px; font-weight: 680; letter-spacing: -0.02em; }
.page-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.mobile-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(13, 21, 36, 0.9);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2.2s infinite;
}
.live-dot.offline { background: var(--red); animation: none; box-shadow: none; }
.live-dot.warn { background: var(--amber); animation: none; box-shadow: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}
.user-chip:hover { border-color: var(--line-strong); color: var(--text); }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #04121a;
  font-size: 12px;
  font-weight: 800;
}

.content { padding: 26px 28px 42px; width: 100%; max-width: 1640px; margin: 0 auto; flex: 1; }

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 28px 20px;
  color: var(--muted-2);
  font-size: 11.5px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); }
.grid-wide { grid-template-columns: minmax(0, 2fr) minmax(300px, 0.9fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* ------------------------------------------------------------------ card */
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(17, 28, 46, 0.92), rgba(11, 18, 31, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.24), transparent);
  opacity: 0.7;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.card-title { font-size: 13.5px; font-weight: 680; letter-spacing: 0.01em; }
.card-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }

/* ------------------------------------------------------------------- kpi */
.kpi {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px 17px;
  min-height: 104px;
}
.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.18);
}
.kpi-icon svg { width: 19px; height: 19px; }
.kpi-icon.green { background: var(--green-soft); color: var(--green); border-color: rgba(52, 211, 153, 0.2); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.2); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(251, 191, 36, 0.2); }
.kpi-icon.purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(167, 139, 250, 0.2); }
.kpi-meta { min-width: 0; }
.kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.kpi-value { font-size: 26px; font-weight: 720; letter-spacing: -0.03em; margin-top: 2px; line-height: 1.15; }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.kpi-trend { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi-trend.good { color: var(--green); }
.kpi-trend.bad { color: var(--red); }
.kpi-trend.warn { color: var(--amber); }

/* ----------------------------------------------------------------- badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.6;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: rgba(52, 211, 153, 0.22); }
.badge-red { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.22); }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(251, 191, 36, 0.22); }
.badge-cyan { background: var(--cyan-soft); color: var(--cyan); border-color: rgba(34, 211, 238, 0.22); }
.badge-purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(167, 139, 250, 0.22); }
.badge-muted { background: rgba(148, 163, 184, 0.08); color: var(--muted); border-color: var(--line); }
.badge-solid {
  background: linear-gradient(135deg, var(--red), #dc2626);
  color: #fff;
  border: none;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(148, 163, 184, 0.07);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: rgba(148, 163, 184, 0.13); border-color: var(--line-strong); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  border-color: rgba(34, 211, 238, 0.5);
  color: #04121a;
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.22);
}
.btn-primary:hover { background: linear-gradient(135deg, #4ce3f5, #22b3ec); color: #04121a; }
.btn-danger { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.35); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); color: #fecaca; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}
.field-hint { font-size: 11px; color: var(--muted-2); line-height: 1.45; }
.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(4, 9, 17, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.input::placeholder { color: var(--muted-2); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea.input { min-height: 92px; resize: vertical; font-family: var(--mono); font-size: 12px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.input-mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.02em; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  border: 1px solid var(--line-strong);
  transition: background 0.18s ease, border-color 0.18s ease;
  flex: 0 0 auto;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch input:checked + .switch-track { background: rgba(52, 211, 153, 0.35); border-color: rgba(52, 211, 153, 0.55); }
.switch input:checked + .switch-track::after { transform: translateX(17px); background: var(--green); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18); }
.switch-label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }

/* ------------------------------------------------------- router checkbox */
.router-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.06);
  color: var(--text-soft);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.router-option:hover { border-color: var(--line-strong); }
.router-option input { accent-color: var(--cyan); margin: 0; }
.router-option:has(input:checked) { border-color: rgba(34, 211, 238, 0.4); background: var(--cyan-soft); }
.router-option-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }
.router-option-dot.online { background: var(--green); }

/* ----------------------------------------------------------------- table */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: rgba(4, 9, 17, 0.35);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid rgba(148, 163, 184, 0.07); vertical-align: middle; }
table.data tbody tr { transition: background 0.12s ease; }
table.data tbody tr:hover { background: rgba(34, 211, 238, 0.035); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.01em; }
.cell-muted { color: var(--muted); }
.cell-strong { font-weight: 650; }
.cell-nowrap { white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.table-empty { padding: 34px 20px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ----------------------------------------------------------------- chart */
.chart-wrap { position: relative; width: 100%; height: 190px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 11px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--cyan); }
.legend-swatch.amber { background: var(--amber); }
.legend-swatch.red { background: var(--red); }

/* ------------------------------------------------------------- bar list */
.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(92px, 1.1fr) minmax(60px, 2fr) 40px; gap: 10px; align-items: center; }
.bar-label { font-size: 11.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 7px; border-radius: 999px; background: rgba(148, 163, 184, 0.13); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--blue)); min-width: 2px; transition: width 0.4s ease; }
.bar-fill.amber { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.bar-fill.red { background: linear-gradient(90deg, var(--red), #ef4444); }
.bar-fill.green { background: linear-gradient(90deg, var(--green), #10b981); }
.bar-value { font-size: 11px; color: var(--muted); text-align: right; font-family: var(--mono); }

/* --------------------------------------------------------------- live feed */
.feed { display: flex; flex-direction: column; max-height: 430px; overflow-y: auto; }
.feed-item {
  display: flex;
  gap: 11px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  animation: feedIn 0.25s ease;
}
@keyframes feedIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.feed-item:last-child { border-bottom: none; }
.feed-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}
.feed-icon svg { width: 14px; height: 14px; }
.feed-icon.blocked { background: var(--red-soft); color: var(--red); }
.feed-icon.whitelisted { background: var(--green-soft); color: var(--green); }
.feed-icon.dry-run { background: var(--amber-soft); color: var(--amber); }
.feed-icon.system { background: var(--cyan-soft); color: var(--cyan); }
.feed-icon.error { background: var(--red-soft); color: var(--red); }
.feed-body { min-width: 0; flex: 1; }
.feed-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.feed-src { font-family: var(--mono); font-size: 12px; font-weight: 650; color: var(--text); }
.feed-msg { color: var(--muted); font-size: 11.5px; margin-top: 3px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed-meta { margin-left: auto; color: var(--muted-2); font-size: 10.5px; font-family: var(--mono); white-space: nowrap; }

/* ------------------------------------------------------------ router cards */
.router-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.router-card { display: flex; flex-direction: column; }
.router-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; }
.router-avatar {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.2);
  flex: 0 0 auto;
}
.router-avatar.offline { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.2); }
.router-avatar svg { width: 20px; height: 20px; }
.router-name { font-size: 14px; font-weight: 680; }
.router-host { font-family: var(--mono); color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.router-status { margin-left: auto; }
.router-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(4, 9, 17, 0.25);
}
.router-stat { text-align: center; }
.router-stat strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.router-stat span { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.07em; }
.router-meta { padding: 12px 18px; display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; }
.router-meta .kv { display: flex; justify-content: space-between; gap: 12px; }
.router-meta .kv span:first-child { color: var(--muted-2); }
.router-meta .kv span:last-child { color: var(--text-soft); text-align: right; overflow-wrap: anywhere; }
.router-actions { display: flex; gap: 7px; padding: 12px 18px 16px; flex-wrap: wrap; margin-top: auto; }
.router-actions .btn { flex: 1 0 auto; min-width: max-content; }

.rules-box { margin: 0 18px 14px; padding: 10px 12px; border-radius: 9px; background: rgba(4, 9, 17, 0.4); border: 1px solid var(--line); font-size: 11px; }
.rules-box .rules-line { display: flex; gap: 8px; align-items: flex-start; padding: 2px 0; color: var(--muted); }
.rules-box .rules-line strong { color: var(--text-soft); font-weight: 600; }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 13, 0.72);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(520px, 100%);
  background: linear-gradient(180deg, #111c2e, #0b1320);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 0; }
.modal-title { font-size: 16px; font-weight: 680; }
.modal-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 0 20px 20px; }

/* ------------------------------------------------------------------ toast */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; width: min(360px, calc(100vw - 36px)); }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 11px;
  background: #101b2c;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--text-soft);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.success { border-color: rgba(52, 211, 153, 0.45); }
.toast.error { border-color: rgba(248, 113, 113, 0.45); }
.toast.warn { border-color: rgba(251, 191, 36, 0.45); }
.toast-icon { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.toast.success .toast-icon { color: var(--green); }
.toast.error .toast-icon { color: var(--red); }
.toast.warn .toast-icon { color: var(--amber); }
.toast.info .toast-icon { color: var(--cyan); }
.toast-close { margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 16px; line-height: 1; }

/* --------------------------------------------------------------- callouts */
.callout {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.05);
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.55;
}
.callout svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.callout strong { color: var(--text); }
.callout-info { background: var(--cyan-soft); border-color: rgba(34, 211, 238, 0.22); }
.callout-info svg { color: var(--cyan); }
.callout-warn { background: var(--amber-soft); border-color: rgba(251, 191, 36, 0.24); }
.callout-warn svg { color: var(--amber); }
.callout-danger { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.24); }
.callout-danger svg { color: var(--red); }
.callout-success { background: var(--green-soft); border-color: rgba(52, 211, 153, 0.22); }
.callout-success svg { color: var(--green); }

/* ------------------------------------------------------------ key/value */
.kv-list { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid rgba(148, 163, 184, 0.07); font-size: 12.5px; }
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--muted); }
.kv-val { color: var(--text-soft); text-align: right; font-weight: 550; overflow-wrap: anywhere; }
.kv-val.mono { font-family: var(--mono); font-size: 11.5px; }

.code-block {
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(3, 7, 14, 0.8);
  border: 1px solid var(--line);
  color: #b7c6dc;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  overflow: auto;
  max-height: 430px;
  white-space: pre;
}

/* --------------------------------------------------------------- hero card */
.hero {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px 26px;
  background:
    radial-gradient(540px 200px at 88% 20%, rgba(34, 211, 238, 0.14), transparent 70%),
    linear-gradient(120deg, rgba(17, 28, 46, 0.96), rgba(10, 17, 30, 0.96));
  flex-wrap: wrap;
}
.hero-gauge {
  position: relative;
  width: 112px;
  height: 112px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
.hero-gauge svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.hero-gauge .gauge-value { font-size: 25px; font-weight: 750; letter-spacing: -0.03em; }
.hero-gauge .gauge-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.hero-main { flex: 1; min-width: 220px; }
.hero-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.hero-sub { color: var(--muted); font-size: 12.5px; margin-top: 5px; max-width: 620px; }
.hero-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; }

/* ------------------------------------------------------------------ misc */
.mono { font-family: var(--mono); }
.text-muted { color: var(--muted); }
.text-soft { color: var(--text-soft); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-cyan { color: var(--cyan); }
.text-sm { font-size: 11.5px; }
.text-xs { font-size: 10.5px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-family: var(--mono);
  white-space: nowrap;
}
.score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-soft);
}
.score-bar { width: 46px; height: 4px; border-radius: 999px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.score-bar i { display: block; height: 100%; border-radius: 999px; background: var(--amber); }
.score-bar i.high { background: var(--red); }
.score-bar i.low { background: var(--green); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: rgba(4, 9, 17, 0.55); border: 1px solid var(--line); }
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 11px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
}
.segmented button.active { background: rgba(34, 211, 238, 0.14); color: var(--cyan); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 38px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(148, 163, 184, 0.07); border: 1px solid var(--line); color: var(--muted-2); }
.empty-icon svg { width: 20px; height: 20px; }
.empty-title { color: var(--text-soft); font-weight: 650; font-size: 13px; }
.empty-text { font-size: 11.5px; max-width: 360px; }

.skeleton { border-radius: 6px; background: linear-gradient(90deg, rgba(148, 163, 184, 0.06), rgba(148, 163, 184, 0.13), rgba(148, 163, 184, 0.06)); background-size: 200% 100%; animation: shimmer 1.4s infinite; min-height: 12px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- login */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bg);
}
.login-aside {
  position: relative;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(700px 420px at 20% 12%, rgba(34, 211, 238, 0.16), transparent 65%),
    radial-gradient(600px 420px at 80% 92%, rgba(59, 130, 246, 0.16), transparent 65%),
    linear-gradient(160deg, #0b1320, #060a12);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.login-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 30% 30%, #000 25%, transparent 75%);
  pointer-events: none;
}
.login-aside > * { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 13px; }
.login-brand .brand-mark { width: 46px; height: 46px; }
.login-headline { font-size: clamp(28px, 3.4vw, 42px); font-weight: 740; letter-spacing: -0.03em; line-height: 1.12; max-width: 520px; }
.login-headline span { color: var(--cyan); }
.login-lead { color: var(--muted); font-size: 14px; max-width: 470px; margin-top: 16px; line-height: 1.65; }
.login-features { display: flex; flex-direction: column; gap: 11px; margin-top: 28px; }
.login-feature { display: flex; align-items: center; gap: 10px; color: var(--text-soft); font-size: 12.5px; }
.login-feature-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(34, 211, 238, 0.1); border: 1px solid rgba(34, 211, 238, 0.2); color: var(--cyan); flex: 0 0 auto; }
.login-feature-icon svg { width: 14px; height: 14px; }
.login-foot { color: var(--muted-2); font-size: 11px; line-height: 1.7; }

.login-main { display: flex; align-items: center; justify-content: center; padding: 34px; }
.login-card { width: min(410px, 100%); }
.login-card .brand-mobile { display: none; }
.login-title { font-size: 23px; font-weight: 720; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 15px; }
.login-form .field > label { font-size: 11.5px; }
.login-card .btn-primary { padding: 11px 14px; font-size: 13px; }
.login-note { margin-top: 18px; color: var(--muted-2); font-size: 11px; text-align: center; line-height: 1.65; }
.login-error {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--red-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fecaca;
  font-size: 12px;
  margin-bottom: 4px;
}
.login-error svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--red); margin-top: 1px; }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 42px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.password-toggle:hover { color: var(--text); }
.password-toggle svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main, .grid-wide { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-card .brand-mobile { display: flex; margin-bottom: 28px; }
}

@media (max-width: 860px) {
  :root { --sidebar: 0px; }
  .sidebar {
    width: 270px;
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(2, 6, 13, 0.62);
    backdrop-filter: blur(2px);
  }
  .main { margin-left: 0; }
  .mobile-toggle { display: grid; place-items: center; }
  .content { padding: 18px 16px 32px; }
  .topbar { padding: 12px 16px; }
  .page-title { font-size: 17px; }
  .page-subtitle { display: none; }
  .footer { padding: 12px 16px 18px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .live-pill span.label { display: none; }
  .user-chip .user-name { display: none; }
  .hero { padding: 18px; gap: 16px; }
  .hero-gauge { width: 92px; height: 92px; }
  .router-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

@media (max-width: 560px) {
  .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
  .card-head { flex-wrap: wrap; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .toolbar-right .btn { flex: 1; }
  .hero-actions .btn { flex: 1; }
  .bar-row { grid-template-columns: 82px 1fr 34px; }
  .login-main { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.language-form { display:flex; align-items:center; gap:8px; margin:0; }
.language-form label { font-size:12px; color:var(--text-muted, #a0aec0); }
.language-form select { width:132px; min-width:0; }
.login-language { position:absolute; top:18px; right:24px; z-index:2; }
@media (max-width: 640px) { .language-form label { display:none; } .language-form select { width:108px; } .topbar-right { gap:6px; flex-wrap:wrap; } .login-language { position:relative; top:auto; right:auto; display:flex; justify-content:flex-end; padding:12px; } }
