/* Roles from the reference palette; dark values are selected steps, not a
   flip. Series colors live here so chart and chrome swap together. */
.viz-root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.viz-root {
  min-height: 100vh;
  background: var(--page);
  color: var(--text-primary);
  padding: 24px 20px 48px;
  max-width: 960px;
  margin: 0 auto;
}
.page-head h1 { margin: 0; font-size: 22px; }
.page-head .sub { margin: 2px 0 20px; color: var(--text-secondary); font-size: 14px; }

.tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
}
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 28px; font-weight: 650; margin: 2px 0; }
.tile-note { color: var(--text-secondary); font-size: 12px; }

.notice {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  position: relative;
}
.card h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.controls { display: flex; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 12px; padding: 5px 10px; cursor: pointer;
}
.seg button.on { background: var(--grid); color: var(--text-primary); font-weight: 600; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 4px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 6px; vertical-align: baseline;
}
.swatch[data-service="openai"] { background: var(--series-1); }
.swatch[data-service="anthropic"] { background: var(--series-2); }
.swatch[data-service="twilio"] { background: var(--series-3); }
.swatch[data-service="fixed"] { background: var(--series-4); }

.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--muted); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  color: var(--text-secondary); min-width: 150px;
}
.tooltip .tt-day { color: var(--text-primary); font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.tooltip .num { font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--grid); }
td { padding: 5px 6px; border-bottom: 1px solid var(--grid); color: var(--text-primary); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.login-page { display: grid; place-items: center; min-height: 100vh; background: #f9f9f7; font-family: system-ui, sans-serif; }
.login-form { display: flex; flex-direction: column; gap: 10px; width: 240px; }
.login-form h1 { margin: 0; font-size: 20px; }
.login-form input, .login-form button { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(11,11,11,0.2); }
.login-form button { cursor: pointer; }
.error { color: #d03b3b; font-size: 13px; margin: 0; }
