/* Dental Insurance Estimate Desk - executive legal redline instrument */

:root {
  --desk: #1C1E21;
  --paper: #FCFBF9;
  --ink: #18181B;
  --muted: #3F3F46;
  --cta: #991B1B;
  --cta-ink: #FFFFFF;
  --accent: #1E3A8A;
  --hair: #A1A1AA;
  --slot: #F4F1EA;
  --rail-ink: #F4F4F5;
  --rail-muted: #D4D4D8;
  --ok: #166534;
  --warn: #854D0E;
  --bad: #9A3412;
  --flash: #DBE4F5;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --pad-x: 40px;
  --hud-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); color: var(--ink); line-height: 1.15; margin: 0; }
p { margin: 0; }
button, input, select { font: inherit; }
button, select, a, label.check, [data-edit-target], summary { cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  background: var(--paper); color: var(--ink); padding: 10px 14px; min-height: 44px;
  border: 2px solid var(--ink); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.docket-rail :focus-visible { outline-color: #93C5FD; }

.money, .kpi-value, .total-value, .calc-value, .derived-value, .num,
.evidence-table, .ledger td, .math-steps, .rail-facts dd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- cockpit topology ---------- */

.cockpit {
  display: grid;
  grid-template-columns: 220px minmax(0, 920px);
  justify-content: center;
  align-items: start;
  column-gap: 24px;
  padding: 24px 24px 16px;
}

.instrument { min-width: 0; }

/* ---------- docket rail ---------- */

.docket-rail { color: var(--rail-ink); min-width: 0; }

.rail-head { padding: 4px 4px 12px; border-bottom: 1px solid #52525B; }
.rail-kicker {
  font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--paper);
}
.rail-sub { font-size: 13px; color: var(--rail-muted); }

.rail-scroll { padding: 14px 2px 56px 0; }

.preset-label-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.preset-label { font-size: 13px; font-weight: 600; color: var(--rail-ink); letter-spacing: 0.02em; }
.sample-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
  padding: 2px 8px; border: 1px solid var(--rail-muted); color: var(--paper);
}
.sample-badge[hidden] { display: none; }

.preset-chips { display: flex; flex-direction: column; gap: 6px; }

[data-preset-chip] {
  display: flex; align-items: flex-start; gap: 8px; text-align: left;
  min-height: 44px; width: 100%;
  padding: 10px 12px 10px 10px;
  background: #2A2D31; color: var(--rail-ink);
  border: 1px solid #52525B; border-left: 4px solid #71717A; border-radius: 0;
  transition: background-color 120ms ease, border-color 120ms ease;
}
[data-preset-chip]:hover { background: #33373C; border-left-color: var(--paper); }
[data-preset-chip]:active { background: #3B3F45; }
[data-preset-chip][aria-pressed="true"] {
  background: var(--slot); color: var(--ink); border-color: var(--slot); border-left-color: var(--cta);
}
.chip-icon { flex: none; margin-top: 2px; }
.chip-text { display: flex; flex-direction: column; min-width: 0; }
.chip-title { font-weight: 700; font-size: 14px; line-height: 1.25; }
.chip-hint { font-size: 12.5px; line-height: 1.3; color: var(--rail-muted); }
[data-preset-chip][aria-pressed="true"] .chip-hint { color: var(--muted); }

.reset-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.reset-group .btn-secondary {
  width: 100%; justify-content: flex-start;
  background: transparent; color: var(--rail-ink); border-color: #71717A;
}
.reset-group .btn-secondary:hover { border-color: var(--paper); background: #2A2D31; }

.undo-toast {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 10px; padding: 8px 10px; max-width: 100%;
  background: var(--slot); color: var(--ink); border-left: 4px solid var(--accent);
  font-size: 14px;
}
.undo-toast[hidden] { display: none; }
.btn-undo { min-height: 44px; }

.trust-reassurance-bar {
  margin-top: 16px; padding: 12px; border: 1px solid #52525B; border-left: 4px solid #6EE7B7;
  display: flex; flex-direction: column; gap: 6px;
}
.trust-badge {
  align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 8px; background: #DCFCE7; color: #14532D;
}
.trust-reassurance-bar p { font-size: 13px; color: var(--rail-ink); line-height: 1.4; }

.rail-status { margin-top: 18px; padding-top: 14px; border-top: 1px solid #52525B; }
.rail-status-title { font-size: 16px; color: var(--paper); margin-bottom: 8px; }
.rail-status .state-pill { margin-bottom: 8px; }
.rail-summary { font-size: 14px; color: var(--rail-ink); line-height: 1.4; }
.rail-status .blocker-list { margin-top: 8px; color: var(--rail-ink); }
.rail-status .link-btn { color: #BFDBFE; }
.rail-facts { margin: 12px 0 0; display: grid; gap: 4px; }
.rail-facts div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.rail-facts dt { color: var(--rail-muted); }
.rail-facts dd { margin: 0; color: var(--paper); }

/* ---------- legal sheet ---------- */

.legal-sheet {
  background: var(--paper);
  color: var(--ink);
  border: 3px double var(--ink);
  border-radius: 0;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  max-width: 920px;
  min-width: 0;
}

.masthead {
  background-color: #FCFBF9;
  color: #18181B;
  border-bottom: 3px double #18181B;
  padding: 18px var(--pad-x) 14px;
}
.caption-ref {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.masthead-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-top: 6px;
}
.masthead h1 {
  font-size: 30px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15;
  max-height: 52px; white-space: nowrap;
}
.masthead-utilities { display: flex; flex-wrap: wrap; gap: 6px; }
.util-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  min-height: 44px; max-height: 50px; padding: 6px 12px;
  background: transparent; color: var(--ink); border: 1px solid var(--ink); border-radius: 0;
  font-size: 14px; font-weight: 600;
}
.util-btn:hover { background: var(--slot); }
.util-btn:active { background: #E9E4D8; }
.util-pro { color: var(--cta); border-color: var(--cta); }
.masthead-subtitle { margin-top: 6px; font-size: 15.5px; color: var(--muted); }
.masthead-status { margin-top: 6px; font-size: 13px; color: var(--muted); }
.masthead-state { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

/* state colours: verdict and validation only */
[data-tone="ready"] { --tone: var(--ok); }
[data-tone="warn"] { --tone: var(--warn); }
[data-tone="invalid"] { --tone: var(--bad); }
[data-tone="idle"] { --tone: var(--muted); }
.masthead-state[data-tone] { color: var(--tone); }

.state-pill {
  display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  border: 2px solid var(--tone, var(--ink)); color: var(--tone, var(--ink)); background: var(--paper);
  white-space: nowrap;
}
.docket-rail .state-pill { background: var(--paper); }

/* ---------- verdict dock ---------- */

.deliverable-dock {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
  padding: 10px var(--pad-x);
  display: flex; flex-direction: column; gap: 8px;
}
.dock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dock-verdict { flex: 1 1 220px; min-width: 0; font-weight: 600; font-size: 15px; line-height: 1.35; }
.dock-actions, .dock-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.dock-row-kpis { align-items: stretch; }
.kpi-grid { flex: 1 1 420px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.kpi {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left;
  min-height: 44px; padding: 6px 10px; min-width: 0;
  background: transparent; border: 0; border-left: 3px solid var(--hair); border-radius: 0; color: var(--ink);
}
.kpi:hover { background: var(--slot); }
.kpi:active { background: #E9E4D8; }
.kpi-primary { border-left-color: var(--accent); }
.kpi-label { font-size: 12px; color: var(--muted); line-height: 1.25; }
.kpi-value { font-size: 18px; font-weight: 600; line-height: 1.25; }
.dock-blocker { font-size: 14px; color: var(--bad); }
.dock-blocker[hidden] { display: none; }

.btn-dock {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  min-height: 44px; padding: 6px 14px; border-radius: 0;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); font-weight: 600; font-size: 14px;
}
.btn-dock:hover { background: #27272A; }
.btn-dock:active { background: #3F3F46; }

/* ---------- buttons ---------- */

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 6px 12px; border-radius: 0;
  background: transparent; color: var(--ink); border: 1px solid var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1.25; text-align: left;
}
.btn-secondary:hover { background: var(--slot); }
.btn-secondary:active { background: #E9E4D8; }
.btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 0;
  background: var(--cta); color: var(--cta-ink); border: 1px solid var(--cta);
  font-weight: 700; font-size: 15px; text-decoration: none;
}
.btn-primary:hover { background: #7F1D1D; }
.btn-primary:active { background: #6B1515; }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 6px 14px; border-radius: 0;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); font-weight: 600;
}
.btn-danger:active { background: #3F3F46; }

.link-btn {
  display: inline; min-height: 44px; padding: 6px 2px; background: none; border: 0;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-align: left;
  font-size: inherit; line-height: 1.4;
}
.link-btn:active { color: var(--ink); }

/* ---------- clauses ---------- */

.instrument-form { margin: 0; }

.clause {
  padding: 72px var(--pad-x) 32px;
  border-bottom: 1px solid var(--hair);
  container-type: inline-size;
}
.clause-first { padding-top: 16px; }
.clause-last { border-bottom: 0; }
.clause-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.clause h2 { font-size: 24px; font-weight: 600; margin-bottom: 14px; line-height: 1.2; }
.sec-num { color: var(--cta); margin-right: 6px; font-weight: 700; }
.clause-text { font-size: 15px; color: var(--muted); margin: 6px 0 12px; max-width: 72ch; padding: 0; }
.sub-num { font-family: var(--font-mono); font-weight: 600; color: var(--ink); margin-right: 4px; }
.live-cue {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); font-weight: 600;
}
.live-cue::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.role-badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; line-height: 1.3; border: 1px solid transparent;
}
.role-badge-in { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }
.role-badge-out { background: var(--ink); color: var(--paper); border-color: var(--ink); }

fieldset.clause-fields { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
legend.clause-text { float: left; width: 100%; }
legend.clause-text + * { clear: both; }

.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.opt { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

input[type="text"], input[type="date"], select {
  width: 100%; min-width: 180px; min-height: 44px;
  background: #F4F1EA;
  border: 0;
  border-bottom: 2px solid #18181B;
  border-radius: 0;
  padding: 6px 8px;
  color: var(--ink);
  font-size: 16px;
}
select { appearance: auto; }
input::placeholder { color: #71717A; opacity: 1; }
input[type="text"]:focus, input[type="date"]:focus, select:focus { border-bottom-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-bottom-color: var(--bad); }

.money-slot { display: flex; align-items: stretch; min-width: 0; }
.money-slot .slot-affix {
  display: flex; align-items: center; flex: none;
  padding: 6px 2px 6px 8px; background: #F4F1EA; border-bottom: 2px solid #18181B;
  font-family: var(--font-mono); color: var(--muted); font-size: 16px;
}
.pct-slot .slot-affix { padding: 6px 8px 6px 2px; }
.money-slot input { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.money-slot:focus-within .slot-affix { border-bottom-color: var(--accent); }
.money-slot.is-invalid .slot-affix { border-bottom-color: var(--bad); }

.validation-cue { font-size: 13px; color: var(--bad); font-weight: 600; line-height: 1.35; }
.validation-cue[hidden] { display: none; }

.derived-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin-top: 16px; }
.derived {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 44px;
  padding: 6px 0; background: none; border: 0; border-top: 1px solid var(--hair); color: var(--ink); text-align: left;
}
.derived:hover .derived-value { text-decoration: underline; }
.derived:active { background: var(--slot); }
.derived-label { font-size: 14px; color: var(--muted); }
.derived-value { font-weight: 600; }

/* ---------- procedure schedule ---------- */

.proc-list { list-style: none; margin: 8px 0 0; padding: 0; }
.proc-row { padding: 16px 0 18px; border-top: 1px solid var(--hair); }
.proc-row:last-child { border-bottom: 1px solid var(--hair); }
.proc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.proc-num { font-family: var(--font-mono); font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.row-remove {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 6px 10px;
  background: none; border: 1px solid transparent; color: var(--muted); font-size: 14px; border-radius: 0;
}
.row-remove:hover { border-color: var(--hair); color: var(--ink); }
.row-remove:active { background: var(--slot); }
.row-remove[hidden] { display: none; }

.field-check { justify-content: flex-end; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; font-size: 14px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }

.proc-calc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.calc-cell {
  display: flex; flex-direction: column; align-items: flex-start; min-height: 44px; padding: 6px 10px;
  background: none; border: 0; border-left: 2px solid var(--hair); text-align: left; color: var(--ink); min-width: 0;
}
.calc-cell:hover { background: var(--slot); }
.calc-cell:active { background: #E9E4D8; }
.calc-label { font-size: 12px; color: var(--muted); }
.calc-value { font-weight: 600; font-size: 15px; }
.calc-cell-patient { border-left-color: var(--accent); }
.proc-row[data-capped="true"] .calc-cell:nth-child(2) { border-left-color: var(--warn); }

.schedule-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; }
.schedule-note { font-size: 13px; color: var(--muted); }

@container (min-width: 720px) {
  .tier-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .proc-grid { grid-template-columns: 200px minmax(0, 1fr) 200px; }
  .proc-grid .field-check { grid-column: span 2; }
}

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

.notice-slot { min-height: 64px; margin-bottom: 14px; }
.record-caption { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 14px; padding: 8px 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); font-size: 14px; }
.record-caption div { min-width: 0; }
.record-caption dt { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.record-caption dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.conflict-banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px;
  border: 1px solid var(--warn); border-left: 5px solid var(--warn); background: #FEF7E6; color: var(--ink);
}
.conflict-banner[hidden] { display: none; }
.conflict-banner > svg { color: var(--warn); flex: none; margin-top: 2px; }
.conflict-title { font-weight: 700; color: var(--warn); }
.conflict-list { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.conflict-list .link-btn { margin-right: 8px; }
.calm-note { padding: 12px 14px; border-left: 3px solid var(--hair); color: var(--muted); font-size: 14px; }
.calm-note[hidden] { display: none; }

.table-wrap { overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
.evidence-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.evidence-table caption {
  caption-side: top; text-align: left; font-family: var(--font-body); font-weight: 700; font-size: 14px;
  padding-bottom: 8px; color: var(--ink);
}
.evidence-table th, .evidence-table td { padding: 8px 8px; border-bottom: 1px solid var(--hair); text-align: left; vertical-align: top; }
.evidence-table thead th {
  font-family: var(--font-body); font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid var(--ink);
}
.evidence-table .num { text-align: right; white-space: nowrap; }
.evidence-table td[data-part="proc"] { font-family: var(--font-body); min-width: 150px; }
.cell-code { font-family: var(--font-mono); font-weight: 600; }
.evidence-table tfoot th, .evidence-table tfoot td { border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); font-weight: 700; }
.edit-row:hover { background: var(--slot); }
.edit-row:active { background: #E9E4D8; }
tr[data-capped="true"] td[data-part="plan"] { color: var(--warn); font-weight: 600; }

.show-math { margin-top: 18px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.show-math summary {
  min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 6px 0;
  font-family: var(--font-display); font-weight: 600; font-size: 18px; list-style: none;
}
.show-math summary::-webkit-details-marker { display: none; }
.show-math summary::before {
  content: ''; width: 8px; height: 8px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: rotate(-45deg); transition: transform 150ms ease;
}
.show-math[open] summary::before { transform: rotate(45deg); }
.show-math summary:active { color: var(--accent); }
.math-intro { font-size: 14.5px; color: var(--muted); margin-bottom: 10px; max-width: 72ch; }
.math-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 12px; }
.math-item { padding: 8px 0 0; border-top: 1px dashed var(--hair); }
.math-head { font-weight: 700; font-size: 14.5px; }
.math-steps { margin: 4px 0 0; padding-left: 22px; font-size: 13px; line-height: 1.6; }
.math-pending { color: var(--muted); font-size: 14px; border-top: 0; }

.determination {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start;
  padding-bottom: 16px; border-bottom: 1px solid var(--hair);
}
.determination-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.determination-state { font-family: var(--font-mono); font-weight: 600; font-size: 20px; color: var(--tone, var(--ink)); }
.determination-next { margin-top: 4px; font-size: 15px; color: var(--ink); max-width: 60ch; }
.blocker-list { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.blocker-list[hidden] { display: none; }
.blocker-list-doc .link-btn strong { color: var(--ink); }

.estimate-stamp {
  max-width: 200px; padding: 8px 12px; text-align: center;
  border: 3px double var(--cta); color: var(--cta);
  font-family: var(--font-mono); font-weight: 600; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  transform: rotate(-3deg); background: var(--paper);
}

.totals-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.total-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 44px; padding: 8px 12px;
  background: none; border: 0; border-top: 2px solid var(--ink); text-align: left; color: var(--ink); min-width: 0;
}
.total-card:hover { background: var(--slot); }
.total-card:active { background: #E9E4D8; }
.total-card-primary { border-top: 4px double var(--accent); }
.total-label { font-size: 13px; color: var(--muted); }
.total-value { font-size: 22px; font-weight: 600; }

.ledgers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; align-items: start; }
.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger caption { text-align: left; font-family: var(--font-display); font-weight: 600; font-size: 16px; padding-bottom: 6px; }
.ledger th { text-align: left; font-weight: 400; color: var(--muted); padding: 8px 6px 8px 0; border-bottom: 1px solid var(--hair); }
.ledger td { text-align: right; padding: 8px 0; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.ledger-final th, .ledger-final td { font-weight: 700; color: var(--ink); border-bottom: 3px double var(--ink); }

.assumptions { margin-top: 22px; }
.assumptions h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.assumptions ul { margin: 0; padding-left: 20px; font-size: 14.5px; color: var(--muted); display: grid; gap: 4px; }

/* ---------- attestation and Pro seal ---------- */

.attest-fields { margin-bottom: 14px; }
.signature-block { margin-top: 8px; }
.sig-lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; margin: 28px 0 18px; }
.sig-line { display: flex; flex-direction: column; gap: 4px; }
.sig-rule { display: block; height: 32px; border-bottom: 1px solid var(--ink); }
.sig-caption { font-size: 13px; color: var(--muted); }

.pro-seal {
  display: flex; gap: 14px; align-items: flex-start; margin-top: 26px; padding: 18px 0 0;
  border-top: 3px double var(--ink);
}
.seal-icon { color: var(--cta); flex: none; margin-top: 4px; }
.pro-seal-body { min-width: 0; }
.pro-seal h3 { font-size: 18px; font-weight: 600; }
.pro-seal p { font-size: 14.5px; color: var(--muted); margin-top: 4px; max-width: 64ch; }
.pro-seal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.locked-wrap { margin-top: 12px; }
.locked-control {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px;
  background: var(--slot); color: var(--ink); border: 1px dashed var(--muted); border-radius: 0; font-weight: 600; font-size: 14px;
}
.locked-control:active { background: #E9E4D8; }
.lock-note { font-size: 13px !important; color: var(--muted); }

.free-watermark {
  margin-top: 26px; padding-top: 10px; border-top: 1px solid var(--hair);
  font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-align: center;
}

/* ---------- click-to-edit flash ---------- */

.flash-recalc { animation: flash-recalc 1s ease-out; }
@keyframes flash-recalc {
  0% { background-color: var(--flash); box-shadow: 0 0 0 4px var(--flash); }
  100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; }
}

/* ---------- dialogs ---------- */

.modal {
  padding: 0; border: 3px double var(--ink); border-radius: 0; background: var(--paper); color: var(--ink);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}
.modal::backdrop { background: rgba(12, 13, 15, 0.72); }
.modal-small { width: min(460px, calc(100vw - 24px)); }
.modal-inner { padding: 22px 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.modal h2 { font-size: 22px; font-weight: 600; }
.modal-small h2 { margin-bottom: 8px; }
.modal-close {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 6px;
  background: none; border: 1px solid var(--hair); border-radius: 0; color: var(--ink);
}
.modal-close:active { background: var(--slot); }
.modal-lede { color: var(--muted); font-size: 15px; margin-bottom: 14px; }
.free-vs-pro-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.free-vs-pro-table th, .free-vs-pro-table td { padding: 8px 8px; border-bottom: 1px solid var(--hair); text-align: left; color: var(--ink); vertical-align: top; }
.free-vs-pro-table thead th { background: var(--ink); color: var(--paper); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.free-vs-pro-table tbody th { font-weight: 600; }
.modal-price { margin-top: 14px; font-weight: 600; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- desk sill and mobile HUD ---------- */

.cockpit-horizon-bar { display: none; }
.mobile-hud { display: none; }

/* ---------- desktop cockpit ---------- */

@media (min-width: 901px) {
  html,
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  body { display: grid; grid-template-rows: minmax(0, 1fr) 28px; }
  .cockpit { height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .docket-rail, .instrument { height: 100%; min-height: 0; display: flex; flex-direction: column; }
  .legal-sheet { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; width: 100%; }
  .masthead, .rail-head { flex: none; }
  .scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 56px;
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 36px), transparent 100%);
    mask-image: linear-gradient(to bottom, black calc(100% - 36px), transparent 100%);
  }
  .scroll-body.is-at-end { -webkit-mask-image: none; mask-image: none; }
  /* scrolled-into-view targets land below the sticky verdict dock */
  .sheet-scroll { scroll-padding-top: calc(var(--dock-h, 132px) + 12px); }
  .sheet-scroll :is(button, a[href], input, select, textarea, summary, details, [tabindex], .field, .clause, h2) {
    scroll-margin-top: calc(var(--dock-h, 132px) + 12px);
  }
  .sheet-scroll .deliverable-dock, .sheet-scroll .deliverable-dock * { scroll-margin-top: 0; }
  .rail-scroll { scrollbar-color: #52525B transparent; }

  .cockpit-horizon-bar {
    display: flex; align-items: center; justify-content: center; gap: 18px;
    height: 28px; padding: 0 16px; overflow: hidden; white-space: nowrap;
    background: #141518; color: var(--rail-muted); border-top: 1px solid #3F3F46;
    font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em;
  }
  .sill-item { flex: none; }
  .sill-guide { color: var(--rail-ink); }
}

@media (min-width: 901px) and (max-width: 1180px) {
  :root { --pad-x: 28px; }
  .cockpit { column-gap: 16px; padding-left: 16px; padding-right: 16px; }
  .cockpit-horizon-bar { gap: 12px; font-size: 10.5px; }
  .sill-telemetry { display: none; }
}

/* ---------- tablet and mobile flow ---------- */

@media (max-width: 900px) {
  .caption-row { display: none; }
  .masthead-subtitle { display: none; }
  .masthead h1 { font-size: 19px; max-height: none; }
  .masthead-row { margin-top: 2px; gap: 4px 8px; }
  .util-btn { min-height: 36px; max-height: 40px; padding: 4px 10px; font-size: 12.5px; }

  :root { --pad-x: 20px; }
  body { padding-bottom: calc(var(--hud-h) + 12px); }
  .cockpit { display: flex; flex-direction: column; gap: 16px; padding: 12px; }
  .instrument { order: 1; width: 100%; }
  .docket-rail { order: 2; width: 100%; padding: 12px; border: 1px solid #3F3F46; }
  .rail-scroll { padding-bottom: 12px; }
  .preset-chips { flex-direction: row; flex-wrap: wrap; }
  [data-preset-chip] { width: auto; flex: 1 1 200px; }
  .reset-group .btn-secondary { width: auto; flex: 1 1 200px; }
  .masthead h1 { white-space: normal; }

  .sheet-scroll { display: flex; flex-direction: column; }
  .sheet-scroll > .instrument-form { display: contents; }
  #sec-1 { order: 1; }
  .deliverable-dock { order: 2; position: static; border-top: 1px solid var(--hair); }
  #sec-2 { order: 3; }
  #sec-3 { order: 4; }
  .sheet-scroll > [data-results] { order: 5; }
  #sec-6 { order: 6; }
  .sheet-scroll > .related-tools-grid { order: 7; }
  .clause { padding-top: 40px; }
  .clause-first { padding-top: 20px; }

  .mobile-hud {
    display: flex; align-items: center; gap: 8px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: var(--hud-h); padding: 8px 12px; overflow: hidden;
    background: var(--ink); color: var(--paper); border-top: 3px double var(--paper);
  }
  .hud-state {
    flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden;
    font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px;
  }
  .hud-link, .hud-btn {
    flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 6px 12px; white-space: nowrap;
    font-weight: 600; font-size: 14px; border-radius: 0;
  }
  .hud-link { color: var(--paper); border: 1px solid #71717A; text-decoration: none; }
  .hud-link:active { background: #27272A; }
  .hud-btn { background: var(--paper); color: var(--ink); border: 1px solid var(--paper); }
  .hud-btn:active { background: var(--slot); }
}

@media (max-width: 720px) {
  .determination { grid-template-columns: minmax(0, 1fr); }
  .estimate-stamp { justify-self: start; }
  .ledgers { grid-template-columns: minmax(0, 1fr); }
  .totals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .total-card-primary { grid-column: span 2; }
}

@media (max-width: 680px) {
  fieldset [class*="grid"],
  form [class*="grid"],
  .field-pair,
  .prop-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .proc-grid .field-check { grid-column: auto; }
  .derived-strip, .sig-lines { grid-template-columns: minmax(0, 1fr); }
  input[type="text"], input[type="date"], select { min-width: 0; }
}

@media (max-width: 640px) {
  :root { --pad-x: 14px; }
  .cockpit { padding: 12px; }
  .masthead { padding: 14px var(--pad-x) 12px; }
  .masthead h1 { font-size: 21px; }
  .masthead-subtitle { font-size: 14.5px; }
  .caption-ref { font-size: 11px; }
  .util-btn { padding: 6px 10px; font-size: 13px; }
  .clause h2 { font-size: 20px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); flex-basis: 100%; }
  .kpi-primary { grid-column: span 2; }
  .dock-row > *, .dock-actions > *, .dock-nav > *, .rail-facts > div { max-width: 100%; }
  .dock-actions, .dock-nav { width: 100%; }
  .dock-actions > *, .dock-nav > * { flex: 1 1 calc(50% - 6px); max-width: 48%; justify-content: center; }
  .proc-calc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-cell-patient { grid-column: span 2; }
  .rail-facts { grid-template-columns: repeat(2, minmax(0, 48%)); justify-content: space-between; }
  .rail-facts div { flex-direction: column; gap: 0; }
  .modal-inner { padding: 16px 14px; }
  .evidence-table { font-size: 12.5px; }
  .pro-seal { flex-direction: column; }
}

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

/* ---------- print: the legal document only ---------- */

@media print {
  @page { margin: 14mm 12mm; }
  html, body { height: auto !important; overflow: visible !important; background: #FFFFFF !important; color: #111827 !important; display: block !important; }
  body { padding: 0 !important; }
  .docket-rail, .masthead, .deliverable-dock, .cockpit-horizon-bar, .mobile-hud, dialog, .skip-link,
  .row-remove, .schedule-actions, .pro-seal, .conflict-list .link-btn, .live-cue, .role-badge, .validation-cue, .link-btn + .link-btn { display: none !important; }
  #estimate-form, .attest-fields, .totals-grid, button, [role="button"], .link-btn, .btn-primary, .btn-secondary,
  a[data-checkout], .show-math > summary, nav, form, input, select, textarea, [data-open-pro] { display: none !important; }
  .cockpit { display: block !important; padding: 0 !important; height: auto !important; }
  #executive-deliverable { display: block !important; height: auto !important; }
  .legal-sheet { box-shadow: none !important; border: 0 !important; display: block !important; max-width: none; background: #FFFFFF !important; }
  .scroll-body, .sheet-scroll {
    display: block !important; overflow: visible !important; height: auto !important; padding: 0 !important;
    -webkit-mask-image: none !important; mask-image: none !important;
  }
  .legal-sheet, .legal-sheet * { color: #111827 !important; background: transparent !important; box-shadow: none !important; }
  .legal-sheet::before {
    content: 'Dental Insurance Estimate Desk \2014  Pre-treatment patient estimate workpaper';
    display: block; font-family: var(--font-display); font-size: 18pt; font-weight: 700;
    border-bottom: 3px double #111827; padding-bottom: 6pt; margin-bottom: 8pt;
  }
  .clause { padding: 10pt 0 !important; border-bottom: 1px solid #111827; break-inside: auto; }
  .clause h2 { font-size: 14pt; break-after: avoid; }
  input[type="text"], input[type="date"], select, .money-slot .slot-affix {
    border: 0 !important; border-bottom: 1px solid #111827 !important; min-height: 0 !important; padding: 2pt 0 !important;
    appearance: none; -webkit-appearance: none;
  }
  input::placeholder { color: transparent !important; }
  .field-pair, .tier-grid, .proc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .proc-row, .math-item, .ledger, .determination, .totals-grid, tr { break-inside: avoid; }
  .table-wrap { overflow: visible !important; }
  .show-math > *:not(summary) { display: block !important; }
  .show-math summary::before { display: none; }
  .estimate-stamp { border-color: #111827 !important; transform: none; }
  .kpi, .total-card, .calc-cell, .derived { border-color: #111827 !important; }
  .free-watermark { display: block !important; font-size: 10pt; border-top: 1px solid #111827; }
  a[href]::after { content: none !important; }
}

/* caption row: reference and live status share one line */
.caption-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px; }
.caption-row .masthead-status { margin-top: 0; }
.cell-sub { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--font-body); }

/* Mobile masthead compaction (post-media override) */
@media (max-width: 900px) {
  header .caption-row { display: none !important; }
  .masthead h1 { font-size: 15.5px !important; line-height: 1.1 !important; max-height: none !important; }
  .masthead-row { margin-top: 0 !important; }
  .masthead-utilities { flex-wrap: nowrap; gap: 4px; max-width: 100%; }
  .util-btn { min-height: 44px !important; max-height: 44px !important; padding: 2px 8px !important; font-size: 11px !important; }
}

/* Keep focus-scrolled fields clear of the bottom chrome (audit 2026-10-19) */
.rail-scroll-body input, .rail-scroll-body select, .rail-scroll-body textarea,
.inspector-scroll-body input, .inspector-scroll-body select, .inspector-scroll-body textarea,
#rail-scroll input, #rail-scroll select, #rail-scroll textarea {
  scroll-margin-bottom: 112px;
}
.rail-scroll-body, #rail-scroll, .inspector-scroll-body { padding-bottom: 112px; }
