:root {
  --bg: #f6f7f5; --surface: #ffffff; --text: #1d2420; --muted: #6b746f; --border: #dde2de;
  --accent: #2f6f4f; --accent-text: #ffffff; --danger: #b3261e; --warn-bg: #fff6e0; --info-bg: #e8f1fb;
  --ok-bg: #e7f4ec; --err-bg: #fdecea; --radius: 8px; --good-text: #006300;
  /* chart tokens: validated categorical slots 1-2, blue sequential ramp, hairline chrome */
  --series-1: #2a78d6; --series-2: #eb6834; --grid: #e1e0d9; --axis: #c3c2b7; --night: rgba(13, 54, 107, .07);
  --seq-100: #cde2fb; --seq-300: #6da7ec; --seq-450: #2a78d6; --seq-600: #184f95; --seq-700: #0d366b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --surface: #1d2320; --text: #e4e9e6; --muted: #98a29c; --border: #2f3833;
    --accent: #5fae86; --accent-text: #0c120f; --danger: #f2867d; --warn-bg: #3a3220; --info-bg: #1d2c3c;
    --ok-bg: #1d3327; --err-bg: #3d2120; --good-text: #0ca30c;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2c2c2a; --axis: #383835; --night: rgba(205, 226, 251, .06);
    --seq-100: #1f2a36; --seq-300: #184f95; --seq-450: #2a78d6; --seq-600: #6da7ec; --seq-700: #cde2fb;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code { font-size: .9em; }
.muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--text); text-decoration: none; }
.topbar nav a:hover { color: var(--accent); }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; }
.spacer { flex: 1; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 .45em; font-size: .8em; }

.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; padding: .25rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: 2.2rem; z-index: 1000; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .4rem; min-width: 12rem; display: flex; flex-direction: column; gap: .2rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / .12); }
.menu-body a, .menu-body button { display: block; width: 100%; text-align: left; padding: .35rem .5rem; }

.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card.center { text-align: center; }
.card.warn { background: var(--warn-bg); }
.login { margin-top: 12vh; }
.row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.row h1 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; }
.tile .label { color: var(--muted); font-size: .85rem; }
.tile .value { font-size: 1.8rem; font-weight: 600; }
.mt { margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
table.dense td { padding: .3rem .5rem; font-size: .9rem; }
td.actions { display: flex; gap: .5rem; justify-content: flex-end; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; }
.field:has(input[type=checkbox]) { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .45rem .6rem; }
textarea { min-height: 5rem; }
.has-error input { border-color: var(--danger); }
small.error { color: var(--danger); }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

button, .button { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 6px; padding: .4rem .8rem; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.wide { width: 100%; }
button.linkish { border: none; background: none; color: var(--accent); padding: .25rem .5rem; }
button.linkish.active { font-weight: 700; }

.flash { padding: .6rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid var(--border); }
.flash.success { background: var(--ok-bg); }
.flash.error { background: var(--err-bg); }
.flash.info { background: var(--info-bg); }
.danger-zone { border-color: var(--danger); }

@media (max-width: 640px) {
  .topbar { padding: .5rem 1rem; }
  td.actions { flex-direction: column; }
}

.tile .value.small { font-size: 1.1rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.scroll-x { overflow-x: auto; }

.card.flush { padding: 0; overflow: hidden; }
.map { width: 100%; background: var(--border); }
.pad { padding: .5rem 1rem; margin: 0; }
.legend { padding: .5rem 1rem; color: var(--muted); font-size: .85rem; display: flex; gap: .4rem 1rem; flex-wrap: wrap; align-items: center; }
.dot { display: inline-block; width: .75rem; height: .75rem; border-radius: 50%; vertical-align: middle; }
.dot-ok { background: #2f9e5b; } .dot-late { background: #e0a100; } .dot-silent { background: #d64545; }
.dot-never { background: #8a8f8c; } .dot-empty { background: #5b7fbf; }
.grid2.wide-left { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 800px) { .grid2.wide-left { grid-template-columns: 1fr; } }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; min-width: 0; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.menu-body.wide { min-width: 18rem; max-height: 60vh; overflow: auto; right: auto; left: 0; }
label.check { display: flex; gap: .4rem; align-items: center; padding: .15rem .25rem; }
label.check.strong { font-weight: 600; margin-top: .3rem; }
label.check.indent { padding-left: 1.4rem; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: .4rem .7rem; cursor: pointer; border-left: 1px solid var(--border); background: var(--surface); }
.seg label:first-child span { border-left: none; }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.kpis .tile .delta { font-size: .85rem; color: var(--muted); }
.kpis .tile .delta.up { color: var(--good-text); }
.chart { width: 100%; }
.strips { display: grid; grid-template-columns: 1fr; gap: .25rem; margin-top: .5rem; }
.strips h3 { font-size: .85rem; font-weight: 500; color: var(--muted); margin: .25rem 0 0 0; }
.insights ul { margin: 0; padding-left: 1.2rem; }
.insights li { margin: .2rem 0; }
p.small { font-size: .85rem; margin: -.5rem 0 .5rem; }
table.num td, table.num th { font-variant-numeric: tabular-nums; }
.share { display: inline-block; width: 80px; height: 6px; background: var(--grid); border-radius: 3px; vertical-align: middle; margin-right: .4rem; overflow: hidden; }
.share span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
details > summary { cursor: pointer; color: var(--muted); margin-top: .5rem; }

/* status (never reused as series colors); always shown with a text label */
.sev { display: inline-block; font-size: .75rem; padding: 0 .45em; border-radius: 4px; color: #fff; text-transform: uppercase; letter-spacing: .03em; }
.sev-critical { background: #d03b3b; } .sev-serious { background: #ec835a; color: #0b0b0b; } .sev-warning { background: #fab219; color: #0b0b0b; }
.badge.alert { background: #d03b3b; color: #fff; }
.grid2.overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid2.overview { grid-template-columns: 1fr; } }
.small-h { font-size: .85rem; font-weight: 400; }
.legend .spacer { flex: 1; }
.kpis .tile .delta.down { color: var(--muted); }
table.num td:not(:first-child), table.num th:not(:first-child) { white-space: nowrap; }

/* --- responsive ------------------------------------------------------------------- */
.nav-toggle, .nav-burger { display: none; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.card { min-width: 0; }
main.container { overflow-wrap: break-word; }
@media (max-width: 760px) {
  .topbar { gap: .5rem; padding: .5rem 1rem; }
  .nav-burger { display: flex; flex-direction: column; justify-content: center; gap: 4px; width: 40px; height: 40px;
    margin-left: auto; order: 2; cursor: pointer; border: 1px solid var(--border); border-radius: 6px; padding: 0 9px; }
  .nav-burger span { display: block; height: 2px; background: var(--text); border-radius: 1px; }
  .topbar .spacer { display: none; }
  .mainnav { display: none !important; order: 3; width: 100%; flex-direction: column; gap: 0 !important; padding: .25rem 0; }
  .mainnav a { padding: .6rem .25rem; border-top: 1px solid var(--border); }
  .nav-toggle:checked ~ .mainnav { display: flex !important; }
  .topbar-right { order: 4; width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .nav-toggle:not(:checked) ~ .topbar-right { display: none; }
  .menu-body { right: auto; left: 0; }
  .container { margin: 1rem auto; padding: 0 .75rem; }
  .card { padding: 1rem .85rem; }
  h1 { font-size: 1.3rem; }
  .row { flex-wrap: wrap; }
  .hide-sm { display: none !important; }
  .tile .value { font-size: 1.5rem; }
  .filters { gap: .4rem; }
  .filters input[type=date] { flex: 1 1 8rem; min-width: 0; }
  .two { grid-template-columns: 1fr; gap: 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .tile { padding: .75rem; }
  td.actions { flex-direction: column; align-items: stretch; }
}
@media (max-width: 400px) { .hide-xs { display: none !important; } }
