/* Light and dark themes, WCAG AA contrast, no meaning carried by colour alone.
   Status is always accompanied by a text label, never colour on its own (§17).

   Tokens follow the Oakridge design language (../Xcel/Oakridge-Energy-Panel.html)
   — near-black-on-cream surfaces, 2-3px radii, dense small-caps labels,
   tabular-nums on every number. Variable NAMES are kept as they were so every
   selector below kept working the moment the values changed underneath it. */

:root {
  color-scheme: light dark;

  --bg: #f4f2ee;
  --surface: #fcfbf9;
  --surface-2: #f1eee8;
  --border: #e2ddd5;
  --border-strong: #c9c2b8;
  --text: #191714;
  --text-muted: #57524a;
  --text-faint: #827c72;
  /* A brighter Oakridge-amber reads well as a rule or highlight but fails AA
     (~3.5:1) as button text on a near-white surface — this is darkened to
     clear 4.5:1 while staying in the same warm-amber family. */
  --accent: #8a5209;
  --ok-fg: #146c43;
  --ok-bg: #d9f2e3;
  --fail-fg: #a3312a;
  --fail-bg: #fbe2df;
  --warn-fg: #8a5a06;
  --warn-bg: #faedcc;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(20, 22, 16, 0.05), 0 4px 14px rgba(20, 22, 16, 0.045);
  --font: "Jost", "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", Consolas, monospace;

  /* Semantic energy-source palette, straight from the Oakridge reference.
     Used only for small decorative swatches (`.sw`) next to a text label —
     never as the sole carrier of meaning, and never as text needing its own
     AA contrast check (the hero figure uses --accent, already verified,
     rather than one of these, since "amount due" isn't tied to one commodity). */
  --solar: #eda100;
  --grid: #2a78d6;
  --gas: #eb6834;
  --ev: #4a3aa7;
  --credit: #1baf7a;
  --solar-soft: #faedcc;
  --grid-soft: #d7e6f9;
  --gas-soft: #fbdfd3;
  --ev-soft: #dcd8ef;
  --credit-soft: #cfeee1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1b1917;
    --surface-2: #221f1c;
    --border: #312e2a;
    --border-strong: #47433d;
    --text: #f5f2ed;
    --text-muted: #b5ada3;
    --text-faint: #867f75;
    --accent: #d9a13c; /* light gold — 7.6:1 against the dark surface it sits on as button text */
    --ok-fg: #7ee0ac;
    --ok-bg: #123423;
    --fail-fg: #f5a099;
    --fail-bg: #3a1815;
    --warn-fg: #f0c96b;
    --warn-bg: #3a2c08;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);

    --solar: #c98500;
    --grid: #3987e5;
    --gas: #d95926;
    --ev: #9085e9;
    --credit: #199e70;
    --solar-soft: #3a2c08;
    --grid-soft: #122740;
    --gas-soft: #3a1d10;
    --ev-soft: #241f3d;
    --credit-soft: #0d2c22;
  }
}

* { box-sizing: border-box; }

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

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

.shell {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.shell__head h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.shell__sub {
  margin: 0.3rem 0 2rem;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

.shell__foot {
  margin-top: 2rem;
  color: var(--text-faint);
  font-size: 0.79rem;
}

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

.card + .card { margin-top: 1.25rem; }

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#status-summary {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
}

/* Wide content scrolls inside its own container; the page never scrolls sideways. */
.checks {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  display: block;
  overflow-x: auto;
}

.checks th,
.checks td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.checks th {
  font-weight: 600;
  color: var(--text-faint);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  border-bottom: 1px solid var(--border-strong);
}

.checks tr:last-child td { border-bottom: none; }

.checks td:first-child {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.checks td:nth-child(3) {
  color: var(--text-muted);
  white-space: normal;
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pill--ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill--fail { background: var(--fail-bg); color: var(--fail-fg); }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 1px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Sign in ------------------------------------------------------------ */

/* Utility, so it must beat whatever `display` the component sets — `.batch`
   and `.dropzone` are flex, `.fileitem` is grid, and all of them are declared
   after this rule. Without !important, source order silently wins and an
   element with is-hidden still renders. */
.is-hidden { display: none !important; }

.card__lede {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.field input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field input:focus-visible { outline-offset: 0; }

/* Six digits, widely spaced — easy to check against the phone in your hand. */
.input--code {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4em;
  text-align: center;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--surface);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}

.button:hover:not(:disabled) { opacity: 0.9; }
.button:disabled { opacity: 0.55; cursor: default; }

.button--quiet {
  color: var(--text);
  background: transparent;
  border-color: var(--border-strong);
  margin-left: 0.5rem;
}

@media (max-width: 30rem) {
  .button,
  .button--quiet {
    display: block;
    width: 100%;
    margin: 0.5rem 0 0;
  }
}

.hint {
  font-weight: 400;
  color: var(--text-faint);
  font-size: 0.78rem;
}

.hint--block {
  display: block;
  margin: 0.6rem 0 0;
}

.notice {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.83rem;
  color: var(--text-muted);
}

.notice h3 {
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text);
}

.notice ul { margin: 0; padding-left: 1.1rem; }
.notice li + li { margin-top: 0.35rem; }

/* --- Passcode reveal ------------------------------------------------------
   Plaintext, shown once — README "Task 1". Deliberately not styled as a
   .notice: this carries a live secret, not background information, so it
   gets the accent border on every side rather than a quiet left rule. */
.passcode-reveal {
  margin: 1.25rem 0;
  padding: 1.1rem 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.passcode-reveal__label {
  margin: 0 0 0.35rem;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.passcode-reveal__label strong { color: var(--text); text-transform: none; letter-spacing: normal; }

.passcode-reveal__code {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.passcode-reveal__meta {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
}

.facts dt {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.mono { font-family: var(--mono); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Status carries its meaning in words; the tint/border is reinforcement. Empty
   takes no space — an empty box with a border read as a stray UI glitch. */
.status {
  margin: 1rem 0 0;
  font-size: 0.88rem;
}

.status:empty { margin: 0; }

.status--ok,
.status--error {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid;
}

.status--ok {
  color: var(--ok-fg);
  background: var(--ok-bg);
  border-color: var(--ok-fg);
}

.status--error {
  color: var(--fail-fg);
  font-weight: 600;
  background: var(--fail-bg);
  border-color: var(--fail-fg);
}

.disclosure {
  margin-top: 2rem;
  font-size: 0.88rem;
}

.disclosure summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.disclosure > *:not(summary) { margin-top: 1rem; }

@media (max-width: 30rem) {
  .shell { padding: 1.5rem 1rem 3rem; }
  .card { padding: 1.1rem; }
}

/* --- Upload ------------------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 2.5rem 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 120ms, background-color 120ms;
}

.dropzone:hover { border-color: var(--accent); }

/* Focus lives on the visually-hidden input, so surface it on the zone. */
.dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dragover is announced by more than colour: the border thickens and the
   background shifts, so it reads without colour perception. */
.dropzone.is-dragover {
  border-style: solid;
  border-color: var(--accent);
  background: var(--surface);
}

.dropzone__icon { font-size: 1.6rem; color: var(--accent); }
.dropzone__main { font-weight: 600; font-size: 1rem; }
.dropzone__hint { color: var(--text-faint); font-size: 0.82rem; }

.camera-row { margin: 0.75rem 0 0; }

/* Shown on touch devices, where photographing a paper bill is the real path. */
@media (hover: hover) and (pointer: fine) {
  .camera-row { display: none; }
}

.batch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

/* Hand-rolled SVG charts (no charting library) — matches the reference this
   whole design comes from (Oakridge-Energy-Panel.html), which draws its own
   charts the same way. */
.chart {
  margin-top: 0.5rem;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-axis {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--text-faint);
}

.batch-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.batch-progress__bar {
  width: 120px;
  flex-shrink: 0;
}

.linkish {
  font: inherit;
  font-size: 0.82rem;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.filelist {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.fileitem {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.fileitem__name {
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.fileitem__meta {
  grid-column: 1;
  font-size: 0.78rem;
  color: var(--text-faint);
}

.fileitem__state { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

/* The progress bar is reinforcement; the percentage is also in the text. */
.progress {
  grid-column: 1 / -1;
  height: 4px;
  margin-top: 0.35rem;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress__fill {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}

.pill--busy { background: var(--border); color: var(--text-muted); }
.pill--warn { background: var(--warn-bg); color: var(--warn-fg); }

.fileitem__error {
  grid-column: 1 / -1;
  margin: 0.35rem 0 0;
  font-size: 0.83rem;
  color: var(--fail-fg);
}

.fileitem__retry { margin-left: 0.5rem; }

/* --- Admin --------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.tab {
  font: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.tab:hover { color: var(--text); }

/* Selected state carries a text weight change and a border, not just colour. */
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.rowaction {
  font: inherit;
  font-size: 0.78rem;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.rowaction + .rowaction { margin-left: 0.6rem; }
.rowaction--danger { color: var(--fail-fg); }

#invite-counts { margin-top: 1.25rem; }

/* --- Bill detail ----------------------------------------------------------
   Adapted from ../Oakridge-Energy-Panel.html — same component vocabulary,
   this app's existing token names (--surface/--border/--text/... rather than
   the reference's own --surface/--line/--ink, which are equivalent values
   under different names). A single-bill view: no trend line, no "vs last
   month" — that needs the own-history work this pass does not build. */

.bill-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.bill-header h2 { margin: 0; }

.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.hero { padding: 0.5rem 0 1.5rem; }

.hero-fig {
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin: 0.4rem 0 0;
  font-variant-numeric: tabular-nums;
}

.hero-sub {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 60ch;
}

.hero-sub b { color: var(--text); font-weight: 600; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1.5rem 0;
}

.tile {
  background: var(--surface);
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tile .k {
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.tile .v {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.tile .n { font-size: 0.76rem; color: var(--text-faint); }

.card-t { font-size: 0.92rem; font-weight: 600; margin-bottom: 0.1rem; }
.card-s { font-size: 0.78rem; color: var(--text-faint); margin-bottom: 1rem; }

.rates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.rate {
  background: var(--surface);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.rate .rk {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.rate .rv {
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.rate .rn { font-size: 0.72rem; color: var(--text-faint); }

.sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* "The arithmetic" — every line item as printed, tfoot rolling up to the
   amount due. Wide content scrolls inside its own container (§ dataviz rule
   already followed elsewhere in this file). */
.tw { overflow-x: auto; margin-top: 0.5rem; }

.arithmetic {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  min-width: 420px;
}

.arithmetic th,
.arithmetic td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.arithmetic th:first-child,
.arithmetic td:first-child { text-align: left; white-space: normal; }

.arithmetic th {
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  border-bottom: 1px solid var(--border-strong);
}

.arithmetic td { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.arithmetic td:first-child { font-family: var(--font); }
.arithmetic tr:last-child td { border-bottom: none; }

.arithmetic tfoot td {
  font-weight: 600;
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
  color: var(--text);
}

.pos { color: var(--credit); }

/* Findings — one card per check result, severity on the left edge rather than
   carried by colour alone (the class name is always printed too). */
.finding {
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius);
}

.finding + .finding { margin-top: 0.6rem; }
.finding--error { border-left-color: var(--fail-fg); }
.finding--warn { border-left-color: var(--warn-fg); }
.finding--info { border-left-color: var(--text-faint); }

.finding__code {
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.3rem;
}

.finding__explanation { margin: 0; font-size: 0.88rem; }

.finding__formula {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-muted);
}


/* ── Overview: what changed ───────────────────────────────────────────────
   A change is not a fault, so these deliberately do not reuse the
   error/warn severity colours: direction carries the meaning, and the
   accent is the same energy palette the charts use. */
.change { border-left-width: 3px; }
.change--up { border-left-color: var(--gas); }
.change--down { border-left-color: var(--credit); }

.change + .change { margin-top: 0.6rem; }

.change__headline {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The AI's sentence. Set apart from the computed figures above it so it
   reads as commentary on the numbers, never as a source of them. */
.change__note {
  margin: 0.55rem 0 0;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.section-lede {
  max-width: 62ch;
  margin-bottom: 1rem;
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ── Progressive disclosure ─────────────────────────────────────────────── */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.disclosure > summary {
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.disclosure > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.disclosure[open] > summary { border-bottom: 1px solid var(--border); }

.disclosure__body { padding: 0.9rem; }
