:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --border: rgba(11, 11, 11, 0.10);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --good: #006300;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --border: rgba(255, 255, 255, 0.10);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --good: #0ca30c;
    --critical: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --border: rgba(255, 255, 255, 0.10);
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3987e5;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --good: #0ca30c;
  --critical: #e66767;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }

header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px max(16px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
header h1 { font-size: 18px; margin: 0; font-weight: 650; }
header .meta { color: var(--muted); font-size: 13px; margin-right: auto; }
.ghost {
  border: 1px solid var(--border); background: transparent; border-radius: 8px;
  padding: 6px 12px; cursor: pointer; color: var(--text-2);
}
.ghost:hover { background: var(--grid); }

nav.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 8px max(16px, calc((100vw - 1200px) / 2)) 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
nav.tabs button {
  border: 0; background: none; padding: 10px 14px; cursor: pointer;
  color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1232px; margin: 0 auto; padding: 16px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters .label { color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--grid); color: var(--text); font-weight: 600; }

.filters select, .filters input {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 6px 10px;
}
.filters input { flex: 1 1 220px; min-width: 0; }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }
.kw-card { margin-bottom: 16px; }
.kw-card summary { cursor: pointer; list-style-position: inside; }
.kw-card .kw-title { font-weight: 600; }
.kw-group { margin-top: 16px; }
.kw-group h3 { font-size: 14px; margin: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 13px; background: var(--page);
}
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 6px; font-size: 15px; line-height: 1; }
.chip button:hover { color: var(--critical); }
.kw-add { display: flex; gap: 6px; }
.kw-add input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 6px 10px; }
.kw-status { font-size: 13px; color: var(--good); min-height: 1.5em; margin-top: 8px; }
.kw-status.error { color: var(--critical); }

.table-wrap.tall { max-height: none; }
table.notices td { white-space: normal; vertical-align: top; padding: 10px; }
table.notices a { font-weight: 500; }
table.notices .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
table.notices .reason { color: var(--text-2); width: 30%; }
@media (max-width: 640px) {
  table.notices .reason, table.notices th:nth-child(2) { display: none; }
}

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 540px), 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); margin-bottom: 16px; }
.card, .tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-width: 0;
}
.card { padding: 16px; }
.card h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.card-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.card-head > div { margin-right: auto; }
.card-head .ghost { padding: 2px 10px; font-size: 13px; }
.chart-box { position: relative; height: 260px; }
.card.wide { grid-column: 1 / -1; }

.tile { padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile .note { color: var(--muted); font-size: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: -4px 0 8px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.legend i.box { width: 10px; height: 10px; border-radius: 2px; }

.table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 160px; }

.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.live .dot { background: var(--good); }
.error { color: var(--critical); }
[hidden] { display: none !important; }
