/* Revenue Rescue Audit — calculator styles.
   Brand: navy #0F2A43 · recovery green #1E9E62 · leak red #E04A2F.
   Themed: dark is the default; light via :root[data-theme="light"].
   The client report (.report-doc) and print stay light on purpose. */

:root {
  /* Brand (theme-independent) */
  --navy: #0f2a43;
  --navy-600: #21486b;
  --green: #1e9e62;
  --green-700: #17784a;
  --green-300: #7fe0ac;
  --red: #e04a2f;
  --red-700: #b43a24;
  --leak: #ff8a6f;

  /* Themeable — DARK defaults */
  --bg: #0b1b2b;
  --card: #12283f;
  --card-soft: #16324e;
  --ink: #e7eef5;
  --muted: #9fb3c4;
  --line: #263d55;
  --field-bg: #0e2135;
  --field-border: #2c465f;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f4f6f8;
  --card: #ffffff;
  --card-soft: #f2f8f4;
  --ink: #14202b;
  --muted: #5c6b78;
  --line: #dde4ea;
  --field-bg: #ffffff;
  --field-border: #dde4ea;
  --shadow: 0 1px 2px rgba(15, 42, 67, 0.06), 0 8px 24px rgba(15, 42, 67, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

/* ── Hero (navy in both themes) ───────────────────────────────────────────── */
.hero {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-600) 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}
.hero-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-mark { color: var(--green); font-size: 18px; }
.hero-title { font-weight: 700; font-size: 20px; letter-spacing: 0.2px; }
.hero-method { color: #9fc7dd; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.hero-figures { display: flex; gap: 30px; align-items: flex-end; }
.hero-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #9fc7dd; }
.hero-number {
  display: block;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.05;
  color: #fff;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}
.hero-number.leaking { color: var(--leak); }
.hero-range { display: block; font-size: 12px; color: #b9cfe0; }
.hero-score { text-align: right; }
.hero-score-number { display: block; font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Theme toggle */
.theme-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 17px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.22); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.form { display: grid; gap: 18px; }

/* Intro (owner-facing) */
.intro {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  text-align: center;
}
.intro h1 { margin: 0 0 10px; font-size: 24px; color: var(--ink); }
.intro p { margin: 0 auto; color: var(--muted); font-size: 15px; max-width: 66ch; }
.intro strong { color: var(--green); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 17px; color: var(--ink); }
.card-hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.card-business { border-top: 4px solid var(--navy-600); }

.leak { border-left: 4px solid var(--green); }
.leak-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.leak-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; }
.leak-k {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--navy-600); color: #fff;
  border-radius: 8px; font-size: 12px; font-weight: 700;
}
.leak-live {
  font-variant-numeric: tabular-nums; font-weight: 700;
  color: var(--green-300);
  background: rgba(30, 158, 98, 0.18);
  padding: 4px 12px; border-radius: 999px; font-size: 13.5px; text-align: right;
}
:root[data-theme="light"] .leak-live { color: var(--green-700); background: rgba(30, 158, 98, 0.1); }
.leak-live.skip { color: var(--muted); background: rgba(127, 143, 158, 0.15); font-weight: 600; }

/* ── Form controls ───────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: stretch; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink); }
/* Push the control to the bottom so inputs align even when labels wrap or carry a hint line. */
.grid label > input, .grid label > select { margin-top: auto; }
label.req > :first-child::after { content: " *"; color: var(--red); }
.opt { font-weight: 500; color: var(--muted); font-size: 11.5px; }
input[type="number"], input[type="text"], input[type="email"], input[type="tel"], select {
  font: inherit; font-size: 15px; padding: 9px 11px;
  border: 1px solid var(--field-border); border-radius: 9px;
  background: var(--field-bg); color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(30, 158, 98, 0.2); }
input.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(224, 74, 47, 0.16); }
.checkline { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 600; }
.checkline input { width: 17px; height: 17px; accent-color: var(--green); }

/* ── Messages ────────────────────────────────────────────────────────────── */
.messages { display: grid; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 9px; font-size: 13.5px; }
.msg-warn { background: rgba(255, 176, 32, 0.14); border: 1px solid rgba(255, 176, 32, 0.4); color: #e0a53a; }
.msg-error { background: rgba(224, 74, 47, 0.14); border: 1px solid rgba(224, 74, 47, 0.4); color: var(--leak); }
:root[data-theme="light"] .msg-warn { background: #fff4e5; border-color: #ffd9a8; color: #8a5300; }
:root[data-theme="light"] .msg-error { background: #fdeae6; border-color: #f5c1b5; color: var(--red-700); }

/* ── Actions ─────────────────────────────────────────────────────────────── */
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.btn { font: inherit; font-weight: 700; font-size: 14px; padding: 11px 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; transition: transform 0.05s, background 0.15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-ghost { background: var(--card-soft); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--green); }

/* ── Report (always light — it's a client document) ──────────────────────── */
.report {
  margin-top: 30px; display: none;
  --card: #ffffff; --ink: #14202b; --muted: #5c6b78; --line: #dde4ea;
}
.report.show { display: block; }
.report-doc { background: #fff; border: 1px solid #dde4ea; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.rep-cover { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-600) 100%); color: #fff; padding: 34px 40px; }
.rep-cover .rep-for { font-size: 13px; color: #9fc7dd; }
.rep-cover h1 { margin: 4px 0 22px; font-size: 24px; font-weight: 700; }
/* Grid keeps the three figures top-aligned regardless of the sub-range line. */
.rep-cover-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, max-content)); gap: 20px 48px; align-items: start; }
.rep-cover-figs .fig { display: flex; flex-direction: column; gap: 4px; }
.rep-sub { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: #9fc7dd; }
.rep-bignum { font-size: 42px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; }
.rep-bignum.red { color: var(--leak); }
.rep-scorebadge { font-size: 42px; font-weight: 800; line-height: 1.05; }

.rep-body { padding: 30px 40px; }
.rep-section { margin-bottom: 34px; }
.rep-section > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--green-700); border-bottom: 2px solid #dde4ea; padding-bottom: 7px; margin: 0 0 16px; }

.leak-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid #dde4ea; }
.leak-row:last-child { border-bottom: none; }
.leak-row .k { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--navy); color: #fff; border-radius: 8px; font-size: 11px; font-weight: 700; }
.leak-row .name { font-weight: 700; color: var(--navy); }
.leak-row .explain { font-size: 13.5px; color: #5c6b78; margin-top: 3px; }
.leak-row .dollars { text-align: right; font-variant-numeric: tabular-nums; }
.leak-row .dollars .big { font-size: 20px; font-weight: 800; color: var(--red-700); }
.leak-row .dollars .rng { font-size: 12px; color: #5c6b78; }
.tag-est { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #8a5300; background: #fff4e5; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }

.db-block { background: #f2f8f4; border: 1px solid #cfe8da; border-radius: 12px; padding: 18px 20px; }
.db-block h3 { margin: 0 0 10px; color: var(--green-700); font-size: 15px; }
.db-figs { display: flex; gap: 34px; flex-wrap: wrap; }
.db-figs .f .n { font-size: 24px; font-weight: 800; color: var(--green-700); font-variant-numeric: tabular-nums; }
.db-figs .f .l { font-size: 12px; color: #5c6b78; }

.scenarios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.scen { border: 1px solid #dde4ea; border-radius: 12px; padding: 16px; text-align: center; }
.scen.likely { border-color: var(--green); box-shadow: 0 0 0 2px rgba(30, 158, 98, 0.18); }
.scen .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #5c6b78; }
.scen .amt { font-size: 24px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; margin: 4px 0; }
.scen .per { font-size: 12px; color: #5c6b78; }
.scen.likely .lbl { color: var(--green-700); font-weight: 700; }

.attack { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.attack li { display: grid; grid-template-columns: 30px 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid #dde4ea; }
.attack li:last-child { border-bottom: none; }
.attack li::before { counter-increment: step; content: counter(step); display: inline-grid; place-items: center; width: 28px; height: 28px; background: var(--green); color: #fff; border-radius: 50%; font-weight: 700; font-size: 13px; }
.attack .a-name { font-weight: 700; color: var(--navy); }
.attack .a-effort { font-size: 12px; color: #5c6b78; }
.attack .a-amt { font-weight: 800; color: var(--green-700); font-variant-numeric: tabular-nums; }

.recovery-summary { background: var(--navy); color: #fff; border-radius: 12px; padding: 22px 26px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.recovery-summary .rs-big { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.recovery-summary .rs-lbl { font-size: 12px; color: #9fc7dd; text-transform: uppercase; letter-spacing: 1px; }

.rep-foot { font-size: 11.5px; color: #5c6b78; border-top: 1px solid #dde4ea; padding: 16px 40px; }

/* ── Footer (centered, padded) ───────────────────────────────────────────── */
.foot { max-width: 760px; margin: 40px auto 0; padding: 24px; text-align: center; }
.foot-note { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.foot-legal { font-size: 11.5px; color: var(--muted); opacity: 0.75; margin: 0 0 14px; line-height: 1.6; }
.foot-brand { font-size: 12px; color: var(--muted); margin: 0; }
.foot-brand a { color: var(--green); text-decoration: none; font-weight: 600; }
.foot-brand a:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero-inner { justify-content: center; text-align: center; }
  .hero-figures { gap: 24px; }
  .hero-number { font-size: 32px; }
  .scenarios { grid-template-columns: 1fr; }
  .intro h1 { font-size: 19px; }
  .rep-cover, .rep-body, .rep-foot { padding-left: 22px; padding-right: 22px; }
}

/* ── Print (Save as PDF) — force light, hide app chrome ──────────────────── */
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #14202b; --muted: #5c6b78; --line: #dde4ea; }
  .hero, .form, .foot { display: none !important; }
  body { background: #fff; }
  .layout { padding: 0; max-width: none; }
  .report { margin: 0; display: block !important; }
  .report-doc { border: none; box-shadow: none; border-radius: 0; }
  .rep-cover, .scen.likely, .db-block, .recovery-summary, .leak-row .k, .attack li::before, .leak-k { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep-section { break-inside: avoid; }
}
