/* Saothar — chart page.
   Series colours are the validated two-slot categorical set (blue = the broad
   aggregate, orange = the sub-group in question), stepped separately for the
   dark surface. Text never wears a series colour; the swatch beside it carries
   identity. */

:root {
  color-scheme: light;
  --surface-0: #f6f6f3;
  --surface-1: #fcfcfb;
  --line:      #e2e1da;
  --grid:      #ebeae3;
  --ink:       #14150f;
  --ink-2:     #52514e;
  --ink-3:     #78776f;
  --accent:    #2c6e64;
  --series-1:  #2a78d6;
  --series-2:  #eb6834;
  --good:      #157a4a;
  --bad:       #b3261e;
  --radius:    10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110; --surface-1: #1a1a19; --line: #2e2e2b; --grid: #262625;
    --ink: #f4f4ef; --ink-2: #c3c2b7; --ink-3: #8d8c83;
    --accent: #6bbfab; --series-1: #3987e5; --series-2: #d95926;
    --good: #4aa87a; --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110; --surface-1: #1a1a19; --line: #2e2e2b; --grid: #262625;
  --ink: #f4f4ef; --ink-2: #c3c2b7; --ink-3: #8d8c83;
  --accent: #6bbfab; --series-1: #3987e5; --series-2: #d95926;
  --good: #4aa87a; --bad: #e66767;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--surface-0); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 62rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }

header.head { border-bottom: 1px solid var(--line); padding-bottom: 1.25rem; margin-bottom: 1.75rem; }
h1 { font-family: var(--serif); font-size: 2rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--accent); }
h1 .gloss { color: var(--ink-3); font-size: 0.95rem; font-family: var(--sans); font-weight: 400; letter-spacing: 0; margin-left: 0.6rem; }
.sub { color: var(--ink-2); margin: 0.4rem 0 0; max-width: 44rem; }
.meta { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); margin-top: 0.75rem; }
.meta b { color: var(--ink-2); font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 2.25rem; }
.tile { background: var(--surface-1); padding: 0.9rem 1rem 1rem; }
.tile dt { min-height: 2.4em; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin: 0 0 0.35rem; }
.tile dd { margin: 0; font-family: var(--mono); font-size: 1.6rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.tile .unit { font-size: 0.9rem; color: var(--ink-3); margin-left: 0.1rem; }
.tile .when { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3); margin-top: 0.3rem; }

figure.chart { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  margin: 0 0 1.5rem; padding: 1.25rem 1.25rem 1rem; }
figure.chart figcaption { margin: 0 0 0.15rem; }
.chart h2 { font-size: 1rem; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.chart .note { color: var(--ink-2); font-size: 0.82rem; margin: 0.2rem 0 0.9rem; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.75rem 0 0; padding: 0; list-style: none;
  font-size: 0.8rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 0.4rem; }
.legend .swatch { width: 0.7rem; height: 0.7rem; border-radius: 2px; flex: none; }

.axis text { font-family: var(--mono); font-size: 10px; fill: var(--ink-3); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.zeroline { stroke: var(--line); stroke-width: 1; }
.serieslabel { font-family: var(--sans); font-size: 11px; font-weight: 600; }
.crosshair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }

.tip { position: absolute; pointer-events: none; opacity: 0; transition: opacity 120ms;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.12); padding: 0.5rem 0.65rem; font-size: 0.78rem;
  min-width: 8.5rem; z-index: 10; }
.tip .p { font-family: var(--mono); color: var(--ink-3); font-size: 0.72rem; margin-bottom: 0.3rem; }
.tip .row { display: flex; align-items: center; gap: 0.4rem; justify-content: space-between; }
.tip .row span:first-child { display: flex; align-items: center; gap: 0.35rem; color: var(--ink-2); }
.tip .row b { font-family: var(--mono); font-weight: 500; }

details.data { margin-top: 0.75rem; }
details.data summary { cursor: pointer; font-size: 0.8rem; color: var(--ink-2); }
details.data table, table.sectors { border-collapse: collapse; margin-top: 0.6rem; width: 100%;
  font-family: var(--mono); font-size: 0.75rem; }
details.data th, details.data td, table.sectors th, table.sectors td {
  text-align: right; padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--grid); white-space: nowrap; }
details.data th:first-child, details.data td:first-child,
table.sectors th:first-child, table.sectors td:first-child { text-align: left; white-space: normal; }
details.data thead th, table.sectors thead th { color: var(--ink-3); font-weight: 500;
  position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
table.sectors tbody tr.total td { font-weight: 600; border-bottom: 1px solid var(--line); }
table.sectors tbody tr.ict td:first-child { color: var(--series-2); font-weight: 600; }
.scroll { overflow-x: auto; max-height: 18rem; overflow-y: auto; }

.recon { font-size: 0.8rem; margin: 0.9rem 0 0; padding: 0.55rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--line); color: var(--ink-2); }
.recon.ok { border-color: color-mix(in srgb, var(--good) 35%, var(--line)); }
.recon.bad { border-color: var(--bad); color: var(--bad); }
.recon b { font-family: var(--mono); font-weight: 500; }

footer { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
  font-size: 0.8rem; color: var(--ink-3); }
footer a { color: var(--accent); }
.err { border: 1px solid var(--bad); color: var(--bad); border-radius: var(--radius); padding: 1rem; }
