:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --warning-bg: #fff4d6;
  --critical: #d03b3b;
  --good-text: #006300;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --warning-bg: #3a2f10;
    --good-text: #0ca30c;
    --focus: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --warning-bg: #3a2f10;
  --good-text: #0ca30c;
  --focus: #3987e5;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font:
    14px / 1.45 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
h1 {
  font-size: 20px;
  margin: 0 0 6px;
}
h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}
code {
  font-size: 12px;
}
.muted {
  color: var(--text-secondary);
  font-weight: 400;
}
.small {
  font-size: 12px;
}
.error {
  color: var(--critical);
  min-height: 1.2em;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand {
  font-weight: 650;
  font-size: 15px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.brand .muted {
  font-size: 12px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--series-1);
}
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.controls label {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-secondary);
}
button,
select,
input {
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
button {
  cursor: pointer;
}
button:hover,
select:hover {
  border-color: var(--axis);
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px 48px;
}
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 0 0 16px;
  min-width: 0;
}
figure.card {
  margin: 0 0 16px;
}
figcaption {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.login {
  max-width: 460px;
  margin: 10vh auto;
}
.login form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.login input {
  flex: 1;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.tile .label {
  color: var(--text-secondary);
  font-size: 12px;
}
.tile .value {
  font-size: 26px;
  font-weight: 650;
  margin-top: 2px;
  letter-spacing: -0.01em;
}
.tile .sub {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 16px;
}
.grid2 > .card,
.grid2 > figure.card {
  margin: 0 0 16px;
}
.chart {
  width: 100%;
  position: relative;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart text {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart text.label {
  fill: var(--text-secondary);
}
.chart text.value {
  fill: var(--text-primary);
}
.gridline {
  stroke: var(--grid);
  stroke-width: 1;
}
.baseline {
  stroke: var(--axis);
  stroke-width: 1;
}
.crosshair {
  stroke: var(--axis);
  stroke-width: 1;
}
.empty {
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}
.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
}
th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr:last-child td {
  border-bottom: none;
}
.tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 10;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 120px;
}
.tooltip .t-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.tooltip .t-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.tooltip .t-row span:first-child {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text-secondary);
}
.tooltip i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}
.tooltip b {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
  main {
    padding: 12px;
  }
}

/* ---------- shell: nav, page head, filters, toast ---------- */
.layout {
  display: flex;
  align-items: flex-start;
  max-width: 1480px;
  margin: 0 auto;
}
.layout main {
  flex: 1;
  min-width: 0;
  margin: 0;
  max-width: none;
}
.nav {
  position: sticky;
  top: 57px;
  width: 200px;
  flex: none;
  padding: 16px 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 10px 4px;
}
.nav-section:first-child {
  padding-top: 0;
}
.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.nav a:hover {
  background: var(--surface-1);
  color: var(--text-primary);
}
.nav a.active {
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--series-1);
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.page-head h1 {
  margin: 0;
}
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filters[hidden] {
  display: none;
}
.filters label {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 13px;
}
.filters select {
  max-width: 200px;
}
.card-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.table-wrap {
  overflow-x: auto;
}
.tile.warn {
  background: var(--warning-bg);
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--series-1);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.toast.error {
  border-left-color: var(--critical);
}
@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }
  .nav {
    position: static;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px 12px;
  }
  .nav-section {
    display: none;
  }
}
