:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1c2a33;
  --ink-soft: #5a6b76;
  --navy: #1e3a5f;
  --navy-mid: #2a4f80;
  /* Color roles (SIMERP brand): navy carries ACTIONS + structure; green is reserved for
     verified positive OUTCOMES (savings, the After scenario, passing validation) so every
     green pixel means "good result", never just "button". Amber is true warnings only. */
  --action: #1e3a5f;         /* primary buttons / interactive */
  --action-hover: #2a4f80;
  --brand: #4caf6a;          /* SIMERP green — positive outcomes */
  --brand-deep: #2e7d4f;     /* green that passes AA on white for small text/borders */
  --accent: #1e3a5f;         /* navy for headings/accents */
  --amber: #f39c12;
  --warn-ink: #92400e;
  --warn-bg: #fdf3e3;
  --danger: #b03030;
  --danger-bg: #fdecec;
  --line: #d8e2ec;
  --before: #6b7884;
  --after: #4caf6a;
  --positive: #2e7d4f;
  --badge-bg: #eef3f7;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 40, 80, 0.07), 0 6px 20px rgba(20, 40, 80, 0.06);
  --focus-ring: 0 0 0 3px rgba(42, 79, 128, 0.35);
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* The results scaffolding must actually hide when [hidden]: these display rules would
   otherwise defeat the UA's [hidden] style and render an empty skeleton on page load. */
[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}

/* Header */
.site-header {
  background: var(--navy);
  color: #fff;
  padding: 0.55rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;          /* phones: nav drops below the logo instead of clipping it */
  gap: 0.25rem 0.75rem;
  min-height: 60px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

@media (max-width: 480px) {
  .site-header { padding: 0.5rem 1rem; }
  .site-logo { height: 26px; }
  .site-nav a { padding: 5px 10px; }
}

.site-logo {
  height: 34px;
  width: auto;
  /* The logo SVG is filled brand navy — knock it out to white on the navy header bar. */
  filter: brightness(0) invert(1);
}

.site-nav {
  display: flex;
  gap: 0;
}

.site-nav a {
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.site-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.site-nav a.active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 0 -2px 0 var(--brand); }

/* Legacy header brand (index.html single-page calculator) */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}
.brand-mark { font-size: 1.25rem; letter-spacing: 0.12em; font-weight: 700; }
.brand-divider { width: 1px; height: 1.2rem; background: rgba(255,255,255,.4); }
.brand-title { font-size: 1rem; font-weight: 500; }

.tagline {
  max-width: 620px;
  margin: 0.5rem auto 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.88rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
}

.intro {
  margin-top: -1.25rem;
  position: relative;
  z-index: 1;
}

.intro p {
  margin: 0 0 0.5rem;
}

.intro p:last-child {
  margin-bottom: 0;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

h1, h2, h3 {
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
  color: var(--navy);
}

/* Form */
.field {
  margin-bottom: 0.9rem;
}

.field-row {
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }
}

.field-row .field {
  flex: 1;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(42, 79, 128, 0.18);
}

fieldset.deductions {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem 0.4rem;
  margin: 0 0 0.9rem;
}

fieldset.deductions legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0 0.4rem;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.4rem;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0;
}

button {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  font-family: inherit;
}

button.primary {
  background: var(--action);
  color: #fff;
}

button.primary:hover {
  background: var(--action-hover);
}

/* The single-employee calculator form keeps its full-width submit; everywhere else
   primaries size to their label so tool screens don't grow billboard-width bars. */
form button.primary {
  width: 100%;
}

button.secondary {
  background: #fff;
  border-color: var(--navy);
  color: var(--navy);
  margin-top: 0.6rem;
  margin-right: 0.4rem;
}

button.secondary:hover {
  background: var(--navy);
  color: #fff;
}

button:disabled,
button.primary:disabled,
button.secondary:disabled {
  cursor: not-allowed;
  opacity: 1;
  background: #e6ebf1;
  border-color: transparent;
  color: var(--ink-soft);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.form-error {
  margin: 0.7rem 0 0;
  color: #b03030;
  font-size: 0.88rem;
}

/* Results */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

@media (max-width: 520px) {
  .comparison {
    grid-template-columns: 1fr;
  }
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  background: #fbfcfd;
}

.result-card.after {
  border-color: rgba(76, 175, 106, 0.4);
  background: #f3faf6;
}

.result-card h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.after-note {
  font-size: 0.72rem;
  font-weight: 600;
  color: #256b43; /* deeper than --brand-deep: 0.72rem bold on the green tint needs the margin */
  background: rgba(76, 175, 106, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.result-sub {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
}

dl {
  margin: 0;
}

.line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9rem;
}

.line dt {
  color: var(--ink-soft);
}

.line dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.line.total {
  border-bottom: none;
  border-top: 2px solid var(--line);
  margin-top: 0.3rem;
  padding-top: 0.5rem;
  font-size: 1rem;
}

.line.total dt {
  color: var(--ink);
  font-weight: 600;
}

/* Badge semantics: quiet navy is the DEFAULT (informational). Amber is opt-in for real
   warnings only — a working state module should never wear the warning color. */
.badge {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--badge-bg);
  color: var(--accent);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  vertical-align: middle;
  font-weight: 700;
}

.badge.soft {
  background: var(--badge-bg);
  color: var(--accent);
}

.badge.warn {
  background: #fdeecf;
  color: #8a6300;
}

.difference {
  margin-top: 1.1rem;
  background: var(--navy);
  color: #fff;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}


.difference-label {
  font-size: 0.82rem;
  opacity: 0.9;
}

.difference-value {
  font-size: 1.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  /* The savings figure is a verified positive outcome — the one place green speaks loudest. */
  color: #7ed6a0;
}

.difference-annual {
  color: rgba(255, 255, 255, 0.85) !important;
}

/* Census */
.census-card {
  margin-top: 1.25rem;
}

.provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.provider-list li {
  background: var(--badge-bg);
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.csv-preview {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.csv-preview summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
}

.csv-preview textarea {
  margin-top: 0.6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.admin-controls {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 0.75rem;
  align-items: end;
  margin: 0.75rem 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
}

.admin-controls .field,
.admin-controls p {
  margin: 0;
}

@media (max-width: 620px) {
  .admin-controls {
    grid-template-columns: 1fr;
  }
}

.csv-output {
  margin-top: 0.8rem;
  overflow-x: auto;
}

.csv-output table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.82rem;
}

.csv-output th,
.csv-output td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

.csv-output th {
  background: var(--badge-bg);
  color: var(--navy);
}

.csv-note {
  margin-top: 0.5rem;
}

/* Footer + utilities */
.site-footer {
  max-width: 980px;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem 2rem;
  text-align: center;
}

.muted {
  color: var(--ink-soft);
}

.small {
  font-size: 0.8rem;
}

.placeholder-note {
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Proposal section
   --------------------------------------------------------------------------- */

.proposal-card {
  max-width: 980px;
  margin: 1.5rem auto;
}

.proposal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--line);
}

.proposal-brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--navy);
}

.proposal-logo {
  height: 36px;
  width: auto;
}

.proposal-client {
  font-size: 1rem;
  font-weight: 600;
}

.proposal-date {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
}

.proposal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
}

.proposal-summary-band {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: var(--badge-bg);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}

.summary-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.proposal-roster {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.proposal-roster th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--line);
  font-weight: 600;
  white-space: nowrap;
}

.proposal-roster td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.proposal-roster tr.ineligible td {
  color: var(--ink-soft);
}

.proposal-compliance {
  font-size: 0.78rem;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.proposal-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

/* ---------------------------------------------------------------------------
   Analysis deliverable table craft — this is the artifact a client sees.
   --------------------------------------------------------------------------- */

/* Wide tables scroll inside their own container; the page never scrolls sideways. */
.table-scroll {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.table-scroll .proposal-roster {
  margin-bottom: 0;
}

/* Money reads right-aligned in tabular numerals — ragged-left currency is unscannable. */
.analysis-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.analysis-table th {
  text-align: right;
}

.analysis-table th:nth-child(-n + 3) {
  text-align: left;
}

/* Identity columns stay pinned while the money columns scroll. The # column gets a fixed
   width so the second sticky column's left offset lines up exactly (no sliver bleed). */
.analysis-table th:first-child,
.analysis-table td:first-child {
  position: sticky;
  left: 0;
  width: 2.2rem;
  min-width: 2.2rem;
  max-width: 2.2rem;
  box-sizing: border-box;
  background: var(--surface);
  z-index: 1;
}

.analysis-table th:nth-child(2),
.analysis-table td:nth-child(2) {
  position: sticky;
  left: 2.2rem;
  background: var(--surface);
  z-index: 1;
}

/* The totals line is the headline of the table — rule it like an accountant would. */
.analysis-table tr.totals-row td {
  border-top: 2px solid var(--navy);
  border-bottom: 3px double var(--navy);
  background: var(--badge-bg);
  font-weight: 700;
}

.analysis-subhead {
  font-size: 0.95rem;
  color: var(--navy);
  margin: 1.25rem 0 0.5rem;
}

.proposal-flags {
  background: var(--warn-bg);
  border: 1px solid #f0d9ab;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  margin: 1rem 0;
}

.proposal-flags ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}

.flag-mark {
  color: var(--warn-ink);
  cursor: help;
}

/* ---------------------------------------------------------------------------
   Print: isolate the proposal section, hide everything else
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Intake page — hero, drop zone, preview, confirmation
   --------------------------------------------------------------------------- */

.intake-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hero-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: #fff;
  border-color: transparent;
}

.hero-card h1 {
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-size: 1.45rem;
  margin: 0 0 .6rem;
  color: #fff;
}

.hero-card p { color: rgba(255,255,255,.85); margin: 0 0 .4rem; }
.hero-card .disclaimer {
  font-size: .78rem;
  color: rgba(255,255,255,.78);
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: .6rem;
  margin-top: .5rem;
}

.template-download-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: .5rem 1rem;
  border-radius: 7px;
  transition: background .15s;
}
.template-download-btn:hover { background: var(--navy-mid); }

.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--brand);
  background: rgba(76,175,106,.05);
}
.drop-zone-icon { font-size: 2rem; display: block; margin-bottom: .4rem; }
.drop-zone-label {
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: .95rem;
  color: var(--navy);
  margin-bottom: .25rem;
}
.drop-zone-sub { font-size: .83rem; color: var(--ink-soft); }
.drop-zone-browse { color: var(--brand-deep); font-weight: 700; text-decoration: underline; cursor: pointer; }

.provider-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .9rem;
}
.provider-row label {
  white-space: nowrap;
  margin-bottom: 0;
}

.intake-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
  margin-bottom: 1rem;
}
.intake-preview-table th {
  text-align: left;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--line);
  padding: .45rem .6rem;
}
.intake-preview-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--line);
}
.intake-preview-table tr:last-child td { border-bottom: none; }
.intake-preview-table tr:hover td { background: var(--bg); }

.detected-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: rgba(76,175,106,.1);
  color: var(--brand-deep);
  border: 1px solid rgba(76,175,106,.3);
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .55rem;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
}

/* Green means "good to submit"; a census that still has blocking errors wears navy. */
.detected-badge.neutral {
  background: var(--badge-bg);
  color: var(--navy);
  border-color: var(--line);
}

.preview-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.confirm-screen {
  text-align: center;
  padding: 1.5rem 1rem;
}
.confirm-icon {
  width: 60px;
  height: 60px;
  background: var(--brand);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.confirm-icon svg { width: 28px; height: 28px; color: #fff; }
.confirm-screen h2 { color: var(--navy); margin-bottom: .5rem; }
.confirm-screen p { color: var(--ink-soft); max-width: 400px; margin: 0 auto .5rem; }
.confirm-detail {
  display: inline-block;
  background: var(--bg);
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .82rem;
  color: var(--ink-soft);
  margin-top: .5rem;
}
.confirm-detail strong { color: var(--navy); }

/* Page footer (intake) */
.page-footer {
  background: var(--navy);
  color: rgba(255,255,255,.75);
  text-align: center;
  font-size: .75rem;
  padding: 1rem 1.5rem;
  line-height: 1.8;
}

/* ---------------------------------------------------------------------------
   Print: isolate the proposal section, hide everything else
   --------------------------------------------------------------------------- */

@media print {
  /* The analysis runs 12+ money columns — portrait Letter cannot hold it. */
  @page {
    size: letter landscape;
    margin: 12mm;
  }

  body > * {
    display: none !important;
  }

  #proposal-section {
    display: block !important;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    max-width: 100%;
  }

  .proposal-actions {
    display: none !important;
  }

  .table-scroll {
    overflow: visible;
  }

  .analysis-table th,
  .analysis-table td {
    position: static !important; /* sticky columns don't print */
  }

  .proposal-roster th,
  .proposal-roster td {
    font-size: 0.72rem;
    padding: 0.25rem 0.4rem;
  }
}

/* ---------------------------------------------------------------------------
   Wizard stepper — shared by the admin workflow and the client intake.
   --------------------------------------------------------------------------- */

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
  flex-wrap: wrap;
}

.wiz-step {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: none;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: default;
}

.wiz-step .wiz-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--badge-bg);
  color: var(--ink-soft);
  font-size: 0.8rem;
  flex: none;
}

.wiz-step.current { color: var(--navy); }
.wiz-step.current .wiz-num { background: var(--navy); color: #fff; }

.wiz-step.done { color: var(--brand-deep); }
.wiz-step.done .wiz-num { background: var(--brand-deep); color: #fff; }

.wiz-step.clickable { cursor: pointer; }
.wiz-step.clickable:hover { background: var(--badge-bg); }

.wiz-connector {
  flex: 0 0 1.75rem;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
}

/* The always-visible "here's your single next action" line. */
.next-cue {
  background: var(--badge-bg);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  color: var(--navy);
  font-weight: 600;
  margin: 0.5rem 0 1rem;
}

.next-cue:empty { display: none; }
