:root {
  --bg: #0a0f17;
  --bg-2: #101826;
  --panel: #121b2a;
  --panel-2: #16223a;
  --line: #22304a;
  --text: #e6edf7;
  --muted: #8fa3bf;
  --accent: #38e0a8;
  --accent-2: #4aa8ff;
  --danger: #ff5c6c;
  --warn: #ffb44a;
  --ok: #38e0a8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: radial-gradient(1200px 600px at 20% -10%, #12304a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0d1521, #0a111c);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #04121a; font-weight: 800;
}
.brand h1 { font-size: 15px; margin: 0; letter-spacing: .3px; }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; color: var(--muted);
  font-weight: 500; font-size: 13px;
}
.nav a:hover { background: #16202f; color: var(--text); }
.nav a.active { background: #1b2b40; color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .ico { width: 16px; text-align: center; opacity: .9; }

.side-footer { margin-top: auto; font-size: 11px; color: var(--muted); display: grid; gap: 6px; }
.side-footer .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.side-footer .dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.main { padding: 20px 24px 48px; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.topbar .pill { font-size: 11px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.topbar .pill b { color: var(--text); }

/* ---------- cards ---------- */
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .sub { color: var(--muted); font-size: 11px; margin-top: 4px; }
.kpi.good .value { color: var(--ok); }
.kpi.bad .value { color: var(--danger); }
.kpi.warn .value { color: var(--warn); }

.score-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.gauge { position: relative; width: 118px; height: 118px; flex: 0 0 auto; }
.gauge svg { transform: rotate(-90deg); }
.gauge .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.gauge .num small { display: block; font-size: 9px; color: var(--muted); letter-spacing: 1px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.badge.ok { color: var(--ok); border-color: #1c4a3c; background: #0e2b23; }
.badge.bad { color: var(--danger); border-color: #4a1c22; background: #2b0e13; }
.badge.warn { color: var(--warn); border-color: #4a3a1c; background: #2b210e; }
.badge.info { color: var(--accent-2); border-color: #1c344a; background: #0e1d2b; }

.sev-critical, .sev-high { color: var(--danger); }
.sev-medium { color: var(--warn); }
.sev-low, .sev-info { color: var(--muted); }

.level-normal { color: var(--ok); }
.level-suspicious, .level-elevated { color: var(--warn); }
.level-high, .level-critical { color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; padding: 9px 12px; background: #101a29; color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; }
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #131f31; }
td.mono, .mono { font-family: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ---------- forms ---------- */
label.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  background: #0c1522; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; color: var(--text); width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(74, 168, 255, .12); }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; min-width: 0; }
.row .shrink { flex: 0 0 auto; }

button.btn {
  border: 1px solid var(--line); background: #182638; border-radius: 9px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 12.5px;
  transition: .15s ease;
}
button.btn:hover { border-color: #32496b; background: #1d2f45; }
button.btn.primary { background: linear-gradient(135deg, var(--accent), #2fbf8f); color: #04170f; border: none; }
button.btn.primary:hover { filter: brightness(1.06); }
button.btn.danger { background: #2b0e13; border-color: #4a1c22; color: var(--danger); }
button.btn.ghost { background: transparent; }
button.btn.small { padding: 5px 9px; font-size: 11px; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.tabs button.active { color: var(--text); background: #1b2b40; border-color: #2c405e; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 150px; }
.bar { height: 8px; border-radius: 999px; background: #122032; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; padding: 5px 0; }
.cat-row .k { color: var(--muted); }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.spark i { flex: 1; background: linear-gradient(180deg, rgba(74,168,255,.85), rgba(56,224,168,.35)); border-radius: 2px 2px 0 0; min-height: 2px; }

/* ---------- login ---------- */
.login-wrap {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(800px 400px at 50% 0%, #14304a 0%, transparent 60%), var(--bg);
  z-index: 50; padding: 20px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; padding-bottom: 6px; }
.login-card p.lead { color: var(--muted); text-align: center; margin: 4px 0 22px; font-size: 12.5px; }

/* ---------- toast / modal ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; }
.toast { background: #16233a; border: 1px solid var(--line); border-left: 3px solid var(--accent-2); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px; max-width: 360px; }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

.modal-back { position: fixed; inset: 0; background: rgba(4, 9, 15, .72); display: grid; place-items: center; z-index: 70; padding: 20px; }
.modal { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.notice { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; }
  .brand { padding: 0; }
  .nav { flex-direction: row; }
  .nav a span.txt { display: none; }
  .side-footer { display: none; }
  .main { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
