/* San Diego Electricity Plan Calculator
   Light and dark are both first-class; the palette is defined once as custom
   properties and flipped by prefers-color-scheme. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --line: #dfe3ea;
  --text: #16191f;
  --text-dim: #5c6473;
  --accent: #0b6bcb;
  --accent-soft: #e7f0fb;
  --good: #0f7b4f;
  --good-soft: #e4f4ec;
  --warn: #8a5a00;
  --warn-soft: #fdf3e0;
  --peak: rgba(220, 90, 60, 0.13);

  --delivery: #4a6fa5;
  --generation: #d98032;
  --fixed: #6a7b8c;
  --adders: #9a6fb0;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --line: #2b323c;
    --text: #e8ecf2;
    --text-dim: #98a2b3;
    --accent: #5ea9f7;
    --accent-soft: #16263a;
    --good: #4ade9a;
    --good-soft: #12291f;
    --warn: #f0b45e;
    --warn-soft: #2a2113;
    --peak: rgba(255, 130, 90, 0.14);

    --delivery: #7ba0d4;
    --generation: #eaa15c;
    --fixed: #93a3b5;
    --adders: #bb95cd;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* --- masthead ---------------------------------------------------------- */

.masthead {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: 56px 0 40px;
  margin-bottom: 32px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.022em;
  font-weight: 680;
}
h1 em { font-style: normal; color: var(--accent); }

/* Body text runs the full width of .wrap, matching the headings above it and
   the step panels below.

   These used to carry `ch` caps — 62ch here, 66ch on .privacy, 72ch in the
   footer. Because `ch` resolves against each element's own font size, the three
   landed on three different right edges, and inverted at that: the footer's
   72ch at 0.83rem came out narrower than this 62ch at 1.06rem. If a reading
   measure is ever wanted back, it should be one value in absolute units rather
   than a per-element `ch`. */
.lede {
  margin: 0 0 20px;
  font-size: 1.06rem;
  color: var(--text-dim);
}
.lede.small { font-size: 0.95rem; }

.privacy {
  margin: 0;
  padding: 12px 16px;
  background: var(--good-soft);
  border-left: 3px solid var(--good);
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  color: var(--text);
}

/* --- steps ------------------------------------------------------------- */

.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

.step h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  font-weight: 640;
}

.num {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

/* The nav sits at the foot of a step and only appears once the step it points at
   exists, so it reads as "you've done enough here" rather than as a submit
   button that might skip something. */
.step-nav {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.step-nav .btn::after {
  content: " ↓";
  font-size: 0.9em;
}

.hidden { display: none !important; }

/* --- dropzone ---------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .hint { color: var(--text-dim); font-size: 0.9rem; margin: 12px 0 0; }

.btn {
  font: inherit;
  font-weight: 550;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }

/* Bill-import accelerator in Step 2 — a button and a one-line explanation, set
   apart from the form fields it fills without shouting for attention. */
.bill-import {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.bill-import .hint { color: var(--text-dim); font-size: 0.9rem; flex: 1 1 16ch; }
.bill-miss { color: var(--text-dim); font-size: 0.86rem; }
/* The one thing the import can't determine — the CCA product tier — called out
   rather than muted, so it reads as "check this", not incidental fine print. */
.bill-highlight {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
}

.how { margin-top: 24px; text-align: left; max-width: 52ch; margin-inline: auto; }
.how summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.how ol { color: var(--text-dim); font-size: 0.9rem; padding-left: 20px; }
a { color: var(--accent); }

/* Reusable disclosure: a scannable summary line with the detail one click away.
   Used to keep the caveats and step intros short by default without cutting a
   word of the explanation behind them. */
details.more { margin-top: 6px; }
details.more > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 550;
  list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
details.more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
details.more > :not(summary) { margin-top: 8px; color: var(--text-dim); font-size: 0.9rem; }
details.more ol, details.more ul { padding-left: 20px; }

/* --- controls ---------------------------------------------------------- */

.controls { display: flex; flex-wrap: wrap; gap: 20px; align-items: start; }
.controls.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 550;
}
label small { font-weight: 400; color: var(--text-dim); font-size: 0.8rem; line-height: 1.4; }

select, input[type="number"] {
  font: inherit;
  font-size: 0.95rem;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  min-width: 0;
}
select:focus-visible, input:focus-visible, .btn:focus-visible, tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

label.check { flex-direction: row; align-items: start; gap: 10px; }
label.check input { margin-top: 3px; flex: none; }
label.check span { display: flex; flex-direction: column; gap: 2px; }

/* --- stats ------------------------------------------------------------- */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: var(--surface-2);
  border-radius: 10px;
}
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.25rem; font-weight: 640; letter-spacing: -0.01em; }
.stat span { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

/* --- notices ----------------------------------------------------------- */

.notice {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  border-left: 3px solid;
}
.notice.warn { background: var(--warn-soft); border-color: var(--warn); }
.notice.info { background: var(--accent-soft); border-color: var(--accent); }
.notice.good { background: var(--good-soft); border-color: var(--good); }
.notice p { margin: 6px 0 0; }
.notice :first-child { margin-top: 0; }

/* The two battery strategies, costed side by side. The winning row is tinted so
   the better choice is legible at a glance without reading both numbers. */
.strategy-compare {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
}
.strategy-row {
  padding: 5px 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.strategy-row.win {
  background: var(--good-soft);
  box-shadow: inset 3px 0 0 var(--good);
}

/* --- headline ---------------------------------------------------------- */

.headline {
  padding: 20px 24px;
  background: var(--good-soft);
  border-radius: 10px;
  margin-bottom: 20px;
}
.headline .big { font-size: 1.35rem; font-weight: 640; letter-spacing: -0.015em; }
.headline .sub { color: var(--text-dim); font-size: 0.92rem; margin-top: 4px; }
.headline .switch { margin-top: 10px; font-size: 0.98rem; }
.headline .why { margin-top: 6px; color: var(--text-dim); font-size: 0.92rem; }
.headline details.more { margin-top: 10px; }
.driver-list { margin: 0; }
.driver-list li { margin: 2px 0; }

/* --- table ------------------------------------------------------------- */

.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 640px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
.num-col { text-align: right; }
td.num-col { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.87rem; }

tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
/* Only the ranking rows do anything when clicked; a pointer on the provider
   table would promise an interaction that isn't there. */
#ranking tbody tr { cursor: pointer; }
/* Two independent facts, so two independent cues: the star and green tint mean
   "cheapest", the blue rail and tint mean "this is the one you picked". A row is
   often both, so neither may depend on the other being absent to read. */
tbody tr.best { background: var(--good-soft); }
tbody tr.selected { background: var(--accent-soft); }
tbody tr.selected td:first-child { box-shadow: inset 3px 0 var(--accent); }
tbody tr.best.selected {
  background: linear-gradient(90deg, var(--good-soft), var(--accent-soft) 55%);
}
tbody tr.best td:first-child::before {
  content: "★";
  color: var(--good);
  margin-right: 6px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.83rem;
  color: var(--text-dim);
  margin: 10px 0 0;
}
.legend .swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: baseline;
}
.legend .swatch.best { background: var(--good-soft); border: 1px solid var(--good); }
.legend .swatch.selected { background: var(--accent-soft); border: 1px solid var(--accent); }
td .plan-sub { display: block; font-size: 0.78rem; color: var(--text-dim); }
td.total { font-weight: 650; }
.delta { color: var(--text-dim); }
/* A gap inside the modelling margin: muted and marked so a near-tie doesn't read
   as a firm difference. The "≈" carries the meaning; the colour just softens it. */
.delta-near { color: var(--text-dim); opacity: 0.75; }
/* A credit gap is not dollars owed, so it does not get the tabular-number
   treatment the money columns have. */
.credit-gap { font-family: inherit; font-size: 0.78rem; }

.footnote { font-size: 0.83rem; color: var(--text-dim); margin: 12px 0 0; }

/* --- true-up ----------------------------------------------------------- */

#trueup { margin-top: 34px; }
#trueup h3 { font-size: 1.05rem; margin: 0 0 4px; }
#trueup-outcome { margin: 0 0 14px; color: var(--text); }
#trueup table { min-width: 420px; }
/* The anniversary row is where the balance stops carrying, so it gets a rule
   under it — the ledger reads as two periods rather than one long run. */
tbody tr.trueup-row td { border-bottom: 2px solid var(--accent); }
.tag {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--accent-soft); color: var(--accent); padding: 1px 6px;
  border-radius: 4px; vertical-align: middle;
}
/* An inferred true-up date is a guess, and must not read with the same
   confidence as one the user copied off their bill. */
small.inferred { color: var(--warn); }

/* --- rate revisions ------------------------------------------------------ */

#rate-revisions { margin-top: 34px; }
#rate-revisions h3 { font-size: 1.05rem; margin: 0 0 4px; }
#rate-revisions p { margin: 0 0 10px; }
.revision-list { margin: 0 0 10px; padding-left: 20px; }
.revision-list li { margin-bottom: 3px; }
/* Distinct from the accent-coloured .tag: this one reports how far a number has
   been checked, which is a caution and must not read as a neutral label. */
.tag.unverified { background: transparent; color: var(--warn); border: 1px solid var(--warn); }
.unverified-note { color: var(--muted); font-size: 0.85rem; }

#provider-table-wrap { margin-top: 34px; }
#provider-table-wrap h3 { font-size: 1.05rem; margin: 0 0 4px; }
#provider-table-wrap .lede.small { margin: 0 0 14px; }

/* --- charts ------------------------------------------------------------ */

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
  margin-top: 32px;
}
figure { margin: 0; }
figcaption {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
figcaption small { font-weight: 400; color: var(--text-dim); font-size: 0.78rem; }

.canvas-wrap {
  position: relative;
  height: 260px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
}

/* --- caveats ----------------------------------------------------------- */

.caveats { display: grid; gap: 14px; font-size: 0.9rem; }
.caveat b { display: block; margin-bottom: 2px; }
.caveat p { margin: 0; color: var(--text-dim); }

/* --- footer ------------------------------------------------------------ */

footer {
  padding: 32px 24px 56px;
  color: var(--text-dim);
  font-size: 0.83rem;
  max-width: 1080px;
}
footer p { margin: 0 0 8px; }
footer a { color: inherit; }
.colophon {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
}
.colophon code {
  font-family: var(--mono);
  font-size: 0.95em;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--surface);
}

/* Gas fuel-switching swap cards (step 4). */
.gas-swaps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.gas-swap-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px 16px;
}
.gas-swap-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}
.gas-swap-head > span { flex: 1; }
label.gas-kwh {
  flex-direction: column;
  align-items: end;
  gap: 2px;
  font-weight: 400;
}
label.gas-kwh input { width: 88px; text-align: right; }
.gas-swap-card .notice { margin: 0; }

@media (max-width: 640px) {
  .masthead { padding: 36px 0 28px; }
  .step { padding: 20px 16px; }
  .wrap { padding: 0 16px; }
  .stat-row { gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
