:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #152033;
  --muted: #5d6b7c;
  --line: #dbe2ea;
  --accent: #0e7c73;
  --accent-2: #1d4ed8;
  --accent-ink: #ffffff;
  --ok: #067647;
  --bad: #b42318;
  --warn: #b54708;
  --crit: #b42318;
  --high: #c4320a;
  --med: #b54708;
  --low: #175cd3;
  --radius: 14px;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar: #10161e;
  --sidebar-ink: #eef3f8;
  --sidebar-muted: #8b99a8;
  --sidebar-line: #243140;
  --sidebar-active: #16332f;
  --chart-grid: rgba(21, 32, 51, 0.08);
  --chart-tick: #5d6b7c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

html[data-theme="dark"] {
  --bg: #0b1017;
  --surface: #141b24;
  --surface-2: #1c2530;
  --ink: #e8eef5;
  --muted: #91a0b0;
  --line: #2a3544;
  --accent: #2dd4bf;
  --accent-2: #60a5fa;
  --accent-ink: #042f2e;
  --ok: #32d583;
  --bad: #f97066;
  --warn: #f79009;
  --crit: #f97066;
  --high: #fb923c;
  --med: #fbbf24;
  --low: #7dd3fc;
  --sidebar: #080c11;
  --sidebar-ink: #eef3f8;
  --sidebar-muted: #8b99a8;
  --sidebar-line: #1c2633;
  --sidebar-active: #12332e;
  --chart-grid: rgba(232, 238, 245, 0.08);
  --chart-tick: #91a0b0;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--muted); }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 1.15rem 0.9rem;
  border-right: 1px solid var(--sidebar-line);
}
.brand, .login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
  padding: 0.2rem 0.45rem 1.2rem;
}
.brand:hover, .login-brand:hover { text-decoration: none; }
.brand strong, .login-brand strong { display: block; letter-spacing: -0.03em; font-size: 1.02rem; }
.brand small, .login-brand small { color: var(--sidebar-muted); font-size: 0.72rem; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 8px;
  border: 2px solid var(--accent-ink);
  border-radius: 4px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.18rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: 0.65rem;
  color: var(--sidebar-muted);
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  font-weight: 500;
  font-size: 0.92rem;
}
.sidebar nav a svg {
  width: 17px; height: 17px; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.sidebar nav a:hover { color: var(--sidebar-ink); text-decoration: none; background: var(--sidebar-active); }
.sidebar nav a.is-active { color: var(--sidebar-ink); background: var(--sidebar-active); }
.sidebar-foot { margin-top: auto; padding: 1rem 0.35rem 0.15rem; border-top: 1px solid var(--sidebar-line); }
.who { display: flex; align-items: center; gap: 0.65rem; margin: 0.85rem 0 0.45rem; }
.who strong { display: block; font-size: 0.88rem; }
.who small { color: var(--sidebar-muted); text-transform: capitalize; }
.who-avatar {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--sidebar-active); color: var(--accent);
  font-weight: 700; text-transform: uppercase; font-size: 0.82rem;
}
.theme-btn, .linkish {
  font: inherit; background: transparent; color: var(--sidebar-muted);
  border: 1px solid var(--sidebar-line); border-radius: 8px;
  padding: 0.38rem 0.65rem; cursor: pointer;
}
.linkish { border: 0; padding: 0; }
.theme-btn:hover, .linkish:hover { color: var(--sidebar-ink); }

.main { flex: 1; padding: 1.4rem 1.7rem 2.6rem; min-width: 0; max-width: 1320px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.04em; }
.page-head p { margin: 0.2rem 0 0; }
.eyebrow { margin: 0 0 0.15rem !important; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.crumb { margin: 0 0 0.2rem; font-size: 0.85rem; }
.head-meta { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.head-stat { font-size: 0.82rem; color: var(--muted); }
.head-stat strong { color: var(--ink); font-weight: 650; margin-left: 0.2rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; margin-bottom: 1rem; }
.kpi, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi { padding: 1rem 1.1rem 1.05rem; position: relative; overflow: hidden; }
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.kpi:nth-child(2)::before { background: var(--high); }
.kpi:nth-child(3)::before { background: var(--accent-2); }
.kpi:nth-child(4)::before { background: var(--ok); }
.kpi-label { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi strong { display: block; font-size: 1.7rem; letter-spacing: -0.04em; margin: 0.22rem 0 0.1rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 0.8rem; }
.panel { padding: 1.05rem 1.15rem 1.15rem; margin-bottom: 1rem; }
.panel h2 { margin: 0; font-size: 0.98rem; letter-spacing: -0.02em; }
.panel-sub { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.78rem; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; margin-bottom: 0.75rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-chart { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1rem; }
.narrow { max-width: 520px; }

.chart-panel { min-width: 0; }
.chart-frame { position: relative; width: 100%; }
.chart-frame-lg { height: 280px; }
.chart-frame-md { height: 220px; }
.chart-frame-donut { height: 280px; }
.chart-frame-bar { height: 260px; }
.chart-frame canvas { width: 100% !important; height: 100% !important; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.68rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.table-tight td, .table-tight th { padding: 0.58rem 0.65rem; }

.pill {
  display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--surface-2);
}
.pill.critical { background: #fce8e6; color: var(--crit); }
.pill.high { background: #fceada; color: var(--high); }
.pill.medium { background: #fef4e6; color: var(--med); }
.pill.low { background: #e6f0fb; color: var(--low); }
.pill.neutral { background: var(--surface-2); color: var(--ink); }
html[data-theme="dark"] .pill.critical { background: #3a1614; }
html[data-theme="dark"] .pill.high { background: #3a2210; }
html[data-theme="dark"] .pill.medium { background: #3a2c10; }
html[data-theme="dark"] .pill.low { background: #10243a; }

.flash { padding: 0.7rem 0.9rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: #e7f6ee; color: var(--ok); }
.flash.err { background: #fde8e8; color: var(--bad); }
html[data-theme="dark"] .flash.ok { background: #123226; }
html[data-theme="dark"] .flash.err { background: #3a1614; }

.btn, button.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  padding: 0.48rem 0.9rem;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn:hover { filter: brightness(0.98); text-decoration: none; }

label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 500; font-size: 0.9rem; }
input, select {
  font: inherit; padding: 0.52rem 0.72rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.filters input { flex: 1; }
.filters.stacked { flex-direction: column; }
.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; }
.actions { display: flex; gap: 0.4rem; align-items: center; justify-content: flex-end; }
.mt { margin-top: 1rem; }

.engine-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.38rem 0.75rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 0.82rem; font-weight: 650;
}
.engine-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.engine-chip.is-up .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.engine-chip.is-down .dot { background: var(--bad); }

.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) 110px 42px; gap: 0.65rem; align-items: center; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.rank-track i { display: block; height: 100%; background: var(--accent); }
.rank-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; }

.sev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.sev-list li { display: flex; justify-content: space-between; align-items: center; }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 1rem 0 0; }
.meta dt { color: var(--muted); font-size: 0.75rem; }
.meta dd { margin: 0.15rem 0 0; font-weight: 600; }
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem 1.2rem; margin: 0; }
.detail dt { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.detail dd { margin: 0.2rem 0 0; }
.audit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; font-size: 0.9rem; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }
.pager { display: flex; gap: 1rem; align-items: center; padding: 0.8rem 0.2rem 0.2rem; color: var(--muted); }

.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem 1.5rem 1.7rem;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 0.25rem; letter-spacing: -0.03em; }
.login-brand { padding: 0 0 1rem; color: var(--ink); }
.login-brand small { color: var(--muted); }
.theme-btn-float {
  position: fixed; top: 1rem; left: 1rem;
  color: var(--muted); border-color: var(--line);
}

@media (max-width: 1100px) {
  .kpis, .grid-2, .grid-chart, .detail { grid-template-columns: 1fr; }
  .chart-frame-lg, .chart-frame-donut { height: 240px; }
}
@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; border: 0; display: flex; align-items: center; gap: 0.8rem; }
  .main { padding: 1.1rem; }
}
