:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #61706a;
  --paper: #f5f1e7;
  --panel: #fffdf8;
  --green: #123c32;
  --green-soft: #e5f0ea;
  --mint: #d9efe5;
  --line: #ccd5d0;
  --amber: #d99a26;
  --red: #9b3c32;
  --shadow: 0 16px 44px rgba(19, 55, 46, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; overflow-wrap: anywhere; }
button, input, select { font: inherit; }
button, select, input[type="file"], .button { touch-action: manipulation; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; z-index: 20; background: #fff; padding: 10px; }
.visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 72px 28px 44px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: clamp(36px, 7vw, 88px);
  align-items: center;
}
.eyebrow { margin: 0; color: var(--green); font-size: .73rem; font-weight: 800; letter-spacing: .18em; }
.hero h1 { max-width: 760px; margin: 10px 0 20px; font: clamp(2.7rem, 6vw, 5rem)/.98 Georgia, serif; letter-spacing: -.045em; }
.lede { max-width: 720px; margin: 0; color: #4f6059; font-size: 1.12rem; }
.hero-actions, .result-actions, .completion-actions, .action-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-actions { margin-top: 26px; }
.hero-note { margin: 13px 0 0; color: var(--muted); font-size: .82rem; }
.result-preview { padding: 26px; border: 1px solid #aec5bb; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.preview-label { margin: 0 0 16px; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .14em; }
.preview-top { display: flex; align-items: baseline; gap: 10px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.preview-top strong { font: 3.2rem/1 Georgia, serif; color: var(--green); }
.preview-top span { font-weight: 700; }
.result-preview dl { margin: 14px 0; }
.result-preview dl div { display: flex; justify-content: space-between; gap: 20px; padding: 5px 0; }
.result-preview dt { color: var(--muted); }
.result-preview dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 800; }
.result-preview .preview-difference { color: var(--red); }
.result-preview > p:last-child { margin: 13px 0 0; color: var(--muted); font-size: .8rem; }

.trust-strip { max-width: 1124px; margin: 0 auto 30px; padding: 18px 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; border-block: 1px solid #becac4; }
.trust-strip div { display: grid; gap: 2px; }
.trust-strip strong { color: var(--green); font-size: .9rem; }
.trust-strip span { color: var(--muted); font-size: .78rem; }

.workspace { max-width: 1040px; margin: 0 auto 80px; padding: 0 28px; }
.status { margin-bottom: 14px; padding: 11px 14px; border-left: 4px solid var(--amber); border-radius: 6px; background: #fff7dc; }
.status.error { border-color: var(--red); background: #fff0ed; color: #74271f; }
.status.success { border-color: #28815f; background: #e9f8f0; color: #17553f; }

.stage-nav { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; border-bottom: 1px solid #aebcb6; }
.stage-nav button { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; padding: 13px 8px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; }
.stage-nav button span { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid currentColor; border-radius: 50%; font-size: .72rem; }
.stage-nav button[aria-current="step"] { border-bottom-color: var(--green); color: var(--green); }
.stage-nav button:disabled { opacity: .42; cursor: not-allowed; }
.mobile-progress { display: none; }

.workflow-shell { overflow: hidden; border: 1px solid #b8c5bf; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.workflow-stage + .workflow-stage { border-top: 1px solid var(--line); }
.stage-header { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 18px 24px; border: 0; background: #faf8f1; color: var(--ink); text-align: left; cursor: pointer; }
.workflow-stage.active .stage-header { background: var(--panel); }
.stage-number { white-space: nowrap; color: #4f6059; font: 1.15rem Georgia, serif; }
.stage-heading { min-width: 0; display: grid; gap: 2px; }
.stage-h { margin: 0; font: inherit; }
.stage-heading .stage-title { margin: 0; font: 1.45rem Georgia, serif; }
.stage-heading small { color: var(--muted); }
.stage-edit { color: var(--green); font-size: .78rem; font-weight: 800; }
.workflow-stage:not(.complete) .stage-edit { visibility: hidden; }
.stage-content { padding: 6px clamp(22px, 5vw, 52px) 42px; }
.stage-intro { max-width: 700px; margin: 0 0 20px; color: var(--muted); }
.setup-block + .setup-block { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.subheading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.subheading h3, .result-heading h3, .completion h3, .calculation-content h3 { margin: 0; font: 1.25rem Georgia, serif; }
.subheading p, .result-heading p, .completion p { margin: 0; color: var(--muted); font-size: .84rem; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 17px; border: 1px solid var(--green); border-radius: 11px; background: #fff; color: var(--green); cursor: pointer; font-weight: 800; text-align: center; text-decoration: none; }
.button.primary { background: var(--green); color: #fff; }
.button.secondary { background: #fff; }
.button.quiet { min-height: 44px; border-color: var(--line); padding: 7px 12px; }
.button.danger { border-color: #c9a39e; color: #7e3028; background: #fff9f7; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.audit-button { margin-top: 25px; }

label { display: grid; gap: 6px; color: #32433d; font-size: .84rem; font-weight: 750; }
input, select { width: 100%; min-width: 0; min-height: 44px; padding: 9px 10px; border: 1px solid #aebdb7; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, button:focus-visible, .button:focus-within, summary:focus-visible { outline: 3px solid rgba(33, 126, 91, .25); outline-offset: 2px; }
.muted, .empty { color: var(--muted); }

.privacy-inline { display: flex; flex-wrap: wrap; gap: 7px 12px; margin: 17px 0 8px; padding: 12px 14px; border-left: 3px solid #60a586; background: var(--green-soft); font-size: .84rem; }
.privacy-inline strong { color: var(--green); }
.local-details, .advanced-details, .calculation-details { margin: 10px 0 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
details > summary { padding: 12px 14px; cursor: pointer; color: var(--green); font-weight: 800; }
.local-details p { margin: 0; padding: 0 14px 14px; color: var(--muted); font-size: .84rem; }

.mapping-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 13px; }
.mapping-item { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.mapping-item p { margin: 5px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.35; }
.rate-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.advanced-details { margin-top: 17px; }
.advanced-rates { padding: 3px 14px 14px; }
.advanced-details > .muted, .advanced-details > .button { margin-left: 14px; margin-right: 14px; }
.advanced-details > .button { margin-bottom: 14px; }

.result-hero { margin: 2px 0 30px; padding: 26px; border-radius: 14px; background: var(--green); color: #fff; }
.result-hero .eyebrow { color: #9ed5bc; }
.result-metrics { display: grid; grid-template-columns: 1.15fr 1.15fr 1fr 1fr; gap: 1px; margin: 17px 0 22px; background: rgba(255,255,255,.24); }
.metric { min-width: 0; padding: 15px; background: var(--green); }
.metric small { display: block; color: #c6ddd3; font-size: .75rem; }
.metric strong { display: block; margin-top: 4px; color: #fff; font: 1.65rem/1.15 Georgia, serif; font-variant-numeric: tabular-nums; }
.metric.emphasized { box-shadow: inset 0 3px 0 0 var(--mint); }
.metric.emphasized strong { color: var(--mint); font-size: 2.05rem; }
.result-hero .button.primary { border-color: #fff; background: #fff; color: var(--green); }
.result-hero .button.secondary { border-color: rgba(255,255,255,.62); background: transparent; color: #fff; }
.result-limit { max-width: 780px; margin: 17px 0 0; color: #c6ddd3; font-size: .78rem; }

.flag-section { scroll-margin-top: 18px; }
.result-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 14px; }
.result-heading label { grid-template-columns: auto 160px; align-items: center; }
.anomaly-list { display: grid; gap: 10px; }
.anomaly { padding: 16px 17px; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 9px; background: #fff; }
.anomaly.high { border-left-color: var(--red); }
.anomaly h3 { margin: 0 0 7px; font-size: 1rem; }
.anomaly p { margin: 5px 0; }
.anomaly code { display: block; padding: 8px 9px; border-radius: 6px; background: #f2f0e9; white-space: normal; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.severity { padding: 2px 6px; border-radius: 5px; background: #f3e1ac; font-size: .68rem; font-weight: 700; text-transform: uppercase; }

.calculation-details { margin-top: 25px; }
.calculation-content { padding: 0 14px 16px; }
.calculation-content h3 { margin: 22px 0 10px; }
.comparison { margin-top: 10px; padding: 12px; border-radius: 8px; background: var(--green-soft); font-variant-numeric: tabular-nums; }
.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; min-width: 680px; border-collapse: collapse; background: #fff; font-variant-numeric: tabular-nums; }
.data-table caption { padding: 10px 12px; background: var(--green-soft); text-align: left; font-weight: 800; }
.data-table th, .data-table td { padding: 9px 11px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { color: var(--muted); font-size: .76rem; }

.completion { display: flex; justify-content: space-between; gap: 22px; align-items: center; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.planned-card { display: flex; gap: 10px 16px; margin-top: 20px; padding: 14px 16px; border-radius: 9px; background: var(--mint); }
.planned-card span { color: #476057; font-size: .84rem; }
.boundary { margin-top: 26px; padding: 20px 2px; border-top: 1px solid #becac4; }
.boundary h2 { margin: 0 0 5px; font: 1.25rem Georgia, serif; }
.boundary p { margin: 0; color: var(--muted); }

@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; padding-top: 44px; }
  .result-preview { max-width: 520px; }
  .trust-strip { grid-template-columns: 1fr; gap: 12px; margin-inline: 20px; }
  .stage-nav { display: none; }
  .mobile-progress { display: block; margin-bottom: 12px; }
  .mobile-progress p { margin: 0 0 6px; color: var(--green); font-size: .8rem; font-weight: 800; }
  .progress-track { overflow: hidden; height: 7px; border-radius: 4px; background: #d7dfdb; }
  .progress-track span { display: block; width: 33.333%; height: 100%; background: var(--green); transition: width .2s ease; }
  .mapping-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-heading, .completion { align-items: stretch; flex-direction: column; }
  .result-heading label { grid-template-columns: auto 1fr; }
}

@media (max-width: 480px) {
  .hero, .workspace { padding-left: 16px; padding-right: 16px; }
  .hero h1 { font-size: 2.65rem; }
  .hero-actions .button, .action-grid .button { width: 100%; }
  .trust-strip { margin-inline: 16px; }
  .workflow-shell { border-radius: 13px; }
  .stage-header { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; padding: 15px 16px; }
  .stage-heading .stage-title { font-size: 1.25rem; }
  .stage-content { padding: 4px 16px 28px; }
  .mapping-grid, .rate-grid { grid-template-columns: 1fr; }
  .privacy-inline { display: grid; }
  .result-hero { margin-inline: -4px; padding: 20px 16px; }
  .result-metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 12px 9px; }
  .metric strong { font-size: 1.4rem; }
  .metric.emphasized strong { font-size: 1.7rem; }
  .result-actions .button, .completion-actions .button { width: 100%; }
  .completion-actions { display: grid; }
  .planned-card { display: grid; }
  .data-table { min-width: 620px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
  .button:hover:not(:disabled) { transform: none; }
}

@media print {
  .hero, .trust-strip, .status, .mobile-progress, .stage-nav, #stage-add, #stage-setup, .stage-header, .result-actions, .completion, .planned-card, .boundary { display: none !important; }
  body, .workspace, .workflow-shell, .stage-content, .result-hero { margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; color: #000; }
  #stage-review { display: block !important; }
  .result-hero .eyebrow, .result-limit, .metric small, .metric strong, .metric.emphasized strong { color: #000; }
  .result-metrics, .metric { background: #fff; }
  .metric.emphasized { box-shadow: none; }
  .calculation-details { display: block; }
  .calculation-details > .calculation-content { display: block; }
  .table-scroll { overflow: visible; border: 0; }
  .data-table { min-width: 0; font-size: 10px; }
  .data-table th, .data-table td { padding: 5px; white-space: normal; }
  .anomaly { break-inside: avoid; }
}
