/* FormworkTwin × esg-spine — Unified Drafting-Sheet Interface
   Paper stock, architectural hairlines, material hues; DIN for measurements, PingFang for prose. */

:root {
  --paper: #E7ECEE;
  --sheet: #FCFDFD;
  --ink: #0E1A21;
  --ink-2: #43535D;
  --ink-3: #7C8C95;
  --rule: #C4CFD4;
  --rule-2: #E4EAEC;

  --timber: #A9722C;
  --tableform: #6E8B74;
  --alu: #2F6D8E;
  --steel: #4A5866;

  --signal: #B4441F;
  --ok: #2F7A5F;
  --amber: #C08A2E;

  --sans: -apple-system, "PingFang HK", "PingFang TC", "Hiragino Sans GB", "Noto Sans TC", system-ui, sans-serif;
  --tech: "DIN Alternate", "DIN Condensed", "Bahnschrift", "Roboto Condensed", "Arial Narrow", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14.5px/1.6 var(--sans);
  font-feature-settings: "tnum" 1;
}

/* ───────────────────────────── masthead ───────────────────────────── */

.masthead {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-direction: column;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 1px 4px rgba(14, 26, 33, .05);
}

.mast-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 52px; padding: 0 clamp(16px, 3.5vw, 44px);
  border-bottom: 1px solid var(--rule);
}

.mast-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
}
.mark { width: 24px; height: 24px; color: var(--ink); flex-shrink: 0; }
.wordmark { font-family: var(--tech); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.brand-divider { color: var(--rule); margin: 0 2px; font-weight: 300; }
.wordmark-sub { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.client {
  font-size: 12px; color: var(--ink-3); padding-left: 10px; border-left: 1px solid var(--rule);
  white-space: nowrap;
}

.mast-meta {
  display: flex; align-items: center; gap: 12px; margin-left: auto;
}

.sandbox {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2); background: rgba(255, 255, 255, 0.6);
  padding: 3px 10px; border: 1px solid var(--rule); border-radius: 2px;
}
.sandbox form { display: inline-flex; margin: 0; }

.actor-meta {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px;
}

/* ───────────────────────────── navigation tabs ───────────────────────────── */

.mast-nav {
  display: flex; align-items: center; gap: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 0 clamp(16px, 3.5vw, 44px);
  height: 38px;
  background: rgba(255, 255, 255, 0.4);
}
.mast-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 2px;
  font-size: 13px; font-weight: 500; color: var(--ink-2); text-decoration: none;
  white-space: nowrap; transition: all 0.12s ease;
}
.nav-tab:hover { color: var(--ink); background: rgba(14, 26, 33, .04); }
.nav-tab.is-active {
  color: var(--ink); font-weight: 600; background: #fff;
  border-color: var(--rule); box-shadow: 0 1px 2px rgba(14, 26, 33, .04);
}
.nav-tab-twin {
  color: var(--ok); font-weight: 600;
}
.nav-tab-twin.is-active {
  background: #E8F5EE; border-color: #A9D7BC; color: var(--ok);
}
.nav-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 1px 4px; border-radius: 2px; background: var(--ok); color: #fff;
  font-family: var(--tech);
}

/* ───────────────────────────── sheet container ───────────────────────────── */

main { padding: 26px clamp(12px, 3vw, 40px) 64px; }

.sheet {
  position: relative;
  max-width: 1200px; margin: 0 auto 28px;
  padding: clamp(24px, 3.4vw, 44px);
  background: var(--sheet);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 3px rgba(14, 26, 33, .03);
}
.sheet::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--rule-2);
  pointer-events: none;
}

.sheet-head { max-width: 72ch; margin-bottom: 28px; }
.sheet-head h1, h1 {
  margin: 0 0 10px; font-size: clamp(22px, 2.6vw, 29px); line-height: 1.32;
  font-weight: 600; letter-spacing: -0.015em; color: var(--ink);
}
h2 {
  font-size: 17px; font-weight: 600; margin: 26px 0 12px;
  color: var(--ink); border-bottom: 1px solid var(--rule-2); padding-bottom: 6px;
}
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; color: var(--ink); }

.lede { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.cue { color: var(--ink-2); font-size: 13.5px; line-height: 1.6; margin: 0 0 14px; }
.formula { color: var(--ink-3); font-size: 11.5px; font-family: var(--tech); }

/* ───────────────────────────── twin subhead ───────────────────────────── */

.sheet-tab-bar {
  max-width: 1200px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}

.sheet-tabs { display: flex; gap: 6px; }
.sheet-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 6px; border: 1px solid var(--rule); background: #fff;
  font: 13px/1 var(--sans); color: var(--ink-2); cursor: pointer; border-radius: 2px;
}
.tab-letter {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border: 1px solid var(--rule);
  font-family: var(--tech); font-size: 13px; font-weight: 700; color: var(--ink-3);
  border-radius: 1px;
}
.sheet-tab:hover { color: var(--ink); background: rgba(14, 26, 33, .03); border-color: var(--ink-3); }
.sheet-tab.is-active { color: var(--ink); font-weight: 600; border-color: var(--ink); background: #fff; }
.sheet-tab.is-active .tab-letter { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.sandbox-note { margin: 0; font-size: 12px; color: var(--ink-3); }

/* ───────────────────────────── sheet A · bench ───────────────────────────── */

.bench { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: clamp(28px, 4vw, 56px); }

.controls { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.field { display: flex; flex-direction: column; gap: 5px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field > label, .field > legend, .mix-head > span:first-child {
  font-size: 12px; color: var(--ink-3); letter-spacing: .01em; margin-bottom: 2px; font-weight: 500;
}

input[type="text"], input[type="number"], input[type="password"], input[type="file"], select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 2px;
  background: #fff; color: var(--ink); font: 14px/1.4 var(--sans);
}
input[type="number"], input[type="text"].tech { font-family: var(--tech); font-variant-numeric: tabular-nums; }
input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible, tr:focus-visible {
  outline: 2px solid var(--alu); outline-offset: 2px;
}

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 2px; overflow: hidden; }
.segmented button {
  padding: 7px 12px; border: 0; border-right: 1px solid var(--rule);
  background: #fff; color: var(--ink-2); font: 12.5px/1 var(--sans); cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button.is-active { background: var(--ink); color: var(--paper); }

/* material mix */
.mix { border-top: 1px solid var(--rule); padding-top: 14px; display: flex; flex-direction: column; gap: 11px; }
.mix-head { display: flex; justify-content: space-between; align-items: baseline; }
.mix-note { font-size: 11.5px; color: var(--ink-3); }

.mix-row { display: grid; grid-template-columns: 11px 74px minmax(0, 1fr) 42px; align-items: center; gap: 10px; }
.mix-row label { font-size: 13px; color: var(--ink); }
.mix-row output { font-family: var(--tech); font-size: 13px; text-align: right; color: var(--ink-2); }
.sw { display: block; width: 11px; height: 11px; }
.sw-timber { background: var(--timber); }
.sw-tableform { background: var(--tableform); }
.sw-alu { background: var(--alu); }
.sw-steel { background: var(--steel); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 16px; background: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--rule); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px;
  background: var(--ink); border: 0; border-radius: 0;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; background: var(--ink); border: 0; border-radius: 0; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button {
  padding: 4px 9px; border: 1px dashed var(--rule); background: none;
  font: 12px/1.2 var(--sans); color: var(--ink-2); cursor: pointer; border-radius: 2px;
}
.presets button:hover { border-style: solid; color: var(--ink); }

/* ───────────────────────────── readout ───────────────────────────── */

.readout { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.ledger-main { min-width: 0; }

.ruler-figure { margin: 0; }
#ruler { display: block; width: 100%; height: auto; overflow: visible; }
.ruler-caption {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  margin-top: 6px; font-size: 11.5px; color: var(--ink-3);
}
.cap-item { display: inline-flex; align-items: center; gap: 6px; }
.cap-right { margin-left: auto; font-family: var(--tech); font-size: 12px; color: var(--ink-2); }
.hatch {
  width: 25px; height: 10px; border: 1px solid var(--rule);
  background: repeating-linear-gradient(45deg, transparent 0 3px, var(--rule) 3px 4px);
}

.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; border-top: 1px solid var(--ink); }
.figure { padding: 12px 14px 12px 0; border-right: 1px solid var(--rule-2); position: relative; }
.figure:last-child { border-right: 0; }
.figure dt { font-size: 11.5px; color: var(--ink-3); margin-bottom: 2px; }
.figure dd {
  margin: 0; font-family: var(--tech); font-size: 24px; font-weight: 700;
  line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums;
}
.figure .unit { font-size: 11px; color: var(--ink-3); font-family: var(--tech); }
.figure-accent dd { font-size: 32px; }
.figure-accent::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 34px; height: 2px; background: var(--timber);
}

.basis {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 8px 12px; background: #F3F6F7; border-left: 2px solid var(--rule);
  font-size: 12px; color: var(--ink-2);
}
.basis-label { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.basis strong { font-family: var(--tech); font-weight: 700; color: var(--ink); }

.materials { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.materials th {
  font-size: 11px; font-weight: 600; color: var(--ink-3); text-align: left;
  padding: 0 8px 6px 0; border-bottom: 1px solid var(--rule);
}
.materials td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--rule-2); }
.materials .num { text-align: right; font-family: var(--tech); font-variant-numeric: tabular-nums; }
.materials td:first-child { display: flex; align-items: center; gap: 8px; }
.materials tr:last-child td { border-bottom: 0; }

.disclaimer { margin: 0; font-size: 11px; line-height: 1.6; color: var(--ink-3); max-width: 62ch; }

.readout-actions { display: flex; gap: 10px; margin-top: 2px; }

/* ───────────────────────────── buttons ───────────────────────────── */

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 15px; border: 1px solid var(--ink); background: #fff; color: var(--ink);
  font: 13px/1 var(--sans); cursor: pointer; border-radius: 2px; text-decoration: none;
  transition: all 0.12s ease;
}
button:hover, .btn:hover { background: rgba(14, 26, 33, .05); }
button[type="submit"], .btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button[type="submit"]:hover, .btn-primary:hover { background: #1c2f3a; color: #fff; }
.btn-ghost { border-color: var(--rule); color: var(--ink-2); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); background: rgba(14, 26, 33, .04); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ───────────────────────────── chain ───────────────────────────── */

.chain { margin-top: 30px; border-top: 1px solid var(--rule); }
.chain summary {
  padding: 12px 0 8px; cursor: pointer; font-size: 13px; color: var(--ink);
  display: flex; justify-content: space-between; align-items: baseline; list-style: none;
}
.chain summary::-webkit-details-marker { display: none; }
.chain summary::after { content: "展開"; font-size: 11.5px; color: var(--ink-3); }
.chain[open] summary::after { content: "收起"; }
#chain-engine { font-family: var(--tech); font-size: 11px; color: var(--ink-3); margin-left: auto; margin-right: 16px; }

.chain-steps { margin: 6px 0 10px; padding: 0; list-style: none; counter-reset: step; }
.chain-steps li {
  counter-increment: step; display: grid; grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 16px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--rule-2); font-size: 12.5px;
}
.chain-steps .step-label { color: var(--ink); font-weight: 600; }
.chain-steps .step-expr { font-family: var(--tech); color: var(--ink-2); }
.chain-steps .step-value { font-family: var(--tech); font-weight: 700; text-align: right; color: var(--ink); }
.chain-note { margin: 0; font-size: 11px; color: var(--ink-3); }

/* ───────────────────────────── title block ───────────────────────────── */

.titleblock {
  display: flex; flex-wrap: wrap; margin-top: 36px; margin-left: auto;
  width: min(100%, 700px); border: 1px solid var(--ink); background: #fff;
}
.tb-cell { flex: 1 1 90px; padding: 6px 10px 7px; border-right: 1px solid var(--rule); min-width: 0; }
.tb-cell:last-child { border-right: 0; }
.tb-wide { flex: 2 1 180px; }
.tb-cell span { display: block; font-size: 10px; color: var(--ink-3); }
.tb-cell strong { display: block; font-family: var(--tech); font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───────────────────────────── sheet B ───────────────────────────── */

.portfolio {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  margin: 0 0 28px; border-top: 1px solid var(--ink);
}
.portfolio > div { padding: 12px 16px 12px 0; border-right: 1px solid var(--rule-2); }
.portfolio > div:last-child { border-right: 0; }
.portfolio dt { font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; }
.portfolio dd {
  margin: 0; font-family: var(--tech); font-size: 25px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.portfolio .unit { font-size: 11px; color: var(--ink-3); margin-left: 3px; font-weight: 400; }
.portfolio .sub { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; margin-top: 3px; }

.ledger { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: clamp(24px, 3vw, 44px); align-items: start; }

.ledger-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  padding: 4px 10px; border: 1px solid var(--rule); background: #fff;
  font: 12px/1.2 var(--sans); color: var(--ink-2); cursor: pointer; border-radius: 2px;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip span { font-family: var(--tech); opacity: .75; margin-left: 3px; }
.chip-flag.is-active { background: var(--signal); border-color: var(--signal); }

.ledger-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ledger-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--ink-3);
  padding: 0 10px 7px 0; border-bottom: 1px solid var(--ink);
}
.ledger-table td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
.ledger-table .num { text-align: right; font-family: var(--tech); font-variant-numeric: tabular-nums; }
.ledger-table tbody tr { cursor: pointer; }
.ledger-table tbody tr:hover td { background: #F4F7F8; }
.ledger-table tbody tr.is-selected td { background: #EDF2F4; }
.ledger-table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--ink); }
.code { font-family: var(--tech); font-weight: 700; letter-spacing: .01em; }
.ledger-note { margin: 10px 0 0; font-size: 11px; color: var(--ink-3); }

.flagdot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: 1px; }
.flagdot.ok { background: var(--ok); }
.flagdot.div_zero, .flagdot.coding { background: var(--signal); }
.flagdot.missing, .flagdot.wip { background: var(--amber); }
.flag-text { font-size: 11.5px; color: var(--ink-2); }
.muted { color: var(--ink-3); }

.status-tag { display: inline-block; padding: 2px 7px; font-size: 11px; border: 1px solid var(--rule); color: var(--ink-2); border-radius: 2px; }
.status-tag.mature { border-color: #9DB4AA; color: #2F5F51; }
.status-tag.early { border-color: #D8B08A; color: #8A5A22; }
.status-tag.pipeline { border-color: var(--rule); color: var(--ink-3); }

.ledger-side { display: flex; flex-direction: column; gap: 24px; }

.detail { border: 1px solid var(--rule); padding: 16px; background: #fff; position: sticky; top: 100px; }
.flag-list { margin: 0 0 12px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); }
.detail-notes { margin: 12px 0 0; padding-top: 9px; border-top: 1px solid var(--rule-2); font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }
.detail-empty { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.detail-code { font-family: var(--tech); font-size: 19px; font-weight: 700; }
.detail-name { font-size: 12.5px; color: var(--ink-2); margin-bottom: 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0 0 14px; }
.detail-grid div { border-top: 1px solid var(--rule-2); padding-top: 6px; }
.detail-grid dt { font-size: 11px; color: var(--ink-3); }
.detail-grid dd { margin: 0; font-family: var(--tech); font-size: 13.5px; font-weight: 700; }

.passport { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--rule); }
.passport li { position: relative; padding: 0 0 14px 16px; }
.passport li::before {
  content: ""; position: absolute; left: -4px; top: 5px; width: 7px; height: 7px;
  background: var(--sheet); border: 1px solid var(--ink);
}
.passport li:last-child { padding-bottom: 0; }
.passport .when { font-family: var(--tech); font-size: 11px; color: var(--ink-3); }
.passport .what { font-size: 12px; color: var(--ink); line-height: 1.5; }
.passport .where { font-size: 11px; color: var(--ink-3); }

.gap-note {
  margin: 0; padding: 10px 12px; background: #FBF3EE; border-left: 2px solid var(--signal);
  font-size: 12px; color: var(--ink-2); line-height: 1.6;
}

.warnings { border-top: 1px solid var(--ink); padding-top: 12px; }
.side-title { margin: 0 0 10px; font-size: 12.5px; font-weight: 600; }
.warning-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.warning-list li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 12px; }
.warning-list .n { font-family: var(--tech); font-size: 11px; color: var(--ink-3); }
.warning-list .w-title { color: var(--ink); font-weight: 600; }
.warning-list .w-note { color: var(--ink-3); font-size: 11px; line-height: 1.5; display: block; margin-top: 2px; }
.w-status { display: inline-block; width: 7px; height: 7px; margin-left: 6px; vertical-align: 1px; }
.w-status.open { background: var(--signal); }
.w-status.in_progress { background: var(--amber); }

/* ───────────────────────────── tables (general) ───────────────────────────── */

table {
  width: 100%; border-collapse: collapse; margin: 16px 0;
  font-size: 13px; background: #fff; border: 1px solid var(--rule-2);
}
th {
  font-size: 11.5px; font-weight: 600; color: var(--ink-2); text-align: left;
  padding: 8px 12px; background: #F3F6F7; border-bottom: 1.5px solid var(--ink);
  letter-spacing: 0.01em;
}
td {
  padding: 8px 12px; border-bottom: 1px solid var(--rule-2);
  vertical-align: middle; color: var(--ink);
}
tr:hover td { background: #F8FAFB; }
td a { color: var(--alu); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ───────────────────────────── badges (general) ───────────────────────────── */

.badge {
  display: inline-flex; align-items: center; border-radius: 2px;
  padding: 2px 7px; font-size: 11px; font-weight: 600;
  font-family: var(--tech); border: 1px solid transparent; line-height: 1.3;
}
.badge.provisional { background: #FEF6E7; color: #8F5B17; border-color: #F0D49E; }
.badge.covered, .badge.accepted { background: #E8F5EE; color: #1E6649; border-color: #A9D7BC; }
.badge.partial, .badge.reviewed { background: #EBF3F8; color: #1D587A; border-color: #B1D1E4; }
.badge.neutral { background: #EFF3F5; color: #43535D; border-color: #CFD9DE; }
.badge.missing, .badge.flagged, .badge.rejected { background: #FDF0ED; color: #9B2C11; border-color: #F4C4B7; }
.badge.explain_needed { background: #F1EFFC; color: #483A9A; border-color: #CDC7F5; }

/* ───────────────────────────── cards & tree (general) ───────────────────────────── */

.card {
  border: 1px solid var(--rule); border-radius: 2px;
  padding: 18px 20px; margin: 16px 0; background: #fff;
  box-shadow: 0 1px 3px rgba(14, 26, 33, .02);
}
.card h3 { margin-top: 0; }

ul.tree {
  list-style: none; border-left: 2px solid var(--rule);
  padding-left: 18px; margin: 12px 0;
}
ul.tree li { position: relative; margin: 8px 0; font-size: 13px; line-height: 1.6; }
ul.tree li::before {
  content: ""; position: absolute; left: -19px; top: 10px; width: 12px; height: 1px; background: var(--rule);
}

/* ───────────────────────────── portal & landing ───────────────────────────── */

.portal-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px; margin: 24px 0 32px;
}
.portal-card {
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--rule); border-radius: 2px; padding: 20px; background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.portal-card:hover {
  border-color: var(--ink); transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(14, 26, 33, .06);
}
.portal-card.featured {
  border-color: var(--ok); background: #FAFDFB;
  box-shadow: 0 2px 8px rgba(47, 122, 95, .08);
}
.portal-tag {
  font-family: var(--tech); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin-bottom: 6px;
}
.portal-card.featured .portal-tag { color: var(--ok); }
.portal-card h3 { margin: 0 0 8px; font-size: 17px; }
.portal-desc { font-size: 13px; color: var(--ink-2); line-height: 1.55; margin: 0 0 16px; flex-grow: 1; }
.portal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───────────────────────────── toast ───────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper); padding: 9px 16px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ───────────────────────────── responsive ───────────────────────────── */

@media (max-width: 980px) {
  .bench { grid-template-columns: minmax(0, 1fr); }
  .ledger { grid-template-columns: minmax(0, 1fr); }
  .ledger-side { max-width: 560px; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure { border-right: 0; border-bottom: 1px solid var(--rule-2); }
  .portfolio { grid-template-columns: repeat(2, 1fr); }
  .portfolio > div:nth-child(2n) { border-right: 0; }
  .mast-top { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .mast-meta { margin-left: 0; width: 100%; justify-content: space-between; }
}

@media (max-width: 640px) {
  .client { display: none; }
  .materials { font-size: 11.5px; }
  .materials th, .materials td { padding-right: 4px; }
  .sheet { padding: 20px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .ledger-table th:nth-child(3), .ledger-table td:nth-child(3) { display: none; }
  .detail { position: static; }
  .titleblock { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

@media print {
  .masthead, .toast, .readout-actions, .sheet-tab-bar, .explorer-toolbar { display: none; }
  .sheet { border: 0; box-shadow: none; padding: 0; }
  .sheet::before { display: none; }
}

/* ───────────────────────── readiness market analytics ───────────────────────── */

.analytics-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px;
  border-bottom: 1.5px solid var(--ink); padding-bottom: 18px; margin-bottom: 22px;
}
.analytics-eyebrow {
  font-family: var(--tech); font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ok); margin-bottom: 4px;
}
.analytics-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sheet [id] { scroll-margin-top: 104px; }

.analytics-kpi-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule);
  margin-bottom: 24px; background: #fff;
}
.akpi {
  padding: 14px 14px; border-right: 1px solid var(--rule-2); position: relative;
}
.akpi:last-child { border-right: 0; }
.akpi::after {
  content: ""; position: absolute; left: 14px; bottom: 0; width: 28px; height: 2px; background: var(--rule);
}
.akpi.akpi-ok::after { background: var(--ok); }
.akpi.akpi-alu::after { background: var(--alu); }
.akpi.akpi-amber::after { background: var(--amber); }
.akpi.akpi-ink::after { background: var(--ink); }
.akpi-label { font-size: 11px; color: var(--ink-3); line-height: 1.35; margin-bottom: 5px; }
.akpi-val {
  font-family: var(--tech); font-size: 26px; font-weight: 700; line-height: 1.05;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.akpi-sub { font-family: var(--tech); font-size: 11px; color: var(--ink-2); margin-top: 4px; }

.analytics-two-col {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 16px 0;
}
.analytics-card { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.analytics-card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--rule-2); padding-bottom: 8px;
}
.analytics-card-head h3 { margin: 0; font-size: 15px; }
.analytics-tag {
  font-family: var(--tech); font-size: 11px; color: var(--ink-3); white-space: nowrap;
}

.stacked-band-bar {
  display: flex; width: 100%; height: 24px; border: 1px solid var(--ink); overflow: hidden; border-radius: 2px;
}
.stacked-seg {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--tech); font-size: 11px; font-weight: 700; color: #fff;
  overflow: hidden; white-space: nowrap; transition: opacity .15s;
}
.stacked-seg:hover { opacity: 0.9; }
.seg-READY { background: var(--ok); }
.seg-IN_PROGRESS { background: var(--alu); }
.seg-BELOW_BASELINE { background: var(--amber); }
.seg-NOT_ASSESSABLE { background: var(--steel); }

.band-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 1px; }

.band-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 2px;
  font-family: var(--tech); font-size: 11px; font-weight: 700; border: 1px solid transparent;
  white-space: nowrap;
}
.band-pill-READY { background: #E8F5EE; color: #1E6649; border-color: #A9D7BC; }
.band-pill-IN_PROGRESS { background: #EBF3F8; color: #1D587A; border-color: #B1D1E4; }
.band-pill-BELOW_BASELINE { background: #FEF6E7; color: #8F5B17; border-color: #F0D49E; }
.band-pill-NOT_ASSESSABLE { background: #EFF3F5; color: #43535D; border-color: #CFD9DE; }

.compact-table { margin: 4px 0 0; font-size: 12.2px; }
.compact-table th { padding: 6px 8px; font-size: 11px; }
.compact-table td { padding: 6px 8px; }
.compact-table .num { text-align: right; font-family: var(--tech); font-variant-numeric: tabular-nums; }

.cohort-block { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: #F7F9FA; border: 1px solid var(--rule-2); }
.cohort-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; font-weight: 600; }
.cohort-stat { font-family: var(--tech); font-size: 12px; color: var(--ok); white-space: nowrap; }
.cohort-note {
  padding: 10px 12px; background: #FAFDFB; border-left: 3px solid var(--ok);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.55;
}

.gateway-list { display: flex; flex-direction: column; gap: 9px; }
.gateway-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 128px; gap: 10px; align-items: center; }
.gateway-code {
  font-family: var(--tech); font-weight: 700; font-size: 12px; padding: 3px 6px;
  text-align: center; background: #F3F6F7; border: 1px solid var(--rule); border-radius: 2px;
}
.gateway-label { font-size: 12px; line-height: 1.3; margin-bottom: 4px; color: var(--ink); }
.gateway-label small { color: var(--ink-3); display: block; font-size: 11px; }
.bar-track {
  position: relative; width: 100%; height: 9px; background: #EDF2F4; border: 1px solid var(--rule-2); border-radius: 1px; overflow: hidden;
}
.bar-fill { height: 100%; background: var(--alu); }
.bar-fill.is-top { background: var(--ok); }
.bar-fill.is-low { background: var(--signal); }
.gateway-num { text-align: right; font-family: var(--tech); font-size: 12px; font-variant-numeric: tabular-nums; }
.gateway-num small { display: block; font-size: 10.5px; color: var(--ink-3); }

.dim-profile-list { display: flex; flex-direction: column; gap: 11px; }
.dim-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; }
.dim-title { font-size: 12px; font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; }
.dim-title span.dim-w { font-family: var(--tech); font-size: 11px; color: var(--ink-3); font-weight: 500; }
.dim-track {
  position: relative; height: 12px; background: #F1F5F7; border: 1px solid var(--rule-2); border-radius: 1px;
}
.dim-span {
  position: absolute; top: 2px; bottom: 2px; background: #B8D2DF; border: 1px solid var(--alu);
}
.dim-median-tick {
  position: absolute; top: -1px; bottom: -1px; width: 2.5px; background: var(--ink); transform: translateX(-1px);
}
.dim-mean-dot {
  position: absolute; top: 2px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); border: 1px solid #fff; transform: translateX(-3px);
}
.dim-nums { font-family: var(--tech); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.dim-nums small { display: block; font-size: 10.5px; color: var(--ink-3); }

.hist-section { border-top: 1px solid var(--rule-2); padding-top: 10px; margin-top: 2px; }
.hist-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(36px, 1fr)); gap: 8px;
  align-items: end; height: 92px; padding-top: 18px;
}
.hist-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.hist-count { font-family: var(--tech); font-size: 11px; font-weight: 700; color: var(--ink-2); }
.hist-bar { width: 100%; max-width: 44px; background: var(--alu); border-radius: 2px 2px 0 0; min-height: 2px; }
.hist-bar.is-peak { background: var(--ok); }
.hist-lbl { font-family: var(--tech); font-size: 10.5px; color: var(--ink-3); }

.pill-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mini-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border: 1px solid var(--rule); background: #fff; border-radius: 2px;
  font-family: var(--tech); font-size: 11px; color: var(--ink-2);
}

.explorer-section { margin-top: 22px; border: 1px solid var(--rule); background: #fff; padding: 18px 20px; }
.sheet-tab-bar {
  display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1.5px solid var(--ink);
  padding-bottom: 10px; margin-bottom: 14px;
}
.tab-btn {
  padding: 6px 12px; border: 1px solid var(--rule); background: #F7F9FA; color: var(--ink-2);
  font: 12.5px/1.2 var(--sans); font-weight: 600; cursor: pointer; border-radius: 2px;
}
.tab-btn:hover { border-color: var(--ink); color: var(--ink); background: #fff; }
.tab-btn.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-pane[hidden] { display: none; }

.explorer-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px;
}
.search-input {
  flex: 1 1 230px; min-width: 180px; padding: 6px 10px; border: 1px solid var(--rule);
  border-radius: 2px; font: 13px/1.3 var(--sans); color: var(--ink); background: #fff;
}
.search-input:focus { outline: 2px solid var(--alu); border-color: var(--alu); }
.select-input {
  padding: 6px 9px; border: 1px solid var(--rule); border-radius: 2px;
  font: 12.5px/1.3 var(--sans); background: #fff; color: var(--ink);
}

.verdict-strip { display: inline-flex; gap: 3px; align-items: center; }
.vdot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; font-family: var(--tech); font-size: 10px; font-weight: 700;
  border-radius: 2px; border: 1px solid transparent;
}
.vdot-p { background: #E8F5EE; color: #1E6649; border-color: #A9D7BC; }
.vdot-f { background: #FDF0ED; color: #9B2C11; border-color: #F4C4B7; }
.vdot-n { background: #EFF3F5; color: #7C8C95; border-color: #D7E0E4; }

.pager {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-top: 10px; font-size: 12px; color: var(--ink-2);
}
.pager-btns { display: flex; gap: 6px; align-items: center; }
.sortable th[data-sort] { cursor: pointer; user-select: none; }
.sortable th[data-sort]:hover { color: var(--ink); background: #E7EEF1; }
.quote-cell { max-width: 240px; font-size: 11.5px; color: var(--ink-2); line-height: 1.4; }

.paired-cohort-list { display: flex; flex-direction: column; gap: 11px; margin-top: 8px; }
.paired-row { display: grid; grid-template-columns: 165px minmax(0, 1fr) 118px; gap: 10px; align-items: center; }
.paired-label { font-size: 12px; line-height: 1.3; font-weight: 600; color: var(--ink); }
.paired-label small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.paired-bars { display: flex; flex-direction: column; gap: 3px; }
.paired-track { position: relative; height: 8px; background: #EDF2F4; border-radius: 1px; overflow: hidden; }
.paired-fill-top { height: 100%; background: var(--ok); }
.paired-fill-top.is-key { background: var(--signal); }
.paired-fill-rest { height: 100%; background: #94A8B3; }
.paired-nums { font-family: var(--tech); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.paired-edge { font-weight: 700; color: var(--ok); }
.paired-edge.is-key { color: var(--signal); }
.paired-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--ink-2); margin-top: 6px; }
.trait-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.trait-card { padding: 10px 12px; background: #F7F9FA; border: 1px solid var(--rule-2); border-left: 3px solid var(--ok); font-size: 12px; line-height: 1.48; }
.trait-card.is-warn { border-left-color: var(--signal); }
.trait-card h4 { margin: 0 0 4px; font-size: 12.5px; color: var(--ink); }

@media (max-width: 1060px) {
  .analytics-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .akpi:nth-child(n+4) { border-top: 1px solid var(--rule-2); }
  .analytics-two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .analytics-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gateway-row { grid-template-columns: 38px minmax(0, 1fr) 88px; }
  .dim-row { grid-template-columns: minmax(0, 1fr); }
  .paired-row { grid-template-columns: minmax(0, 1fr); }
  .trait-grid { grid-template-columns: minmax(0, 1fr); }
}

