:root {
  color-scheme: light;
  --bg: #F4F7F5; --surface: #FFFFFF; --surface-2: #EDF2EF; --ink: #172420; --muted: #5C6B66; --line: #D8E0DC;
  --accent: #1E6F5C; --accent-ink: #145546; --accent-soft: #DDEFE8;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --good-soft: #e3f4e3; --warn-soft: #fff1d6; --serious-soft: #fde7de; --crit-soft: #f8dede; --info-soft: #dfe9f3; --info: #2F5D8A;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(23,36,32,.06), 0 6px 20px -14px rgba(23,36,32,.2);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1614; --surface: #182220; --surface-2: #1F2B28; --ink: #E4ECE8; --muted: #9AAAA3; --line: #2A3834;
    --accent: #5CC3A2; --accent-ink: #8ED9C1; --accent-soft: #173A31;
    --good-soft: #173426; --warn-soft: #3a2e15; --serious-soft: #3b2320; --crit-soft: #3b2020; --info-soft: #1B2C3E; --info: #6FA3DA;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --grid: #2c3a36; --axis: #384843;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1614; --surface: #182220; --surface-2: #1F2B28; --ink: #E4ECE8; --muted: #9AAAA3; --line: #2A3834;
  --accent: #5CC3A2; --accent-ink: #8ED9C1; --accent-soft: #173A31;
  --good-soft: #173426; --warn-soft: #3a2e15; --serious-soft: #3b2320; --crit-soft: #3b2020; --info-soft: #1B2C3E; --info: #6FA3DA;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --grid: #2c3a36; --axis: #384843;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px -14px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
h1, h2, h3 { font-family: "Bricolage Grotesque", system-ui, sans-serif; letter-spacing: -0.01em; margin: 0; line-height: 1.15; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ----- layout ----- */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1320px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 18px; height: 52px; }
.brand { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
nav.main { display: flex; gap: 4px; }
nav.main a { padding: 6px 10px; border-radius: 6px; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
nav.main a:hover { background: var(--surface-2); text-decoration: none; }
nav.main a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.badge.ok { background: var(--good); }
.spacer { flex: 1; }
.page { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head form { margin-left: auto; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { display: flex; align-items: baseline; gap: 10px; }
.card h2 .sub { font-family: system-ui, sans-serif; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; background: var(--good-soft); border: 1px solid var(--good); }
.flash.err { background: var(--crit-soft); border-color: var(--crit); }

/* ----- stat tiles ----- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); display: block; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile .l { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 26px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.tile .v.warn { color: var(--serious); }
.tile .v.crit { color: var(--crit); }
.tile .v.good { color: var(--good); }
.tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ----- tables ----- */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; padding: 8px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 18px; }
.chip.ok { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: #8a5a00; }
.chip.serious { background: var(--serious-soft); color: var(--serious); }
.chip.crit { background: var(--crit-soft); color: var(--crit); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.neutral { background: var(--surface-2); color: var(--muted); }
.chip.acc { background: var(--accent-soft); color: var(--accent-ink); }
:root[data-theme="dark"] .chip.warn { color: #f0c15a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.warn { color: #f0c15a; } }

/* ----- forms & buttons ----- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; line-height: 1.3; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.ghost { border-color: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { padding: 5px 8px; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.field { display: grid; gap: 3px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; }

/* ----- detail split ----- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.viewer { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; height: calc(100vh - 140px); min-height: 560px; position: sticky; top: 70px; }
.viewer iframe, .viewer img { width: 100%; height: 100%; border: 0; object-fit: contain; background: #fff; }
.reasons li { margin: 2px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ----- charts ----- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.chart .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 5px; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); display: none; min-width: 140px; z-index: 5; }
.chart .tip .h { color: var(--muted); margin-bottom: 3px; }
.chart .tip .r { display: flex; justify-content: space-between; gap: 12px; }
.chart .tip .r b { font-variant-numeric: tabular-nums; }
.chart .tip .r i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 5px; }
.chart .tools { display: flex; justify-content: flex-end; }
.chart .tools button { background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 4px; }
.chart .tools button:hover { color: var(--ink); }
.chart table.t { margin-top: 8px; font-size: 12.5px; }
.chart text { font-family: system-ui, -apple-system, sans-serif; fill: var(--muted); font-size: 11px; }
.chart .bar { rx: 0; }
.chart .bar:hover { filter: brightness(1.1); }
.chart .lbl { fill: var(--ink); font-size: 11px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis line { stroke: var(--axis); stroke-width: 1; }

.deadlines li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.deadlines li:last-child { border-bottom: 0; }
.deadlines .when { font-variant-numeric: tabular-nums; color: var(--muted); }
.deadlines .soon { color: var(--serious); font-weight: 600; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 5px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
.theme-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
details summary { cursor: pointer; color: var(--muted); }
pre.json { background: var(--surface-2); padding: 10px; border-radius: 6px; overflow: auto; font-size: 11.5px; max-height: 320px; }
