:root {
  --ink: #17181c;
  --ink-soft: #5b5e68;
  --paper: #ffffff;
  --surface: #f7f6fb;
  --border: #e6e4ee;
  --purple: #6d28d9;
  --purple-dark: #5b21b6;
  --purple-tint: #f1ecfd;
  --good: #1f7a4c;
  --good-bg: #e9f6ee;
  --warn: #9a5b00;
  --warn-bg: #fdf1de;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(23,24,28,0.04), 0 8px 24px -12px rgba(23,24,28,0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a { color: var(--purple); }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Landing / auth ---- */
.landing-hero {
  padding: 64px 20px 8px;
  text-align: center;
}
.landing-hero-inner { max-width: 640px; margin: 0 auto; }
.landing-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  margin: 14px 0 16px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.landing-lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0 auto;
  max-width: 56ch;
}
.hero-shot { max-width: 820px; margin: 0 auto; padding: 0 20px; }
.hero-shot img {
  width: 100%;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.landing-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 56px;
}
.auth-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 40px;
  max-width: 420px;
  width: 100%;
}
.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.landing-main .brand { display: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--purple); display: inline-block; }
.auth-card h2 {
  font-size: 1.3rem;
  margin: 4px 0 22px;
  letter-spacing: -0.01em;
  text-align: center;
}
.auth-foot {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 18px 0 0;
}

.section-narrow { width: 100%; max-width: 780px; }
.section-title {
  text-align: center;
  font-size: 1.4rem;
  margin: 0 0 30px;
  letter-spacing: -0.01em;
}

.steps-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
@media (max-width: 680px) { .steps-row { grid-template-columns: 1fr; } }
.step {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 20px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 100px;
  background: var(--purple);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.step h3 { margin: 0 0 6px; font-size: 1rem; }
.step p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

.stakes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) { .stakes { grid-template-columns: 1fr; } }
.stakes-col {
  border-radius: 12px;
  padding: 22px 24px;
  border: 1px solid var(--border);
}
.stakes-before { background: var(--warn-bg); border-color: #f3dcae; }
.stakes-after { background: var(--good-bg); border-color: #bfe0cb; }
.stakes-col h3 { margin: 0 0 12px; font-size: 1rem; }
.stakes-before h3 { color: var(--warn); }
.stakes-after h3 { color: var(--good); }
.stakes-col ul { margin: 0; padding-left: 18px; font-size: 0.9rem; color: var(--ink); }
.stakes-col li { margin-bottom: 8px; }
.stakes-col li:last-child { margin-bottom: 0; }

.guide-note {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  padding: 0 10px;
}
.guide-note p { margin: 0 auto; max-width: 60ch; }

.landing-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
  padding: 36px 20px 48px;
}
.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.tab-btn {
  flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 8px;
  font-weight: 600; font-size: 0.9rem; color: var(--ink-soft); cursor: pointer;
}
.tab-btn.active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

form { display: flex; flex-direction: column; gap: 14px; }
label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="text"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
}
input:focus { outline: 2px solid var(--purple); outline-offset: 1px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }
.btn-danger-ghost { background: transparent; border: 1px solid var(--border); color: var(--danger); }

.error-msg { background: #fdecea; color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; display: none; }
.error-msg.show { display: block; }

/* ---- Tax estimator modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23,24,28,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin: 0 0 8px; font-size: 1.25rem; }
.modal-sub { color: var(--ink-soft); font-size: 0.88rem; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; }
.field select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
}
.result-box {
  background: var(--purple-tint);
  border-radius: 10px;
  padding: 18px 20px;
  text-align: center;
  margin-bottom: 14px;
}
.result-box .stat-value { color: var(--purple-dark); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.modal-skip {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 16px;
  cursor: pointer;
  text-decoration: underline;
}

/* ---- App shell ---- */
.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; }
.topbar .email { color: var(--ink-soft); font-size: 0.85rem; margin-right: 12px; }

main.app { padding: 28px 0 60px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
@media (max-width: 720px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.stat-card.accent { background: var(--purple); color: #fff; border-color: var(--purple); }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.75; margin-bottom: 6px; }
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-foot { font-size: 0.8rem; opacity: 0.7; margin-top: 6px; }
/* White text at 0.7/0.75 opacity on the purple accent card computes to
   4.2:1 / 4.6:1 contrast -- below (or barely at) the 4.5:1 WCAG AA minimum
   for normal-weight text this small. Raised to 0.85 here, which computes to
   ~5.5:1, comfortable margin above AA. Scoped to .accent only since the
   same classes on white cards use near-black text at ~7.8:1 and don't need
   it. */
.stat-card.accent .stat-label,
.stat-card.accent .stat-foot { opacity: 0.85; }

.pro-banner {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #f3dcae;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 16px; }
.panel h2 small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.8rem; margin-top: 2px; }

.entry-form { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; gap: 10px; align-items: end; }
@media (max-width: 640px) { .entry-form { grid-template-columns: 1fr; } }
.entry-form label { display: block; margin-bottom: 5px; }

table.entries { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.entries th { text-align: left; color: var(--ink-soft); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 6px; border-bottom: 1px solid var(--border); }
table.entries td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
table.entries tr:last-child td { border-bottom: none; }
.empty-row td { color: var(--ink-soft); text-align: center; padding: 24px 0; }

.tax-pct-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tax-pct-row input { max-width: 90px; }

.deadline-row { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.deadline-note { color: var(--ink-soft); font-size: 0.88rem; margin: 0; flex: 1; min-width: 220px; }

.period-current { font-weight: 700; color: var(--purple); }
.period-past { color: var(--ink-soft); }

/* ---- Trend sparkline (plain SVG, no charting library) ---- */
.trend-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.trend-bar-wrap { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.trend-bar { width: 100%; max-width: 34px; background: var(--purple); border-radius: 4px 4px 0 0; min-height: 3px; }
.trend-bar.zero { background: var(--border); }
.trend-label { font-size: 0.68rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.trend-empty { color: var(--ink-soft); font-size: 0.9rem; padding: 12px 0; }
