/* Cobursa | AI Compute Buildout Model
   One cell grammar for every number: [unit prefix | value], fixed widths, tabular figures. */
:root {
  --bg: #faf9f6;
  --paper: #fffdf9;
  --ink: #212c47;
  --ink-soft: #5c6480;
  --ink-faint: #8b91a6;
  --line: #e6e3da;
  --line-strong: #cfcbc0;
  --sage: #d0d5c6;
  --sage-soft: #eef0e8;
  --input: #d6ebf6;
  --input-deep: #c1e0f0;
  --input-border: #9cc8de;
  --focus: #2f6f95;
  --calc: #efeeea;
  --calc-deep: #e3e1da;
  --pass: #d4efd8;
  --pass-ink: #1f5a2c;
  --fail: #f8e1d3;
  --fail-ink: #8a3b1c;
  --accent: #2b3a63;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --unit-w: 44px;   /* unit prefix column */
  --val-w: 124px;   /* value column */
  --cell-w: calc(var(--unit-w) + var(--val-w));
  --row-h: 36px;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--input-deep); color: var(--ink); }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.005em; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 16px; line-height: 1.3; }
p { margin: 0 0 8px; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.site-header { background: var(--bg); border-bottom: 1px solid var(--line); }
.header-inner {
  max-width: 1160px; margin: 0 auto; padding: 16px 24px 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
}
.brand { display: flex; align-items: baseline; gap: 14px; text-decoration: none; color: inherit; }
.brand-mark { font-family: var(--sans); font-weight: 500; font-size: 20px; letter-spacing: -0.03em; }
.brand-title { font-size: 14px; color: var(--ink-soft); }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.tabs { width: 100%; display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; margin-top: 4px; scrollbar-width: none; -ms-overflow-style: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; margin-bottom: 0; font: inherit; font-weight: 500; color: var(--ink-soft); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  height: 34px; padding: 0 14px; border-radius: var(--radius); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); }
.share-box { width: 100%; padding: 6px 0 2px; }
.share-box label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; font: inherit; font-size: 13px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.linklike { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Page ---------- */
main { max-width: 1160px; margin: 0 auto; padding: 8px 24px 64px; }
.panel { display: none; }
.panel.active { display: block; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; font-size: 13px; color: var(--ink-soft); padding: 16px 0 8px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 7px; border: 1px solid rgba(33,44,71,0.12); }
.swatch.input { background: var(--input); }
.swatch.calc { background: var(--calc); }
.swatch.pass { background: var(--pass); }
.swatch.fail { background: var(--fail); }

.section { padding: 28px 0 8px; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: 0; padding-top: 12px; }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 24px; margin-bottom: 18px; }
.section-head p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); max-width: 68ch; }

.cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 56px; row-gap: 8px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.group { margin-bottom: 24px; }
.group > h3 { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }

/* Aligned label / cell rows */
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--cell-w); align-items: center; column-gap: 16px;
  min-height: var(--row-h); padding: 3px 0;
}
.row.two { grid-template-columns: minmax(0, 1fr) var(--cell-w) var(--cell-w); }
.row .label { font-size: 14px; line-height: 1.35; }
.row .label small { display: block; font-size: 12px; color: var(--ink-faint); line-height: 1.35; margin-top: 1px; }
.row.total .label { font-weight: 600; }
.row.total { border-top: 1px solid var(--line-strong); margin-top: 4px; padding-top: 6px; }
.row .text { min-width: 0; text-align: right; font-weight: 500; white-space: nowrap; }
.row.free { grid-template-columns: auto minmax(0, 1fr); }
.row.free .text { white-space: normal; }
.row.head { min-height: 0; padding: 0 0 4px; }
.row.head span { font-size: 12px; color: var(--ink-faint); text-align: right; }

/* ---------- The cell ---------- */
.cell {
  display: inline-grid; grid-template-columns: var(--unit-w) var(--val-w); width: var(--cell-w); height: 32px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; vertical-align: middle;
  font-variant-numeric: tabular-nums; background: var(--paper);
}
.cell .u {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--ink-soft); background: var(--calc-deep); border-right: 1px solid var(--line-strong);
  letter-spacing: 0.01em; user-select: none;
}
.cell .v, .cell input {
  -moz-appearance: textfield; appearance: none;
  display: block; width: 100%; height: 100%; margin: 0; padding: 0 10px; border: 0; background: transparent;
  font: inherit; font-size: 14px; color: var(--ink); text-align: right; line-height: 30px;
}
.cell.in { border-color: var(--input-border); }
.cell.in .u { background: var(--input-deep); border-right-color: var(--input-border); color: var(--ink); }
.cell.in input { background: var(--input); }
.cell.in:hover { border-color: var(--focus); }
.cell.in:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(47,111,149,0.22); }
.cell.in input:focus { outline: none; }
.cell.calc .v { background: var(--calc); }
.cell.pass .v { background: var(--pass); color: var(--pass-ink); font-weight: 600; }
.cell.fail .v { background: var(--fail); color: var(--fail-ink); font-weight: 600; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Segmented control, same footprint as a cell */
.seg {
  display: inline-grid; grid-template-columns: 1fr 1fr; width: var(--cell-w); height: 32px;
  border: 1px solid var(--input-border); border-radius: var(--radius); overflow: hidden; background: var(--input);
}
.seg button {
  appearance: none; border: 0; background: transparent; padding: 0 6px; font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg button + button { border-left: 1px solid var(--input-border); }
.seg button:hover:not(.active) { background: var(--input-deep); }
.seg button.active { background: var(--ink); color: #fff; }
.seg:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(47,111,149,0.22); }

/* ---------- Key metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 8px; }
@media (max-width: 520px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
.metric { border-radius: var(--radius); padding: 12px 14px 10px; background: var(--sage-soft); min-width: 0; }
.metric.pass { background: var(--pass); }
.metric.fail { background: var(--fail); }
.metric .value { font-size: 24px; font-weight: 600; line-height: 1.15; white-space: nowrap; letter-spacing: -0.01em; }
.metric .label { font-size: 13px; margin-top: 4px; }
.metric .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; line-height: 1.35; }
.metric.pass .sub, .metric.pass .label { color: var(--pass-ink); }
.metric.fail .sub, .metric.fail .label { color: var(--fail-ink); }
.verdict { font-size: 13px; font-weight: 500; margin: 6px 0 16px; }
.verdict.pass { color: var(--pass-ink); }
.verdict.fail { color: var(--fail-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: 1px; }

.note { font-size: 13px; color: var(--ink-soft); line-height: 1.5; max-width: 70ch; }
.defs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 40px; font-size: 13px; color: var(--ink-soft); line-height: 1.45; margin-top: 8px; }
.defs p { margin: 0; }
.defs strong { color: var(--ink); font-weight: 600; }
@media (max-width: 900px) { .defs { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
thead th { font-weight: 500; color: var(--ink-faint); font-size: 12px; border-bottom: 1px solid var(--line-strong); padding-top: 0; }
tr.total td { font-weight: 600; border-top: 1px solid var(--line-strong); }
tr.subhead td { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--ink); padding-top: 22px; padding-bottom: 6px; border-bottom: 1px solid var(--line-strong); }
.table-wrap { overflow-x: auto; }

.fcf { table-layout: fixed; min-width: 900px; }
.fcf th, .fcf td { padding: 6px 8px; }
.fcf th:first-child, .fcf td:first-child { padding-left: 0; }
.fcf .yr { width: 92px; }
.fcf tr.key td { background: var(--pass); font-weight: 600; }

.assump td.val { width: calc(var(--cell-w) + 20px); }
.assump th.unit, .assump td.unit { color: var(--ink-soft); font-size: 12.5px; text-align: left; white-space: nowrap; width: 170px; }
.assump td.note { color: var(--ink-soft); font-size: 12.5px; text-align: left; line-height: 1.4; }
.assump td:first-child { min-width: 220px; }

/* ---------- Sensitivity ---------- */
.sens-controls { margin: 4px 0 12px; }
.sens { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 40px; }
@media (max-width: 960px) { .sens { grid-template-columns: 1fr; } }
.heat { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; margin-top: 8px; }
.heat th, .heat td { border: 0; padding: 0; height: 34px; text-align: center; font-size: 13.5px; }
.heat thead th { font-weight: 500; color: var(--ink-faint); font-size: 12px; }
.heat thead th.axis { text-align: left; padding-left: 4px; }
.heat tbody th { font-weight: 500; color: var(--ink-soft); font-size: 13px; text-align: right; padding-right: 8px; width: 84px; }
.heat td { border-radius: 5px; font-weight: 500; }
.heat td.pass { background: var(--pass); color: var(--pass-ink); }
.heat td.fail { background: var(--fail); color: var(--fail-ink); }
.heat td.base { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; }

/* ---------- About ---------- */
.prose { max-width: 72ch; font-size: 15px; line-height: 1.6; }
.prose h2 { margin: 28px 0 10px; }
.prose h3 { margin: 16px 0 6px; }
.prose ul { padding-left: 20px; margin: 0 0 10px; }
.prose li { margin-bottom: 4px; }
.prose .fine { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 18px 24px 32px; font-size: 12.5px; color: var(--ink-soft); }
.site-footer .inner { max-width: 1160px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--radius); font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .18s ease-out, transform .18s ease-out; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  :root { --val-w: 104px; }
  .header-inner { padding: 12px 16px 0; }
  main { padding: 8px 16px 48px; }
}
@media print {
  .site-header .header-actions, .tabs, .site-footer, .toast { display: none !important; }
  .panel { display: block !important; page-break-before: always; }
  .panel:first-of-type { page-break-before: auto; }
  body { background: #fff; }
}

/* ---------- Access gate (inline, replaces the model panels until unlocked) ---------- */
body.locked .header-actions { display: none; }
.gate { max-width: 560px; padding: 8px 0 24px; }
.gate h2 { font-size: 22px; margin-bottom: 8px; }
.gate p { font-size: 14px; color: var(--ink-soft); line-height: 1.55; max-width: 60ch; }
.gate form { margin-top: 20px; display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; }
.field label small { font-weight: 400; color: var(--ink-faint); }
.field input {
  height: 38px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.field input:hover { border-color: var(--focus); }
.field input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px rgba(47,111,149,0.22); }
.field input[aria-invalid="true"] { border-color: var(--fail-ink); }
.field .hint { font-size: 12px; color: var(--ink-faint); }
.gate .actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.gate .btn.primary { height: 38px; padding: 0 18px; font-size: 14px; }
.gate .btn.primary[disabled] { opacity: 0.6; cursor: progress; }
.gate .consent { font-size: 12.5px; color: var(--ink-soft); max-width: 60ch; }
.gate .error { font-size: 13px; color: var(--fail-ink); }
.feedback { margin-top: 24px; }
.feedback form { display: grid; gap: 14px; max-width: 560px; }
.feedback textarea { padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius); resize: vertical; min-height: 110px; }
.feedback textarea:hover, .feedback input:hover { border-color: var(--focus); }
.feedback textarea:focus, .feedback input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px rgba(47,111,149,0.22); }
.feedback textarea[aria-invalid="true"], .feedback input[aria-invalid="true"] { border-color: var(--fail-ink); }
.feedback .actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.feedback .btn.primary { height: 38px; padding: 0 18px; font-size: 14px; }
.feedback .btn.primary[disabled] { opacity: 0.6; cursor: progress; }
.feedback .consent { font-size: 12.5px; color: var(--ink-soft); }
.feedback .error { font-size: 13px; color: var(--fail-ink); }
.feedback .error:empty { display: none; }
.feedback .ok { font-size: 14px; color: var(--pass-ink); font-weight: 500; }
body.locked .feedback { display: none; }
.gate .error:empty { display: none; }
.prose table { font-size: 13.5px; margin: 8px 0 14px; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 6px 10px 6px 0; }
.prose h1 { margin-bottom: 6px; }

/* Narrow screens: two-cell rows stack the label above the cells */
@media (max-width: 640px) {
  .row.two { grid-template-columns: 1fr 1fr; row-gap: 4px; }
  .row.two .label { grid-column: 1 / -1; }
  .row.two .cell { justify-self: end; }
  .row.two.total { padding-top: 8px; }
}
