/* Octopus Energy Texas · Savings Estimate
   Clean, minimal, on-brand (TODO-008).
   Color roles: mint = savings / positive numbers / selected state.
                magenta = the single primary action per screen.
   Surfaces over outlines; one hairline; the only glow is the hero number. */

:root {
  --bg: #100030;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-3: rgba(255, 255, 255, 0.12);
  --hairline: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: rgba(214, 204, 255, 0.64);
  --faint: rgba(214, 204, 255, 0.4);
  --mint: #18f0b8;
  --mint-tint: rgba(24, 240, 184, 0.14);
  --magenta: #f050f8;
  --warn: #ffd166;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;
  /* 8-pt spacing scale */
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px; --s6: 64px;
  color-scheme: dark;
  font-size: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.0625rem; line-height: 1.45; -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; clip-path: inset(50%); overflow: hidden; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; white-space: nowrap; }

.app { max-width: 1120px; margin: 0 auto; padding: 0 var(--s3) var(--s5); }

/* ── Header ─────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 12px 0 var(--s1); }
.brand { display: flex; align-items: center; gap: var(--s1); }
.brand-logo {
  font-size: 1.9rem; line-height: 1; min-inline-size: var(--tap); min-block-size: var(--tap);
  padding: 0; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; transition: transform 0.2s;
}
.brand-logo:hover { transform: rotate(-8deg); }
.brand-text { display: flex; align-items: baseline; gap: var(--s1); flex-wrap: wrap; }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-name span { color: var(--mint); font-weight: 600; }
.brand-sub { color: var(--muted); font-size: 0.875rem; }
.top-actions { display: flex; align-items: center; gap: 2px; }

/* ── Buttons ────────────────────────────────────────── */
.btn-quiet {
  min-block-size: 44px; min-inline-size: 44px; padding: 0 var(--s2); border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font-weight: 600; font-size: 0.9375rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-quiet:hover { color: var(--text); background: var(--surface); }
.btn-quiet.icon { padding: 0; }
.btn-primary {
  min-block-size: 52px; padding: 0 var(--s4); border: 0; border-radius: 999px;
  background: var(--magenta); color: var(--bg); font-weight: 700; font-size: 1.0625rem; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.link { border: 0; background: none; padding: 0 2px; min-block-size: 44px; color: var(--text); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; cursor: pointer; font-size: inherit; }
.link:hover { text-decoration-color: var(--text); }

/* ── Stepper ────────────────────────────────────────── */
.stepper ol { list-style: none; display: flex; justify-content: center; align-items: center; gap: var(--s1); padding: 0; margin: 0 0 var(--s3); }
.stepper li { display: flex; align-items: center; gap: var(--s1); }
.stepper li + li::before { content: ""; inline-size: 32px; block-size: 1px; background: var(--hairline); }
.stepper button {
  min-block-size: 44px; padding: 0 var(--s1); border: 0; background: none; color: var(--faint);
  font-size: 0.875rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: var(--s1);
}
.stepper .num {
  display: inline-grid; place-items: center; inline-size: 22px; block-size: 22px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 0.75rem;
}
.stepper button:hover { color: var(--muted); }
.stepper button[aria-current="step"] { color: var(--text); }
.stepper button[aria-current="step"] .num { background: var(--mint); color: var(--bg); }

/* ── Step layout ────────────────────────────────────── */
.step { margin: 0 auto; }
.step.narrow { max-width: 680px; }
.step.wide { max-width: 920px; }
.step-title { font-size: 1.75rem; line-height: 1.15; margin: 0 0 var(--s1); letter-spacing: -0.02em; font-weight: 800; }
.step-lede { color: var(--muted); margin: 0 0 var(--s3); font-size: 1rem; }
form { margin: 0; }

.section { border: 0; margin: 0 0 var(--s3); padding: 0; min-width: 0; }
.section-label {
  display: block; padding: 0; margin: 0 0 var(--s1); color: var(--muted);
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); margin-bottom: var(--s1); }
.section-head .section-label { margin: 0; }
.field-label { display: block; font-size: 0.875rem; color: var(--muted); margin: 12px 0 6px; }
.section-head + div > .field-label:first-child { margin-top: 0; }
.opt { color: var(--faint); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.meta-line { margin: 4px 0 -8px; color: var(--muted); font-size: 0.875rem; display: flex; align-items: center; gap: 4px; }
.region-wrap { margin-top: 0; }
.region-wrap .field-label { margin-top: 0; }

/* inputs */
select, .input-unit input, .month-cell input {
  inline-size: 100%; min-block-size: 48px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 0 var(--s2); font-size: 1.0625rem; font-weight: 600;
}
select {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
select option { background: #1c0b4a; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 72px; }
.input-unit span { position: absolute; right: var(--s2); color: var(--faint); font-size: 0.875rem; pointer-events: none; }
select:focus, .input-unit input:focus, .month-cell input:focus { outline: none; border-color: var(--mint); background: var(--surface-3); }
input::placeholder { color: var(--faint); font-weight: 500; }

/* segmented control (radio group) */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); }
.seg label { position: relative; flex: 1 1 0; display: flex; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  min-block-size: 44px; padding: 0 var(--s2); border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--mint-tint); color: var(--mint); }
.seg input:focus-visible + span { outline: 2px solid var(--mint); outline-offset: -2px; }
.seg-sm { display: inline-flex; padding: 3px; }
.seg-sm label { flex: 0 0 auto; }
.seg-sm span { min-block-size: 40px; padding: 0 14px; font-size: 0.875rem; }
@media (pointer: coarse) { .seg-sm span { min-block-size: 44px; } }

.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s1); }
.month-cell { display: grid; gap: 4px; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.month-cell input { min-block-size: 44px; padding: 0 10px; font-size: 1rem; }

/* ── Step 2 rows ────────────────────────────────────── */
.rows { background: var(--surface); border-radius: var(--radius); }
.row { padding: var(--s3); }
.row + .row { border-top: 1px solid var(--hairline); }
.row-main { display: flex; align-items: center; gap: var(--s2); }
.row-text { flex: 1; min-width: 0; }
.row-title { margin: 0; font-size: 1.125rem; font-weight: 600; display: flex; align-items: center; gap: var(--s1); }
.row-desc { margin: 2px 0 0; color: var(--muted); font-size: 0.875rem; }
.tag { font-size: 0.75rem; font-weight: 700; color: var(--mint); background: var(--mint-tint); padding: 2px 8px; border-radius: 999px; }
.impact { color: var(--mint); font-weight: 700; font-size: 0.9375rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.impact.neg { color: var(--muted); }
.row-body { padding-top: var(--s2); }
.row-body .field-pair { margin-top: 0; }

/* switch */
.switch { position: relative; display: inline-flex; inline-size: 52px; block-size: 32px; flex: none; cursor: pointer; }
.switch::before { content: ""; position: absolute; inset: -8px; } /* 48px touch target */
.switch input { position: absolute; inset: -8px; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { inline-size: 100%; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.switch .track::after {
  content: ""; position: absolute; top: 4px; left: 4px; inline-size: 24px; block-size: 24px; border-radius: 50%;
  background: var(--text); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--mint); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--bg); }
.switch input:focus-visible + .track { outline: 2px solid var(--mint); outline-offset: 3px; }

/* ── Actions (not sticky) ───────────────────────────── */
.actions { display: flex; align-items: center; gap: var(--s2); max-width: 680px; margin: var(--s3) auto 0; }
.app[data-step="3"] .actions { max-width: 920px; }
.ticker { flex: 1; margin: 0; text-align: right; font-size: 0.9375rem; }
.app[data-step="3"] .ticker { display: none; }
.app[data-step="3"] .actions::before { content: ""; flex: 1; order: 1; }
.app[data-step="3"] #btn-next { order: 2; }
.tk-muted { color: var(--muted); }
.tk-num { color: var(--mint); font-variant-numeric: tabular-nums; }

/* ── Step 3 estimate ────────────────────────────────── */
.estimate { display: grid; gap: var(--s4); }
.hero { text-align: center; padding-top: var(--s2); }
.hero-label { margin: 0; color: var(--muted); font-size: 0.875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.hero-num {
  margin: var(--s1) 0; font-size: clamp(3.5rem, 10vw, 6rem); font-weight: 800; line-height: 1; letter-spacing: -0.04em;
  color: var(--mint); text-shadow: 0 0 48px rgba(24, 240, 184, 0.3); font-variant-numeric: tabular-nums;
}
.hero-num.neutral { color: var(--text); text-shadow: none; }
.hero-unit { font-size: 0.35em; font-weight: 700; letter-spacing: 0; color: var(--muted); margin-left: 4px; }
.hero-line { margin: 0 0 var(--s3); color: var(--muted); display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-select {
  inline-size: auto; min-block-size: 40px; padding: 0 32px 0 12px; font-size: 1rem; font-weight: 600; color: var(--text);
  background-color: var(--surface); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
}
.term-seg { margin: 0 auto; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.tile { background: var(--surface); border-radius: var(--radius); padding: var(--s3); display: grid; gap: 4px; }
.tile-label { color: var(--muted); font-size: 0.875rem; }
.tile-val { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-val.muted { color: var(--muted); }
.tile-val small { font-size: 0.9375rem; color: var(--muted); font-weight: 500; margin-left: 2px; }
.included { margin: calc(var(--s2) * -1) 0 0; color: var(--muted); text-align: center; font-size: 0.9375rem; }
.included .free { color: var(--mint); }

.breakdown ul { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); }
.breakdown li { display: flex; justify-content: space-between; padding: 14px var(--s3); }
.breakdown li + li { border-top: 1px solid var(--hairline); }
.breakdown .amt { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--mint); }
.breakdown .amt.neg { color: var(--muted); }
.breakdown .total { font-weight: 700; }

.detail { background: var(--surface); border-radius: var(--radius); padding: 0 var(--s3); }
.detail summary {
  min-block-size: 52px; display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  list-style: none; color: var(--muted); font-weight: 600;
}
.detail summary::-webkit-details-marker { display: none; }
.detail summary::after { content: ""; inline-size: 8px; block-size: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); transition: transform 0.2s; }
.detail[open] summary::after { transform: rotate(-135deg) translateY(-3px); }
.detail summary:hover { color: var(--text); }
.detail[open] { padding-bottom: var(--s3); }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.8125rem; margin-bottom: var(--s1); }
.legend .key { inline-size: 10px; block-size: 10px; border-radius: 3px; display: inline-block; margin-left: var(--s2); }
.legend .key:first-child { margin-left: 0; }
.key.today { background: rgba(214, 204, 255, 0.28); }
.key.octo { background: var(--mint); }
.chart-bars { inline-size: 100%; block-size: auto; display: block; }
.chart-bars .grid { stroke: var(--hairline); stroke-width: 1; }
.chart-bars .year-sep { stroke: var(--faint); stroke-dasharray: 3 4; stroke-width: 1; }
.chart-bars .axis { fill: var(--faint); font-size: 16px; }
.chart-bars .axis.year { font-size: 13px; }
.bar-today { fill: rgba(214, 204, 255, 0.28); }
.bar-octopus { fill: var(--mint); }

.props { margin: 0; text-align: center; color: var(--faint); font-size: 0.875rem; }
.empty { text-align: center; padding: var(--s5) 0; color: var(--muted); }
.empty p { margin: 0 0 var(--s2); }

/* ── Drawer (rep only) ──────────────────────────────── */
.drawer {
  margin: 0 0 0 auto; block-size: 100dvh; max-block-size: 100dvh; inline-size: min(720px, 100vw); max-inline-size: 100vw;
  border: 0; padding: 0; background: #150640; color: var(--text);
}
.drawer::backdrop, .mascot::backdrop { background: rgba(5, 0, 20, 0.6); }
.drawer-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  padding: var(--s2) var(--s3); background: #150640; border-bottom: 1px solid var(--hairline);
}
.drawer-head h2 { margin: 0; font-size: 1.125rem; }
.drawer-head small { color: var(--muted); font-size: 0.8125rem; font-weight: 600; margin-left: var(--s1); }
.drawer-head form { margin: 0; }
#drawer-body { padding: 0 var(--s3) var(--s4); }
.dsec { border-bottom: 1px solid var(--hairline); padding: var(--s3) 0; }
.dsec h3 { margin: 0 0 var(--s2); font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s2); margin-bottom: var(--s2); }
.dfield label { display: block; font-size: 0.8125rem; color: var(--muted); margin-bottom: 4px; }
.dfield select { min-block-size: 44px; font-size: 1rem; }
.dnote { color: var(--muted); font-size: 0.8125rem; margin: var(--s1) 0; }
.input-unit.sm input { min-block-size: 44px; font-size: 1rem; padding-right: 72px; }
.input-unit.sm span { font-size: 0.75rem; }
.vol-choice { border: 0; background: var(--surface); border-radius: var(--radius-sm); padding: var(--s1) var(--s2); margin: 0 0 var(--s2); }
.vol-choice legend { font-size: 0.8125rem; color: var(--muted); padding: 0; float: left; inline-size: 100%; margin: 4px 0; }
.radio-line { clear: both; display: flex; align-items: center; gap: 10px; min-block-size: 44px; cursor: pointer; font-size: 0.9375rem; }
.radio-line input { inline-size: 20px; block-size: 20px; accent-color: var(--mint); }
.radio-line small { color: var(--muted); }
.warn { color: var(--warn); font-style: normal; font-weight: 600; font-size: 0.8125rem; }
.program { background: var(--surface); border-radius: var(--radius-sm); padding: var(--s2); }
.program.off { color: var(--muted); }
.program-head { font-weight: 700; }
.program-head small { color: var(--muted); font-weight: 500; }
.program-vals { display: flex; flex-wrap: wrap; gap: var(--s3); margin: var(--s1) 0; }
.program-vals strong { color: var(--text); }
.dwarn { list-style: none; padding: 0; margin: var(--s2) 0 0; color: var(--muted); font-size: 0.8125rem; display: grid; gap: 4px; }
.table-wrap { overflow-x: auto; }
.atable { inline-size: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.atable th, .atable td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.atable thead th { color: var(--muted); font-weight: 600; }
.atable tbody th { font-weight: 500; }
.atable .num { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.atable .date { white-space: nowrap; }
.atable .src { color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.atable tr.is-over { background: var(--surface); }
.chip { display: inline-block; font-size: 0.6875rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: 4px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.chip.warn { color: var(--warn); }
.chip.over { color: var(--text); }

/* ── Mascot dialog ──────────────────────────────────── */
.mascot {
  inline-size: min(400px, calc(100vw - 2rem)); border: 0; border-radius: var(--radius);
  padding: var(--s4) var(--s3) var(--s3); background: #1c0b4a; color: var(--text); text-align: center;
}
.mascot-emoji { font-size: 3rem; line-height: 1; }
.mascot h2 { margin: var(--s2) 0 var(--s1); font-size: 1.25rem; }
.mascot p { margin: 0 0 var(--s3); color: var(--muted); font-size: 1rem; }
.mascot form { margin: 0; }

/* ── Small screens ──────────────────────────────────── */
@media (max-width: 640px) {
  .app { padding: 0 var(--s2) var(--s4); }
  .brand-sub { display: none; }
  .stepper .label-long { display: none; }
  .field-pair { grid-template-columns: 1fr; }
  .month-grid { grid-template-columns: repeat(3, 1fr); }
  .section-head { flex-direction: column; align-items: flex-start; }
  .compare { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
  .ticker { flex-basis: 100%; order: -1; text-align: left; }
}

/* ── Print: one-page leave-behind ───────────────────── */
.print-sheet { display: none; }
@page { size: letter; margin: 0.5in; }
@media print {
  :root { font-size: 10pt; color-scheme: light; }
  body { background: #fff !important; color: #100030; }
  .app, dialog { display: none !important; }
  .print-sheet { display: block !important; color: #100030; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ps-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8pt; border-bottom: 1px solid #e6e2f3; }
  .ps-brand { font-size: 15pt; font-weight: 800; letter-spacing: -0.02em; }
  .ps-brand b { color: #0a9c78; font-weight: 600; }
  .ps-meta { color: #5d567a; font-size: 9pt; }
  .ps-hero { text-align: center; margin: 10pt 0 8pt; }
  .print-sheet .hero-label { color: #5d567a; font-size: 9pt; }
  .ps-big { margin: 2pt 0; font-size: 34pt; font-weight: 800; line-height: 1; color: #0a9c78; letter-spacing: -0.03em; }
  .ps-big small { font-size: 14pt; color: #5d567a; font-weight: 600; letter-spacing: 0; }
  .print-sheet .hero-line { color: #5d567a; margin: 0; display: block; }
  .print-sheet .compare { gap: 10pt; margin: 0 0 6pt; }
  .print-sheet .tile { background: #f5f3fb; padding: 6pt 12pt; border-radius: 8pt; }
  .print-sheet .tile-label { color: #5d567a; }
  .print-sheet .tile-val { font-size: 14pt; }
  .print-sheet .tile-val small { color: #5d567a; }
  .print-sheet .included { margin: 0 0 6pt; color: #5d567a; }
  .print-sheet .included .free { color: #0a9c78; font-weight: 600; }
  .print-sheet .breakdown { margin: 0 0 6pt; }
  .print-sheet .section-label { color: #5d567a; font-size: 8pt; margin-bottom: 4pt; }
  .print-sheet .breakdown ul { background: #f5f3fb; border-radius: 8pt; }
  .print-sheet .breakdown li { padding: 3pt 12pt; min-block-size: 0; }
  .print-sheet .breakdown li + li { border-color: #e6e2f3; }
  .print-sheet .breakdown .amt { color: #0a9c78; }
  .print-sheet .props { color: #5d567a; margin: 4pt 0; }
  .ps-fine { color: #5d567a; font-size: 7pt; margin: 3pt 0; }
  .ps-assume { margin-top: 8pt; }
  .print-sheet .atable { font-size: 7pt; table-layout: auto; }
  .print-sheet .atable th, .print-sheet .atable td { padding: 1.5pt 4pt; border-bottom: 1px solid #eeebf6; }
  .print-sheet .atable thead th { color: #5d567a; }
  .print-sheet .atable .src { color: #5d567a; font-size: 6pt; inline-size: 55%; }
  .print-sheet .atable td:first-child { white-space: nowrap; }
}
