:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: rgba(11, 11, 11, 0.10);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6e6d68;
  --accent: #2a78d6;
  --bar: #2a78d6;
  --track: #e1e0d9;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --link: #1c5cab;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: rgba(255, 255, 255, 0.10);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9b9a92;
    --accent: #3987e5;
    --bar: #3987e5;
    --track: #2c2c2a;
    --link: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: rgba(255,255,255,0.10);
  --text: #f0efec; --text-2: #c3c2b7; --muted: #9b9a92; --accent: #3987e5; --bar: #3987e5;
  --track: #2c2c2a; --link: #86b6ef;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--link); }
code { font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.err { color: var(--critical); min-height: 1.5em; margin: 8px 0 0; }
.stack { display: grid; gap: 12px; margin-top: 16px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 9px 14px; background: var(--accent); color: #fff; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.small { padding: 4px 10px; font-size: 13px; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.qr { background: #fff; border-radius: 8px; padding: 8px; width: 220px; max-width: 100%; margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }

.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
.spacer { flex: 1; }
.top strong, .top button, .chip { white-space: nowrap; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.icon-btn { display: none; background: transparent; color: var(--text); padding: 6px 10px; }
.nav { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto; }
.nav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.view { padding: 24px; min-width: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 20px; }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 30px; font-weight: 650; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--muted); }
.tile.na .value { font-size: 15px; font-weight: 500; color: var(--muted); }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 140px) 1fr 48px; align-items: center; gap: 10px; font-size: 14px; }
.bar-track { height: 10px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.dot { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.dot.good { background: var(--good); } .dot.warning { background: var(--warning); color: #0b0b0b; }
.dot.serious { background: var(--serious); } .dot.critical { background: var(--critical); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.links { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.link-card { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.link-card:hover { border-color: var(--accent); }
.link-card strong { display: block; } .link-card span { font-size: 13px; color: var(--muted); }
.note { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--text-2); margin-bottom: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.secret-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .icon-btn { display: inline-block; }
  .nav { position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 3; transform: translateX(-100%); transition: transform .2s; }
  .nav.open { transform: none; }
  .view { padding: 16px; }
  #updated, #who, #chpw { display: none; }
  .top { gap: 8px; }
}
@media print {
  .nav, .top, button { display: none !important; }
  .app { display: block; } .view { padding: 0; }
  .card { break-inside: avoid; }
}
