/* Palette aliases — canonical values live in ../brand.css (--an-*).
   Fallbacks keep the page correct if brand.css ever fails to load. */
:root {
  --navy: var(--an-navy, #001F4D);
  --navy-2: var(--an-navy-2, #0A2E6B);
  --orange: var(--an-orange, #FF6B35);
  --orange-2: var(--an-orange-2, #E85A24);
  --cyan: var(--an-cyan, #00D4FF);
  --silver: var(--an-silver, #E8E8E8);
  --charcoal: var(--an-charcoal, #2D2D2D);
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --text: #0A1628;
  --muted: #5A6577;
  --border: #E1E5EC;
  --shadow: 0 1px 3px rgba(0,31,77,0.06), 0 4px 12px rgba(0,31,77,0.04);
  --shadow-lg: 0 4px 12px rgba(0,31,77,0.08), 0 12px 32px rgba(0,31,77,0.06);
  --r: 10px;
  --r-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--navy);
  color: white;
  border-bottom: 3px solid var(--orange);
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  color: white; font-weight: 700; font-size: 18px;
  text-decoration: none;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange);
  display: inline-block;
  box-shadow: 0 0 12px rgba(255,107,53,0.6);
}
.brand-sub {
  font-weight: 400; opacity: 0.65; font-size: 13px;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding-left: 10px;
}
.topnav { display: flex; gap: 20px; }
.topnav a { color: rgba(255,255,255,0.85); font-size: 14px; }
.topnav a:hover { color: white; text-decoration: none; }

/* ── Steps ──────────────────────────────────────── */
.step { display: none; }
.step.active { display: block; }

/* ── Step 1 ─────────────────────────────────────── */
.hero {
  max-width: 720px;
  margin: 80px auto 40px;
  padding: 0 24px;
  text-align: center;
}
.hero h1 {
  font-size: 40px; font-weight: 700; color: var(--navy);
  margin: 0 0 16px; line-height: 1.15;
}
.hero h1 { margin-bottom: 28px; }
.hero .lede {
  font-size: 15px; color: var(--muted);
  max-width: 560px; margin: 14px auto 0;
}

.address-form {
  display: flex; gap: 10px;
  max-width: 560px; margin: 0 auto;
}
.input-wrap { position: relative; flex: 1; }
#address-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: white;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#address-input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0,31,77,0.1);
}
#estimate-btn {
  padding: 14px 24px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: var(--r);
  font-weight: 600;
  font-size: 15px;
  transition: background .15s;
}
#estimate-btn:hover { background: var(--orange-2); }
#estimate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  list-style: none; margin: 0; padding: 4px 0;
  max-height: 280px; overflow-y: auto;
  z-index: 100;
  text-align: left;
}
.suggestions li {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover, .suggestions li.active { background: var(--bg); }

.hint {
  text-align: center;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.linkbtn {
  background: none; border: none; padding: 0;
  color: var(--navy); text-decoration: underline;
  cursor: pointer; font-size: inherit;
}
.linkbtn:hover { color: var(--orange); }

.error {
  max-width: 560px; margin: 16px auto 0;
  padding: 10px 14px;
  background: #FFF3F0;
  border: 1px solid #FFD4C7;
  color: #B23A0F;
  border-radius: var(--r);
  font-size: 14px;
}

.samples {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.samples span { margin-right: 10px; }
.chip {
  display: inline-block;
  padding: 6px 14px;
  margin: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--navy);
  transition: all .15s;
}
.chip:hover { background: var(--navy); color: white; border-color: var(--navy); }

/* ── Step 2 ─────────────────────────────────────── */
.results-wrap {
  max-width: 880px;
  margin: 24px auto;
  padding: 0 24px;
}

.location-line {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 14px;
}

/* Hero result */
.hero-result {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: white;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  text-align: center;
}
.hero-kicker {
  font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--cyan);
  margin-bottom: 10px;
}
.hero-headline { margin-bottom: 22px; }
.hero-number {
  font-size: 64px; font-weight: 800; line-height: 1;
  color: white;
  font-variant-numeric: tabular-nums;
}
.hero-unit {
  display: block;
  font-size: 17px; color: rgba(255,255,255,0.75);
  margin-top: 6px;
}
.hero-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 auto 26px;
  max-width: 620px;
}
.chip-stat {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r);
  padding: 10px 8px;
}
.chip-stat span {
  display: block;
  font-size: 18px; font-weight: 700; color: var(--orange);
  font-variant-numeric: tabular-nums;
}
.chip-stat small {
  font-size: 11px; color: rgba(255,255,255,0.65);
}

.bill-block {
  max-width: 520px; margin: 0 auto;
  text-align: left;
}
.bill-block > label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; font-weight: 600; color: white;
  margin-bottom: 10px;
}
.bill-block .pval { color: var(--cyan); }
.bill-presets {
  display: flex; gap: 8px; margin-bottom: 10px;
  flex-wrap: wrap;
}
.bill-chip {
  flex: 1; min-width: 70px;
  padding: 8px 4px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: white; font-size: 13px;
  transition: all .15s;
}
.bill-chip:hover { background: rgba(255,255,255,0.16); }
.bill-chip.active {
  background: var(--orange);
  border-color: var(--orange);
  font-weight: 700;
}
.bill-block input[type=range] { width: 100%; accent-color: var(--orange); }
.bill-block .param-hint { color: rgba(255,255,255,0.6); }

.hero-source {
  margin-top: 22px;
  font-size: 11px; color: rgba(255,255,255,0.5);
}

/* Hero loading shimmer */
.hero-loading { padding: 40px 0 30px; }
.shimmer-bar {
  height: 58px; max-width: 340px;
  margin: 0 auto 18px;
  border-radius: 10px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.06) 25%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.hero-loading-msg {
  font-size: 14px; color: rgba(255,255,255,0.7);
  text-align: center;
}

/* Advanced accordion */
.advanced {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  margin-top: 16px;
  overflow: hidden;
}
.advanced summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 600; font-size: 15px; color: var(--navy);
  list-style: none;
  display: flex; align-items: baseline; gap: 10px;
}
.advanced summary::before {
  content: "▸";
  transition: transform .15s;
  color: var(--orange);
}
.advanced[open] summary::before { transform: rotate(90deg); }
.summary-hint {
  font-weight: 400; font-size: 12px; color: var(--muted);
}
.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 28px;
  padding: 4px 20px 18px;
}
.auto-badge {
  display: inline-block;
  background: rgba(0,212,255,0.15);
  color: #0090b0;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 1px 6px; border-radius: 4px;
  margin-right: 4px;
}
.linkbtn.small { font-size: 12px; margin-top: 4px; }
.location-label {
  font-size: 14px; color: var(--navy);
  font-weight: 600;
  word-break: break-word;
}

.param { margin: 14px 0; }
.param label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--charcoal); font-weight: 500;
  margin-bottom: 6px;
}
.pval {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--navy);
  font-weight: 600;
  font-size: 13px;
}
.param input[type=range] {
  width: 100%;
  accent-color: var(--orange);
}
.param-hint {
  font-size: 12px; color: var(--muted);
  margin-top: 4px;
}
.param-toggle .toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; color: var(--charcoal);
  font-weight: 500;
}
.param-toggle input { accent-color: var(--orange); }

/* KPIs */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border-top: 3px solid transparent;
}
.kpi.highlight { border-top-color: var(--orange); }
.kpi-label {
  font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 26px; font-weight: 700; color: var(--navy);
  line-height: 1.1;
}
.kpi-value .unit {
  font-size: 13px; color: var(--muted);
  font-weight: 400; margin-left: 4px;
}
.kpi-sub {
  margin-top: 6px;
  font-size: 12px; color: var(--muted);
  min-height: 1em;
}

/* Chart cards */
.chart-card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}
.chart-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.chart-header h3 {
  margin: 0; font-size: 15px; color: var(--navy);
}
.chart-sub { font-size: 12px; color: var(--muted); }
.chart-wrap {
  position: relative;
  height: 240px;
}
#map {
  height: 260px;
  width: 100%;
  border-radius: var(--r);
  overflow: hidden;
}

/* Help tooltip — hover, keyboard focus, and tap all reveal it */
.help {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 15px; height: 15px;
  margin-left: 5px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0,31,77,0.12);
  color: var(--navy);
  font-size: 10px; font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  transition: background .15s;
}
.help:hover, .help:focus-visible, .help.open {
  background: var(--orange);
  color: white;
  outline: none;
}
/* On the dark hero card the default dark badge is invisible — light it up.
   Scoped by ancestor so new tooltips inside the hero need no extra class. */
.help.light,
.hero-result .help { background: rgba(255,255,255,0.22); color: white; }
.help.light:hover, .help.light:focus-visible,
.hero-result .help:hover, .hero-result .help:focus-visible { background: var(--orange); }

.help .tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 260px;
  padding: 9px 12px;
  background: var(--charcoal);
  color: white;
  font-size: 12px; font-weight: 400;
  line-height: 1.5;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden;
  transition: opacity .15s, transform .15s;
  z-index: 200;
  pointer-events: none;
}
.help .tip::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--charcoal);
}
.help:hover .tip,
.help:focus-visible .tip,
.help.open .tip {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
}
/* On phones an anchored tooltip always runs off one edge, so present it as a
   fixed bottom sheet instead — never clipped, and comfortable to read. */
@media (max-width: 620px) {
  .help .tip {
    position: fixed;
    left: 12px; right: 12px; bottom: 16px;
    width: auto; max-width: none;
    transform: translateY(8px);
    font-size: 13px;
    padding: 13px 15px;
  }
  .help .tip::after { display: none; }
  .help:hover .tip,
  .help:focus-visible .tip,
  .help.open .tip { transform: translateY(0); }

  /* Touch target: keep the badge small but give it ~40px of hit area. */
  .help { width: 18px; height: 18px; font-size: 11px; }
  .help::before { content: ""; position: absolute; inset: -11px; }
}

/* Finance card */
.finance-card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}
.finance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
.finance-col {
  padding: 14px 16px;
  border-radius: var(--r);
  background: rgba(0,31,77,0.03);
  border: 1px solid var(--border);
}
.finance-col.finance-highlight {
  background: rgba(255,107,53,0.06);
  border-color: rgba(255,107,53,0.3);
}
.finance-tag {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
  margin-bottom: 6px; font-weight: 600;
}
.finance-value {
  font-size: 22px; font-weight: 700; color: var(--navy);
  line-height: 1.1; margin-bottom: 8px;
}
.finance-value .unit {
  font-size: 12px; color: var(--muted);
  font-weight: 400; margin-left: 4px;
}
.finance-line {
  font-size: 13px; color: var(--charcoal);
  line-height: 1.5;
}
.finance-line.finance-muted { color: var(--muted); font-size: 12px; }
.finance-hint {
  margin-top: 10px;
  font-size: 11px; color: var(--muted);
}
.finance-hint code {
  background: rgba(0,31,77,0.06);
  padding: 1px 5px; border-radius: 3px;
  font-size: 11px;
}
@media (max-width: 620px) {
  .finance-grid { grid-template-columns: 1fr; }
}

.disclaimer {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  padding: 12px 16px;
  background: rgba(0,31,77,0.03);
  border-left: 3px solid var(--navy);
  border-radius: 4px;
}
.disclaimer strong { color: var(--navy); }

/* About */
.about {
  max-width: 720px;
  margin: 60px auto;
  padding: 0 24px;
  color: var(--muted);
  font-size: 15px;
}
.about h2 {
  color: var(--navy);
  font-size: 20px;
  margin-bottom: 12px;
}

/* Responsive */
@media (max-width: 860px) {
  .hero h1 { font-size: 30px; }
  .hero-number { font-size: 46px; }
  .hero-result { padding: 26px 18px; }
  .hero-chips { grid-template-columns: repeat(2, 1fr); }
  .advanced-grid { grid-template-columns: 1fr; }
  .address-form { flex-direction: column; }
  #estimate-btn { width: 100%; }
}

/* Phone refinements */
@media (max-width: 620px) {
  /* Header: drop the subtitle so the brand never wraps */
  .brand-sub { display: none; }
  .topbar { padding: 12px 16px; }
  .topnav { gap: 16px; }
  .topnav a { font-size: 13px; }

  .results-wrap, .hero, .about { padding-left: 16px; padding-right: 16px; }
  .location-line { flex-direction: column; gap: 4px; align-items: flex-start; }

  /* Even 2x2 grid instead of a stranded fourth chip */
  .bill-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .bill-chip { min-width: 0; }
  .bill-block > label { font-size: 13px; gap: 10px; }
  .bill-block .pval { white-space: nowrap; }

  /* Keep the accordion label on one line */
  .summary-hint { display: none; }

  #map { height: 200px; }
}
