/* Free Tax Estimator — v1 design system. Mobile-first. */

:root {
  --bg: #F5F6F4;
  --card: #FFFFFF;
  --ink: #16181A;
  --ink-soft: #3A3D42;
  --muted: #71767D;
  --line: #E6E8E4;
  --brand: #0E3B2C;          /* deep tax green */
  --brand-ink: #FFFFFF;
  --accent: #146C43;         /* action green */
  --refund: #157A44;
  --refund-bg: #E7F4EC;
  --owed: #A85B0B;
  --owed-bg: #FBF1E2;
  --info-bg: #EBF1FB;
  --info-ink: #1D4FA3;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16,24,20,.05), 0 8px 24px rgba(16,24,20,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; position: relative; }

.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; animation: screenIn .28s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Landing ---------- */
#screen-landing { justify-content: space-between; }
.landing-wrap { padding: calc(env(safe-area-inset-top) + 56px) 28px 24px; }
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 19px;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.landing-title {
  font-size: 40px; line-height: 1.08; letter-spacing: -.022em; font-weight: 800;
  margin: 0 0 14px;
}
.landing-sub { font-size: 18px; line-height: 1.45; color: var(--ink-soft); margin: 0 0 28px; }
.landing-points { list-style: none; margin: 0 0 34px; padding: 0; display: grid; gap: 12px; }
.landing-points li { display: flex; gap: 10px; align-items: center; font-size: 16px; font-weight: 500; }
.tick {
  width: 24px; height: 24px; border-radius: 50%; background: var(--refund-bg); color: var(--refund);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex: none;
}
.landing-note { text-align: center; color: var(--muted); font-size: 14px; margin: 14px 0 0; }

.btn-primary {
  appearance: none; border: 0; border-radius: 16px; background: var(--brand); color: var(--brand-ink);
  font-family: var(--font); font-weight: 700; font-size: 17px; padding: 17px 20px; width: 100%;
  cursor: pointer; transition: transform .08s ease, filter .15s ease;
}
.btn-primary:active { transform: scale(.985); filter: brightness(1.08); }
.btn-primary:disabled { opacity: .45; }
.btn-big { font-size: 18px; padding: 19px 20px; }

.btn-ghost {
  appearance: none; border: 0; background: none; color: var(--accent);
  font-family: var(--font); font-size: 16px; font-weight: 600; padding: 10px 4px; cursor: pointer;
  min-height: 44px;
}
.btn-secondary {
  appearance: none; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 14px; font-family: var(--font); font-weight: 600; font-size: 15px;
  padding: 13px 16px; cursor: pointer;
}
.btn-secondary:active { background: #F0F1EE; }

.disclaimer {
  padding: 18px 28px calc(env(safe-area-inset-bottom) + 22px);
  font-size: 12.5px; line-height: 1.5; color: var(--muted); text-align: center;
}

/* ---------- Loading ---------- */
#screen-loading, #screen-computing { justify-content: center; }
.loading-wrap { padding: 0 40px; text-align: center; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 26px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 8px; }
.loading-step { color: var(--muted); font-size: 15px; margin: 0 0 22px; min-height: 22px; }
.loading-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.loading-fill {
  height: 100%; width: 5%; border-radius: 99px; background: var(--brand);
  transition: width .4s ease;
}

/* ---------- Interview ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar-title { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.progress { flex: 1; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 0 6px; }
.progress-fill { height: 100%; width: 0%; background: var(--brand); border-radius: 99px; transition: width .3s ease; }
.progress-label { font-size: 13px; color: var(--muted); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

.qcard { padding: 18px 22px 30px; animation: qIn .25s ease; }
@keyframes qIn { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
.q-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 0 10px; }
.q-title { font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.18; margin: 0 0 8px; }
.q-hint { font-size: 15.5px; line-height: 1.5; color: var(--ink-soft); margin: 0 0 24px; }
.q-hint a { color: var(--accent); }

.opt-list { display: grid; gap: 12px; margin-bottom: 8px; }
.opt-card {
  appearance: none; text-align: left; width: 100%;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 17px 18px; font-family: var(--font); cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .15s ease, transform .08s ease;
  box-shadow: var(--shadow);
}
.opt-card:active { transform: scale(.985); }
.opt-card.selected { border-color: var(--brand); box-shadow: 0 0 0 1.5px var(--brand); }
.opt-card .opt-title { font-size: 17px; font-weight: 700; }
.opt-card .opt-sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.opt-check {
  margin-left: auto; width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 700;
}
.opt-card.selected .opt-check { background: var(--brand); border-color: var(--brand); }

.chip-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.chip {
  appearance: none; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 99px; padding: 12px 18px; font-family: var(--font);
  font-size: 15.5px; font-weight: 600; cursor: pointer; min-height: 48px;
}
.chip.selected { border-color: var(--brand); background: #EAF3EE; color: var(--brand); }

.money-wrap { margin-bottom: 8px; }
.money-field {
  display: flex; align-items: center; background: var(--card);
  border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 6px 6px 6px 18px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.money-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1.5px var(--brand); }
.money-field .cur { font-size: 24px; font-weight: 700; color: var(--muted); margin-right: 6px; }
.money-field input {
  border: 0; outline: 0; flex: 1; min-width: 0; background: none;
  font-family: var(--font); font-size: 30px; font-weight: 800; letter-spacing: -.02em;
  padding: 12px 8px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.money-field input::placeholder { color: #C4C7C2; font-weight: 600; }
.field-label { font-size: 15px; font-weight: 700; margin: 18px 0 8px; }
.field-label:first-child { margin-top: 0; }
.field-sub { font-size: 13.5px; color: var(--muted); margin: -4px 0 8px; }

.stepper-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.stepper-label { font-size: 16px; font-weight: 600; }
.stepper-label small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--bg); font-size: 22px; font-weight: 700; color: var(--ink);
  cursor: pointer; line-height: 1;
}
.stepper button:active { background: #E4E6E1; }
.stepper .val { font-size: 20px; font-weight: 800; min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }

.q-actions { margin-top: 26px; display: grid; gap: 10px; }
.q-skip { text-align: center; }

/* ---------- Results ---------- */
.results-body { padding: 8px 18px 10px; }
.hero-card {
  border-radius: 22px; padding: 26px 22px; margin: 6px 0 14px; color: #fff;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero-card.refund { background: linear-gradient(135deg, #0E3B2C, #146C43); }
.hero-card.owed { background: linear-gradient(135deg, #5C3A08, #A85B0B); }
.hero-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; opacity: .85; margin-bottom: 8px; }
.hero-amount { font-size: 46px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.hero-sub { margin-top: 10px; font-size: 15px; opacity: .92; line-height: 1.45; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card-title { font-size: 17px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 10px; }
.card p.body { font-size: 15px; line-height: 1.6; color: var(--ink-soft); margin: 0 0 10px; }
.card p.body:last-child { margin-bottom: 0; }

.line-row {
  appearance: none; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 13px 2px; font-family: var(--font); cursor: pointer; text-align: left;
}
.line-row:last-child { border-bottom: 0; }
.line-row:active { background: #F4F5F2; }
.line-name { font-size: 15.5px; font-weight: 600; }
.line-name .ln { color: var(--muted); font-weight: 500; font-size: 13px; display: block; }
.line-amt { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.line-row .chev { color: var(--muted); font-size: 18px; }

.pill {
  display: inline-block; font-size: 12.5px; font-weight: 700; border-radius: 99px;
  padding: 5px 12px; margin-bottom: 10px;
}
.pill.refund { background: var(--refund-bg); color: var(--refund); }
.pill.owed { background: var(--owed-bg); color: var(--owed); }

.cta-row { display: grid; gap: 10px; margin: 18px 0 8px; }

/* ---------- Lab ---------- */
.scenario-card { border: 1.5px solid var(--line); }
.delta-up { color: var(--owed); font-weight: 700; }
.delta-down { color: var(--refund); font-weight: 700; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin-top: 6px; }
.compare-table th, .compare-table td { text-align: right; padding: 9px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; }
.compare-table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.saved-row { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.saved-row:last-child { border-bottom: 0; }
.saved-name { font-weight: 700; font-size: 15.5px; flex: 1; }
.saved-meta { font-size: 13px; color: var(--muted); }
.icon-btn {
  appearance: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px;
  min-width: 44px; min-height: 44px; font-size: 16px; cursor: pointer; padding: 8px 12px;
  font-family: var(--font); font-weight: 600;
}

/* ---------- Sheet ---------- */
.sheet-scrim {
  position: fixed; inset: 0; background: rgba(10,14,12,.45); z-index: 20;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 520px; margin: 0 auto;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 22px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 82dvh; overflow-y: auto;
  animation: sheetUp .28s cubic-bezier(.32,.72,.35,1);
  box-shadow: 0 -12px 40px rgba(0,0,0,.18);
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: .6; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 6px auto 14px; }
.sheet-body h3 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; }
.sheet-body p { font-size: 15.5px; line-height: 1.62; color: var(--ink-soft); margin: 0 0 12px; }
.sheet-cite { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
#sheet-close { margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 30px); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 15px; font-weight: 600;
  padding: 13px 22px; border-radius: 99px; z-index: 30; box-shadow: var(--shadow);
  animation: toastIn .25s ease; max-width: 88vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

@media (min-width: 560px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
