/* Layout: controls bar on top, then a two-column grid of chart panels (one column on phones).
   Utilitarian analyst tool: quiet chrome, color reserved for the data. */
:root {
  color-scheme: light;
  --page: #f6f7f6;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --grid: #e5e4de;
  --axis: #c3c2b7;
  --line: rgba(11, 11, 11, 0.12);
  --accent: #1c5cab;
  --accent-soft: #e3edf9;
  --price: #0b0b0b;
  --band: rgba(11, 11, 11, 0.07);
  /* categorical slots, fixed order */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c7-soft: #a58ff7; --c8: #e34948;
  --c-other: #9a9891;
  --seq-lo: #eef4fc; --seq-hi: #0d366b;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f0f0f; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8d86;
    --grid: #2c2c2a; --axis: #45453f; --line: rgba(255, 255, 255, 0.12);
    --accent: #6da7ec; --accent-soft: #1c2a3d; --price: #ffffff; --band: rgba(255, 255, 255, 0.09);
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #9085e9; --c7-soft: #5a48c0; --c8: #e66767; --c-other: #77756f;
    --seq-lo: #1d2633; --seq-hi: #9ec5f4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f0f; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8d86;
  --grid: #2c2c2a; --axis: #45453f; --line: rgba(255, 255, 255, 0.12);
  --accent: #6da7ec; --accent-soft: #1c2a3d; --price: #ffffff; --band: rgba(255, 255, 255, 0.09);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9; --c7-soft: #5a48c0; --c8: #e66767; --c-other: #77756f;
  --seq-lo: #1d2633; --seq-hi: #9ec5f4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 var(--font-ui); }
.page { max-width: 1440px; margin: 0 auto; padding-inline: 20px; padding-block: 20px 40px; }

/* masthead */
.masthead { display: flex; flex-wrap: wrap; gap: 8px 32px; align-items: end; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
h1 { font: 600 26px/1.1 var(--font-head); letter-spacing: 0.01em; margin: 0 0 4px; text-wrap: balance; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; font-size: 13px; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.nav a:hover { color: var(--ink); border-color: var(--muted); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.sub { margin: 0; color: var(--ink-2); max-width: 70ch; }
.status { margin: 0; font: 12px/1.4 var(--font-data); color: var(--muted); max-width: 52ch; }

/* controls */
.controls { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end;
  background: var(--page); padding-block: 12px; border-bottom: 1px solid var(--line); }
.ctl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ctl-hour { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
.lbl { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.source-note { margin: 0; font-size: 12px; color: var(--muted); max-width: 36ch; }
.lbl.inline { align-self: center; }
.lbl output { font: 500 12px var(--font-data); letter-spacing: 0; text-transform: none; color: var(--ink); margin-left: 6px; }
select, input[type="search"], input[type="number"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: 34px; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 8px 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { font: inherit; color: var(--ink-2); background: transparent; border: 0; padding: 6px 12px; min-height: 34px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--surface); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg-sm button { font-size: 12px; padding: 4px 10px; min-height: 30px; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* panels */
main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; position: relative; }
.panel-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; z-index: 3; }
.panel-actions:not(:empty) ~ .panel-head { padding-right: 72px; }
.panel-wide { grid-column: 1 / -1; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: start; }
.panel-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.panel-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
h2 { font: 600 17px/1.2 var(--font-head); margin: 0 0 4px; letter-spacing: 0.01em; }
.h-note { font: 500 11px var(--font-data); color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.note { margin: 0; color: var(--ink-2); font-size: 13px; max-width: 80ch; }
.chart { width: 100%; min-height: 120px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.empty { color: var(--muted); font-size: 13px; padding: 28px 0; text-align: center; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); }
.legend button { font: inherit; color: inherit; background: none; border: 0; padding: 2px 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.legend button[aria-pressed="false"] { opacity: 0.35; }
.legend-static > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-line { width: 16px; height: 0; border-top: 2px dashed var(--c-other); border-radius: 0; }
.mk { display: inline-block; width: 0; height: 11px; border-left: 2px dashed; margin: 0 5px -1px 2px; }
.sw-neg { width: 3px; height: 10px; border-radius: 0; background: var(--ink); margin-inline: 4px; }

/* svg chrome */
.axis text { fill: var(--muted); font: 11px var(--font-data); font-variant-numeric: tabular-nums; }
.axis path, .axis line { stroke: var(--axis); }
.gridline line { stroke: var(--grid); }
.gridline path { display: none; }
.zero { stroke: var(--axis); }
.axis-title { fill: var(--muted); font: 11px var(--font-ui); }
.dlabel { font: 500 11px var(--font-ui); fill: var(--ink-2); }
.price-rule { stroke: var(--price); stroke-width: 1.5; }
.price-band { fill: var(--band); }
.lsl-band { fill: var(--ink); opacity: 0.06; }
.lsl-rule { stroke: var(--ink); stroke-dasharray: 4 3; opacity: 0.45; }
.lsl-label { font-size: 11px; fill: var(--muted); }
.mix-label { font-size: 13px; fill: var(--ink-2); }
.mix-value { font: 12px var(--font-data); fill: var(--ink); }
.price-label { fill: var(--ink); font: 500 11px var(--font-data); }
.price-label-bg { fill: var(--surface); }
.crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }

/* tooltip */
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); max-width: 300px; }
.tip h4 { margin: 0 0 4px; font: 600 12px var(--font-data); }
.tip table { border-collapse: collapse; }
.tip td { padding: 1px 6px 1px 0; }
.tip td.n { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }

/* tables */
.scroll-x { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child, table.data td.t, table.data th.t { text-align: left; }
table.data th { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; background: var(--surface); }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data td { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
table.data td.t { font-family: var(--font-ui); }
table.data tr:hover td { background: var(--accent-soft); }
.bar-cell { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--accent); vertical-align: middle; margin-left: 6px; opacity: 0.7; }
.table-view summary { cursor: pointer; color: var(--ink-2); font-size: 12px; }
.units-wrap { max-height: 520px; overflow: auto; }
.heat-scale { display: flex; align-items: center; gap: 8px; font: 11px var(--font-data); color: var(--muted); }
.heat-scale .ramp { width: 160px; height: 10px; border-radius: 3px; }

.foot { margin-top: 24px; color: var(--muted); font-size: 12px; max-width: 100ch; }
.foot a { color: var(--accent); }

@media (max-width: 900px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .controls { position: static; }
}
@media (max-width: 480px) {
  .page { padding-inline: 16px; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.linkish { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.has-tip { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
th.sortable.has-tip { cursor: pointer; }
.tip .tip-body { margin: 0; line-height: 1.45; color: var(--ink-2); }
.tip { max-width: 320px; }
.date-step { display: flex; gap: 4px; align-items: stretch; }
.step { font: 600 18px/1 var(--font-ui); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  min-width: 34px; min-height: 34px; padding: 0 8px; cursor: pointer; }
.step:hover:not(:disabled) { background: var(--accent-soft); }
.step:disabled { opacity: 0.35; cursor: not-allowed; }

/* pinned chart readouts, download menu, copy link */
.tip.tip-pinned { position: absolute; z-index: 15; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); }
.tip-pin-note { margin: 6px 0 0; font-size: 11px; color: var(--muted); }
.crosshair.pin-mark { stroke: var(--ink); stroke-dasharray: none; opacity: 0.7; }
details.dl { position: relative; }
details.dl > summary { list-style: none; }
details.dl > summary::-webkit-details-marker { display: none; }
details.dl > summary:hover { color: var(--ink); border-color: var(--muted); }
.dl-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; min-width: 140px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }
.dl-menu button { font: inherit; font-size: 13px; text-align: left; color: var(--ink); background: none; border: 0; border-radius: 5px; padding: 7px 10px; cursor: pointer; }
.dl-menu button:hover:not(:disabled) { background: var(--accent-soft); }
.dl-menu button:disabled { color: var(--muted); cursor: default; }
.nav-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.nav-row .nav { margin-bottom: 0; }
/* icon buttons: download and copy link, on panels and in the header */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px;
  background: none; color: var(--muted); cursor: pointer; font: inherit; }
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn.copied { color: var(--c3); border-color: var(--c3); }
.copy-link { font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.tip td.n { white-space: nowrap; }
.sub-h { font-size: 0.95rem; font-weight: 600; margin: 1.4rem 0 0.2rem; }
.tip .muted { color: var(--muted); }

/* min/max price boxes next to a chart's range buttons */
.price-range { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-2); }
.price-range[hidden] { display: none; }
.price-range input { width: 72px; min-height: 30px; padding: 3px 6px; font-size: 12px; }
.link-btn { font: inherit; font-size: 12px; color: var(--accent); background: none; border: 0; padding: 4px; cursor: pointer; }
.st-grid th { text-align: center; }
.st-grid th .muted { font-weight: 400; text-transform: none; letter-spacing: 0; }
.st-grid td:nth-child(n+4) { text-align: center; min-width: 58px; }
.st-grid td.st-na { background: repeating-linear-gradient(135deg, var(--line) 0 2px, transparent 2px 7px); }
.st-grid th.st-na { color: var(--line); }

/* Overview: headline box, capacity bars, layer cards */
:root { --g1: #0d366b; --g2: #1f4f96; --g3: #2f6fc4; --g4: #4f8fdc; --g5: #7fb0ec; --g6: #a8c8f0; --track: rgba(11, 11, 11, 0.08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --g1: #9ec5f4; --g2: #7fb0ec; --g3: #5a95e0; --g4: #3b78c8; --g5: #2a5a9c; --g6: #1d4274; --track: rgba(255, 255, 255, 0.1); } }
:root[data-theme="dark"] { --g1: #9ec5f4; --g2: #7fb0ec; --g3: #5a95e0; --g4: #3b78c8; --g5: #2a5a9c; --g6: #1d4274; --track: rgba(255, 255, 255, 0.1); }
.headline { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px 32px; align-items: start; }
@media (max-width: 900px) { .headline { grid-template-columns: 1fr; } }
.lede { font: 600 28px/1.15 var(--font-head); letter-spacing: 0.005em; margin: 0; text-wrap: balance; }
.lede .lvl { display: inline-block; padding: 0 10px; border-radius: 6px; color: #fff; }
.lede-sub { margin: 6px 0 0; color: var(--ink-2); max-width: 62ch; }
.expect { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; }
.expect li { border-top: 2px solid var(--line); padding-top: 8px; min-width: 0; }
.expect .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.expect .k .sw { width: 10px; height: 10px; }
.expect .v { font: 500 26px/1.1 var(--font-data); font-variant-numeric: tabular-nums; margin-top: 2px; }
.expect .w { font-size: 12px; color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.expect .w b { color: var(--ink); font-weight: 500; }
.expect .w2 { font-size: 11px; color: var(--muted); margin-top: 4px; }
.sparkwrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sparkwrap h3 { font: 600 13px/1.3 var(--font-ui); margin: 0; color: var(--ink-2); }
.bandlbl { font: 500 11px var(--font-ui); }
.rows { display: grid; grid-template-columns: minmax(150px, max-content) minmax(0, 1fr) max-content; gap: 9px 12px; align-items: center; font-variant-numeric: tabular-nums; }
.rows .lab { font-size: 13px; display: flex; align-items: flex-start; gap: 7px; min-width: 0; }
.rows .lab .sw { margin-top: 4px; width: 10px; height: 10px; flex: none; }
.rows .lab small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; white-space: normal; max-width: 28ch; }
.rows .bar { position: relative; height: 18px; background: var(--track); border-radius: 3px; overflow: hidden; min-width: 0; }
.rows .bar i { position: absolute; top: 0; bottom: 0; left: 0; }
.rows .bar i.tick { width: 3px; background: var(--ink); }
.rows .bar i.act { width: 3px; background: var(--surface); border-inline: 1px solid var(--ink); }
.rows .val { font: 12px var(--font-data); color: var(--ink-2); white-space: nowrap; text-align: right; }
.rows .val b { color: var(--ink); font-weight: 500; }
.rows .sect { grid-column: 1 / -1; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
@media (max-width: 480px) { .rows { grid-template-columns: minmax(0, 1fr) max-content; } .rows .lab { grid-column: 1 / -1; } }
.sw-act { width: 3px; height: 10px; border-radius: 0; background: var(--surface); border-inline: 1px solid var(--ink); margin-inline: 4px; }
.layers { display: flex; flex-wrap: wrap; gap: 8px; }
.layer { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; max-width: 30ch; }
.layer.now { border-color: var(--ink); }
.layer .st { font: 500 11px var(--font-data); color: var(--muted); }
.layer.now .st { color: var(--ink); }
.layer p { margin: 0; font-size: 11px; color: var(--ink-2); line-height: 1.35; }
.panel-tools.ctl-hour { flex-direction: column; align-items: stretch; gap: 2px; }
