:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --forecast: #86b6ef;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --other: #a8a69f;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-text: #006300; --critical-text: #b42323; --warning-text: #8a5a00;
  --good-bg: #e6f5e6; --warning-bg: #fff4dc; --critical-bg: #fbe7e7;
  --input-bg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --accent-soft: #184f95; --forecast: #184f95;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --other: #6b6a65;
    --good-text: #0ca30c; --critical-text: #e66767; --warning-text: #fab219;
    --good-bg: #13260f; --warning-bg: #2e2508; --critical-bg: #2e1414;
    --input-bg: #232321;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --accent-soft: #184f95; --forecast: #184f95;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --other: #6b6a65;
  --good-text: #0ca30c; --critical-text: #e66767; --warning-text: #fab219;
  --good-bg: #13260f; --warning-bg: #2e2508; --critical-bg: #2e1414;
  --input-bg: #232321;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 14px; }
.muted { color: var(--text-2); margin: 0; }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-inner { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab { border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 500; padding: 6px 14px; border-radius: 7px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

main { padding-top: 20px; padding-bottom: 48px; }
.panel { display: none; }
.panel.active { display: block; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin: 0 0 16px; }
.empty { text-align: center; padding: 48px 18px; }

.status-banner { display: none; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; border: 1px solid var(--border); }
.status-banner.show { display: flex; }
.status-banner .icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; flex: none; }
.status-banner.good { background: var(--good-bg); color: var(--good-text); }
.status-banner.good .icon { background: var(--good); }
.status-banner.warning { background: var(--warning-bg); color: var(--warning-text); }
.status-banner.warning .icon { background: var(--warning); color: #0b0b0b; }
.status-banner.critical { background: var(--critical-bg); color: var(--critical-text); }
.status-banner.critical .icon { background: var(--critical); }
.status-banner .detail { font-weight: 400; color: var(--text-2); }

.notes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.notes li { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 8px; padding: 8px 12px; color: var(--text-2); font-size: 13px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.kpi .label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 600; margin: 4px 0 6px; overflow-wrap: anywhere; }
.kpi .sub { color: var(--text-2); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.kpi .sub b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi.hero .value { font-size: 32px; }
.meter { height: 6px; border-radius: 3px; background: var(--accent-soft); margin: 2px 0 8px; overflow: hidden; }
.meter > div { height: 100%; border-radius: 3px; background: var(--accent); }
.meter.warning > div { background: var(--warning); }
.meter.critical > div { background: var(--critical); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pill::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good-text); } .pill.good::before { background: var(--good); }
.pill.warning { color: var(--warning-text); } .pill.warning::before { background: var(--warning); }
.pill.critical { color: var(--critical-text); } .pill.critical::before { background: var(--critical); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.grid-2 .card { margin: 0; }
.grid-2 { margin-bottom: 16px; }
.chart-card { margin: 0 0 16px; }
.chart-card figcaption { margin-bottom: 10px; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
th { color: var(--text-2); font-weight: 500; font-size: 12px; background: var(--surface); position: sticky; top: 0; }
td { font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th.left, td.left { text-align: left; }
tbody tr:hover { background: var(--surface-2); }
tr.forecast td { color: var(--muted); font-style: italic; }
tr.nodata td { color: var(--muted); }
tfoot td { font-weight: 600; border-top: 1px solid var(--axis); border-bottom: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.neg { color: var(--critical-text); }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-style: normal; }
.tag.actual { background: var(--accent-soft); color: var(--text); }

.inline { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
select, input { font: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; }
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 20px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.form-grid label.check { flex-direction: row; align-items: flex-start; gap: 8px; grid-column: 1 / -1; font-weight: 400; }
.form-grid label.check input { margin-top: 3px; }
#overrideTable input { width: 160px; text-align: right; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--axis); background: var(--surface); color: var(--text); padding: 8px 16px; border-radius: 8px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--critical-text); }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.msg { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }
.msg.error { color: var(--critical-text); }
.msg.ok { color: var(--good-text); }

.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px dashed var(--axis); border-radius: 12px; padding: 36px 16px; margin-top: 14px; cursor: pointer; text-align: center; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: var(--surface-2); }
.drop-title { font-weight: 600; }
.progress { margin-top: 14px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.progress-track { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .2s; }
.formula { margin: 0; padding-left: 18px; color: var(--text-2); display: grid; gap: 6px; }
.formula b { color: var(--text); }

@media (max-width: 1000px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi .value { font-size: 20px; }
  .kpi.hero .value { font-size: 26px; }
  .chart-box { height: 240px; }
}
.status-banner { flex-wrap: wrap; }
.panel, .card, .grid-2 > *, .kpi-grid > * { min-width: 0; }
h1 { overflow-wrap: anywhere; }

.coverage { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.coverage .day { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--surface-2); display: flex; flex-direction: column; min-width: 0; }
.coverage .day span { color: var(--text-2); font-size: 11px; }
.coverage .day b { font-weight: 600; font-variant-numeric: tabular-nums; }
.coverage .day em { font-style: normal; font-size: 11px; color: var(--warning-text); }
.coverage .day.partial { border-color: var(--warning); }
.coverage .day.missing { background: var(--critical-bg); border-color: var(--critical); }
.coverage .day.missing b { color: var(--critical-text); font-weight: 500; }
.coverage .day.inbeginning { background: transparent; border-style: dashed; }
.coverage .day.inbeginning b { color: var(--text-2); font-weight: 500; }

code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border-radius: 6px; padding: 2px 6px; }
.webhook-url { margin: 12px 0; display: grid; gap: 6px; }
.url-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.url-row code { padding: 7px 10px; overflow-wrap: anywhere; }
.stat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 12px 0; }
.stat-list > div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; min-width: 0; }
.stat-list span { color: var(--text-2); font-size: 12px; }
.stat-list b { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cutover { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.cutover label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.coverage .day em.src { color: var(--accent); }

.topbar-inner { row-gap: 10px; }
.user-box { display: flex; align-items: center; gap: 8px; }
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: 100%; max-width: 380px; padding: 16px; }
.login-card { display: grid; gap: 14px; padding: 24px; }
.login-card h1 { font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.login-card .btn { width: 100%; padding: 10px; }
.login-card .msg { margin: 0; min-height: 1.5em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
