/* ── Tokens ── */
:root {
  --bg:           #f0f4ff;
  --surface:      #ffffff;
  --surface2:     #e8eeff;
  --border:       #c5d0f0;
  --fg:           #0d1333;
  --fg2:          #4a5480;
  --fg3:          #8a94c0;
  --accent:       #2563eb;
  --accent-mid:   #60a5fa;
  --accent-light: #dbeafe;
  --warn:         #dc2626;
  --warn-light:   #fee2e2;
  --radius:       10px;
  --max:          820px;
  --nav-h:        60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1e; --surface: #111827; --surface2: #1e2a45;
    --border: #2d3f6b; --fg: #e8eeff; --fg2: #8a94c0; --fg3: #4a5480;
    --accent: #60a5fa; --accent-mid: #93c5fd; --accent-light: #1e3a5f;
    --warn: #f87171; --warn-light: #2d1515;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0f1e; --surface: #111827; --surface2: #1e2a45;
  --border: #2d3f6b; --fg: #e8eeff; --fg2: #8a94c0; --fg3: #4a5480;
  --accent: #60a5fa; --accent-mid: #93c5fd; --accent-light: #1e3a5f;
  --warn: #f87171; --warn-light: #2d1515;
  color-scheme: dark;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
h1,h2,h3 { text-wrap: balance; line-height: 1.2; }
a { color: var(--accent); }

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
}
.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding-left: max(16px, env(safe-area-inset-left,0px));
  padding-right: max(16px, env(safe-area-inset-right,0px));
}
.logo {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.3rem;
  color: var(--accent);
}
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a { text-decoration: none; color: var(--fg2); font-size: 0.9rem; }
.btn-nav {
  background: var(--accent);
  color: #fff !important;
  border-radius: 6px;
  padding: 0.4rem 1rem;
  font-weight: 500;
  transition: opacity .15s;
}
.btn-nav:hover { opacity: .85; }

/* ── Hero ── */
.hero {
  display: flex; align-items: center; gap: 3rem;
  max-width: var(--max); margin: 0 auto;
  padding: 4rem max(16px, env(safe-area-inset-left,0px));
  padding-right: max(16px, env(safe-area-inset-right,0px));
}
.hero-inner { flex: 1; }
.eyebrow {
  font-size: 0.75rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .75rem;
}
h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 400; margin: 0 0 1rem;
}
h1 em { font-style: italic; color: var(--accent); }
.hero-sub { color: var(--fg2); max-width: 50ch; margin: 0 0 1.5rem; font-size: 1rem; }
.btn-primary {
  display: inline-block;
  background: var(--accent); color: #fff;
  border-radius: 8px; padding: .75rem 1.5rem;
  text-decoration: none; font-weight: 600; font-size: .95rem;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }

/* Hero visual */
.hero-visual {
  flex-shrink: 0; width: 220px; height: 220px;
  position: relative; display: flex; align-items: center; justify-content: center;
}
@media (max-width: 600px) { .hero-visual { display: none; } .hero { padding-top: 2.5rem; } }
.globe-ring {
  width: 180px; height: 180px; border-radius: 50%;
  border: 2px solid var(--accent-light);
  box-shadow: 0 0 0 16px color-mix(in srgb, var(--accent) 8%, transparent);
}
.stat-float {
  position: absolute;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .9rem;
  display: flex; flex-direction: column; gap: .1rem;
  box-shadow: 0 4px 16px color-mix(in srgb, #000 10%, transparent);
}
.stat-float--1 { top: 20px; left: -10px; }
.stat-float--2 { bottom: 20px; right: -10px; }
.sf-label { font-size: .7rem; color: var(--fg3); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.sf-val { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.8rem; line-height: 1; color: var(--fg); }
.sf-accent { color: var(--accent); }

/* ── How it works ── */
.how { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 3.5rem max(16px, env(safe-area-inset-left,0px));
  padding-right: max(16px, env(safe-area-inset-right,0px));
}
h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 400;
  margin: 0 0 1.5rem;
}
.section-sub { color: var(--fg2); margin: -.8rem 0 2rem; font-size: 1.75rem; }
.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem;
}
.step { padding: 1.2rem; }
.step-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-light); color: var(--accent);
  font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.step h3 { margin: 0 0 .4rem; font-size: 1rem; font-weight: 600; }
.step p { margin: 0; color: var(--fg2); font-size: .9rem; }

/* ── Calculator section ── */
.calc-section { padding-block: 3rem; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem;
}
.card-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.1rem; font-weight: 400; margin: 0 0 1.2rem;
}
.results-card { margin-top: 1.5rem; }

/* Form */
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 140px; }
.form-group.wide { flex: 2; min-width: 200px; }
label { font-size: .78rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--fg2); }
input, select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: .5rem .75rem;
  color: var(--fg); font-family: inherit; font-size: .95rem; width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
select option { background: var(--surface); }

/* Period rows */
.periods-list { display: flex; flex-direction: column; gap: .75rem; }
.period-row {
  display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap;
  padding: 1rem; background: var(--surface2); border-radius: 8px; border: 1px solid var(--border);
}
.period-row .form-group { margin: 0; }
.btn-remove {
  background: none; border: 1px solid var(--border); color: var(--fg2);
  border-radius: 6px; padding: .5rem .75rem; cursor: pointer; font-size: 1rem;
  line-height: 1; flex-shrink: 0; align-self: flex-end; transition: color .15s, border-color .15s;
}
.btn-remove:hover { color: var(--warn); border-color: var(--warn); }
.btn-add {
  background: none; border: 1px dashed var(--accent); color: var(--accent);
  border-radius: 6px; padding: .6rem 1rem; cursor: pointer;
  font-family: inherit; font-size: .9rem; width: 100%; margin-top: .5rem;
  transition: background .15s;
}
.btn-add:hover { background: var(--accent-light); }
.btn-calc {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: .85rem 2rem; font-family: inherit; font-size: 1rem; font-weight: 500;
  cursor: pointer; width: 100%; transition: opacity .15s;
}
.btn-calc:hover { opacity: .88; }

/* Error */
.error-msg {
  background: var(--warn-light); border: 1px solid var(--warn); color: var(--warn);
  border-radius: 6px; padding: .6rem .9rem; font-size: .88rem; margin-top: .5rem; display: none;
}

/* Results */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-tile {
  background: var(--surface2); border-radius: 8px;
  padding: 1rem 1.2rem; border: 1px solid var(--border);
}
.stat-tile.hi  { background: var(--accent-light); border-color: var(--accent); }
.stat-tile.lo  { background: var(--warn-light);   border-color: var(--warn); }
.stat-label { font-size: .72rem; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--fg2); margin-bottom: .2rem; }
.stat-value { font-family: 'DM Serif Display', Georgia, serif; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-value.hi { color: var(--accent); }
.stat-value.lo { color: var(--warn); }
.stat-sub { font-size: .78rem; color: var(--fg2); margin-top: .2rem; }

/* Table */
.breakdown { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
th { text-align: left; padding: .5rem .75rem; font-size: .72rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--fg2); border-bottom: 1px solid var(--border); }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.bar-cell { min-width: 100px; }
.bar-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }

/* Compensation */
.comp-note { font-size: .88rem; color: var(--fg2); line-height: 1.6; margin-bottom: 1rem; }
.comp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: .75rem; }
.comp-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.comp-card h4 { margin: 0 0 .3rem; font-size: .85rem; font-weight: 600; }
.comp-val { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--warn); }
.comp-card p { margin: .3rem 0 0; font-size: .8rem; color: var(--fg2); }
.disclaimer { font-size: .78rem; color: var(--fg3); border-top: 1px solid var(--border); padding-top: .75rem; margin-top: .75rem; line-height: 1.5; }

/* Email card */
.email-card { background: var(--accent-light); border-color: var(--accent); }
.btn-email {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: .7rem 1.5rem; font-family: inherit; font-size: .95rem; font-weight: 500;
  cursor: pointer; margin-top: .75rem; transition: opacity .15s;
}
.btn-email:hover { opacity: .88; }
.checkbox-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .88rem; color: var(--fg2); margin-top: .5rem; cursor: pointer;
  width: fit-content;
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px; flex-shrink: 0; margin: 0; cursor: pointer;
}
.email-status { margin-top: .75rem; font-size: .88rem; }
.email-status.ok   { color: var(--accent); }
.email-status.err  { color: var(--warn); }

/* Footer */
.footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 3rem; }
.footer-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 2rem max(16px, env(safe-area-inset-left,0px));
  padding-right: max(16px, env(safe-area-inset-right,0px));
}
.footer p { color: var(--fg3); font-size: .82rem; margin: .4rem 0 0; }
/* ── New styles for mode toggle and US states (append to style.css) ── */

.mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  width: fit-content;
}
.mode-btn {
  background: var(--surface);
  border: none;
  color: var(--fg2);
  padding: 0.55rem 1.2rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid var(--border);
}
.mode-btn:last-child { border-right: none; }
.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.single-hint {
  font-size: 0.88rem;
  color: var(--fg2);
  line-height: 1.6;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.single-hint[hidden] { display: none !important; }

#btn-add-period[hidden] { display: none !important; }
