:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fa; --surface-3: #eef0f3; --border: #e2e5ea; --border-strong: #cdd2d9;
  --text: #0f1720; --text-2: #4a5462; --text-3: #6c7684; --accent: #1f5fbf; --accent-2: #174b99; --accent-soft: #e8f0fc; --focus: #3b82f6;
  --sidebar: #0e1621; --sidebar-text: #aab4c2; --sidebar-active: #ffffff; --sidebar-hover: #182231;
  --critical: #d03b3b; --high: #ec835a; --medium: #fab219; --low: #2a78d6; --good: #0ca30c; --good-text: #0a7d0a;
  --critical-soft: #fdecec; --high-soft: #fdf0ea; --medium-soft: #fef6e2; --low-soft: #e9f1fc; --good-soft: #e8f6e8;
  --grid: #e1e0d9; --axis: #c3c2b7; --code: #f1f3f5; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --radius: 10px; --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14; --surface: #121821; --surface-2: #161d27; --surface-3: #1c2430; --border: #232c38; --border-strong: #2f3a48;
    --text: #e8ecf1; --text-2: #b4bdc9; --text-3: #8893a2; --accent: #5b9bf0; --accent-2: #7cb0f5; --accent-soft: #15263d; --focus: #5b9bf0;
    --sidebar: #080b10; --sidebar-hover: #121821;
    --critical-soft: #3a1717; --high-soft: #3a2116; --medium-soft: #372a0e; --low-soft: #14243a; --good-soft: #10291a; --good-text: #3ec13e;
    --low: #3987e5; --grid: #2c2c2a; --axis: #383835; --code: #0e141c; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f14; --surface: #121821; --surface-2: #161d27; --surface-3: #1c2430; --border: #232c38; --border-strong: #2f3a48;
  --text: #e8ecf1; --text-2: #b4bdc9; --text-3: #8893a2; --accent: #5b9bf0; --accent-2: #7cb0f5; --accent-soft: #15263d; --focus: #5b9bf0;
  --sidebar: #080b10; --sidebar-hover: #121821;
  --critical-soft: #3a1717; --high-soft: #3a2116; --medium-soft: #372a0e; --low-soft: #14243a; --good-soft: #10291a; --good-text: #3ec13e;
  --low: #3987e5; --grid: #2c2c2a; --axis: #383835; --code: #0e141c; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--sidebar) 232px, var(--bg) 232px); }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; }
.brand svg { flex: none; }
.brand b { display: block; font-size: 14px; letter-spacing: .01em; }
.brand small { display: block; font-size: 11.5px; color: var(--sidebar-text); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav a.active { background: #1b2635; color: var(--sidebar-active); }
.nav a svg { opacity: .85; flex: none; }
.nav .badge { margin-left: auto; background: var(--critical); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #5f6b7b; padding: 16px 10px 6px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #1d2734; padding: 14px 8px 0; font-size: 12.5px; }
.sidebar-foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .role { color: var(--sidebar-text); text-transform: capitalize; }
.sidebar-foot .row { display: flex; gap: 6px; margin-top: 10px; }
.sidebar-foot button { flex: 1; background: transparent; border: 1px solid #2a3544; color: var(--sidebar-text); border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: 12px; }
.sidebar-foot button:hover { color: #fff; border-color: #3a4757; }
.mobile-bar { display: none; }

main { min-width: 0; padding: 26px 32px 64px; max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; letter-spacing: -.015em; margin: 0; line-height: 1.25; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.crumb { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.updated { font-size: 12px; color: var(--text-3); }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; font-size: 13px; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--critical); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number], select, textarea {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; padding: 7px 10px; min-height: 34px; font-size: 13px; max-width: 100%; }
textarea { width: 100%; min-height: 76px; resize: vertical; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text-2); }
label.field input, label.field select { width: 100%; }
.hint { font-size: 12.5px; color: var(--text-3); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 220px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; color: var(--text-3); font-weight: 500; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { color: var(--text-3); font-weight: 400; margin-left: 4px; }

/* Cards and panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.panel > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel > header h2 { font-size: 14px; margin: 0; font-weight: 600; }
.panel > header .hint { margin: 0; }
.panel .body { padding: 16px 18px; }
.panel .body.flush { padding: 0; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.kpi .sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; }
a.kpi { color: inherit; display: block; }

.banner { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 16px; box-shadow: var(--shadow); }
.banner .icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.banner b { display: block; font-size: 15px; }
.banner span { color: var(--text-3); font-size: 13px; }
.banner.critical { border-color: color-mix(in srgb, var(--critical) 40%, var(--border)); }
.banner.critical .icon { background: var(--critical-soft); color: var(--critical); }
.banner.warning .icon { background: var(--high-soft); color: var(--high); }
.banner.good .icon { background: var(--good-soft); color: var(--good-text); }

/* Severity and status */
.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--low); flex: none; }
.sev.critical::before { background: var(--critical); }
.sev.high::before { background: var(--high); }
.sev.medium::before { background: var(--medium); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 18px; margin-right: 6px; }
.pill.open { background: var(--critical-soft); color: var(--critical); }
.pill.acknowledged { background: var(--medium-soft); color: color-mix(in srgb, var(--medium) 55%, var(--text)); }
.pill.resolved, .pill.pass, .pill.online { background: var(--good-soft); color: var(--good-text); }
.pill.false_positive { background: var(--surface-3); color: var(--text-3); }
.pill.fail, .pill.gap, .pill.offline { background: var(--critical-soft); color: var(--critical); }
.pill.unknown, .pill.pending { background: var(--surface-3); color: var(--text-3); }
.pill.monitored { background: var(--low-soft); color: var(--low); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 7px; vertical-align: 1px; }
.dot.online { background: var(--good); }
.dot.offline { background: var(--critical); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip b { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--text-3); margin-left: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
.sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 1px; overflow-wrap: anywhere; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.wrap { overflow-wrap: anywhere; }
.empty { padding: 28px 18px; text-align: center; color: var(--text-3); }
.empty b { display: block; color: var(--text-2); margin-bottom: 2px; }
.more { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); gap: 12px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list a.row { display: flex; gap: 12px; color: inherit; width: 100%; }
.list a.row:hover { text-decoration: none; }
.list li:hover:has(a.row) { background: var(--surface-2); }
.list .main { flex: 1; min-width: 0; }
.list .main b { display: block; font-weight: 600; font-size: 13.5px; }
.list .main span { display: block; color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { color: var(--text-3); font-size: 12px; white-space: nowrap; text-align: right; }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 7px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv ul { margin: 0; padding-left: 16px; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin: 20px 0 8px; }
.section-title:first-child { margin-top: 0; }
.prose { color: var(--text-2); margin: 0 0 4px; }

/* Meters and charts */
.meter { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.meter svg { flex: 1; min-width: 60px; }
.meter .num { font-size: 12.5px; font-weight: 600; width: 40px; text-align: right; }
.track { fill: var(--surface-3); }
.fill-good { fill: var(--good); } .fill-medium { fill: var(--medium); } .fill-high { fill: var(--high); } .fill-critical { fill: var(--critical); } .fill-low { fill: var(--low); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.chart .line { fill: none; stroke: var(--low); stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: color-mix(in srgb, var(--low) 14%, transparent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.critical { background: var(--critical); } .legend i.high { background: var(--high); } .legend i.medium { background: var(--medium); } .legend i.low { background: var(--low); }
.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 7px 9px; border-radius: 6px; white-space: nowrap; z-index: 5; transform: translate(-50%, -100%); margin-top: -8px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tooltip b { display: block; margin-bottom: 2px; }
.bars .bar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.bars .bar-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bars .bar-row .num { text-align: right; font-weight: 600; }
.bars svg rect.v { fill: var(--low); }
.score { display: flex; align-items: baseline; gap: 4px; }

/* Code blocks */
pre.code { background: var(--code); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font: 12.5px/1.55 var(--mono); overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; align-items: flex-start; }
.copy-row pre { flex: 1; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 17px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--text-3); font-size: 12px; }
.timeline .what { overflow-wrap: anywhere; }

/* Disclosure rows */
details.row-detail { border-bottom: 1px solid var(--border); }
details.row-detail:last-child { border-bottom: 0; }
details.row-detail > summary { list-style: none; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 18px; cursor: pointer; }
details.row-detail > summary::-webkit-details-marker { display: none; }
details.row-detail > summary::before { content: "›"; color: var(--text-3); font-size: 16px; transition: transform .15s; display: inline-block; width: 22px; text-align: center; }
details.row-detail[open] > summary::before { transform: rotate(90deg); }
details.row-detail > summary:hover { background: var(--surface-2); }
details.row-detail .detail-body { padding: 4px 18px 16px 50px; color: var(--text-2); font-size: 13px; }
.row-title b { font-weight: 600; }
.row-title span { display: block; color: var(--text-3); font-size: 12.5px; overflow-wrap: anywhere; }

/* Dialog */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(8, 12, 18, .55); }
dialog header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
dialog header h2 { margin: 0; font-size: 16px; }
dialog .body { padding: 18px 20px; }
dialog footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.icon-btn { background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 20px; line-height: 1; padding: 4px; }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 13px; background: var(--medium-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--medium) 35%, transparent); margin-bottom: 14px; }
.notice.error { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.notice.info { background: var(--low-soft); border-color: color-mix(in srgb, var(--low) 30%, transparent); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 8px; font-size: 13px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 40px); }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; border: 1px solid var(--border); }
.qr svg { display: block; width: 180px; height: 180px; }
.skeleton { color: var(--text-3); padding: 40px 0; text-align: center; }

/* Login */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 30px 28px; box-shadow: var(--shadow); }
.auth-card .brand { color: var(--text); padding: 0 0 22px; }
.auth-card .brand small { color: var(--text-3); }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p { color: var(--text-3); margin: 0 0 20px; }
.auth-card input { width: 100%; font-size: 16px; min-height: 40px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.auth-card .error { color: var(--critical); font-size: 13px; min-height: 20px; margin: 0 0 8px; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--text-3); text-align: center; }

@media (max-width: 1100px) {
  .grid.two, .grid.side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .banner { flex-wrap: wrap; }
  .banner .btn { margin-left: 48px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; background: var(--sidebar); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 30; }
  .mobile-bar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
  main { padding: 18px 16px 48px; }
  .grid.halves { grid-template-columns: minmax(0, 1fr); }
  .filters input[type=search] { min-width: 0; flex: 1 1 100%; }
  .hide-sm { display: none; }
  .bars .bar-row { grid-template-columns: 110px minmax(0, 1fr) 40px; }
  details.row-detail .detail-body { padding-left: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Utilities (inline style attributes are blocked by the CSP) */
.u-stat { font-size: 20px; font-weight: 650; }
.u-m0 { margin: 0; } .u-mt0 { margin-top: 0; } .u-mt6 { margin-top: 6px; } .u-mt8 { margin-top: 8px; } .u-mt12 { margin: 12px 0 0; }
.u-mb6 { margin-bottom: 6px; } .u-mb12 { margin-bottom: 12px; } .u-mb14 { margin-bottom: 14px; } .u-mb16 { margin-bottom: 16px; }
.u-mlauto { margin-left: auto; } .u-narrow { max-width: 560px; } .u-center { margin: 40px auto; }
