/* System Design: page styles. Colours come from tokens.css only. */
:root {
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* header */
.bar { border-bottom: 1px solid var(--line); background: var(--surface); }
.bar-row { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.dot { width: 12px; height: 12px; border-radius: 6px; background: var(--accent); }
.crumb { color: var(--text-2); }
.crumb::before { content: "/"; margin-right: 12px; color: var(--muted); }
.grow { flex: 1; }

/* controls */
.btn {
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
select {
  min-height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 16px 0; }
.speed { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; }
.clock { margin-left: auto; color: var(--text-2); font-size: 14px; }

/* layout */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding-top: 24px; padding-bottom: 8px; flex: 1; }
main { min-width: 0; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.lede { margin: 8px 0 0; max-width: 720px; color: var(--text-2); }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.eyebrow .mono { text-transform: none; letter-spacing: 0; margin-left: 8px; font-weight: 400; }

.scenario-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.scenario-list button {
  width: 100%; min-height: 40px; padding: 8px 12px; text-align: left; border: 1px solid transparent;
  border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.scenario-list button:hover { background: var(--raised); }
.scenario-list button[aria-current="true"] { background: var(--raised); border-color: var(--accent); font-weight: 600; }

.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; margin-bottom: 16px; }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.two .panel, main > .panel { margin-bottom: 16px; }

/* diagram */
.diagram { overflow-x: auto; }
.hint { display: none; margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.diagram svg { display: block; width: 100%; min-width: 640px; height: auto; }
.t { fill: var(--text); font: 14px var(--sans); }
.t2 { fill: var(--text-2); font: 13px var(--sans); }
.tm { fill: var(--muted); font: 12px var(--sans); }
.box { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.box.queue { fill: var(--bg); }
.box.dlq { fill: var(--bg); stroke: var(--bad); stroke-dasharray: 5 4; }
.cell { fill: var(--raised); stroke: var(--line); }
.cell.on { fill: var(--accent); stroke: none; }
.dcell.on { fill: var(--bad); stroke: none; }
.edge { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.edge.fail { stroke: var(--bad); stroke-dasharray: 4 3; }
.arrowhead { fill: var(--muted); }
.consumer .box { fill: var(--surface); }
.consumer .prog { fill: var(--accent-ink); opacity: 0.35; }
.breaker.closed { fill: var(--ok); }
.breaker.open { fill: var(--bad); }
.breaker.half { fill: var(--warn); }
.consumer.busy .box { fill: var(--accent); stroke: var(--accent); }
.consumer.busy text { fill: var(--accent-ink); }
.consumer.down .box { fill: var(--bad); stroke: var(--bad); }
.consumer.down text { fill: var(--accent-ink); }

/* metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.metrics div[hidden] { display: none; }
.metrics div { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 14px; }
.metrics dt { color: var(--muted); font-size: 12px; }
.metrics dd { margin: 2px 0 0; font: 600 22px var(--mono); }
#m-dead.alert { color: var(--bad); }
.metrics dd.small { font-size: 15px; line-height: 33px; }

/* chart, watch, log */
#chart { display: block; width: 100%; height: auto; }
.axis { stroke: var(--line); stroke-width: 1; }
.line-depth { fill: none; stroke: var(--accent); stroke-width: 2; }
.line-dlq { fill: none; stroke: var(--bad); stroke-width: 2; }
.watch { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 14px; }
.watch li + li { margin-top: 6px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13px; }
.log li { display: flex; gap: 12px; padding: 4px 0; border-top: 1px solid var(--line); color: var(--text-2); }
.log li:first-child { border-top: 0; }
.log time { flex: none; width: 64px; color: var(--muted); font-family: var(--mono); }
.log .warn { color: var(--warn); }
.log .bad { color: var(--bad); }
.log .ok { color: var(--ok); }
.log .empty { color: var(--muted); }

footer { border-top: 1px solid var(--line); margin-top: 32px; }
.ftr { padding-top: 20px; padding-bottom: 20px; font-size: 13px; color: var(--muted); }

/* tablet and phone */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  nav .scenario-list { flex-direction: row; flex-wrap: wrap; }
  nav .scenario-list button { width: auto; border-color: var(--line); }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .two { grid-template-columns: minmax(0, 1fr); }
  .hint { display: block; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 24px; }
  .clock { margin-left: 0; width: 100%; }
  .crumb { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
