/* ==========================================================================
   Plan Selection Tool -- design system
   --------------------------------------------------------------------------
   Warm ivory background, generous rounded surfaces, one amber accent, and
   near-black "ink" panels for emphasis. The intent is that a client sees a
   designed product rather than a default framework theme.

   Structure of this file:
     1. Tokens
     2. Base elements + typography
     3. Layout shell (header, nav, main, cards)
     4. Forms + buttons
     5. Tables
     6. Auth + client-site gate
     7. Broker/admin components
     8. Wizard
     9. Results (chart + comparison table)
    10. Mobile
    11. Print / Save as PDF
   ========================================================================== */

/* ------------------------------------------------------------ 1. tokens */
:root {
  /* Warm neutrals. The background is a gradient rather than a flat fill --
     it's most of what stops the page reading as a default template. */
  --bg-a: #fdfbf4;
  --bg-b: #f9f2e2;
  --bg-c: #f4ebd6;
  --surface: #ffffff;
  --surface-sunken: #fbf8f0;

  /* Near-black used for high-contrast panels and the primary text colour.
     Warm rather than pure black so it sits with the ivory. */
  --ink: #1a1917;
  --ink-soft: #2c2925;

  --accent: #f2c230;         /* amber -- primary actions, highlights */
  --accent-strong: #e3ad0f;
  --accent-soft: #fdf4d5;
  --accent-line: #f0dda2;
  /* Computed per brand colour at request time (see theming.py). Defaults
     here keep the stylesheet standalone when no branding is set. */
  --on-accent: #1a1917;
  --on-accent-strong: #1a1917;
  --accent-text: #876d1b;
  --chart-accent: #f2c230;
  --chart-dark: #2c2925;

  --text: #1a1917;
  --muted: #857f72;
  --border: #ece5d5;
  --border-strong: #ded4bd;

  --good: #2f7d54;
  --good-bg: #eef7f1;
  --danger: #c2412d;
  --danger-bg: #fdf1ee;
  --warn: #a16207;
  --warn-bg: #fdf6e3;

  /* Warm-tinted shadows; a neutral grey shadow looks dirty over ivory. */
  --shadow-sm: 0 1px 2px rgba(60, 48, 20, 0.04);
  --shadow: 0 2px 6px rgba(60, 48, 20, 0.05), 0 6px 18px rgba(60, 48, 20, 0.05);
  --shadow-lg: 0 8px 30px rgba(60, 48, 20, 0.10);

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, Helvetica, Arial, sans-serif;

  --maxw: 1080px;
}

/* --------------------------------------------- 2. base + typography */
* { box-sizing: border-box; }

body {
  font-family: var(--font);
  /* fixed attachment keeps the gradient from repeating as the page scrolls */
  background: linear-gradient(158deg, var(--bg-a) 0%, var(--bg-b) 46%, var(--bg-c) 100%) fixed;
  background-color: var(--bg-b);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 { letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; margin: 0 0 0.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; margin: 0 0 0.3rem; font-weight: 700; }
h4 {
  font-size: 0.74rem; margin: 1.5rem 0 0.6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}

a { color: inherit; }

.hint { color: var(--muted); font-size: 0.86rem; margin: 0.3rem 0 0.9rem; line-height: 1.55; }

.warning {
  background: var(--warn-bg); border: 1px solid #f0e0b8; color: #7c4a03;
  border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1rem;
  font-size: 0.87rem;
}
.notice-good {
  background: var(--good-bg); border: 1px solid #cfe7d9; color: #1f5c3c;
  border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1rem;
  font-size: 0.87rem;
}

/* ------------------------------------------------- 3. layout shell */
/* The header floats on the gradient instead of being an opaque bar with a
   rule under it -- that bar is the single most "default template" element. */
header { background: transparent; border: none; position: static; }
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 1.6rem 1.75rem 0.9rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.25rem; flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: var(--radius);
  background: var(--ink); color: var(--accent);
  font-weight: 800; font-size: 0.85rem; letter-spacing: -0.02em;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
header h1 { margin: 0; font-size: 1.12rem; font-weight: 700; }
.tagline { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.8rem; }
.tagline a { color: var(--muted); text-decoration: none; }
.tagline a:hover { color: var(--text); }

/* Pill nav: a soft container with a dark "ink" pill marking the current tab. */
nav {
  display: flex; gap: 0.15rem; align-items: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  padding: 0.28rem; border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 0.5rem 1rem; border-radius: var(--radius-pill);
  font-size: 0.85rem; font-weight: 600; font-family: inherit;
  color: var(--muted); text-decoration: none;
  transition: background 0.16s, color 0.16s;
  min-height: 0;
}
.tab-btn:hover { color: var(--text); background: rgba(26, 25, 23, 0.05); }
.tab-btn.active {
  background: var(--ink); color: #fff; font-weight: 600; box-shadow: none;
}

main { max-width: var(--maxw); margin: 0 auto; padding: 0.75rem 1.75rem 4.5rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-card {
  background: var(--surface);
  border: 1px solid rgba(236, 229, 213, 0.9);
  border-radius: var(--radius-xl);
  padding: 1.75rem 1.9rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.panel-header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.2rem;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.2rem 1.35rem;
  margin-bottom: 0.9rem; box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 0.2rem; }

/* ------------------------------------------------ 4. forms + buttons */
label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.9rem; }

input, select {
  font-family: inherit; font-size: 0.92rem;
  padding: 0.7rem 0.85rem; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text); background: var(--surface);
  margin-top: 0.35rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1.5rem; }

button {
  border: none; border-radius: var(--radius-pill); cursor: pointer;
  font-size: 0.87rem; font-weight: 700; font-family: inherit;
  padding: 0.72rem 1.5rem;
  transition: transform 0.06s, background 0.16s, box-shadow 0.16s, opacity 0.16s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* Amber with dark text: the accent is too light to carry white type. */
button.primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
button.primary:hover { background: var(--accent-strong); color: var(--on-accent-strong); box-shadow: var(--shadow); }

button.secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
}
button.secondary:hover { background: var(--surface-sunken); border-color: var(--muted); }

button.danger-link {
  background: none; color: var(--danger); padding: 0.4rem 0.6rem; font-size: 0.82rem;
}
button.danger-link:hover { text-decoration: underline; }

.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 1.5rem;
  line-height: 1; color: var(--muted); padding: 0.15rem 0.5rem; border-radius: var(--radius-sm);
}
.icon-btn:hover { color: var(--text); background: var(--surface-sunken); }

.checkbox-row { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; margin-bottom: 0.9rem; }
.checkbox-row label {
  display: flex; align-items: center; gap: 0.45rem;
  margin: 0; font-weight: 500; font-size: 0.88rem; cursor: pointer;
}
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent-strong); }

.upload-row { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }
.file-drop {
  flex: 1; min-width: 200px; padding: 0.95rem 1.1rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-sunken); color: var(--muted);
  cursor: pointer; font-size: 0.88rem; font-weight: 600;
  margin: 0; transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover { border-color: var(--accent-strong); background: var(--accent-soft); }

.status-line { font-size: 0.85rem; color: var(--muted); margin-top: 0.7rem; min-height: 1.2em; }
.status-line.busy { color: var(--text); font-weight: 600; }

.spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 0.55rem;
  border: 2px solid var(--border-strong); border-top-color: var(--accent-strong);
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }

/* ------------------------------------------------------- 5. tables */
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th {
  text-align: left; font-weight: 700; color: var(--muted);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border);
}
td { padding: 0.75rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
td input, td select { margin-top: 0; }
#services-table .svc-type { min-width: 150px; }

/* ------------------------------------------ 6. auth + site gate */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 2.4rem 2.2rem;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 400px;
}
.auth-card h2 { font-size: 1.25rem; }
.auth-alt { text-align: center; margin-top: 1.2rem; font-size: 0.86rem; color: var(--muted); }
.auth-alt a { color: var(--text); font-weight: 700; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

.site-gate-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
}
.site-gate-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 2.6rem 2.3rem;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; text-align: center;
}
.site-gate-card h1 { font-size: 1.45rem; margin: 0 0 0.4rem; font-weight: 800; }
.site-gate-card .gate-logo { max-height: 58px; margin-bottom: 1.1rem; }
.site-gate-card form { margin-top: 1.4rem; text-align: left; }

/* ------------------------------------- 7. broker/admin components */
.plan-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.plan-card-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.plan-card-actions button { padding: 0.5rem 1rem; font-size: 0.8rem; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.1rem; }
.settings-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem; background: var(--surface-sunken);
}
.settings-card h3 { font-size: 0.98rem; }
.settings-card .upload-row { margin-top: 0.9rem; }
.settings-card input[type="file"] { font-size: 0.8rem; padding: 0.5rem; }

.count-badge {
  display: inline-block; background: var(--accent); color: var(--on-accent);
  font-size: 0.72rem; font-weight: 800; border-radius: var(--radius-pill);
  padding: 0.12rem 0.55rem; margin-left: 0.45rem; vertical-align: middle;
}
.reset-action-cell { white-space: nowrap; }
.reset-action-cell button + button { margin-left: 0.4rem; }
.reset-link-box {
  margin-top: 1.1rem; padding: 1rem 1.15rem; border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg); background: var(--accent-soft);
}
.reset-link-row { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.reset-link-row input {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem; margin-top: 0;
}
.reset-link-box .hint { margin-bottom: 0; }

.sbc-link { color: var(--text); font-weight: 700; text-decoration: underline;
            text-decoration-color: var(--accent); text-underline-offset: 3px; }
.sbc-link:hover { text-decoration-color: var(--accent-strong); }
.sbc-missing { color: var(--muted); font-style: italic; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26, 25, 23, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 2rem 1.25rem; backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  width: 100%; max-width: 760px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.4rem 1.7rem 0.9rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1.4rem 1.7rem; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.6rem;
  padding: 1.1rem 1.7rem; border-top: 1px solid var(--border);
}

/* ------------------------------------------------------ 8. wizard */
.wizard-progress { display: flex; gap: 0.4rem; margin-bottom: 2rem; }
.wizard-progress .dot {
  height: 5px; flex: 1; border-radius: var(--radius-pill);
  background: var(--border); transition: background 0.25s;
}
.wizard-progress .dot.done { background: var(--accent); }
.wizard-progress .dot.current { background: var(--ink); }

.wizard-step { min-height: 250px; }
.wizard-step .step-eyebrow {
  font-size: 0.72rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.7rem;
}
.wizard-step .step-question {
  font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em;
  line-height: 1.2; margin-bottom: 1.6rem; max-width: 30ch;
}
.wizard-step .step-sub {
  color: var(--muted); font-size: 0.88rem;
  margin: -1.1rem 0 1.6rem; max-width: 44ch;
}
.wizard-step .step-input { max-width: 22rem; }
.wizard-step .step-input input, .wizard-step .step-input select {
  font-size: 1.05rem; padding: 0.85rem 1rem;
}

.wizard-nav {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border); padding-top: 1.4rem; margin-top: 1.6rem;
}
.wizard-nav button { min-width: 112px; }

.plan-check-card, .level-card {
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem 1.15rem; display: flex; align-items: center; gap: 0.85rem;
  cursor: pointer; background: var(--surface);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.plan-check-card { margin-bottom: 0.6rem; max-width: 30rem; }
.plan-check-card:hover, .level-card:hover { border-color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.plan-check-card input, .level-card input { width: auto; margin: 0; accent-color: var(--accent-strong); }
.plan-check-card span { font-size: 0.95rem; font-weight: 600; }

.level-list { display: flex; flex-direction: column; gap: 0.65rem; max-width: 34rem; }
.level-card { align-items: flex-start; }
.level-card input { margin-top: 0.25rem; }
.level-card.selected {
  border-color: var(--accent-strong); background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-line);
}
.level-card .level-text { display: flex; flex-direction: column; gap: 0.12rem; }
.level-card .level-text strong { font-size: 0.98rem; }
.level-card .level-blurb { color: var(--muted); font-size: 0.85rem; }

.customize-btn { margin-top: 1.3rem; display: block; }
.customize-panel {
  margin-top: 1rem; padding: 1.2rem 1.3rem; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface-sunken); max-width: 34rem;
}
.customize-panel .hint { margin-top: 0; }
.usage-grid { display: flex; flex-direction: column; gap: 0.6rem; }
.usage-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: 0.89rem; }
.usage-row .usage-label { flex: 1; }
.usage-row .usage-input { width: 5.5rem; flex: none; padding: 0.45rem 0.6rem; margin-top: 0; }

/* ----------------------------------------------------- 9. results */
.review-summary {
  font-size: 0.85rem; color: var(--muted); margin-bottom: 1.1rem;
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}
.link-btn, .review-summary button.link-btn, .show-detail-btn {
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--text); font-weight: 700; font-size: 0.84rem;
  font-family: inherit; text-decoration: underline;
  text-decoration-color: var(--accent); text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-color: var(--accent-strong); }
.show-detail-btn { margin-top: 1.1rem; }

.results-panel {
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 1.9rem 2rem; background: var(--surface); box-shadow: var(--shadow);
}
.results-head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}
.results-heading { margin: 0; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.025em; }
.results-head-row .print-btn { padding: 0.6rem 1.15rem; font-size: 0.82rem; }

.chart-wrap { width: 100%; overflow-x: auto; }
.cost-chart { width: 100%; height: auto; min-width: 320px; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis-label { font-size: 11px; fill: var(--muted); font-weight: 600; }
.chart-plan-name { font-size: 11.5px; fill: var(--text); font-weight: 600; }
.chart-total { font-size: 13px; font-weight: 800; fill: var(--ink); }
.chart-total-inside { fill: var(--ink); }

.bar-premium { fill: var(--chart-dark); }
.bar-oop { fill: var(--chart-accent); }
.worst-line { stroke: #c2412d; stroke-width: 2; stroke-dasharray: 5 3; }
.worst-label { font-size: 10.5px; font-weight: 800; fill: #c2412d; }

.chart-legend {
  display: flex; flex-wrap: wrap; gap: 0.45rem 1.5rem; justify-content: center;
  margin-top: 1rem; font-size: 0.81rem; color: var(--muted); font-weight: 600;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-premium { background: var(--chart-dark); }
.swatch-oop { background: var(--chart-accent); }
.swatch-worst { background: transparent; border-top: 2px dashed #c2412d; height: 0; width: 16px; border-radius: 0; }

.compare-table { width: 100%; margin-top: 1.9rem; border-collapse: collapse; }
.compare-table th, .compare-table td {
  padding: 0.7rem 0.75rem; text-align: right; border-bottom: 1px solid var(--border);
  font-size: 0.89rem;
}
.compare-table thead th {
  text-align: right; vertical-align: bottom; font-size: 0.82rem;
  text-transform: none; letter-spacing: -0.01em; color: var(--text); font-weight: 700;
}
.compare-table th.corner { border-bottom: 1px solid var(--border); }
.compare-table tbody th[scope="row"] {
  text-align: left; font-weight: 600; color: var(--muted); white-space: normal;
  text-transform: none; letter-spacing: 0; font-size: 0.85rem;
}
.compare-table .row-note { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.compare-table .col-best { background: var(--accent-soft); }
.compare-table thead th.col-best { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.compare-table .total-row td { font-size: 1.05rem; font-weight: 800; }
.compare-table .total-row th[scope="row"] { font-weight: 700; color: var(--text); }
.compare-table .worst-row td { color: var(--danger); font-weight: 700; }
.compare-table .hsa-row td { color: var(--good); }
.compare-table .hsa-cell { font-weight: 700; }
.compare-table thead .best-tag { display: block; margin-top: 0.3rem; }

.best-tag {
  display: inline-block; background: var(--accent); color: var(--on-accent);
  font-size: 0.66rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.07em; padding: 0.16rem 0.55rem; border-radius: var(--radius-pill);
}
.plan-cost-best { border-color: var(--accent-strong); }
.result-total { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.result-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.hsa-note {
  margin-top: 0.9rem; padding: 0.75rem 0.95rem; background: var(--good-bg);
  border: 1px solid #cfe7d9; border-radius: var(--radius);
}
.hsa-note strong { color: var(--good); font-size: 1.05rem; }
.hsa-note .hint { margin: 0.1rem 0 0; }

.results-footnote { margin-top: 1.2rem; }
.detail-panel { margin-top: 0.7rem; }
.detail-panel table { margin: 0.5rem 0 0; }
.detail-total-row td { border-top: 2px solid var(--border-strong); border-bottom: none; }
.detail-block { margin-top: 1.3rem; }
.detail-block h4 { margin: 0 0 0.35rem; font-size: 0.8rem; color: var(--text); }

/* ------------------------------------------------------ 10. mobile */
@media (max-width: 720px) {
  .header-inner { padding: 1.1rem 1rem 0.7rem; gap: 0.8rem; }
  header h1 { font-size: 1rem; }
  .brand-mark { width: 36px; height: 36px; font-size: 0.76rem; }

  nav {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap; scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; padding: 0.5rem 0.85rem; }

  main { padding: 0.5rem 0.9rem 3.5rem; }
  .panel-card { padding: 1.25rem 1.15rem; border-radius: var(--radius-lg); }
  .results-panel { padding: 1.3rem 1.15rem; border-radius: var(--radius-lg); }
  h2 { font-size: 1.15rem; }
  .wizard-step .step-question { font-size: 1.35rem; }

  button { padding: 0.75rem 1.3rem; min-height: 44px; }
  .panel-header-row { flex-direction: column; align-items: stretch; gap: 0.7rem; }
  .panel-header-row button { width: 100%; }

  /* 16px stops iOS Safari zooming when a field is focused */
  input, select { font-size: 16px; }

  .upload-row { flex-direction: column; align-items: stretch; }
  .upload-row button, .upload-row input, .file-drop { width: 100%; }

  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .modal-overlay { padding: 0; }
  .modal { max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal-body { flex: 1; }
  .modal-footer { position: sticky; bottom: 0; background: var(--surface); }
  .modal-footer button { flex: 1; }

  .grid2, .grid3 { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }

  .results-head-row { flex-direction: column; align-items: stretch; gap: 0.7rem; }
  .results-head-row .print-btn { width: 100%; }
  .chart-legend { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .reset-link-row { flex-direction: column; }
  .reset-link-row button { width: 100%; }
  .auth-card, .site-gate-card { padding: 1.8rem 1.4rem; }
}

@media (max-width: 420px) {
  .cost-chart { min-width: 300px; }
  .compare-table th, .compare-table td { padding: 0.5rem; font-size: 0.84rem; }
}


/* ------------------------------------------------- 12. branding controls */
.brand-logo { max-height: 42px; max-width: 190px; object-fit: contain; }

.color-row { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.9rem; }
/* Native colour swatches render as a bordered box by default; strip the
   chrome so it reads as a swatch rather than a form control. */
.color-row input[type="color"] {
  width: 46px; height: 42px; padding: 3px; flex: none; margin-top: 0;
  border-radius: var(--radius-sm); cursor: pointer; background: var(--surface);
}
.color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-row input[type="text"] {
  flex: 1; max-width: 12rem; margin-top: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.color-row button { flex: none; padding: 0.6rem 1.1rem; }

.brand-preview {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  padding: 1.1rem 1.2rem; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface-sunken);
}
.bp-swatch {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Broker credit on client mini-sites: present but deliberately quiet, so
   the employer's brand stays the dominant one on the page. */
.site-credit {
  max-width: var(--maxw); margin: 0 auto; padding: 0 1.75rem 3rem;
  display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  color: var(--muted); font-size: 0.78rem;
}
.site-credit img { max-height: 22px; max-width: 110px; object-fit: contain; opacity: 0.85; }

@media (max-width: 720px) {
  .color-row { flex-wrap: wrap; }
  .color-row input[type="text"] { max-width: none; }
  .color-row button { width: auto; }
  .site-credit { padding: 0 1rem 2rem; }
}

/* --------------------------------------- 11. print / save as PDF */
.print-only { display: none; }

@media print {
  @page { margin: 14mm; }

  /* The gradient must not print; and colour-adjust keeps the chart bars
     filled when the reader enables background graphics. */
  body {
    background: #fff !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    font-size: 10pt;
  }

  header, nav, .wizard-nav, .wizard-progress, .review-summary,
  .print-btn, .show-detail-btn, .link-btn, .site-credit { display: none !important; }

  .print-only { display: block; }

  main { max-width: 100%; padding: 0; }
  .panel-card, .results-panel {
    border: none; box-shadow: none; padding: 0; margin: 0; background: #fff;
  }

  .print-header { margin-bottom: 1rem; border-bottom: 2px solid #1a1917; padding-bottom: 0.6rem; }
  .print-title-row { display: flex; justify-content: space-between; align-items: flex-start; }
  .print-header h1 { font-size: 17pt; margin: 0 0 0.15rem; color: #1a1917; }
  .print-sub { margin: 0; font-size: 9.5pt; color: #444; }
  .print-assumptions { margin-top: 0.7rem; font-size: 9.5pt; }
  .print-assumptions ul { margin: 0.2rem 0 0.6rem; padding-left: 1.1rem; }
  .print-assumptions li { margin: 0.05rem 0; }

  .results-heading { font-size: 12pt; margin: 0 0 0.5rem; }
  .cost-chart { max-height: 78mm; }
  .chart-legend { font-size: 8.5pt; margin-top: 0.4rem; }

  .compare-table {
    page-break-inside: avoid; font-size: 9.5pt; width: 100%;
    display: table; overflow: visible; white-space: normal;
  }
  .compare-table th, .compare-table td { padding: 0.32rem 0.4rem; }
  .compare-table .col-best { background: transparent; font-weight: 700; }
  .compare-table .total-row { border-top: 1.5px solid #333; }
  .sbc-link { color: #000; text-decoration: none; font-weight: 400; }
  .sbc-link::after { content: " (see SBC)"; font-size: 8pt; color: #555; }

  .detail-panel { display: block !important; }
  .detail-block { page-break-inside: avoid; }
  .detail-block h4 { font-size: 10pt; }
  .results-footnote { font-size: 8.5pt; color: #555; margin-top: 0.6rem; }

  a[href]::after { content: ""; }
}


/* --------------------------------------------- 13. Actuarial Toolbox */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.1rem; margin-top: 1.2rem; }
.tool-tile {
  display: flex; flex-direction: column; gap: 0.5rem; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem 1.6rem;
  background: var(--surface-sunken); transition: border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.tool-tile:hover { border-color: var(--accent-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.tool-tile h3 { margin: 0.4rem 0 0; }
.tool-tile p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.tool-tile p:last-of-type { flex: 1; }
.tool-tile-tagline { font-weight: 600; color: var(--text) !important; font-size: 0.86rem !important; }
/* A tool that exists in the shell but isn't built: present, clearly not ready,
   and not dressed up as a working link. */
.upcoming-head { margin-top: 2.2rem; }
.tool-tile.is-planned { background: var(--surface); border-style: dashed; }
.tool-tile.is-planned:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: none; }
.tool-tile.is-planned .tool-tile-mark { background: var(--surface-sunken); color: var(--muted);
  border: 1px solid var(--border-strong); }
.tool-tile.is-planned h3 { color: var(--muted); }
.tool-tile-cta { align-self: flex-start; text-decoration: none; }

.placeholder-card { text-align: left; }
.placeholder-card .tool-tile-mark { margin-bottom: 0.9rem; }
.placeholder-card h2 { margin-bottom: 0.15rem; }

/* Per-broker tool access, on the admin dashboard */
.tools-cell { white-space: nowrap; }
.tool-toggle { display: inline-flex; align-items: center; margin: 0 0.2rem 0 0; cursor: pointer; }
.tool-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.tool-toggle span {
  display: inline-block; min-width: 30px; text-align: center;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.03em;
  padding: 0.22rem 0.4rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--muted); transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tool-toggle input:checked + span { background: var(--accent); border-color: var(--accent-strong); color: var(--on-accent); }
.tool-toggle input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: 1px; }
.tool-toggle input:disabled + span { opacity: 0.5; }
.tool-save-note { font-size: 0.72rem; margin-left: 0.4rem; color: var(--muted); }
.tool-save-note.ok { color: var(--good); font-weight: 700; }
.tool-save-note.bad { color: var(--danger); font-weight: 700; }
.tool-tile-mark {
  width: 42px; height: 42px; border-radius: var(--radius); background: var(--ink); color: var(--accent);
  font-weight: 800; font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
}
.tool-tile-cta { font-weight: 700; font-size: 0.86rem; color: var(--accent-text); margin-top: 0.4rem; }

/* ------------------------------------------------------ 14. AV calculator */
.av-main { max-width: 1360px; }
.av-toolbar { padding: 1.1rem 1.5rem; }
.av-toolbar-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 0.9rem; }
.av-inline { margin: 0; min-width: 220px; flex: 1 1 220px; }
.av-inline select, .av-inline input[type="text"] { margin-top: 0.3rem; padding: 0.55rem 0.75rem; }

/* Client type-ahead */
.av-combo { position: relative; }
.av-combo input[type="text"] { padding-right: 2rem; }
.combo-clear {
  position: absolute; right: 0.45rem; bottom: 0.35rem; background: none; border: none;
  font-size: 1.15rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
}
.combo-clear:hover { color: var(--text); background: var(--surface-sunken); }
.combo-list {
  position: absolute; z-index: 40; top: 100%; left: 0; right: 0; margin: 0.2rem 0 0; padding: 0.3rem;
  list-style: none; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.combo-list li {
  padding: 0.45rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.88rem; font-weight: 600;
}
.combo-list li:hover, .combo-list li.active { background: var(--accent-soft); }
.combo-list li.combo-empty { color: var(--muted); font-weight: 500; cursor: default; }
.combo-list li.combo-empty:hover { background: none; }
.av-toolbar-row button { padding: 0.62rem 1.1rem; }
.av-toolbar .status-line { margin-top: 0.5rem; }

.av-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
.av-results { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 1.25rem; }
.av-results .panel-card { margin-bottom: 0; padding: 1.3rem 1.5rem; }
@media (max-width: 1000px) { .av-layout { grid-template-columns: 1fr; } .av-results { position: static; } }

.av-name { margin: 0.6rem 0 1rem; }
.av-fields label { margin-bottom: 0.9rem; }
.av-money, .av-pct { position: relative; display: block; }
.av-money input { padding-left: 1.6rem; }
.av-pct input { padding-right: 1.8rem; }
.av-money::before, .av-pct::before {
  position: absolute; top: 50%; transform: translateY(-50%); margin-top: 0.17rem;
  color: var(--muted); font-size: 0.85rem; font-weight: 600; pointer-events: none;
}
.av-money::before { content: '$'; left: 0.8rem; }
.av-pct::before { content: '%'; right: 0.85rem; }
.av-num, .av-services input.copay { font-variant-numeric: tabular-nums; }

/* Only shown while the field is still following the individual figure. */
.auto-note { display: none; font-size: 0.7rem; font-weight: 500; color: var(--muted); margin-top: 0.25rem; }
.av-fields label.is-auto .auto-note { display: block; }
.av-fields label.is-auto input { border-style: dashed; }
.av-sbc select.wide { width: 108px; }

.av-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.7rem 1.4rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.av-toggle { display: flex; align-items: flex-start; gap: 0.6rem; margin: 0; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.av-toggle input { width: auto; margin: 0.25rem 0 0; accent-color: var(--accent-strong); }
.av-toggle small { display: block; color: var(--muted); font-weight: 500; font-size: 0.8rem; line-height: 1.45; margin-top: 0.15rem; }

.av-tablewrap { overflow-x: auto; }
.av-services th.c, .av-services td.c { text-align: center; }
.av-services td { padding: 0.45rem 0.6rem; }
.av-services tr.group td { padding: 1.1rem 0.6rem 0.35rem; font-weight: 700; font-size: 0.9rem; border-bottom: 1px solid var(--border-strong); }
.av-services tr.group:first-child td { padding-top: 0.2rem; }
.av-services td input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-strong); }
.av-services td .av-money { width: 118px; margin: 0 auto; }
.av-services td input.copay { margin-top: 0; padding: 0.45rem 0.6rem 0.45rem 1.5rem; font-size: 0.86rem; text-align: right; border-radius: var(--radius-sm); }
.av-services td .av-money::before { margin-top: 0; }
.av-services tr.off td { color: var(--muted); }
.av-services tr.off td input.copay { opacity: 0.5; }
.av-services td .note { font-size: 0.78rem; color: var(--muted); }
.av-services td .linknote { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; margin: 0.15rem 0 0; font-weight: 500; }
.av-services td .linknote input { width: 13px; height: 13px; margin: 0; }
.av-services tr.linked td input[data-f] { opacity: 0.55; }

.av-card { border-top: 4px solid var(--accent); }
.av-value { font-size: 3.4rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 0.25rem 0 0.4rem; font-variant-numeric: tabular-nums; }
.av-value small { font-size: 1.5rem; color: var(--muted); font-weight: 600; }
.av-meter { margin-top: 1rem; }
.av-meter svg { width: 100%; height: auto; display: block; }
.av-meter .tier { font: 700 9.5px var(--font); letter-spacing: 0.05em; text-transform: uppercase; fill: var(--muted); }
.av-meter .tick { stroke: var(--border-strong); stroke-width: 1; }
.av-meter .track { fill: var(--surface-sunken); }
.av-meter .fill { fill: var(--accent); }
.av-meter .mv { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 3 2; }
.av-meter .needle { fill: var(--ink); }
.av-meter .needle-label { font: 700 11px var(--font); fill: var(--ink); }
.av-pill { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 0.25rem 0.7rem; border-radius: var(--radius-pill); margin-top: 0.8rem; }
.av-pill.ok { background: var(--good-bg); color: var(--good); }
.av-pill.no { background: var(--warn-bg); color: var(--warn); }

.av-breakdown td { padding: 0.45rem 0; }
.av-breakdown td:last-child, .num { text-align: right; font-variant-numeric: tabular-nums; }
.av-breakdown tr.sub td:first-child { padding-left: 0.9rem; color: var(--muted); }
.av-breakdown tr.total td { border-bottom: none; border-top: 1px solid var(--border-strong); font-weight: 800; }

.av-details summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; list-style: none; display: flex; justify-content: space-between; }
.av-details summary::after { content: '+'; color: var(--muted); }
.av-details[open] summary::after { content: '–'; }
.av-details[open] summary { margin-bottom: 0.8rem; }
.av-cat { font-size: 0.8rem; }
.av-cat th, .av-cat td { text-align: right; padding: 0.35rem 0.5rem; white-space: nowrap; }
.av-cat th:first-child, .av-cat td:first-child { text-align: left; white-space: normal; }
.av-cat tr.total td { font-weight: 800; border-top: 1px solid var(--border-strong); border-bottom: none; }

.modal-wide { max-width: 1100px; width: 100%; }
.av-compare th { text-align: right; }
.av-compare th:first-child, .av-compare td:first-child { text-align: left; font-weight: 600; color: var(--muted); }
.av-compare td.num { white-space: nowrap; }
.av-compare tr.differs td { background: var(--accent-soft); }
.av-compare tr.differs td:first-child { color: var(--text); }
.diff-tag { display: inline-block; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-text); border: 1px solid var(--accent-line); border-radius: var(--radius-pill); padding: 0.05rem 0.45rem; margin-left: 0.4rem; vertical-align: middle; }
.av-sbc { font-size: 0.84rem; }
.av-sbc td, .av-sbc th { padding: 0.35rem 0.5rem; vertical-align: middle; }
.av-sbc th.c, .av-sbc td.c { text-align: center; }
.av-sbc td.quote { color: var(--muted); font-size: 0.76rem; max-width: 300px; }
.av-sbc td.was { color: var(--muted); white-space: nowrap; }
.av-sbc tr.changed td:nth-child(2) { font-weight: 700; }
.av-sbc tr.group td { padding: 0.9rem 0.5rem 0.3rem; font-weight: 800; font-size: 0.74rem;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
  border-bottom: 1px solid var(--border-strong); }
.av-sbc tr.group:first-child td { padding-top: 0.2rem; }
.av-sbc input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-strong); }
.av-sbc input[type="number"], .av-sbc select { margin-top: 0; padding: 0.35rem 0.5rem 0.35rem 1.4rem;
  font-size: 0.82rem; border-radius: var(--radius-sm); width: 108px; text-align: right;
  font-variant-numeric: tabular-nums; }
.av-sbc select { padding-left: 0.5rem; text-align: left; width: 78px; }
.av-sbc .av-money::before, .av-sbc .av-pct::before { margin-top: 0; font-size: 0.78rem; }
.av-sbc .av-money, .av-sbc .av-pct { display: inline-block; }
.sbc-svc-cell { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.sbc-flag { display: inline-flex; align-items: center; gap: 0.22rem; margin: 0; font-size: 0.7rem;
  font-weight: 700; color: var(--muted); cursor: pointer; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.18rem 0.34rem; white-space: nowrap; }
.sbc-flag input[type="checkbox"] { width: 13px; height: 13px; }
.sbc-svc-cell input[type="number"] { width: 84px; }
.sbc-flag:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.av-sbc tr.changed { background: rgba(242, 194, 48, 0.06); }

@media print {
  .av-toolbar, .av-inputs, header nav, .modal-footer, #compare-picker { display: none !important; }
  .modal-overlay { position: static; background: none; padding: 0; backdrop-filter: none; }
  .modal { max-width: none; box-shadow: none; }
}


/* ------------------------------- 15. admin: broker management + step-in */
/* A step-in is the one state where what you see isn't who you are, so the
   bar is full-bleed, high-contrast and always above the header. */
.stepin-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; background: var(--ink); color: #fff;
  padding: 0.6rem 1.75rem; font-size: 0.84rem; line-height: 1.4;
}
.stepin-bar strong { color: var(--accent); }
.stepin-bar form { margin: 0; }
.stepin-exit {
  background: var(--accent); color: var(--on-accent); border: none;
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 700;
  border-radius: var(--radius-pill); cursor: pointer; white-space: nowrap;
}

/* The brokers table carries a lot per row; give the name room and let the
   whole thing scroll rather than crushing the action buttons. */
.brokers-table { table-layout: auto; }
.brokers-table th, .brokers-table td { padding-left: 0.5rem; padding-right: 0.5rem; }
.brokers-table th:first-child, .brokers-table td:first-child { padding-left: 0; min-width: 170px; }
.brokers-table td:last-child { text-align: right; padding-right: 0; }
.brokers-table .reset-action-cell button { padding: 0.45rem 0.85rem; font-size: 0.78rem; }
.brokers-table .reset-action-cell form { display: inline; margin: 0; }
.panel-card > .av-tablewrap, .brokers-wrap { overflow-x: auto; }
.broker-name { font-weight: 700; }
td .note { font-size: 0.76rem; color: var(--muted); margin-top: 0.1rem; }
.nowrap { white-space: nowrap; }

.usage-cell { white-space: nowrap; }
.usage-stat {
  display: inline-block; font-size: 0.7rem; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem; margin-right: 0.25rem;
}
.usage-stat b { color: var(--text); font-size: 0.8rem; margin-left: 0.15rem; }
.usage-stat.muted-stat { opacity: 0.45; }

.access-table { width: 100%; }
.access-table th { font-size: 0.68rem; }
.access-table td { padding: 0.5rem 0.4rem; vertical-align: middle; }
.access-table input[type="date"]:disabled { opacity: 0.45; }
.access-table input[type="date"] { margin-top: 0.15rem; padding: 0.45rem 0.55rem; font-size: 0.84rem; }
.access-table label.note { display: block; margin: 0; font-size: 0.7rem; }
.checkbox-inline {
  display: inline-flex; align-items: center; gap: 0.4rem; margin: 0;
  font-size: 0.86rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.checkbox-inline input { width: auto; margin: 0; accent-color: var(--accent-strong); }

/* ------------------------------------------------- 15. Demographic Modeler */
.dm-main { max-width: 1360px; }
.btn-link { display: inline-block; text-decoration: none; padding: 0.55rem 1rem; font-size: 0.82rem; font-weight: 700;
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.btn-link:hover { background: var(--surface-sunken); border-color: var(--muted); }
.dm-setup label { margin-bottom: 0.9rem; }
.dm-setup .auto-note { display: block; font-weight: 500; color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; }
.dm-industry-row { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.dm-industry-row select, .dm-industry-row input { margin-top: 0; }
.dm-industry-row select#code-type { flex: 0 0 150px; }

.dm-review-grid { display: grid; grid-template-columns: 1fr 1.1fr 1.4fr; gap: 1.4rem; align-items: start; }
@media (max-width: 1000px) { .dm-review-grid { grid-template-columns: 1fr; } }
.dm-issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dm-issues li { display: flex; gap: 0.7rem; align-items: flex-start; font-size: 0.86rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); background: var(--surface-sunken); border: 1px solid var(--border); }
.dm-issues li small { display: block; color: var(--muted); margin-top: 0.15rem; }
.dm-issue-count { flex: 0 0 auto; min-width: 2.2rem; text-align: center; font-weight: 800; font-size: 0.82rem; padding: 0.15rem 0.4rem; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border-strong); }
.dm-issues li.lvl-error { background: var(--danger-bg); border-color: #f2c9c1; }
.dm-issues li.lvl-error .dm-issue-count { color: var(--danger); }
.dm-issues li.lvl-warn { background: var(--warn-bg); border-color: #efd9a5; }
.dm-issues li.lvl-warn .dm-issue-count { color: var(--warn); }
.dm-issues li.lvl-ok { background: var(--good-bg); }
.dm-issues li.lvl-ok .dm-issue-count { color: var(--good); }
.dm-map { font-size: 0.86rem; }
.dm-map td, .dm-map th { padding: 0.4rem 0.5rem; }
.dm-map td select, .dm-map td input[type="text"] { margin-top: 0; padding: 0.4rem 0.55rem; font-size: 0.84rem; }
.dm-map td input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-strong); }
.dm-map tr.off td { color: var(--muted); }
.dm-map tr.off td input[type="text"] { opacity: 0.5; }
.dm-map .c { text-align: center; }
.dm-map td select { min-width: 190px; }
.dm-agegroups td:first-child { white-space: nowrap; }
.dm-order .icon-btn { font-size: 0.7rem; padding: 0.2rem 0.35rem; }

.dm-section h3 { margin-bottom: 0.2rem; }
.dm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dm-state-mode { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.78rem; color: var(--muted); }
.dm-state-mode select { margin: 0; width: auto; padding: 0.35rem 0.6rem; font-size: 0.82rem; }
.dm-section h4 { margin: 0 0 0.5rem; }
/* minmax(0, max-content): each column hugs its table, but can still give way
   when the two together would overflow the card. */
.dm-two { display: grid; grid-template-columns: repeat(2, minmax(0, max-content));
  gap: 1.5rem 2.5rem; align-items: start; justify-content: start; margin-top: 0.9rem; }
.dm-two > * { min-width: 0; }
@media (max-width: 900px) { .dm-two { grid-template-columns: 1fr; } }
/* Tables size to their contents rather than stretching to the card. A broker
   copies these straight into a client report, and a table stretched to 1300px
   pastes as a row of numbers marooned at opposite edges of the page. */
.dm-table { width: auto; max-width: 100%; font-size: 0.86rem; }
.dm-table th, .dm-table td { padding: 0.45rem 0.6rem; }
.dm-table th { letter-spacing: 0.04em; }
.dm-table th:first-child, .dm-table td:first-child { padding-left: 0.15rem; }
.dm-table th.num, .dm-table td.num { padding-left: 1.5rem; }
.dm-table th.num, .dm-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dm-table th.c { text-align: center; }
.dm-table tr.total td { font-weight: 800; border-top: 1px solid var(--border-strong); border-bottom: none; }
.dm-table td small { display: block; color: var(--muted); font-weight: 500; font-size: 0.76rem; }
.dm-foot { color: var(--muted); font-size: 0.8rem; line-height: 1.5; margin: 0.8rem 0 0; }
.is-good { color: var(--good); font-weight: 700; }
.is-bad { color: var(--danger); font-weight: 700; }
.dm-chart { max-width: 560px; }
/* The grid columns size to their contents now, so the charts need a width of
   their own -- an SVG with no intrinsic size would otherwise collapse. */
.dm-two .chart-wrap, .dm-section > .chart-wrap { width: 520px; max-width: 100%; }
.bar-good { fill: var(--good); }
.bar-bad { fill: var(--danger); }

.dm-icon { --dm-icon-bg: var(--ink); display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 12px; background: var(--ink); color: var(--accent); vertical-align: middle; }
.dm-icon svg { width: 22px; height: 22px; }
.dm-icon-lg { width: 52px; height: 52px; flex-basis: 52px; border-radius: 16px; }
.dm-icon-lg svg { width: 30px; height: 30px; }
.dm-icon-sm { width: 26px; height: 26px; flex-basis: 26px; border-radius: 8px; margin-right: 0.5rem; }
.dm-icon-sm svg { width: 15px; height: 15px; }
.dm-h3 { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.3rem; }
.dm-head-title { display: flex; align-items: center; gap: 1rem; }
.dm-report-head { border-top: 4px solid var(--accent); }
.dm-head-row { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.dm-head-row h2 { margin: 0; font-size: 1.5rem; }
/* The headline numbers read as a row of small cards rather than loose text --
   this is the first thing a client looks at, so it earns the emphasis. */
.dm-head-stats { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.dm-head-stats div {
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  min-width: 92px; padding: 0.6rem 0.85rem; border-radius: var(--radius);
  background: var(--surface-sunken); border: 1px solid var(--border);
}
.dm-head-stats b { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dm-head-stats span { font-size: 0.66rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; text-align: center; }
.dm-head-stats div.is-good { background: var(--good-bg); border-color: #cfe6d8; }
.dm-head-stats div.is-good b { color: var(--good); }
.dm-head-stats div.is-bad { background: var(--danger-bg); border-color: #f2c9c1; }
.dm-head-stats div.is-bad b { color: var(--danger); }
.dm-head-stats div.is-good span, .dm-head-stats div.is-bad span { color: inherit; opacity: 0.75; }

.dm-plan { border-top: 1px dashed var(--border-strong); padding-top: 1.1rem; margin-top: 1.1rem; }
.dm-plan:first-of-type { border-top: none; padding-top: 0.5rem; }
.dm-plan h4 { display: flex; align-items: center; }
.dm-plan h4 { font-size: 1.05rem; text-transform: none; letter-spacing: -0.01em; color: var(--text); margin-bottom: 0.7rem; }
.dm-plan h4 small { font-weight: 500; color: var(--muted); font-size: 0.82rem; margin-left: 0.5rem; text-transform: none; letter-spacing: 0; }
.dm-plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, max-content));
  gap: 1.2rem 2.5rem; align-items: start; justify-content: start; }
@media (max-width: 900px) { .dm-plan-grid { grid-template-columns: 1fr; } }
.dm-sources ul { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.82rem; color: var(--muted); }
.dm-sources li { margin: 0.15rem 0; }

@media print {
  .no-print, .dm-main .av-toolbar, #setup-card, #review-card { display: none !important; }
  .dm-main { max-width: 100%; }
  /* Sections flow across pages; the pieces a reader needs to see whole -- a
     table, a chart with its legend, one plan's block -- are what stay together. */
  .dm-section { border-bottom: 1px solid #ddd; padding: 0.5rem 0 0.7rem; margin: 0; }
  .dm-section .dm-table, .dm-section .chart-wrap, .dm-plan, .dm-head-row,
  .dm-two > * { page-break-inside: avoid; }
  .dm-h3 { page-break-after: avoid; }
  /* A footnote belongs with the table it explains, never stranded at the top
     of the next page. */
  .dm-foot { page-break-before: avoid; }
  .dm-sources { page-break-inside: avoid; }
  /* A Letter page is narrower than the screen card, and a six-column table
     beside a chart does not fit -- so the paired blocks stack rather than
     losing their right-hand columns off the edge. */
  .dm-two { grid-template-columns: minmax(0, max-content); gap: 0.7rem; }
  .dm-plan-grid { grid-template-columns: repeat(3, minmax(0, max-content)); gap: 0.7rem 1.4rem; }
  .dm-two .chart-wrap, .dm-section > .chart-wrap { width: 400px; }
  .dm-table { font-size: 8.5pt; }
  .dm-table th, .dm-table td { padding: 0.22rem 0.4rem; }
  .dm-chart { max-height: 60mm; }
  .dm-head-stats b { font-size: 14pt; }
  .dm-foot { font-size: 7.5pt; }
  .dm-icon { --dm-icon-bg: #1a1917; background: #1a1917 !important; color: #f2c230 !important; }
}

/* ---- Monte Carlo -------------------------------------------------- */
/* One box per stop loss level. Laid out as a wrapping row so three or four
   sit on one line at desktop width and stack cleanly on a narrow screen. */
/* Four inputs as a 2x2 rather than a row of three and an orphan. */
.mc-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1.5rem; }
@media (max-width: 720px) { .mc-grid2 { grid-template-columns: 1fr; } }

.mc-ssl-set { border: 0; padding: 0; margin: 1rem 0 0; }
.mc-ssl-set legend { font-weight: 600; font-size: 0.86rem; padding: 0; }
.mc-ssl-boxes { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.mc-ssl-row { display: flex; align-items: center; gap: 0.15rem; }
.mc-ssl-row input { width: 8.5rem; margin: 0; font-variant-numeric: tabular-nums; }
.mc-ssl-row .icon-btn { font-size: 1rem; line-height: 1; padding: 0.2rem 0.35rem; }

/* The plain-English gloss under each percentile label. */
.mc-why { display: block; color: var(--muted); font-size: 0.76rem; font-weight: 400; line-height: 1.35; margin-top: 0.1rem; }

/* Seven columns of figures. Wrapping the headers rather than letting the
   table overflow means the whole comparison is visible at once -- which is
   the point of a comparison. */
/* .dm-table sets white-space: nowrap on numeric headers, which is right for a
   four-column table and is exactly what made this seven-column one overflow.
   Same specificity, declared later, so these win. */
.mc-ssl-table { table-layout: fixed; width: 100%; margin-top: 1rem; }
.mc-ssl-table th, .mc-ssl-table th.num {
  white-space: normal; vertical-align: bottom;
  font-size: 0.74rem; line-height: 1.25; padding-left: 0.4rem; padding-right: 0.4rem;
}
.mc-ssl-table td, .mc-ssl-table td.num {
  font-size: 0.84rem; padding-left: 0.4rem; padding-right: 0.4rem;
}
.mc-ssl-table th:first-child, .mc-ssl-table td:first-child { width: 11%; padding-left: 0.15rem; }
