/* Home Health Note Queue · CPA greenbar workpaper (tax_accounting_ledger / inline_spreadsheet_grid) */

:root {
  --canvas: #E6F4EA;
  --paper: #FFFFFF;
  --wb: #F0FDF4;
  --hdr-ink: #064E3B;
  --ink: #111827;
  --muted: #334155;
  --pro: #047857;
  --pro-ink: #FFFFFF;
  --accent: #B45309;
  --hair: #6EE7B7;
  --cell: #94A3B8;
  --focus-bg: #ECFDF5;
  --ready-ink: #1E3A8A; --ready-bg: #EFF6FF; --ready-line: #1E3A8A;
  --warn-ink: #78350F; --warn-bg: #FEF3C7; --warn-line: #B45309;
  --crit-ink: #7F1D1D; --crit-bg: #FEE2E2; --crit-line: #B91C1C;
  --hold-ink: #7C2D12; --hold-bg: #FFEDD5; --hold-line: #C2410C;
  --idle-ink: #334155; --idle-bg: #F1F5F9; --idle-line: #94A3B8;
  --font-display: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --max: 1420px;
  --gutter: 24px;
  --inline: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
}

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

[hidden] { display: none !important; }

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

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

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; overflow-wrap: anywhere; }

a { color: var(--hdr-ink); }

button, select, input, a { font: inherit; }
button, select, [role="button"], a, summary, label[for], .alert-toggle { cursor: pointer; }

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

.skip-link {
  position: absolute; left: 12px; top: 8px; z-index: 100;
  padding: 10px 14px; min-height: 44px;
  background: var(--paper); color: var(--hdr-ink);
  border: 2px solid var(--pro);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

:focus-visible { outline: 3px solid var(--pro); outline-offset: 2px; }

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

.btn-tool, .btn-ghost, .btn-pro, .btn-primary, .btn-secondary, #reset-btn, .preset-chip,
.btn-row-remove, .verdict-target, .link-btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 14px;
  border-radius: 0;
  font-weight: 600; font-size: 14px; line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}

.btn-tool, #reset-btn, .btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
}
.btn-tool:hover, #reset-btn:hover, .btn-secondary:hover { background: var(--focus-bg); }
.btn-tool:active, #reset-btn:active, .btn-secondary:active { transform: translateY(1px); background: #D1FAE5; }

.btn-tool--quiet { border-color: var(--cell); color: var(--hdr-ink); }

.btn-ghost {
  background: transparent; color: var(--hdr-ink);
  border: 1.5px dashed var(--hdr-ink);
  white-space: normal; text-align: left;
}
.btn-ghost:hover { background: var(--focus-bg); }
.btn-ghost:active { transform: translateY(1px); }

.btn-pro, .btn-primary {
  background: var(--pro); color: var(--pro-ink);
  border: 1.5px solid var(--pro);
}
.btn-pro:hover, .btn-primary:hover { background: #065F46; border-color: #065F46; }
.btn-pro:active, .btn-primary:active { transform: translateY(1px); background: #064E3B; }

.icon-btn {
  min-width: 44px; padding: 6px;
  background: transparent; color: inherit;
  border: 1px solid transparent;
}
.icon-btn:hover { border-color: currentColor; }
.icon-btn:active { transform: translateY(1px); }

.link-btn {
  background: var(--paper); color: var(--crit-ink);
  border: 1px solid var(--crit-line);
  margin: 8px 8px 0 0;
}
.link-btn:active { transform: translateY(1px); }

svg { flex: none; }

/* ---------- header / workbook ribbon ---------- */

header.wb-header {
  position: sticky; top: 0; z-index: 40;
  background-color: #F0FDF4;
  color: #064E3B;
  border-bottom: 2px solid #047857;
}

.wb-header__row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px var(--inline);
}

.wb-brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }

.wp-code {
  flex: none;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: #064E3B; background: var(--paper);
  border: 1px solid #047857;
  padding: 4px 8px;
}

.wb-brand__text { min-width: 0; }

.wb-title {
  font-size: 20px; line-height: 1.25; white-space: nowrap; color: #064E3B;
  max-height: 52px;
}

.wb-subtitle { margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }

.deliverable-dock {
  position: relative;
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px 20px;
  padding: 6px var(--inline) 8px;
  border-top: 1px solid var(--hair);
}

.dock-verdict { display: flex; align-items: center; gap: 10px; flex: 1 1 300px; min-width: 0; margin: 0; flex-wrap: wrap; }
.dock-short { font-weight: 600; font-size: 14px; color: var(--ink); }

.dock-kpis { display: flex; gap: 0; margin: 0; }
.dock-kpi { padding: 0 14px; border-left: 1px solid var(--hair); min-width: 0; }
.dock-kpi dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dock-kpi dd { margin: 0; font-family: var(--font-mono); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

.dock-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.action-msg {
  position: absolute; right: var(--inline); top: calc(100% + 6px);
  background: var(--ink); color: #fff;
  font-size: 13px; padding: 6px 10px;
}

/* status chip (verdict label; text, not colour alone) */
.status-chip {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 8px; border: 1.5px solid; white-space: nowrap;
}
[data-tone="idle"].status-chip { color: var(--idle-ink); background: var(--idle-bg); border-color: var(--idle-line); }
[data-tone="hold"].status-chip { color: var(--hold-ink); background: var(--hold-bg); border-color: var(--hold-line); }
[data-tone="warn"].status-chip { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-line); }
[data-tone="critical"].status-chip { color: var(--crit-ink); background: var(--crit-bg); border-color: var(--crit-line); }
[data-tone="ready"].status-chip { color: var(--ready-ink); background: var(--ready-bg); border-color: var(--ready-line); }

/* ---------- engagement / formula ribbon ---------- */

.engagement-ribbon { background: var(--paper); border-bottom: 1px solid var(--cell); }
.ribbon-inner { padding: 0 var(--inline); }

.ribbon-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 8px 0; }
.ribbon-row--presets { border-top: 1px dashed var(--hair); }

.ribbon-entity { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; flex: 1 1 260px; min-width: 0; }
.ribbon-label, .ribbon-field label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.entity-name { font-family: var(--font-display); font-size: 16px; color: var(--hdr-ink); overflow-wrap: anywhere; }

.sample-badge, .derived-badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; border: 1px dashed var(--accent); color: #92400E; background: #FFFBEB;
}

.ribbon-field { display: flex; flex-direction: column; gap: 2px; }
.ribbon-field select { min-width: 200px; }

.ribbon-kpis { display: flex; flex-wrap: wrap; margin: 0; }
.ribbon-kpi { padding: 2px 14px; border-left: 1px solid var(--hair); min-width: 0; }
.ribbon-kpi dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ribbon-kpi dd { margin: 0; font-family: var(--font-mono); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 30px; display: flex; align-items: center; }
.ribbon-kpi[role="button"]:hover { background: var(--focus-bg); }

.preset-caption { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.preset-chip {
  background: var(--wb); color: var(--hdr-ink);
  border: 1px solid var(--cell);
}
.preset-chip::before { content: ""; width: 8px; height: 8px; border: 1.5px solid currentColor; background: transparent; }
.preset-chip[aria-pressed="true"] { background: #064E3B; color: #fff; border-color: #064E3B; }
.preset-chip[aria-pressed="true"]::before { background: currentColor; }
.preset-chip:hover { border-color: var(--hdr-ink); }
.preset-chip:active { transform: translateY(1px); }

.reset-group { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.trust-reassurance-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  padding: 6px var(--inline);
  background: var(--wb);
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
}
.trust-reassurance-bar p { margin: 0; color: var(--muted); }
.trust-badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--hdr-ink); border: 1px solid var(--pro); padding: 2px 8px; background: var(--paper);
}

/* ---------- workbook sheet ---------- */

.workbook {
  max-width: var(--max);
  margin: 0 auto;
  background: var(--paper);
  border-left: 1px solid var(--cell);
  border-right: 1px solid var(--cell);
}

.ws-section { padding: 1.25rem var(--gutter); border-bottom: 1px solid var(--hair); }
.ws-section--queue { padding-bottom: 4.5rem; }
.ws-section--review { padding-top: 4.5rem; padding-bottom: 4.5rem; }

.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 12px; }
.section-head h2 { font-size: 20px; color: var(--hdr-ink); line-height: 1.2; }
.section-note { flex: 1 1 100%; margin: 0; font-size: 13.5px; color: var(--muted); max-width: 900px; }

.live-cue { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 600; color: var(--hdr-ink); }
.live-dot { width: 8px; height: 8px; background: var(--pro); }

.role-badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  line-height: 1.3; white-space: nowrap;
}
.role-badge-in { background: #064E3B; color: #FFFFFF; }
.role-badge-out { background: #111827; color: #FFFFFF; }

/* fields */
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field > label, .cell-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.req, .opt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-left: 4px; }
.req { color: #92400E; }
.opt { color: var(--muted); }

.field-pair { display: grid; grid-template-columns: repeat(2, minmax(200px, 380px)); gap: 12px 32px; }
.prop-grid { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 16px 32px; padding: 12px 0 4px; }

.cell-input {
  width: 100%; min-width: 180px; min-height: 44px;
  padding: 8px 6px;
  border: 0;
  border-bottom: 1.5px solid #047857;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.cell-input:focus { background: #ECFDF5; outline: 2px solid var(--pro); outline-offset: 0; }
.cell-input[aria-invalid="true"] { border-bottom-color: var(--crit-line); background: #FEF2F2; }
.cell-input[aria-disabled="true"] { border-bottom-style: dashed; color: var(--muted); }
.cell-input::placeholder { color: #475569; opacity: 1; }
select.cell-input { padding-right: 4px; }

.field-hint { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.validation-cue { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; color: #991B1B; }
.validation-cue::before { content: "Fix · "; font-family: var(--font-mono); font-size: 11px; }

.lock-note { display: flex; align-items: flex-start; gap: 6px; margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.inline-action { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-action .cell-input { flex: 1 1 200px; width: auto; }
.template-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.template-list:empty { display: none; }

.prop-collapsible { margin-top: 12px; border-top: 1px dashed var(--hair); }
.step-tab {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 0;
  font-weight: 600; color: var(--hdr-ink);
}

/* ---------- visit grid ---------- */

.grid-wrap { width: 100%; }

.visit-grid { width: 100%; border-collapse: collapse; table-layout: fixed; border: 1px solid var(--cell); }
.visit-grid col.c-num { width: 44px; }
.visit-grid col.c-alert { width: 132px; }
.visit-grid thead th {
  background: var(--wb); color: var(--hdr-ink);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  text-align: left; padding: 8px 6px;
  border: 1px solid var(--cell);
}
.visit-grid tbody.visit:nth-of-type(even) > tr { background: var(--wb); }
.visit-grid td, .visit-grid th.cell-num { border: 1px solid var(--cell); vertical-align: top; }
.visit-grid td.cell { padding: 4px; }
.cell-num {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--hdr-ink);
  text-align: center; padding: 14px 4px;
}
.visit-grid .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.visit[data-state="critical"] .cell-num { box-shadow: inset 5px 0 0 var(--crit-line); }
.visit[data-state="high"] .cell-num { box-shadow: inset 5px 0 0 var(--hold-line); }
.visit[data-state="medium"] .cell-num { box-shadow: inset 5px 0 0 var(--warn-line); }

.alert-toggle { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--crit-ink); }
.alert-toggle input { width: 20px; height: 20px; accent-color: #B91C1C; flex: none; }

.visit-computed > td { padding: 6px 8px 8px; border-top: 1px dashed var(--hair); }
.computed-strip {
  display: grid;
  grid-template-columns: 96px 104px 118px 132px minmax(220px, 1fr) minmax(190px, 220px) auto;
  gap: 4px 14px; align-items: center;
}
.cx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cx-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cx-val { font-family: var(--font-mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cx-text { font-size: 13px; line-height: 1.35; min-height: 2.7em; }
.cx-owner .cell-input { min-height: 44px; }

.btn-row-remove {
  background: transparent; color: var(--crit-ink);
  border: 1px solid var(--cell); padding: 6px 10px; font-size: 13px;
}
.btn-row-remove:hover { border-color: var(--crit-line); background: #FEF2F2; }
.btn-row-remove:active { transform: translateY(1px); }

.grid-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 12px; }
.grid-foot .field-hint { flex: 1 1 320px; }

.urgency-tag {
  display: inline-flex; align-items: center; width: fit-content;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border: 1.5px solid var(--cell); color: var(--muted); background: var(--paper);
  white-space: nowrap;
}
.urgency-tag[data-urgency="critical"] { color: var(--crit-ink); background: var(--crit-bg); border-color: var(--crit-line); }
.urgency-tag[data-urgency="high"] { color: var(--hold-ink); background: var(--hold-bg); border-color: var(--hold-line); }
.urgency-tag[data-urgency="medium"] { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-line); }
.urgency-tag[data-urgency="low"] { color: var(--ready-ink); background: var(--ready-bg); border-color: var(--ready-line); }
.urgency-tag[data-urgency="clear"] { color: #1F2937; background: var(--idle-bg); border-color: var(--cell); }
.urgency-tag[data-urgency="deferred"], .urgency-tag[data-urgency="incomplete"] { border-style: dashed; color: var(--muted); }

.flash-recalc { animation: flash-recalc 1.1s ease-out; }
@keyframes flash-recalc {
  0% { background-color: #FDE68A; box-shadow: 0 0 0 3px var(--accent); }
  100% { background-color: transparent; box-shadow: 0 0 0 0 transparent; }
}

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

.results { display: flex; flex-direction: column; gap: 16px; }

.verdict-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 16px 20px; min-height: 92px;
  border: 1px solid var(--idle-line); border-left-width: 6px;
  background: var(--idle-bg);
}
.verdict-sentence { margin: 0; flex: 1 1 420px; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.verdict-banner[data-tone="hold"] { background: var(--hold-bg); border-color: var(--hold-line); }
.verdict-banner[data-tone="warn"] { background: var(--warn-bg); border-color: var(--warn-line); }
.verdict-banner[data-tone="critical"] { background: var(--crit-bg); border-color: var(--crit-line); }
.verdict-banner[data-tone="ready"] { background: var(--ready-bg); border-color: var(--ready-line); }
.verdict-target { background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink); }
.verdict-target:active { transform: translateY(1px); }
.verdict-target.is-empty { visibility: hidden; }

.guidance-slot { min-height: 11.5rem; display: flex; flex-direction: column; gap: 8px; }
.guidance-line { margin: 0; font-size: 14.5px; }
.guidance-label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--hdr-ink); border-bottom: 1.5px solid var(--pro); margin-right: 6px;
}
.conflict-banner {
  padding: 12px 16px;
  border: 1.5px solid var(--crit-line); border-left-width: 6px;
  background: var(--crit-bg); color: var(--crit-ink);
  font-size: 14px;
}
.conflict-title { display: block; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.conflict-actions .link-btn { margin: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--cell); border: 1px solid var(--cell); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--paper); min-width: 0; }
.kpi:nth-child(n+4) { background: #FBFEFC; }
.kpi[role="button"]:hover { background: var(--focus-bg); }
.kpi-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi-value { font-family: var(--font-mono); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

.deck-title { font-size: 16px; color: var(--hdr-ink); padding-top: 8px; border-top: 1px solid var(--hair); }

.table-scroll { width: 100%; overflow-x: auto; }

.roster-table, .ledger-table, .free-vs-pro-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.roster-table th, .roster-table td, .ledger-table th, .ledger-table td, .free-vs-pro-table th, .free-vs-pro-table td {
  border: 1px solid var(--cell); padding: 8px 10px; text-align: left; vertical-align: top;
}
.roster-table thead th, .ledger-table thead th, .free-vs-pro-table thead th {
  background: var(--wb); color: var(--hdr-ink);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
}
.roster-table tbody tr:nth-child(even), .ledger-table tbody tr:nth-child(even), .free-vs-pro-table tbody tr:nth-child(even) { background: var(--wb); }
.roster-table .num, .ledger-table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.roster-table .refs { font-family: var(--font-mono); font-size: 13px; }
.roster-table tbody th { font-weight: 600; }
tr[role="button"]:hover, li[role="button"]:hover, div[role="button"]:hover { background: var(--focus-bg); }

.signoff-strip { margin-top: 2.5rem; }
.signoff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; align-items: start; padding-top: 12px; }
.signoff-cta { display: flex; align-items: center; min-height: 100%; }

/* ---------- executive deliverable ---------- */

#executive-deliverable { padding: 4.5rem var(--gutter); background: var(--canvas); }
.deliv-head { max-width: 1180px; margin: 0 auto 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.deliv-head h2 { font-size: 24px; color: var(--hdr-ink); }
.deliv-code { margin: 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.paper {
  max-width: 1180px; margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--cell);
  border-top: 4px solid var(--hdr-ink);
  padding: 32px 40px;
  display: flex; flex-direction: column; gap: 24px;
}

.paper-stamp {
  margin: 0; align-self: flex-start;
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: .12em;
  color: #991B1B; border: 2px solid #B91C1C; padding: 4px 10px;
}

.paper-verdict { display: flex; flex-direction: column; gap: 6px; padding-bottom: 16px; border-bottom: 1px solid var(--cell); align-items: flex-start; }
.paper-verdict__sentence { margin: 0; font-family: var(--font-display); font-size: 18px; line-height: 1.4; }
.paper-verdict__next { margin: 0; font-size: 14px; color: var(--muted); }

.totals-table { width: min(560px, 100%); border-collapse: collapse; font-size: 14.5px; }
.totals-table caption { text-align: left; font-family: var(--font-display); font-weight: 700; font-size: 16px; padding-bottom: 6px; color: var(--hdr-ink); }
.totals-table th { text-align: left; font-weight: 500; padding: 6px 8px; border-bottom: 1px dotted var(--cell); }
.totals-table td { text-align: right; padding: 6px 8px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; border-bottom: 1px dotted var(--cell); }
.totals-table tr.row-total th, .totals-table tr.row-total td { border-top: 1px solid #111827; border-bottom: 3px double #111827; font-weight: 700; }

.paper-h { font-size: 16px; color: var(--hdr-ink); }
.ledger-table { font-size: 13.5px; }
.ledger-table td, .ledger-table th { padding: 6px 8px; }
.ledger-table tbody th { font-family: var(--font-mono); font-weight: 600; }

.paper-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 40px; }
.paper-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.blocker-list { list-style: none; margin: 0; padding: 0; min-height: 20rem; }
.blocker, .blocker-none { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 6px; border-bottom: 1px solid var(--hair); font-size: 14px; }
.blocker[data-urgency="critical"] { box-shadow: inset 4px 0 0 var(--crit-line); padding-left: 12px; }
.blocker-who { font-family: var(--font-mono); font-weight: 600; font-size: 13px; }
.blocker-act { flex: 1 1 100%; color: var(--muted); font-size: 13px; }

.meta-list { margin: 0; display: flex; flex-direction: column; }
.meta-list > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--hair); }
.meta-list dt { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }

.show-math { border-left: 4px solid var(--accent); padding: 0 0 0 14px; }
.show-math summary {
  display: flex; align-items: center; min-height: 44px; padding: 6px 0;
  color: #92400E; font-weight: 700;
}
.math-list { margin: 4px 0 8px; padding-left: 18px; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; font-variant-numeric: tabular-nums; }

.free-watermark {
  margin: 0; padding-top: 12px; border-top: 1px dashed var(--cell);
  text-align: center; font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.paper-disclaimer { margin: 0; font-size: 12.5px; color: var(--muted); }

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

.wb-footer { background: var(--wb); border-top: 2px solid var(--pro); padding: 2rem var(--inline) 2.5rem; }
.wb-footer__inner { display: flex; flex-direction: column; gap: 12px; }
.footer-disclaimer { margin: 0; font-size: 13px; color: var(--muted); max-width: 900px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 0; font-size: 14px; }
.footer-links a:active { color: var(--ink); }

/* ---------- mobile HUD, toast, dialogs ---------- */

.mobile-hud { display: none; }

.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  max-width: min(480px, calc(100vw - 24px));
  padding: 10px 12px 10px 16px;
  background: var(--ink); color: #fff;
  border-left: 5px solid var(--hair);
  box-shadow: 0 8px 24px rgba(17, 24, 39, .25);
}
.toast[hidden] { display: none; }
.toast-msg { margin: 0; flex: 1 1 220px; font-size: 14px; }
.toast .btn-tool { background: var(--paper); }
.toast .icon-btn { color: #fff; }

.wb-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 24px;
  border: 2px solid var(--hdr-ink); border-radius: 0;
  background: var(--paper); color: var(--ink);
}
.wb-dialog::backdrop { background: rgba(17, 24, 39, .55); }
.wb-dialog h2 { font-size: 20px; color: var(--hdr-ink); }
#preset-dialog { width: min(520px, calc(100vw - 24px)); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-lede { font-size: 14.5px; color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.free-vs-pro-table { font-size: 13.5px; margin: 8px 0 16px; }
.free-vs-pro-table tbody th { font-weight: 600; }
.checkout-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.price-note { margin: 0; font-size: 13px; color: var(--muted); }
.license-box { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--cell); display: flex; flex-direction: column; gap: 6px; }
.license-box > label { font-weight: 600; font-size: 14px; }
[data-license-status][data-state="error"] { color: #991B1B; font-weight: 600; }
[data-license-status][data-state="ok"] { color: var(--hdr-ink); font-weight: 600; }

/* ---------- responsive ---------- */

@media (max-width: 1199px) {
  .visit-grid, .visit-grid tbody, .visit-grid tr, .visit-grid td, .visit-grid th.cell-num { display: block; }
  .visit-grid { border: 0; }
  .visit-grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .visit-grid tbody.visit { border: 1px solid var(--cell); margin-bottom: 14px; }
  .visit-grid .visit-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 16px; padding: 10px 12px; }
  .visit-grid td, .visit-grid th.cell-num { border: 0; }
  .visit-grid td.cell { padding: 0; }
  .cell-num { grid-column: 1 / -1; text-align: left; padding: 2px 0; }
  .cell-num::before { content: "Visit row "; }
  .visit-grid .cell-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .visit-computed > td { padding: 10px 12px; }
  .computed-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
  .cx-action { grid-column: span 2; }
  .cx-owner { grid-column: span 2; }
  .btn-row-remove { justify-self: start; }
  .visit[data-state="critical"] .cell-num, .visit[data-state="high"] .cell-num, .visit[data-state="medium"] .cell-num { box-shadow: none; }
  .visit[data-state="critical"] { border-left: 5px solid var(--crit-line); }
  .visit[data-state="high"] { border-left: 5px solid var(--hold-line); }
  .visit[data-state="medium"] { border-left: 5px solid var(--warn-line); }
}

@media (min-width: 901px) and (max-width: 1199px) {
  .blocker-list { min-height: 25rem; }
}

@media (min-width: 901px) and (max-width: 1279px) {
  .dock-verdict { flex-basis: 220px; }
  .dock-scroll-cue span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dock-scroll-cue { min-width: 44px; padding: 6px 10px; }
}

@media (max-width: 900px) {
  :root { --gutter: 16px; }
  header.wb-header { position: static; }
  .wb-title { font-size: 18px; }
  .visit-grid .visit-inputs, .computed-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cx-action, .cx-owner { grid-column: 1 / -1; }
  .paper-pair, .signoff-grid { grid-template-columns: minmax(0, 1fr); }
  .paper { padding: 24px 20px; }
  .ribbon-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 48%)); gap: 6px 4%; width: 100%; }
  .ribbon-kpi { border-left: 0; border-top: 1px solid var(--hair); padding: 4px 0 0; }
  .reset-group { margin-left: 0; }
  .ws-section--review, #executive-deliverable { padding-top: 3rem; padding-bottom: 3rem; }
  .guidance-slot { min-height: 11rem; }

  body { padding-bottom: 76px; }
  .mobile-hud {
    display: flex; align-items: center; gap: 10px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: 64px; padding: 8px 12px;
    background: var(--wb); color: var(--hdr-ink);
    border-top: 2px solid var(--pro);
    white-space: nowrap;
  }
  .hud-short { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 14px; color: var(--ink); }
  .mobile-hud .btn-tool { margin-left: auto; }
  .toast { left: 12px; right: 12px; bottom: 76px; max-width: none; }
  .action-msg { position: static; }
}

@media (max-width: 680px) {
  fieldset [class*="grid"],
  form [class*="grid"],
  .field-pair,
  .prop-grid,
  .visit-grid .visit-inputs {
    grid-template-columns: minmax(0, 1fr);
  }
  :root { --gutter: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 24px; }
  .dock-verdict { flex-basis: 100%; }
  .dock-kpi:first-child { border-left: 0; padding-left: 0; }
  .ribbon-field { width: 100%; }
  .ribbon-field select { width: 100%; }
  .meta-list > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .guidance-slot { min-height: 15.5rem; }
  .verdict-banner { min-height: 12.5rem; align-content: flex-start; }
  .results .table-scroll { min-height: 21rem; }
  .paper-verdict { min-height: 11rem; }
  .meta-list { min-height: 17.5rem; }
  .kpi-grid { min-height: 20.5rem; }
  .blocker-list { min-height: 26.5rem; }
  .verdict-sentence { flex-basis: 100%; font-size: 16px; }
  .btn-ghost { white-space: normal; }
}

@media (max-width: 560px) {
  .hud-short { display: none; }
  .wb-header__row { flex-wrap: nowrap; align-items: flex-start; }
  .wb-brand { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- print: only the close workpaper ---------- */

@media print {
  @page { margin: 14mm 12mm; }
  body { background: #FFFFFF; color: #111827; padding: 0; font-size: 11pt; }
  header, nav, .skip-link, .engagement-ribbon, .trust-reassurance-bar, .ws-section, .wb-footer, .cockpit-horizon-bar,
  .mobile-hud, .toast, dialog, .deliv-head .role-badge, button, input, select, #live-status { display: none !important; }
  .workbook { border: 0; max-width: none; background: #FFFFFF; }
  .deliv-head { max-width: none; margin: 0 0 8px; }
  #executive-deliverable { display: block !important; padding: 0; background: #FFFFFF; }
  .paper { border: 0; border-top: 3px solid #111827; padding: 12px 0 0; max-width: none; color: #111827; background: #FFFFFF; gap: 14px; }
  .paper *, .deliv-head * { color: #111827 !important; background: #FFFFFF !important; box-shadow: none !important; }
  .status-chip, .urgency-tag { border-color: #111827 !important; }
  .ledger-table, .totals-table { page-break-inside: auto; }
  .ledger-table tr, .blocker, .meta-list > div, .totals-table tr { break-inside: avoid; page-break-inside: avoid; }
  .ledger-table thead { display: table-header-group; }
  .paper-pair { grid-template-columns: 1fr 1fr; }
  .blocker-list { min-height: 0; }
  .table-scroll { overflow: visible; }
  .show-math summary::marker { content: ""; }
  .free-watermark { display: block; font-size: 10pt; }
  body.is-pro .free-watermark { display: none; }
}

/* Review fix (2026-10-19): mobile dock + header compact */
@media (max-width: 900px) {
  header.wb-header { position: static !important; }
  .wb-header__row { flex-wrap: nowrap !important; align-items: center !important; justify-content: space-between !important; padding: 6px 12px !important; }
  .wb-subtitle { display: none !important; }
  .wb-title { font-size: 17px !important; }
  .wb-header .deliverable-dock { display: none !important; }
}

/* Review fix (2026-10-19): closed details fix + subtitle spacing */
.prop-collapsible:not([open]) > :not(summary) { display: none !important; }
.wb-subtitle { margin-top: 6px !important; }

/* Review fix (2026-10-19): horizon sill */
.cockpit-horizon-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 16px; border-top: 1px solid var(--hair); font-size: 12px; color: var(--muted); background: #F0FDF4; }
.btn-dock-jump { white-space: nowrap; }
@media (max-width: 900px) { .cockpit-horizon-bar { display: none; } }
