/* OSHA 300A workpaper. Institutional regulatory workpaper: inputs left, record right. */
:root {
  --canvas: #F7F8FA;
  --paper: #FFFFFF;
  --header: #1B365D;
  --header-ink: #EEF2F7;
  --ink: #1C1917;
  --muted: #78716C;
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-tint: #EEF2F7;
  --accent: #F59E0B;
  --attention-ink: #92400E;
  --attention-bg: #FFFBEB;
  --attention-line: #FCD34D;
  --error-ink: #B42318;
  --error-bg: #FEF3F2;
  --error-line: #F4A29B;
  --line: #E7E5E4;
  --copper: #374151;
  --copper-dark: #253141;
  --copper-tint: #F1F5F9;
  --copper-line: #CBD5E1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(68, 44, 22, 0.06), 0 6px 18px rgba(68, 44, 22, 0.06);
  --font-display: 'Source Sans 3', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --horizon-h: 28px;
  --hud-h: 60px;
}

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

html {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.18;
  margin: 0;
  color: var(--ink);
}

p { margin: 0; }

a { color: var(--primary-dark); text-underline-offset: 2px; }
a:hover { color: var(--header); }

button, input, select, textarea { font: inherit; color: inherit; }
button, select, summary, [role="button"], a, label.choice, .preset-chip { cursor: pointer; }

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

.num, .kpi-value, .summary-value, .mv-value, .hud-figures, .ledger-table td, .chip-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

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

[hidden] { display: none !important; }

details:not([open]) > :not(summary) { display: none; }

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

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary, .btn-header, .btn-pro, .btn-pro-outline, .link-btn, .btn-math {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-dark); color: #FFFFFF; }
.btn-primary:active { transform: translateY(1px); background: var(--header); }

.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: #A8A29E; background: #FAF7F4; }
.btn-secondary:active { transform: translateY(1px); background: #F5F0EB; }

.btn-compact { padding: 6px 12px; font-size: 13px; }

.link-btn {
  background: transparent;
  color: var(--primary-dark);
  padding: 6px 8px;
  text-decoration: underline;
}
.link-btn:active { color: var(--header); }

/* ---------- Header stack ---------- */

.app-header-stack { flex-shrink: 0; }

header.masthead {
  background-color: #1B365D;
  color: #EEF2F7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 4px 20px;
}

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

.est-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #FDE7C8;
  color: #6B3410;
  border: 2px solid #F7C98B;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.est-avatar[data-has-initials="true"] .est-avatar-icon { display: none; }
.est-avatar[data-has-initials="false"] .est-initials { display: none; }

.wordmark {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.12;
  color: #EEF2F7;
  white-space: nowrap;
  max-height: 52px;
  letter-spacing: 0.01em;
}

.masthead-subtitle {
  font-size: 13.5px;
  line-height: 1.35;
  color: #EEF2F7;
  max-width: 70ch;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.status-pill, .verdict-pill, .hud-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
[data-status="ready"].status-pill, [data-status="ready"] .verdict-pill, .hud-pill[data-status="ready"] {
  background: #CCFBF1; color: #1B365D; border-color: #5EEAD4;
}
[data-status="attention"].status-pill, [data-status="attention"] .verdict-pill, .hud-pill[data-status="attention"] {
  background: #FEF3C7; color: #78350F; border-color: var(--accent);
}
[data-status="incomplete"].status-pill, [data-status="incomplete"] .verdict-pill, .hud-pill[data-status="incomplete"] {
  background: #FEE4E2; color: #912018; border-color: #F97066;
}

.btn-header {
  background: rgba(240, 253, 250, 0.08);
  color: #EEF2F7;
  border-color: rgba(240, 253, 250, 0.45);
  min-height: 44px;
  max-height: 50px;
  padding: 6px 14px;
  font-size: 13px;
  white-space: nowrap;
}
.btn-header:hover { background: rgba(240, 253, 250, 0.16); }
.btn-header:active { background: rgba(240, 253, 250, 0.24); }

.unified-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 46px;
  padding: 6px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.toolbar-est {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 16px;
}
.toolbar-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.toolbar-est-name { overflow-wrap: anywhere; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--canvas);
  color: var(--ink);
  white-space: nowrap;
}
.chip-count { background: var(--primary-tint); border-color: #99F6E4; color: var(--header); }
.chip-deadline { color: var(--ink); }
.chip-deadline svg { color: #B45309; }

.live-cue {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary-dark);
}

.workflow-bar {
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
}
.workflow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 6px;
  min-height: 22px;
}
.workflow-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  padding: 1px 4px;
  border-radius: 6px;
  line-height: 1.6;
}
.workflow-link:hover { color: var(--primary-dark); text-decoration: underline; }
.workflow-link:active { color: var(--header); }
.workflow-link-out { color: var(--primary-dark); }
.workflow-arrow { color: #A8A29E; display: inline-flex; }

/* ---------- Role badges ---------- */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.role-badge-in { background: #1B365D; color: #EEF2F7; }
.role-badge-out { background: #FEF3C7; color: #78350F; border: 1px solid var(--accent); }

/* ---------- Workbench ---------- */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding: 2px 16px 0;
}

.workbench > * { min-width: 0; }

.inspector-pane {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
}

.inspector-head {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
.inspector-head-note { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.form-section:first-child { padding-top: 14px; }

.inspector-scroll-body {
  padding: 16px 20px 56px;
}

.dock-jump-shelf {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Scenario strip ---------- */

.scenario-strip { display: grid; gap: 8px; }
.scenario-caption-row { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.scenario-caption-row .reset-chip { margin-left: auto; flex: 0 0 auto; }
.scenario-caption { font-size: 12.5px; font-weight: 800; color: var(--muted); letter-spacing: 0.02em; }

.sample-badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 800;
  background: #FEF3C7;
  color: #78350F;
  border: 1px solid var(--accent);
}

.scenario-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip, .reset-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  text-align: left;
  flex: 1 1 180px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(68, 44, 22, 0.05);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.preset-chip:hover { border-color: #5EEAD4; background: #FBFFFE; }
.preset-chip:active { background: var(--primary-tint); transform: translateY(1px); }
.preset-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); box-shadow: inset 0 0 0 1px var(--primary); }

.preset-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  background: #FDE7C8;
  color: #6B3410;
}
.preset-avatar-b { background: #D9F2EC; color: #1B365D; }
.preset-avatar-c { background: #EDE4F7; color: #4A2D73; }

.preset-text { display: grid; min-width: 0; }
.preset-name { font-weight: 800; font-size: 13.5px; line-height: 1.25; }
.preset-note { font-size: 12px; color: var(--muted); line-height: 1.3; }

.reset-chip {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  border-style: dashed;
  border-color: #A8A29E;
  background: var(--canvas);
}
.reset-chip:hover { border-color: var(--primary); }
.reset-chip:active { background: #F5F0EB; transform: translateY(1px); }
.reset-main { font-weight: 800; font-size: 13.5px; white-space: nowrap; }
.reset-sub { font-size: 12px; color: var(--muted); }

.undo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 6px 6px 6px 14px;
  border-radius: 10px;
  background: var(--primary-tint);
  border: 1px solid #99F6E4;
}
.undo-text { font-weight: 700; font-size: 13.5px; color: var(--header); }

.trust-reassurance-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--primary-tint);
  color: var(--header);
  font-size: 13.5px;
}
.trust-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 12px;
}

/* ---------- Form ---------- */

.workpaper-form { display: grid; gap: 0; }

.form-section {
  border: 0;
  margin: 0;
  padding: 24px 0 8px;
  min-width: 0;
  display: grid;
  gap: 14px;
}
.form-section + .form-section { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 32px; }

.section-legend { padding: 0; margin-bottom: 4px; float: none; }
.section-title { font-size: 19px; color: var(--header); line-height: 1.2; }

.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.field-pair > * { min-width: 0; }

.field { display: grid; gap: 4px; align-content: start; min-width: 0; }

.field label, .field-label, .field-legend {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.35;
}

.req, .opt {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 4px;
}
.req { color: var(--primary-dark); }
.opt { color: var(--muted); }

input[type="text"], select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #D6D3D1;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px; /* >=16px stops iOS Safari zooming the viewport on focus */
  line-height: 1.35;
}
textarea { resize: vertical; }
.field-wide { grid-column: 1 / -1; }
.note-input { resize: none; overflow-wrap: anywhere; overflow-x: hidden; }
select { appearance: auto; }
input[type="text"]:hover, select:hover, textarea:hover { border-color: #A8A29E; }
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid rgba(15, 118, 110, 0.25); outline-offset: 0; }
input::placeholder, textarea::placeholder { color: #8A8580; }

.field-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.field-msg { font-size: 12.5px; line-height: 1.4; font-weight: 700; }
.field-msg:empty { display: none; }
.msg-needed { color: var(--muted); font-weight: 600; }
.msg-error, .validation-cue { color: var(--error-ink); }
.validation-cue::before { content: "! "; font-weight: 800; }
.has-error input[type="text"], input[aria-invalid="true"] {
  border-color: var(--error-ink);
  background: var(--error-bg);
}

.choice-group { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
.choice-group .field-legend { padding: 0; margin-bottom: 6px; }
.choice-list { display: grid; gap: 6px; }
.choice-list-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.choice:hover { border-color: #A8A29E; }
.choice:active { background: var(--canvas); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.choice input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--primary); flex: 0 0 auto; }
.choice span { display: grid; min-width: 0; }
.choice strong { font-size: 14px; line-height: 1.3; }
.choice small { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.choice-compact { align-items: center; }
.choice-compact input { margin-top: 0; }

.prop-collapsible {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
}
.collapsible-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 0;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-dark);
}
.collapsible-summary:active { color: var(--header); }
.prop-collapsible[open] .prop-grid { padding-bottom: 14px; }

.chip-field { display: grid; gap: 6px; }
.freq-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.freq-chip {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-weight: 700;
  font-size: 13.5px;
}
.freq-chip:hover { border-color: #A8A29E; }
.freq-chip:active { transform: translateY(1px); }
.freq-chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }

/* Payroll checklist rows */
.payroll-list { display: grid; gap: 10px; }

.payroll-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px 14px;
  background: var(--paper);
  display: grid;
  gap: 10px;
  min-width: 0;
}
.payroll-row[data-status="blocked"] { border-color: var(--error-line); }
.payroll-row[data-reviewed="true"] { background: #FBFEFD; }

.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.row-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.row-state {
  font-size: 11.5px;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--canvas);
  color: var(--muted);
  border: 1px solid var(--line);
}
[data-status="counted"] > .row-head .row-state { background: var(--primary-tint); color: var(--header); border-color: #99F6E4; }
[data-status="blocked"] > .row-head .row-state { background: var(--error-bg); color: var(--error-ink); border-color: var(--error-line); }

.review-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px 6px 4px;
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  border-radius: 999px;
}
.review-toggle:hover { color: var(--ink); }
.review-toggle:active .review-circle { transform: scale(0.94); }
.review-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #A8A29E;
  display: inline-grid;
  place-items: center;
  color: transparent;
  background: var(--paper);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.review-toggle[aria-pressed="true"] { color: var(--primary-dark); }
.review-toggle[aria-pressed="true"] .review-circle { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }

.row-remove {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.row-remove:hover { color: var(--error-ink); border-color: var(--error-line); }
.row-remove:active { background: var(--error-bg); }

.row-grid .field label { font-size: 12.5px; }

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.action-msg { font-size: 13px; font-weight: 700; color: var(--primary-dark); }

.flash-recalc { animation: flash-recalc 0.9s ease-out; }
@keyframes flash-recalc {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.65); background-color: #FFFBEB; }
  100% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}

/* ---------- Deliverable zone ---------- */

.deliverable-zone { min-height: 0; padding: 0 0 56px; }

.deliverable-dock {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 16px;
}

.dock-results { display: grid; gap: 4px; }

.verdict-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }

.verdict {
  flex: 1 1 280px;
  display: grid;
  gap: 1px;
  min-height: 44px;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
}
.verdict:hover { border-color: var(--line); background: var(--canvas); }
.verdict:active { background: #F5F0EB; }
.verdict-top { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.verdict .verdict-pill { padding: 0 10px; font-size: 12px; line-height: 1.5; }
.verdict-headline { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; line-height: 1.2; }

.verdict-detail, .awaiting-state {
  display: block;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink);
}
.verdict-jump { color: var(--primary-dark); font-weight: 800; text-decoration: underline; margin-left: 4px; white-space: nowrap; }
.awaiting-state { font-weight: 700; color: var(--muted); }

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

.kpi-row { display: flex; gap: 8px; flex: 1 1 210px; min-width: 0; }
.kpi {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  display: grid;
  align-content: center;
  text-align: left;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--canvas);
}
.kpi:hover { border-color: #5EEAD4; }
.kpi:active { background: var(--primary-tint); }
.kpi-label { font-size: 10.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.2; white-space: nowrap; }
.kpi-value { font-size: 16px; font-weight: 500; line-height: 1.15; }

.dock-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dock-scroll-cue { padding-left: 12px; padding-right: 12px; font-size: 13px; }
.dock-msg {
  position: absolute;
  right: 16px;
  top: calc(100% + 6px);
  z-index: 31;
  max-width: calc(100% - 32px);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--header);
  color: #EEF2F7;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.dock-msg:empty { display: none; }

/* The printable sheet */
.doc-sheet {
  margin-top: 2px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.doc { padding: 20px 24px 24px; display: grid; gap: 18px; }

.doc-head { display: grid; gap: 4px; }
.doc-kicker { font-size: 11.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.doc-title { font-size: 22px; color: var(--header); }
.doc-est { font-weight: 700; font-size: 15px; justify-self: start; border-radius: 6px; padding: 2px 4px; }

.incomplete-stamp {
  justify-self: start;
  margin-top: 4px;
  padding: 3px 10px;
  border: 2px solid var(--error-ink);
  color: var(--error-ink);
  border-radius: 6px;
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.08em;
}

.sample-warning {
  justify-self: start;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--attention-ink);
  background: var(--attention-bg);
  border: 1px solid var(--attention-line);
  border-radius: 8px;
  padding: 2px 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.summary-card {
  min-width: 0;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.summary-card + .summary-card { border-left: 1px solid var(--line); }
.summary-label { font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.3; }
.summary-value { font-size: 24px; font-weight: 500; line-height: 1.2; overflow-wrap: anywhere; }
.summary-word { font-family: var(--font-display); font-weight: 600; font-size: 20px; }

[data-determination="required"] { color: var(--header); }
[data-determination="not_indicated"] { color: var(--ink); }
[data-determination="review_required"] { color: var(--attention-ink); }
[data-determination="incomplete"] { color: var(--error-ink); }

.doc-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
}
.meta-item { min-width: 0; border-radius: 8px; padding: 2px 4px; }
.meta-item dt { font-size: 11px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.meta-item dd { margin: 0; font-size: 13px; line-height: 1.4; }

[data-edit-target] { cursor: pointer; }
.summary-card:hover, .meta-item:hover, .det:hover, .kv-row:hover, .note-list li[data-edit-target]:hover,
.plain-list li[data-edit-target]:hover, .doc-est:hover, .conflict-item:hover, .ledger-table tbody tr:hover {
  background: #FAF7F4;
}
.summary-card:active, .meta-item:active, .det:active, .kv-row:active, .ledger-table tbody tr:active { background: #F5F0EB; }

.math-row { display: grid; gap: 10px; }
.btn-math {
  justify-self: start;
  background: #FFFBEB;
  color: #78350F;
  border-color: var(--accent);
}
.btn-math:hover { background: #FEF3C7; }
.btn-math:active { background: #FDE68A; transform: translateY(1px); }
.math-panel {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 14px;
}
.math-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }

.check-slot { min-height: 46px; display: grid; align-content: start; }
.check-clear {
  font-size: 13px;
  color: var(--header);
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--primary-tint);
}
.conflict-banner {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  border-left-width: 5px;
  background: var(--attention-bg);
}
.conflict-item { display: grid; gap: 2px; border-radius: 6px; padding: 2px 4px; }
.conflict-title { font-weight: 800; color: var(--attention-ink); font-size: 14px; }
.conflict-rows { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.conflict-msg { font-size: 13px; }

.doc-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
}
.doc-pair > * { min-width: 0; }

.doc-section { display: grid; gap: 8px; align-content: start; min-width: 0; }
.doc-section h3 { font-size: 16px; color: var(--header); }
.doc-section:focus { outline: none; }

.det { display: grid; gap: 4px; padding: 8px 6px; border-radius: 8px; border-bottom: 1px solid var(--line); min-height: var(--det-min, 150px); align-content: start; }
.det-form { font-weight: 700; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.det-value { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.det-basis { font-size: 13px; color: var(--ink); line-height: 1.45; }

.kv { margin: 0; display: grid; }
.kv-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 8px;
  padding: 6px 6px;
  border-bottom: 1px solid var(--line);
  border-radius: 4px;
  min-width: 0;
}
.kv-row dt { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.kv-row dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.section-note { font-size: 12.5px; color: var(--muted); font-weight: 700; }

.table-wrap {
  height: 276px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ledger-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ledger-table th {
  position: static;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #FAF8F6;
}
.ledger-table td { padding: 6px 10px; border-bottom: 1px solid #F0EEEC; font-size: 12.5px; }
.ledger-table .num-col { text-align: right; }
.ledger-table td.is-invalid { color: var(--error-ink); font-weight: 600; text-decoration: underline wavy var(--error-ink); }
.ledger-table tr[data-status="blocked"] td:last-child { color: var(--error-ink); font-weight: 700; }
.ledger-table tr[data-status="empty"] td { color: var(--muted); }

.note-list, .plain-list { margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.note-list { list-style: none; min-height: var(--notes-min, 136px); align-content: start; }
.note-list li { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); line-height: 1.45; }
.note-list li[data-kind="blocker"] { border-color: var(--error-line); background: var(--error-bg); }
.note-list li[data-kind="conflict"] { border-color: var(--accent); background: var(--attention-bg); }
.note-kind { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
li[data-kind="blocker"] .note-kind { color: var(--error-ink); }
li[data-kind="conflict"] .note-kind { color: var(--attention-ink); }
li[data-kind="note"] .note-kind { color: var(--muted); }
.plain-list { padding-left: 20px; line-height: 1.45; }
.plain-list li { border-radius: 6px; padding: 1px 4px; }
#next-list { min-height: var(--next-min, 156px); align-content: start; }
.assumption-list { min-height: var(--assume-min, 106px); align-content: start; }
#audit-list { min-height: var(--audit-min, 244px); align-content: start; }

.doc-foot { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; }
.doc-disclaimer { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.free-watermark {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------- Pro card (after the packet, outside the document) ---------- */

.pro-card {
  margin-top: 72px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--copper-line);
  background: var(--copper-tint);
  display: grid;
  gap: 10px;
}
.pro-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
.pro-card-title { font-size: 18px; color: var(--copper-dark); }
.pro-price { font-weight: 800; color: var(--copper-dark); font-size: 14px; }
.pro-card-copy { font-size: 13.5px; }
.lock-note { font-size: 12.5px; color: #6B5A4E; }
.pro-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pro-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--copper-line);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  font-weight: 700;
  font-size: 13.5px;
  min-width: 0;
}
.pro-action svg { color: var(--copper); }
.pro-action:hover { border-color: var(--copper); }
.pro-action:active { background: #F6E7DA; transform: translateY(1px); }
.pro-action-label { flex: 1 1 auto; min-width: 0; }
.lock-tag {
  font-size: 11px;
  font-weight: 800;
  color: var(--copper-dark);
  background: var(--copper-tint);
  border: 1px solid var(--copper-line);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
html[data-pro="true"] .lock-tag { display: none; }
.pro-msg { font-size: 13px; font-weight: 700; color: var(--copper-dark); }
.pro-msg:empty { display: none; }
.pro-saved { display: grid; gap: 6px; }
.pro-saved-title { font-size: 14px; color: var(--copper-dark); }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.saved-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 8px; border-radius: 8px; background: var(--paper); border: 1px solid var(--copper-line); }
.saved-text { flex: 1 1 200px; font-size: 13px; min-width: 0; }
.saved-empty { font-size: 13px; color: #6B5A4E; }

.btn-pro, .btn-pro-outline {
  background: var(--copper);
  color: #FFFFFF;
}
.btn-pro:hover { background: var(--copper-dark); }
.btn-pro:active { transform: translateY(1px); background: #5E2F12; }
.btn-pro-outline { background: transparent; color: var(--copper-dark); border-color: var(--copper); justify-self: start; }
.btn-pro-outline:hover { background: #F6E7DA; }
.btn-pro-outline:active { background: #EFD9C6; }

.trust-footer {
  margin: 24px 4px 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Dialogs ---------- */

.app-dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  max-width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(28, 25, 23, 0.25);
}
.app-dialog::backdrop { background: rgba(28, 25, 23, 0.45); }
.app-dialog h2 { font-size: 20px; margin-bottom: 8px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; color: var(--copper-dark); }

.pro-dialog { display: none; }
.pro-dialog[open] { display: grid; gap: 14px; }
.pro-dialog-lede { font-size: 14px; }
.free-vs-pro-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.free-vs-pro-table th, .free-vs-pro-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.free-vs-pro-table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.free-vs-pro-table thead th:last-child, .free-vs-pro-table td:last-child { background: var(--copper-tint); color: var(--copper-dark); }
.free-vs-pro-table tbody th { font-weight: 700; }
.pro-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pro-dialog .btn-primary[data-checkout] { background: var(--copper); }
.pro-dialog .btn-primary[data-checkout]:hover { background: var(--copper-dark); }
.pro-dialog .btn-primary[data-checkout]:active { background: #5E2F12; }
.pro-fine { font-size: 12.5px; color: var(--muted); }
.pro-active-note { font-weight: 700; color: var(--copper-dark); }
.restore-block { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.restore-block > .btn-secondary { justify-self: start; }
.restore-panel { display: grid; gap: 6px; }
.restore-panel label { font-weight: 700; font-size: 13.5px; }
.restore-row { display: flex; flex-wrap: wrap; gap: 8px; }
.restore-row input { flex: 1 1 220px; min-width: 180px; font-family: var(--font-mono); }
.license-feedback { font-size: 13px; font-weight: 700; }
.license-feedback:empty { display: none; }
.license-feedback.is-error { color: var(--error-ink); }
.license-feedback.is-ok { color: var(--header); }

/* ---------- Horizon bar, mobile verdict, HUD ---------- */

.cockpit-horizon-bar {
  flex-shrink: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  font-size: 12px;
  color: #57534E;
  background: var(--paper);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}
.horizon-item { display: inline-flex; align-items: center; gap: 6px; }
.horizon-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--error-ink); }
.horizon-dot[data-status="ready"] { background: var(--primary); }
.horizon-dot[data-status="attention"] { background: var(--accent); }

.mobile-verdict, .mobile-hud { display: none; }

/* ---------- Desktop cockpit ---------- */

@media (min-width: 901px) {
  html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  body { display: flex; flex-direction: column; }
  .workbench {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }
  .inspector-pane { height: 100%; }
  .inspector-scroll-body, .deliverable-zone {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
  }
  .inspector-scroll-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .deliverable-zone { height: 100%; padding-bottom: 56px; }
  .scroll-fade {
    -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-fade.at-bottom { -webkit-mask-image: none; mask-image: none; }
  .deliverable-dock { position: sticky; top: 0; z-index: 30; }
  input[type="text"], select { min-width: 180px; }
}

@media (min-width: 901px) and (max-width: 1360px) {
  .doc { --det-min: 152px; --audit-min: 300px; }
  .verdict { min-height: 66px; align-content: start; }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .doc { --det-min: 172px; --notes-min: 176px; --next-min: 196px; --assume-min: 126px; --audit-min: 376px; }
  .summary-grid { min-height: 128px; }
  .masthead-subtitle { font-size: 12.5px; }
  .live-cue { margin-left: 0; }
}

/* ---------- Mobile and tablet ---------- */

@media (max-width: 900px) {
  html, body { height: auto; overflow: visible; }
  body { padding-bottom: calc(var(--hud-h) + 16px); }
  header.masthead { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 8px 16px; gap: 4px 8px; }
  .brand { display: contents; }
  .est-avatar { grid-column: 1; grid-row: 1; }
  .wordmark { grid-column: 1; grid-row: 1; padding-left: 48px; align-self: center; }
  .masthead-actions { grid-column: 2; grid-row: 1; gap: 6px; }
  .masthead-subtitle { grid-column: 1 / -1; grid-row: 2; font-size: 13px; }
  .unified-toolbar { padding: 6px 16px; }
  .toolbar-est { display: none; }
  .live-cue { margin-left: auto; }
  .workflow-bar { display: none; }
  .cockpit-horizon-bar { display: none; }

  .mobile-verdict { display: block; padding: 8px 12px 0; }
  .mobile-verdict-btn {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 44px;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow);
    text-align: left;
  }
  .mobile-verdict-btn:active { background: var(--canvas); }
  .mv-item { display: grid; flex: 1 1 28%; max-width: 48%; min-width: 0; }
  .mv-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
  .mv-value { font-size: 15px; font-weight: 500; }

  .workbench { display: block; padding: 8px 12px 0; }
  .inspector-pane { height: auto; }
  .inspector-scroll-body { padding: 14px 14px 20px; }
  .dock-jump-shelf { justify-content: stretch; padding: 12px 14px; }
  .dock-jump-shelf .btn-dock-jump { width: 100%; }
  .deliverable-zone { margin-top: 16px; padding-bottom: 24px; }
  .deliverable-dock { position: relative; padding: 12px; }
  .verdict { min-height: 88px; align-content: start; }
  .kpi { padding: 8px 12px; }
  .undo-bar, .trust-reassurance-bar { padding: 8px 12px; }
  .doc { padding: 16px 14px 20px; }

  .trust-reassurance-bar { order: 5; }
  .inspector-scroll-body { display: flex; flex-direction: column; }
  .workpaper-form { order: 3; }
  .scenario-strip { order: 1; }

  .scenario-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-caption-row, .scenario-row { display: contents; }
  .scenario-caption { grid-column: 1; align-self: center; }
  .sample-badge { grid-column: 2; justify-self: end; align-self: center; }
  .scenario-caption-row .reset-chip { margin-left: 0; order: 2; }
  .scenario-row > .preset-chip:first-child { grid-column-start: 1; }
  .undo-bar { grid-column: 1 / -1; order: 3; }
  .preset-chip, .reset-chip { padding: 6px 10px; gap: 8px; }
  .preset-avatar { width: 30px; height: 30px; font-size: 12px; }
  .reset-main { white-space: normal; }

  .mobile-hud {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: var(--hud-h);
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--paper);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(68, 44, 22, 0.08);
    white-space: nowrap;
    overflow: hidden;
  }
  .hud-figures { flex: 1 1 auto; min-width: 0; font-size: 13px; overflow: hidden; }
  .hud-btn { flex: 0 0 auto; padding: 6px 14px; }
  .doc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pro-card { margin-top: 48px; }
}

@media (max-width: 680px) {
  fieldset [class*="grid"], form [class*="grid"], .field-pair, .prop-grid, .choice-list-row, .doc-pair, .pro-actions {
    grid-template-columns: minmax(0, 1fr);
  }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .doc-meta { grid-template-columns: minmax(0, 1fr); }
  .chip-deadline { display: none; }
  .inspector-head-note { display: none; }
  .dock-actions { width: 100%; }
  .dock-actions > .btn-primary, .dock-actions > .btn-secondary { flex: 1 1 40%; }
  .doc { --det-min: 128px; --notes-min: 136px; --next-min: 160px; --assume-min: 184px; --audit-min: 244px; }
}

@media (max-width: 420px) {
  .masthead-actions .btn-header { padding: 6px 8px; font-size: 12px; }
  .masthead-actions .status-pill { padding: 3px 8px; font-size: 12px; }
  .wordmark { font-size: 21px; }
}

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

/* ---------- Print: only the record ---------- */

@media print {
  @page { margin: 14mm; }
  html, body { height: auto !important; overflow: visible !important; background: #FFFFFF !important; color: #111827 !important; }
  body { display: block !important; padding: 0 !important; }
  .app-header-stack, header, nav, form, .inspector-pane, .deliverable-dock, .mobile-verdict, .mobile-hud,
  .cockpit-horizon-bar, dialog, button, .pro-card, .trust-footer, .skip-link, .dock-msg, .undo-bar,
  .math-row, .check-clear { display: none !important; }
  .workbench, .deliverable-zone { display: block !important; padding: 0 !important; margin: 0 !important; height: auto !important; overflow: visible !important; -webkit-mask-image: none !important; mask-image: none !important; }
  #executive-deliverable { display: block !important; border: 0 !important; box-shadow: none !important; margin: 0 !important; }
  #executive-deliverable * { color: #111827 !important; background: #FFFFFF !important; box-shadow: none !important; }
  .doc { padding: 0 !important; }
  .doc-head { display: grid !important; }
  .table-wrap { height: auto !important; overflow: visible !important; }
  .det, .note-list, #next-list, .assumption-list, #audit-list, .check-slot, .summary-grid { min-height: 0 !important; }
  .incomplete-stamp { border-color: #111827 !important; font-size: 16px !important; }
  .free-watermark { display: block !important; margin-top: 8px; }
  .doc-pair { grid-template-columns: 1fr 1fr; }
  a { text-decoration: none; }
}
