/* model-scale — hand-written CSS, no framework.
   Colour roles follow the house data-viz palette; light and dark are each
   selected against their own surface rather than flipped. */

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --plane: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --surface: #1a1a19;
    --plane: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --accent: #3987e5;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --surface: #1a1a19;
  --plane: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --accent: #3987e5;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 clamp(12px, 3vw, 40px) 64px;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- header ------------------------------------------------------------ */

.site-head {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 0 20px;
}

.site-head h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.head-text p {
  margin: 0;
  max-width: 62ch;
  color: var(--ink-2);
}

.head-actions {
  display: flex;
  gap: 8px;
}

button {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--axis);
}

/* ---- layout ------------------------------------------------------------ */

.layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1080px;
  margin: 0 auto;
  min-width: 0;
}

/* ---- scenario bar ------------------------------------------------------ */

.scenario-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}

.segment {
  flex: 1 1 160px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.segment:hover {
  background: var(--plane);
  border-color: transparent;
  color: var(--ink);
}

.segment-active,
.segment-active:hover {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.scenario-params {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.scenario-params:empty {
  display: none;
}

.inline-num {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-2);
}

.inline-num input {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  width: 9ch;
  padding: 6px 10px;
  text-align: right;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 8px;
}

.inline-suffix {
  color: var(--ink-2);
}

.scenario-question {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---- setup row --------------------------------------------------------- */

.setup-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.setup-note {
  margin: 8px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
}

.setup-note.speculative {
  color: var(--serious);
}

.setup-note:empty {
  display: none;
}

/* ---- advanced disclosures ---------------------------------------------- */

.advanced {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
}

.advanced > summary {
  cursor: pointer;
  padding: 13px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  list-style-position: inside;
}

.advanced > summary:hover {
  color: var(--ink);
}

.advanced[open] > summary {
  border-bottom: 1px solid var(--grid);
  margin-bottom: 14px;
}

.advanced > .field-grid,
.advanced > .chart-grid,
.advanced > .panel-sub,
.advanced > .aside {
  margin-bottom: 16px;
}

/* ---- fields ------------------------------------------------------------ */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--axis);
  color: var(--muted);
  font-size: 9px;
  cursor: help;
  flex: none;
}

.field-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field input[type='number'],
.field select,
.preset select {
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--ink);
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.field input:focus-visible,
.field select:focus-visible,
.preset select:focus-visible,
.inline-num input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-unit {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
}

.field-check .field-input {
  order: -1;
}

.field-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.preset {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-2);
  min-width: 0;
}

.panel-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 70ch;
}

.aside {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* ---- results ----------------------------------------------------------- */

.headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.hero + .hero {
  border-left: 1px solid var(--grid);
  padding-left: 28px;
}

@media (max-width: 700px) {
  .hero + .hero {
    border-left: none;
    padding-left: 0;
    padding-top: 14px;
    border-top: 1px solid var(--grid);
  }
}

.hero-value {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-sub {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 13px;
}

/* ---- cost table -------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.cost-table th,
.cost-table td {
  text-align: right;
  padding: 7px 12px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

.cost-table thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cost-table th[scope='row'],
.cost-table td:first-child,
.cost-table thead th:first-child {
  text-align: left;
  white-space: normal;
}

.cost-table .row-capex td,
.cost-table .row-opex td {
  color: var(--ink-2);
}

.cost-table .row-subtotal th {
  font-weight: 600;
  color: var(--ink);
  border-top: 1px solid var(--axis);
}

.cost-table .row-total th {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  border-top: 2px solid var(--axis);
  border-bottom: none;
  padding-top: 10px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.tile {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--plane);
  min-width: 0;
}

.tile-label {
  font-size: 11.5px;
  color: var(--muted);
}

.tile-value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.tile-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}

.apply-btn {
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.apply-btn:hover {
  border-color: transparent;
  filter: brightness(1.08);
}

/* Applied state: reads as "undo this", not as a second primary action. */
.apply-btn-revert {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--axis);
}

.apply-btn-revert:hover {
  border-color: var(--ink-2);
  filter: none;
}

/* ---- stacked memory bar ------------------------------------------------ */

.stack {
  margin-bottom: 14px;
}

.stack-track {
  display: flex;
  gap: 2px; /* the 2px surface gap between fills */
  height: 26px;
  border-radius: 5px;
  overflow: hidden;
}

.stack-seg {
  min-width: 2px;
  border-radius: 3px;
}

.stack-legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
}

.stack-legend li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.legend-name {
  color: var(--ink-2);
}

.legend-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---- notes ------------------------------------------------------------- */

.note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 0 0 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}

.note:last-child {
  margin-bottom: 0;
}

.note-icon {
  flex: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-top: 1px;
}

.note-good .note-icon {
  background: var(--good);
}
.note-warning .note-icon {
  background: var(--warning);
  color: #0b0b0b;
}
.note-serious .note-icon {
  background: var(--serious);
  color: #0b0b0b;
}
.note-critical .note-icon {
  background: var(--critical);
}

/* ---- sweep ------------------------------------------------------------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 14px;
}

.chart {
  margin: 0;
  min-width: 0;
}

.chart figcaption {
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.chart-plot {
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 200px;
  display: block;
  overflow: visible;
}

.chart-svg .grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart-svg .axis {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart-svg .tick {
  fill: var(--muted);
  font-size: 9.5px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.chart-svg .tick-y {
  text-anchor: end;
}

.chart-svg .tick-x {
  text-anchor: middle;
}

.chart-svg .series-line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-svg .series-dot {
  fill: var(--series-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-svg .series-focus {
  fill: var(--series-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-svg .crosshair {
  stroke: var(--axis);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-tip {
  position: absolute;
  transform: translate(-50%, -160%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  display: flex;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(11, 11, 11, 0.12);
}

/* Must beat the `display: flex` above, or the [hidden] attribute does nothing. */
.chart-tip[hidden] {
  display: none;
}

.chart-tip strong {
  color: var(--muted);
  font-weight: 500;
}

.table-view {
  margin-top: 18px;
  font-size: 12.5px;
}

.table-view summary {
  cursor: pointer;
  color: var(--ink-2);
}

.table-view table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  display: block;
  overflow-x: auto;
}

.table-view th,
.table-view td {
  text-align: right;
  padding: 5px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

.table-view th {
  color: var(--muted);
  font-weight: 500;
}

.table-view th:first-child,
.table-view td:first-child {
  text-align: left;
}

.row-current {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-weight: 600;
}

/* ---- footer ------------------------------------------------------------ */

.site-foot {
  max-width: 1080px;
  margin: 28px auto 0;
  color: var(--ink-2);
  font-size: 12.5px;
}

.site-foot summary {
  cursor: pointer;
  padding: 10px 0;
}

.foot-body {
  max-width: 90ch;
  border-left: 2px solid var(--grid);
  padding-left: 16px;
}

.foot-body p {
  margin: 0 0 10px;
  line-height: 1.6;
}

.foot-body code {
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
}

.foot-warn {
  color: var(--serious);
}

.foot-meta {
  color: var(--muted);
  margin-top: 12px;
}
