:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #dddcd6;
  --grid: #ecebe6;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --band: rgba(42, 120, 214, 0.07);
  --good: #0d7a3a;
  --warning: #9a5b00;
  --critical: #b3261e;
  --warning-bg: #fff4dc;
  --critical-bg: #fde8e6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #34332f;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --band: rgba(57, 135, 229, 0.12);
    --good: #4cc27a;
    --warning: #e0a43a;
    --critical: #f07a71;
    --warning-bg: #3a2c0f;
    --critical-bg: #3d1a17;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --border: #34332f;
  --grid: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --band: rgba(57, 135, 229, 0.12);
  --good: #4cc27a;
  --warning: #e0a43a;
  --critical: #f07a71;
  --warning-bg: #3a2c0f;
  --critical-bg: #3d1a17;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }

.shell { display: flex; min-height: 100vh; }
.menu {
  width: 190px; flex: none; padding: 1rem 0.75rem;
  background: var(--surface-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.15rem;
}
.brand { font-weight: 600; margin: 0 0.5rem 0.75rem; }
.menu a {
  color: var(--text-primary); text-decoration: none;
  padding: 0.35rem 0.5rem; border-radius: 6px;
}
.menu a[aria-current="page"] { background: var(--surface-0); font-weight: 600; }
.menu a:hover { background: var(--surface-0); }
.controls { margin: 1rem 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.logout { margin: auto 0.5rem 0; }
.content { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 3rem; }

button {
  font: inherit; padding: 0.4rem 0.75rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { border: 0; background: none; color: var(--text-secondary); padding: 0; }

.headline { color: var(--text-secondary); margin-bottom: 1rem; }
.badge {
  display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.8rem;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.badge.warning { color: var(--warning); border-color: var(--warning); }
.notice { padding: 0.6rem 0.8rem; border-radius: 6px; margin: 0 0 1rem; }
.notice.warning { background: var(--warning-bg); color: var(--warning); }
.notice.critical { background: var(--critical-bg); color: var(--critical); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface-1); }
th, td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.85rem; }
td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.provisional { color: var(--text-muted); font-style: italic; }
pre.log {
  background: var(--surface-1); border: 1px solid var(--border); padding: 0.75rem;
  overflow-x: auto; white-space: pre-wrap; font-size: 0.8rem;
}

code { overflow-wrap: anywhere; }
.doc { min-width: 0; }
.doc table { display: block; overflow-x: auto; width: auto; }
.doc pre { overflow-x: auto; }
details { margin: 0.5rem 0; }
summary { cursor: pointer; color: var(--text-secondary); }

.chart { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
         padding: 0.5rem; margin: 1rem 0; position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--surface-0);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.5rem;
  font-size: 0.8rem; display: none; white-space: nowrap;
}
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.85rem;
          color: var(--text-secondary); margin: 0.25rem 0.5rem; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid;
            vertical-align: middle; margin-right: 0.35rem; }
.legend i.dash { border-top-style: dashed; }
.legend i.dot { border-top-style: dotted; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
         padding: 1.5rem; width: min(340px, calc(100vw - 32px)); }
.login form { display: flex; flex-direction: column; gap: 0.75rem; }
.login label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--text-secondary); }
.login input { font: inherit; padding: 0.45rem; border-radius: 6px;
               border: 1px solid var(--border); background: var(--surface-0);
               color: var(--text-primary); }
.error { color: var(--critical); }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .menu { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0;
          border-bottom: 1px solid var(--border); padding: 0.5rem 16px; }
  .brand { width: 100%; margin-bottom: 0.25rem; }
  .controls { flex-direction: row; margin: 0.25rem 0; }
  .logout { margin: 0.25rem 0; }
  .content { padding: 1rem 16px 2rem; }
}
