/* ============================================================================
 * Fire Alarm Subcontractor Profit Split Calculator — styles
 * 3D Technology Services, Inc.
 * D4 brand kit: TEAL primary, GOLD highlights, WHITE background, BLACK
 * Times New Roman identity/headings. Red/yellow/green are SAFETY semantics
 * (35% protection status) and are deliberately NOT part of the brand palette
 * — they must never be re-tinted. Numeric tables keep a sans tabular font.
 * ==========================================================================*/
:root {
  --brand: #0f766e;            /* 3DTSI teal */
  --brand-dark: #0b5d57;
  --brand-bg: #e7f4f2;         /* light teal tint */
  --gold: #b8860b;             /* gold highlight (borders/accents) */
  --gold-soft: #d4af37;
  --gold-ink: #8a6508;         /* darker gold for TEXT on white (contrast) */
  --gold-bg: #faf4e3;
  --ink: #111111;              /* brand black */
  --ink-soft: #4a5568;
  --paper: #ffffff;            /* white background (D4) */
  --card: #ffffff;
  --line: #dbe1ea;
  --serif: "Times New Roman", Times, Georgia, serif;   /* identity/headings */
  /* status colors — SAFETY semantics, unchanged by the brand kit */
  --green: #1e7e34;
  --green-bg: #e6f4ea;
  --yellow: #b7791f;
  --yellow-bg: #fdf3d7;
  --red: #c62828;
  --red-bg: #fdecea;
  /* text-safe status inks — the SAME safety semantics, darkened only enough
     to meet WCAG AA (>= 4.5:1) both on the tinted pill backgrounds and on
     white (the old --yellow text on --yellow-bg measured 3.29:1). The base
     --green/--yellow/--red stay as GRAPHIC fills/borders (>= 3:1 on white).
     scripts/check-a11y.js verifies these ratios on every run. */
  --green-text: #15662a;
  --yellow-text: #7a5210;
  --red-text: #b32222;
  --info: #2b6cb0;
  --info-bg: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

/* ---------- Keyboard focus visibility (WCAG 2.4.7 / 1.4.11) -------------- */
/* One strong, consistent ring for every keyboard-focused control. Solid
   teal (7.7:1 on white) — translucent rings are invisible to low-vision
   users. :focus-visible keeps plain mouse clicks ring-free. */
:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 2px; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* ---------- Header (white letterhead: black TNR, teal logo, gold rule) --- */
header.app-header {
  background: var(--paper);
  color: var(--ink);
  padding: 14px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--gold);
}
.app-title { display: flex; align-items: center; gap: 12px; }
.app-title .logo {
  background: var(--brand);
  color: #fff;
  border: 2px solid var(--gold-soft);
  border-radius: 8px;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.app-title h1 { font-family: var(--serif); color: var(--ink); font-size: 20px; margin: 0; font-weight: 700; }
.app-title .sub { font-size: 12.5px; color: var(--ink-soft); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Sticky live summary bar ------------------------------------- */
.summary-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 26px;
  padding: 8px 22px;
  align-items: center;
}
.summary-bar .metric { min-width: 130px; }
.summary-bar .metric .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.summary-bar .metric .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-bar .metric .v.neg { color: var(--red); }

/* ---------- Status pill -------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 5px 14px;
  font-weight: 700; font-size: 13px;
}
.pill::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
/* pill text uses the AA text inks; the dot inherits them via currentColor */
.pill.green  { background: var(--green-bg);  color: var(--green-text); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.pill.red    { background: var(--red-bg);    color: var(--red-text); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(198, 40, 40, .15); } }

/* ---------- Tabs --------------------------------------------------------- */
nav.tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 10px 22px 0;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
nav.tabs button {
  appearance: none; border: 1px solid transparent; border-bottom: none;
  background: transparent; color: var(--ink-soft);
  padding: 9px 14px; font: inherit; font-weight: 600; font-size: 13.5px;
  border-radius: 8px 8px 0 0; cursor: pointer;
}
nav.tabs button:hover { color: var(--ink); background: var(--brand-bg); }
nav.tabs button.active {
  background: var(--paper); color: var(--brand);
  border-color: var(--line); border-bottom: 2px solid var(--paper);
  margin-bottom: -1px;
  box-shadow: inset 0 3px 0 var(--gold-soft);   /* gold accent on the active tab */
}
nav.tabs button .badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 10.5px; padding: 1px 6px; margin-left: 5px; vertical-align: 1px;
}
/* live subtotal chip on each money tab, e.g. "3. Material Costs  $20,192" */
nav.tabs button .tab-chip {
  background: var(--brand-bg); color: var(--brand);
  border-radius: 999px; font-size: 11px; font-weight: 700;
  padding: 1px 8px; margin-left: 5px; vertical-align: 1px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
nav.tabs button.active .tab-chip { background: var(--brand); color: #fff; }

/* ---------- Layout / cards ---------------------------------------------- */
main { padding: 18px 22px 80px; max-width: 1280px; margin: 0 auto; }
section.tab-panel { display: none; }
section.tab-panel.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; font-family: var(--serif); color: var(--ink); font-weight: 700; }
.card h3 { margin: 14px 0 6px; font-size: 13.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.card .hint { color: var(--ink-soft); font-size: 13px; margin: 0 0 12px; }

.grid { display: grid; gap: 12px 18px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 3px; }
.field input[type="text"], .field input[type="number"], .field input[type="date"],
.field select, .field textarea {
  width: 100%; padding: 8px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand); border-color: var(--brand);
}
.field input:disabled, .field select:disabled { background: #eef1f5; color: #7a8494; cursor: not-allowed; }
.field .note { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.field.currency { position: relative; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- Collapsible rarely-used field groups ------------------------- */
details.fieldgroup {
  border: 1px solid var(--line); border-radius: 8px;
  background: #fafbfd; margin: 14px 0 4px;
}
details.fieldgroup > summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: 9px 12px; display: flex; align-items: baseline; gap: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em;
}
details.fieldgroup > summary::-webkit-details-marker { display: none; }
details.fieldgroup > summary::before {
  content: "\25B8"; color: var(--gold-ink); font-size: 12px; flex: 0 0 auto;
}
details.fieldgroup[open] > summary::before { content: "\25BE"; }
details.fieldgroup > summary:hover { color: var(--ink); background: var(--brand-bg); border-radius: 8px; }
details.fieldgroup > summary:focus-visible {
  outline: 2px solid var(--brand-dark); outline-offset: -2px; border-radius: 8px;
}
details.fieldgroup .fg-hint {
  text-transform: none; letter-spacing: 0; font-weight: 500;
  font-size: 12px; color: var(--ink-soft);
}
details.fieldgroup .fg-body { padding: 4px 12px 14px; }
details.fieldgroup .fg-body .hint { margin-top: 4px; }

/* computed / read-only figures */
.calc-out {
  background: #f0f3f7; border: 1px dashed var(--line); border-radius: 7px;
  padding: 8px 10px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.calc-out.neg { color: var(--red); }

/* ---------- Explainer / assumption boxes -------------------------------- */
.explainer {
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 6px; padding: 10px 14px; font-size: 13px; margin: 10px 0;
}
.explainer b { color: var(--info); }
.assumption {
  background: var(--yellow-bg); border-left: 4px solid var(--yellow);
  border-radius: 6px; padding: 8px 12px; font-size: 12.5px; margin: 8px 0;
}

/* ---------- Warnings ----------------------------------------------------- */
.warning-list { list-style: none; margin: 0; padding: 0; }
.warning-list li {
  border-radius: 7px; padding: 9px 12px 9px 38px; margin-bottom: 7px;
  font-size: 13.5px; position: relative;
}
.warning-list li::before { position: absolute; left: 12px; top: 8px; font-weight: 800; }
.warning-list li.red    { background: var(--red-bg); color: #7a1f1f; border: 1px solid #f2c4c0; }
.warning-list li.red::before { content: "\26D4"; }
.warning-list li.yellow { background: var(--yellow-bg); color: #6b4a12; border: 1px solid #ecd9a8; }
.warning-list li.yellow::before { content: "\26A0"; }
.warning-list li.info   { background: var(--info-bg); color: #234e78; border: 1px solid #c4dbf2; }
.warning-list li.info::before { content: "\2139"; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 8px 14px; cursor: pointer; box-shadow: var(--shadow);
}
.btn:hover { border-color: #b6c0cf; background: #fafbfd; }
.btn.primary { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--brand-bg); border-color: var(--brand); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* ---------- Dashboard tiles ---------------------------------------------- */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.tile .v { font-size: 26px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.tile.green  { border-top: 4px solid var(--green); }
.tile.yellow { border-top: 4px solid var(--yellow); }
.tile.red    { border-top: 4px solid var(--red); }
.tile.hero   { grid-column: span 2; }
.tile .v.neg { color: var(--red); }

/* ---------- Dashboard money visualization (pure SVG) --------------------- */
.viz-empty { color: var(--ink-soft); font-size: 13px; font-style: italic; margin: 8px 0; }
svg.waterfall, svg.payout-gauge { width: 100%; height: auto; display: block; }
svg.waterfall text, svg.payout-gauge text {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
svg.waterfall .wf-axis { stroke: var(--ink-soft); stroke-width: 1; }
svg.waterfall .wf-link { stroke: #b6c0cf; stroke-width: 1; stroke-dasharray: 3 3; }
svg.waterfall rect.wf-start   { fill: var(--brand); }
svg.waterfall rect.wf-expense { fill: #64748b; }               /* neutral slate — costs */
svg.waterfall rect.wf-profit  { fill: var(--gold-soft); stroke: var(--gold); stroke-width: 1; }
/* the pool bar carries the status color — SAFETY semantics, never re-tinted */
svg.waterfall rect.wf-pool.green  { fill: var(--green); }
svg.waterfall rect.wf-pool.yellow { fill: var(--yellow); }
svg.waterfall rect.wf-pool.red    { fill: var(--red); }
svg.waterfall text.wf-amount { font-size: 12px; font-weight: 800; fill: var(--ink); }
svg.waterfall text.wf-amount.neg { fill: var(--red); }
svg.waterfall text.wf-name { font-size: 11px; font-weight: 600; fill: var(--ink-soft); }

.gauge-legend {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; margin: 2px 0 8px;
}
.gauge-legend .gauge-flag {
  display: inline-block; border-radius: 999px; padding: 2px 10px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; white-space: nowrap;
}
.gauge-legend .gauge-flag.within { background: var(--green-bg); color: var(--green-text); }
.gauge-legend .gauge-flag.over   { background: var(--red-bg);   color: var(--red-text); }
svg.payout-gauge rect.g-safe   { fill: var(--green-bg); }
svg.payout-gauge rect.g-danger { fill: var(--red-bg); }
svg.payout-gauge rect.g-track  { fill: none; stroke: var(--line); stroke-width: 1; }
svg.payout-gauge rect.g-fill      { fill: var(--brand); }
svg.payout-gauge rect.g-fill-over { fill: var(--red); }
svg.payout-gauge line.g-base { stroke: var(--gold); stroke-width: 3; }
svg.payout-gauge line.g-max  { stroke: var(--ink); stroke-width: 2; }
svg.payout-gauge text.g-max-label { font-size: 11.5px; font-weight: 700; fill: var(--ink); }
svg.payout-gauge line.g-needle.within { stroke: var(--green); stroke-width: 2.5; }
svg.payout-gauge line.g-needle.over   { stroke: var(--red);   stroke-width: 2.5; }
svg.payout-gauge text.g-req-label { font-size: 11.5px; font-weight: 800; }
svg.payout-gauge text.g-req-label.within { fill: var(--green); }
svg.payout-gauge text.g-req-label.over   { fill: var(--red); }

/* ---------- Tables (audit, packages, reports) ---------------------------- */
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  /* numeric tables keep a readable sans font even inside serif reports (D4) */
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); background: #f7f9fc; }
table.data td.money, table.data th.money { text-align: right; white-space: nowrap; }
table.data td.formula { color: var(--ink-soft); font-size: 12.5px; }
table.data tr.total td { font-weight: 800; border-top: 2px solid var(--ink); }
table.data td.neg { color: var(--red); font-weight: 700; }

/* ---------- Project library (Saved Projects panel) ----------------------- */
.lib-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 12px; }
.lib-toolbar-spacer { flex: 1 1 auto; }
#library-list { overflow-x: auto; }   /* the table scrolls on narrow screens */
.lib-table td { vertical-align: middle; }
.lib-table .lib-name { font-weight: 600; }
.lib-table .lib-date { white-space: nowrap; color: var(--ink-soft); font-size: 12.5px; }
.lib-table .lib-actions, .lib-table .lib-actions-h { text-align: right; white-space: nowrap; }
.lib-table .pill { font-size: 11px; padding: 3px 9px; }
/* sortable column headers — plain-looking buttons that keep th typography */
button.lib-sort {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft);
}
button.lib-sort:hover, button.lib-sort:focus { color: var(--brand); text-decoration: underline; }
button.lib-sort.active { color: var(--ink); font-weight: 800; }
tr.lib-invalid td { background: var(--red-bg); color: var(--ink-soft); }

/* ---------- Scope split rows ---------------------------------------------*/
.scope-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 4px; border-bottom: 1px solid var(--line);
}
.scope-row .name { flex: 1 1 260px; font-weight: 600; }
.scope-row .cost { min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  appearance: none; border: none; background: #fff; font: inherit; font-size: 12.5px;
  font-weight: 600; padding: 6px 14px; cursor: pointer; color: var(--ink-soft);
}
.seg button.on-tdsi { background: #23303f; color: #fff; }
.seg button.on-sub  { background: var(--brand); color: #fff; }

/* ---------- Scenario cards ------------------------------------------------*/
.scenario-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.scenario-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.scenario-card.red    { border-top: 5px solid var(--red); }
.scenario-card.yellow { border-top: 5px solid var(--yellow); }
.scenario-card.green  { border-top: 5px solid var(--green); }
.scenario-card h3 { margin: 0; font-size: 15px; }
.scenario-card .desc { font-size: 12.5px; color: var(--ink-soft); min-height: 34px; }
.scenario-card dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13px; }
.scenario-card dt { color: var(--ink-soft); }
.scenario-card dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.scenario-card dd.big { font-size: 16px; font-weight: 800; }
.scenario-card dd.neg { color: var(--red); }

/* ---------- Scenario storytelling (Stage 6) -------------------------------
   Gold is the D4 brand highlight — the BEST badge/ring is a brand accent,
   while red/yellow/green stay reserved for the safety status border. */
.scenario-reco {
  grid-column: 1 / -1;
  background: var(--gold-bg); border: 1px solid var(--gold-soft);
  border-left: 4px solid var(--gold); border-radius: var(--radius);
  padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--ink);
}
.scenario-reco .reco-star { color: var(--gold-ink); }
.scenario-reco.neutral {
  background: var(--card); border-color: var(--line); border-left-color: var(--line);
  color: var(--ink-soft); font-weight: 400;
}
.scenario-card.best { outline: 2px solid var(--gold); outline-offset: 1px; }
.best-badge {
  align-self: flex-start; background: var(--gold-soft); color: #3b2f00;
  border: 1px solid var(--gold); border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 10px;
}
.deltas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.deltas-label { color: var(--ink-soft); font-weight: 600; }
.delta {
  background: #f4f6f8; border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 9px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-soft);
}
.delta.pos { color: var(--brand-dark); border-color: var(--brand); background: var(--brand-bg); }
.delta.neg { color: var(--gold-ink); border-color: var(--gold-soft); background: var(--gold-bg); }
.delta.base { font-style: italic; font-weight: 500; }

/* ---------- Report view (screen + print clone) ---------------------------- */
/* Reports carry the Times New Roman identity (D4); table.data re-asserts the
   sans tabular font for numbers. */
#report-view, .report-clone { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 36px; font-family: var(--serif); }
#report-view h1, .report-clone h1 { font-size: 20px; margin: 0; }
#report-view h2, .report-clone h2 { font-size: 15px; margin: 20px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
#report-view .confidential, .report-clone .confidential { color: var(--red); font-weight: 800; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }

/* D4 brand letterhead — teal logo, black TNR identity, gold rule (mirrors the
   app header). Shared by all four reports. */
.rpt-letterhead {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  border-bottom: 3px solid var(--gold); padding-bottom: 12px;
}
.rpt-brand { display: flex; align-items: center; gap: 12px; }
.rpt-logo {
  background: var(--brand); color: #fff; border: 2px solid var(--gold-soft);
  border-radius: 8px; width: 46px; height: 46px;
  display: grid; place-items: center; text-align: center;
  font-family: var(--serif); font-weight: 700; font-size: 13px;
  letter-spacing: .5px; line-height: 1.05;
}
.rpt-company-name { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--ink); }
.rpt-company-tag { font-size: 11.5px; color: var(--ink-soft); }
.rpt-doc { text-align: right; }
.rpt-meta-row {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 18px;
  font-size: 12.5px; color: var(--ink-soft);
  padding: 8px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px;
}

/* Document-end stamp — gold rule bookends the letterhead. Per-PAGE footers
   (page numbers) are added by the @page margin boxes in the print block. */
.rpt-footer {
  margin-top: 28px; padding-top: 8px; border-top: 3px solid var(--gold);
  font-size: 11px; color: var(--ink-soft);
}

/* Executive Summary — status banner, recommendation, warnings rollup */
.rpt-status-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 14px 0;
}
.rpt-status-banner.green  { border-color: var(--green);  background: var(--green-bg); }
.rpt-status-banner.yellow { border-color: var(--yellow); background: var(--yellow-bg); }
.rpt-status-banner.red    { border-color: var(--red);    background: var(--red-bg); }
.rpt-status-note { font-size: 13.5px; }
.rpt-reco {
  border-left: 4px solid var(--gold); background: var(--gold-bg);
  padding: 9px 12px; border-radius: 0 8px 8px 0; font-size: 14px; margin: 8px 0;
}
.rpt-warnline { font-size: 12px; color: var(--ink-soft); }

/* Executive Summary — compact waterfall snapshot (SVG rect fills are inline
   so they survive printing; only the text styling lives here). */
.rpt-wf svg { display: block; max-width: 100%; }
.rpt-wf-label  { font: 11.5px "Segoe UI", system-ui, Arial, sans-serif; fill: var(--ink-soft); }
.rpt-wf-amount { font: 600 11.5px "Segoe UI", system-ui, Arial, sans-serif; fill: var(--ink); font-variant-numeric: tabular-nums; }
.rpt-wf-amount.neg { fill: var(--red); font-weight: 700; }
.rpt-wf-axis { stroke: #9aa4b2; stroke-width: 1; stroke-dasharray: 3 3; }

/* Subcontractor Offer — signature & date blocks */
.rpt-signatures { display: flex; gap: 44px; margin-top: 30px; }
.sig-block { flex: 1; min-width: 0; }
.sig-party { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.sig-row { border-bottom: 1px solid var(--ink); height: 32px; }
.sig-caption { font-size: 10.5px; color: var(--ink-soft); margin: 3px 0 10px; }

/* ---------- Progress strip (Bid → Costs → Sub quote → Decision) ---------- */
.progress-strip {
  display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap;
  padding: 8px 22px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.p-step {
  appearance: none; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); font: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 9px; padding: 6px 12px;
  text-align: left; color: var(--ink);
}
.p-step:hover { border-color: var(--brand); background: var(--brand-bg); }
.p-step .p-num {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 2px solid var(--line); color: var(--ink-soft);
  font-weight: 800; font-size: 12.5px;
}
.p-step .p-text { display: flex; flex-direction: column; }
.p-step .p-label { font-family: var(--serif); font-weight: 700; font-size: 14px; line-height: 1.2; }
.p-step .p-state { font-size: 11px; color: var(--ink-soft); line-height: 1.3; }
.p-step.done .p-num {
  background: var(--brand); border-color: var(--brand); color: #fff;
  font-size: 0;                                   /* hide the number… */
}
.p-step.done .p-num::before { content: "\2713"; font-size: 13px; }  /* …show ✓ */
.p-step.done .p-state { color: var(--brand); font-weight: 600; }
.p-step.next { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-bg); }
.p-step.next .p-num { border-color: var(--gold); color: var(--gold-ink); }
.p-step.next .p-state { color: var(--gold-ink); font-weight: 700; }
.p-arrow { align-self: center; color: var(--ink-soft); font-size: 15px; }

/* ---------- Home view ------------------------------------------------------*/
.home-paths { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 4px; }
.home-path {
  appearance: none; text-align: left; cursor: pointer; font: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
  display: flex; flex-direction: column; gap: 8px; color: var(--ink);
  border-top: 4px solid var(--brand);
}
/* NOTE: no `outline: none` here — the keyboard focus ring must stay visible
   on the big Home path buttons (the gold hover tint alone is not a ring). */
.home-path:hover, .home-path:focus-visible {
  border-color: var(--gold); border-top-color: var(--gold);
  background: var(--gold-bg);
}
.home-path .hp-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--brand-bg); color: var(--brand);
}
.home-path .hp-title { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.home-path .hp-desc { font-size: 13px; color: var(--ink-soft); }
.home-steps { margin: 4px 0 0; padding-left: 22px; font-size: 14px; }
.home-steps li { margin-bottom: 8px; }

/* ---------- Plain-English help layer (js/help.js) ------------------------- */
.help-btn {
  appearance: none; cursor: pointer;
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-grid; place-items: center;
  margin-left: 8px; vertical-align: 2px; padding: 0;
  border: 1px solid var(--brand); background: var(--brand-bg); color: var(--brand);
  font: 700 12px/1 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--brand); color: #fff; }
.help-btn:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 1px; }

.help-popover {
  position: absolute; z-index: 200;
  width: min(400px, calc(100vw - 24px));
  background: var(--card); border: 1px solid var(--gold); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
  padding: 14px 16px;
}
.help-popover:focus { outline: none; }
.help-popover .hp-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  border-bottom: 2px solid var(--gold-soft); padding-bottom: 6px; margin-bottom: 8px;
}
.help-popover h3 { margin: 0; font-family: var(--serif); font-size: 15px; color: var(--ink); }
.help-popover .hp-close {
  appearance: none; border: none; background: none; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 2px; color: var(--ink-soft);
}
.help-popover .hp-close:hover, .help-popover .hp-close:focus-visible { color: var(--ink); }
.help-popover p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; color: var(--ink); }
.help-popover p:last-child { margin-bottom: 0; }

/* Help tab — worked example walkthrough */
.math-step {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.math-step .ms-text { flex: 1 1 auto; }
.math-step .ms-title { font-family: var(--serif); font-weight: 700; font-size: 14.5px; }
.math-step .ms-plain { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.math-step .ms-amount {
  min-width: 110px; text-align: right; font-weight: 800; font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.math-verdict { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 13.5px; }

/* Help tab — glossary */
dl.glossary { margin: 0; column-gap: 40px; }
@media (min-width: 900px) { dl.glossary { column-count: 2; } }
dl.glossary .g-entry { break-inside: avoid; padding: 6px 0; }
dl.glossary dt { font-weight: 700; font-size: 13.5px; color: var(--ink); }
dl.glossary dd { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }

/* ---------- Estimate importer -------------------------------------------- */
.dropzone {
  border: 2px dashed #b6c0cf; border-radius: var(--radius);
  padding: 34px 20px; text-align: center; cursor: pointer;
  background: #fafbfd; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-bg); }
.dropzone .dz-icon { font-size: 34px; color: var(--brand); line-height: 1; margin-bottom: 6px; }
.chip {
  display: inline-block; border-radius: 999px; padding: 2px 10px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.chip-high   { background: var(--green-bg);  color: var(--green-text); }
.chip-medium { background: var(--yellow-bg); color: var(--yellow-text); }
.chip-low    { background: var(--red-bg);    color: var(--red-text); }
#import-table select { max-width: 260px; padding: 5px 6px; font-size: 12.5px; }
#import-paste { width: 100%; font: 13px/1.5 Consolas, monospace; }

/* ---------- Utility ------------------------------------------------------ */
.muted { color: var(--ink-soft); }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.mt0 { margin-top: 0; }
.hidden { display: none !important; }
.lock-note { font-size: 12px; color: var(--brand); font-weight: 700; }

/* ---------- App footer: version stamp (Stage 11) -------------------------- */
footer.app-footer {
  max-width: 1280px;
  margin: -56px auto 0;              /* tucks into main's bottom padding */
  padding: 0 22px 24px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
}
footer.app-footer #app-version { font-weight: 700; color: var(--brand); }
footer.app-footer #app-offline-status { color: var(--gold-ink); font-weight: 700; }

/* ---------- Print: only the report prints -------------------------------- */
@media print {
  /* Per-page footers: generated-by stamp (bottom-left) + page numbers
     (bottom-right) via @page margin boxes — supported by Chrome/Edge 131+;
     older browsers ignore the boxes and still print the report's own
     .rpt-footer stamp at the end of the document. */
  @page {
    margin: 16mm 14mm 20mm;
    @bottom-left {
      content: "3D Technology Services, Inc. — generated by TheFireSub";
      font: 9px "Times New Roman", Times, serif; color: #4a5568;
    }
    @bottom-right {
      content: "Page " counter(page) " of " counter(pages);
      font: 9px "Times New Roman", Times, serif; color: #4a5568;
    }
  }
  body { background: #fff; }
  header.app-header, .summary-bar, .progress-strip, nav.tabs, .no-print, main > section.tab-panel,
  .help-btn, .help-popover, footer.app-footer { display: none !important; }
  main { padding: 0; max-width: none; }
  #print-root { display: block !important; }
  #report-view, .report-clone { border: none; border-radius: 0; padding: 0; }
  .pill.red { animation: none; }
  /* keep the letterhead teal/gold, status tints, and table shading on paper */
  #print-root, #print-root * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-clone h2 { break-after: avoid; }
  .report-clone table.data tr { break-inside: avoid; }
  .report-clone .rpt-letterhead, .report-clone .rpt-status-banner, .report-clone .rpt-wf,
  .report-clone .rpt-signatures, .report-clone .sig-block { break-inside: avoid; }
}
#print-root { display: none; }
@media print { #print-root { display: block; } }

/* ---------- Responsive ---------------------------------------------------- */
@media (max-width: 720px) {
  main { padding: 12px 12px 60px; }
  .summary-bar { padding: 8px 12px; gap: 4px 16px; }
  .progress-strip { padding: 8px 12px; }
  .p-step .p-state { display: none; }
  .p-arrow { display: none; }
  .summary-bar .metric .v { font-size: 14.5px; }
  nav.tabs { padding: 8px 8px 0; overflow-x: auto; flex-wrap: nowrap; }
  nav.tabs button { white-space: nowrap; }
  .tile.hero { grid-column: span 1; }
  #report-view { padding: 16px; }
}
