/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #0b0f14;
  --bg-soft: #10161d;
  --surface: #151d26;
  --surface-2: #1b2530;
  --border: #263241;
  --text: #eef2f6;
  --text-dim: #9fb0c0;
  --text-faint: #6b7c8d;
  --accent: #ff5a36;
  --accent-dim: #d8461f;
  --accent-ink: #1a0800;
  --good: #33c17b;
  --warn: #ffb347;
  --cream: #fff7f0;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

@media (prefers-color-scheme: light) {
  :root:not([data-force-dark]) {
    --bg: #f6f7f9;
    --bg-soft: #ffffff;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e6ea;
    --text: #14181d;
    --text-dim: #5a6672;
    --text-faint: #8b97a3;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; font-weight: 700; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--cream); color: #111;
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.container { max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* =============================================================
   3. Typography
   ============================================================= */
h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.2rem; }
.eyebrow {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); font-weight: 600;
}
.lede { color: var(--text-dim); font-size: 1.1rem; max-width: 60ch; }

/* =============================================================
   4. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.5rem; border-radius: 999px; font-weight: 600; font-size: .95rem;
  transition: transform .35s var(--ease-out), background .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); transform: translateY(-2px); box-shadow: 0 12px 28px -10px rgba(255,90,54,.55); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn-sm { padding: .55rem 1.1rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.75rem;
}

.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .04em;
  padding: .35rem .7rem; border-radius: 999px; font-weight: 600;
}
.badge-demo { background: rgba(255,179,71,.14); color: var(--warn); border: 1px solid rgba(255,179,71,.35); }
.badge-live { background: rgba(51,193,123,.14); color: var(--good); border: 1px solid rgba(51,193,123,.35); }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .5rem 1rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
}

/* Form */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; color: var(--text-dim); font-weight: 600; }
.field input, .field select {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .8rem 1rem; color: var(--text); font: inherit; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field-error { border-color: #e05252 !important; }
.field-error-msg { color: #ff8787; font-size: .8rem; }

/* Toast (never alert()) */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: .9rem 1.3rem; border-radius: var(--radius-sm); font-size: .9rem;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
  z-index: 999; max-width: 90vw;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { border-color: #e05252; }
.toast.is-success { border-color: var(--good); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,8,11,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  z-index: 998; opacity: 0; pointer-events: none; transition: opacity .3s var(--ease-out);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 460px; width: 100%; padding: 2rem; transform: translateY(12px); transition: transform .3s var(--ease-out);
}
.modal-overlay.is-open .modal { transform: translateY(0); }
.modal-close { position: absolute; top: 1rem; right: 1rem; }

/* =============================================================
   5. Header / nav
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; }
.logo-mark { width: 30px; height: 30px; color: var(--accent); }
.nav-links { display: none; gap: 2rem; }
.nav-links a { color: var(--text-dim); font-weight: 500; font-size: .93rem; transition: color .25s var(--ease-out); }
.nav-links a:hover { color: var(--text); }
.header-cta { display: flex; align-items: center; gap: .75rem; }

/* App top bar */
.app-bar {
  position: sticky; top: 0; z-index: 40; background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
.app-bar .container { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 1rem; }
.credits-pill { font-family: var(--mono); }
.account-menu { position: relative; }
.account-trigger { display: flex; align-items: center; gap: .5rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.account-dropdown {
  position: absolute; right: 0; top: calc(100% + .6rem); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 180px; padding: .4rem; display: none; box-shadow: 0 20px 40px -20px rgba(0,0,0,.5);
}
.account-dropdown.is-open { display: block; }
.account-dropdown a, .account-dropdown button {
  display: block; width: 100%; text-align: left; padding: .6rem .8rem; border-radius: 6px; font-size: .9rem;
}
.account-dropdown a:hover, .account-dropdown button:hover { background: var(--surface-2); }

/* =============================================================
   6. Sections — landing
   ============================================================= */
section { padding: clamp(3rem, 8vw, 6.5rem) 0; }

.hero { padding-top: clamp(3.5rem, 10vw, 7rem); }
.hero-grid { display: grid; gap: 2.5rem; align-items: center; }
.hero-copy .eyebrow { margin-bottom: 1rem; }
.hero-copy h1 { margin-bottom: 1.1rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: 1.6rem; }
.hero-note { color: var(--text-faint); font-size: .85rem; margin-top: .9rem; }

.hero-demo {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  background: var(--surface);
}
.demo-toggle { display: flex; border-bottom: 1px solid var(--border); }
.demo-toggle button {
  flex: 1; padding: .8rem; font-size: .85rem; font-weight: 600; color: var(--text-dim);
  border-bottom: 2px solid transparent;
}
.demo-toggle button.is-active { color: var(--text); border-color: var(--accent); }
.demo-panel { padding: 1.25rem; display: none; }
.demo-panel.is-active { display: block; }
.demo-panel img, .demo-panel svg { border-radius: var(--radius-sm); border: 1px solid var(--border); }
.demo-caption { color: var(--text-faint); font-size: .82rem; margin-top: .7rem; text-align: center; }

.section-head { max-width: 640px; margin-bottom: 2.5rem; }
.section-head .eyebrow { margin-bottom: .8rem; }

.diff-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.diff-card { padding: 1.6rem; }
.diff-card .num { font-family: var(--mono); color: var(--accent); font-size: .82rem; margin-bottom: .8rem; }

.steps { counter-reset: step; display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.step { position: relative; padding-left: 3.2rem; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: var(--mono);
}
.step h3 { margin-bottom: .4rem; }
.step p { color: var(--text-dim); font-size: .93rem; }

/* Pricing */
.pricing-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: stretch; }
.plan-card { display: flex; flex-direction: column; position: relative; }
.plan-card.is-popular { border-color: var(--accent); }
.plan-popular-tag {
  position: absolute; top: -12px; left: 1.5rem; background: var(--accent); color: #fff;
  font-size: .72rem; font-weight: 700; padding: .3rem .7rem; border-radius: 999px; letter-spacing: .03em;
}
.plan-name { color: var(--text-dim); font-weight: 600; margin-bottom: .6rem; }
.plan-price { display: flex; align-items: baseline; gap: .3rem; margin-bottom: .3rem; }
.plan-price .amount { font-size: 2.4rem; font-weight: 800; }
.plan-price .period { color: var(--text-faint); font-size: .9rem; }
.plan-blurb { color: var(--text-faint); font-size: .85rem; margin-bottom: 1.4rem; }
.plan-features { list-style: none; display: flex; flex-direction: column; gap: .6rem; margin: 1.4rem 0; flex: 1; }
.plan-features li { display: flex; gap: .6rem; font-size: .9rem; color: var(--text-dim); align-items: flex-start; }
.plan-features li svg { flex-shrink: 0; width: 18px; height: 18px; color: var(--good); margin-top: 2px; }

.payg-note { text-align: center; color: var(--text-faint); font-size: .88rem; margin-top: 2rem; }

.faq-list { max-width: 760px; }
.faq-item { border-bottom: 1px solid var(--border); padding: 1.3rem 0; }
.faq-item summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item p { color: var(--text-dim); margin-top: .8rem; font-size: .93rem; }

.final-cta { text-align: center; }
.final-cta .btn { margin-top: 1.5rem; }

.site-footer { border-top: 1px solid var(--border); padding: 3rem 0; color: var(--text-faint); font-size: .85rem; }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2rem; }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a:hover { color: var(--text); }

/* =============================================================
   7. App shell
   ============================================================= */
.app-main { padding-top: 2.5rem; padding-bottom: 4rem; }
.tool-grid { display: grid; gap: 2rem; grid-template-columns: 1fr; }
.tool-card { padding: 2rem; }
.address-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.address-row .field { flex: 1; min-width: 240px; margin-bottom: 0; }
.cost-line { display: flex; align-items: center; justify-content: space-between; margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px dashed var(--border); font-size: .9rem; color: var(--text-dim); }

[data-state] .state-idle, [data-state] .state-working, [data-state] .state-done, [data-state] .state-error { display: none; }
[data-state="idle"] .state-idle { display: block; }
[data-state="working"] .state-working { display: block; }
[data-state="done"] .state-done { display: block; }
[data-state="error"] .state-error { display: block; }

.spinner { width: 42px; height: 42px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 1.5rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.working-box { text-align: center; padding: 2.5rem 1rem; color: var(--text-dim); }

.report-summary-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 1.5rem 0; }
.stat-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.stat-tile .label { font-size: .74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.stat-tile .value { font-size: 1.4rem; font-weight: 800; margin-top: .3rem; }

table.measure-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.measure-table th, table.measure-table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
table.measure-table th { color: var(--text-faint); font-weight: 600; font-size: .78rem; text-transform: uppercase; }

.diagram-wrap { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .8rem; font-size: .78rem; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

.quote-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.2rem; margin-top: 1.5rem; }
.quote-row { display: flex; justify-content: space-between; padding: .45rem 0; font-size: .9rem; }
.quote-row.total { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .8rem; font-weight: 700; font-size: 1.05rem; }

.api-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; font-family: var(--mono); font-size: .82rem; overflow-x: auto; white-space: pre; }

/* Account page */
.account-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.history-row { display: flex; justify-content: space-between; padding: .7rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.history-row .muted { color: var(--text-faint); }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .demo-toggle button { font-size: .9rem; }
}
@media (min-width: 720px) {
  .nav-links { display: flex; }
}
@media (min-width: 960px) {
  .hero-grid { grid-template-columns: 1.1fr 1fr; }
  .tool-grid { grid-template-columns: 320px 1fr; }
  .account-grid { grid-template-columns: 280px 1fr; }
}

/* =============================================================
   9. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation-duration: 1.6s; }
}

/* Print (report PDF-ish view) */
@media print {
  .site-header, .app-bar, .site-footer, .no-print { display: none !important; }
}
