/*
 * Application styles. Deliberately plain CSS — no framework, no build step.
 * Propshaft serves this file directly.
 */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --line: #e3e3df;
  --edge: #8e8e87;
  --accent: #2f5d50;
  --out: #9a3412;
  --in: #166534;

  /* Money crossing the account boundary. Green in, red out — validated in
     band and above 3:1 against the surface. The pair is ΔE 4 apart under
     deuteranopia, which is to say identical, so nothing in either chart may
     rest on the hue alone: the bars separate in and out by which side of zero
     they sit on, and the lines are dashed and directly labelled. */
  --flow-in: #166534;
  --flow-out: #991b1b;
  --flow-net: #6b6b66;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #1e1f23;
    --text: #e8e8e4;
    --muted: #9a9a94;
    --line: #303138;
    --edge: #74757f;
    --accent: #7fb4a2;
    --out: #f0a882;
    --in: #86c99b;

    /* Re-stepped for the dark surface rather than flipped: the dark band is
       only L 0.48-0.67, so the light-mode steps fall outside it. */
    --flow-in: #16a34a;
    --flow-out: #ef4444;
    --flow-net: #9a9a94;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1.5rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin: 0 0 .25rem; font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.summary { margin: 0; color: var(--muted); }
.summary .as-of { font-size: .82rem; }

/* Explains a column whose meaning is not obvious from its header. */
.note { margin: .5rem 0 0; color: var(--muted); font-size: .82rem; max-width: 62ch; }

/* Recessive against Amount — it is context for the row, not the row's fact. */
td.balance { color: var(--muted); }

/* --- holdings: positions & basis --- */

.holdings { margin-bottom: 2.5rem; }
.holdings h2 { font-size: 1.05rem; margin: 0 0 .25rem; }

.fund-heading {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  font-size: .95rem;
  gap: .5rem;
  margin: 1.75rem 0 .5rem;
}

.fund-heading__meta { color: var(--muted); font-size: .8rem; font-weight: 400; }

/* Tabular figures so share counts and money line up column-wise. */
.symbol { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }
table.positions .numeric, table.basis .numeric { font-variant-numeric: tabular-nums; }

table.positions tfoot th,
table.positions tfoot td,
table.basis tfoot th,
table.basis tfoot td {
  border-top: 2px solid var(--line);
  font-weight: 600;
  padding-top: .55rem;
}

.pct { color: var(--muted); font-size: .78rem; margin-left: .3rem; }
td.pct-cell { color: var(--muted); }
td.share-of-position { color: var(--muted); font-variant-numeric: tabular-nums; }

/* A flagged lot is a data-quality warning, not a value judgement about the
   money, so the row is tinted rather than coloured like a loss — and the flag
   glyph carries the meaning so it is never colour alone. */
tr.is-suspect { background: color-mix(in srgb, var(--out) 8%, transparent); }
tr.is-suspect td.share-of-position { color: var(--text); font-weight: 600; }
.flag { color: var(--out); cursor: help; margin-left: .15rem; }

/* The running total is a reading aid for the column beside it, so it sits back
   from the per-lot gain rather than competing with it. */
td.cumulative { color: var(--muted); font-variant-numeric: tabular-nums; }
table.basis tfoot td.cumulative { color: var(--text); }

/* Distinguishes what created a lot without leaning on colour alone. */
.lot-kind {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .74rem;
  padding: .1rem .5rem;
  white-space: nowrap;
}

.lot-kind--capital-gain { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.lot-kind--transfer-in { border-style: dashed; }

/* --- filters --- */

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.filters__row + .filters__row { margin-top: .875rem; }

.filters label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .8rem;
  color: var(--muted);
}

.filters input,
.filters select {
  font: inherit;
  font-size: .9rem;
  padding: .4rem .5rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  min-width: 11rem;
}

.filters__actions { display: flex; gap: .5rem; align-items: center; margin-left: auto; }

.filters input[type="submit"] {
  min-width: 0;
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: .45rem 1rem;
}

.button-link { color: var(--muted); font-size: .85rem; text-decoration: none; }
.button-link:hover { color: var(--text); text-decoration: underline; }

/* --- table --- */

.transactions {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.transactions th,
.transactions td {
  text-align: left;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.transactions thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
}

.transactions tbody tr:last-child td { border-bottom: 0; }
.transactions tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.account { color: var(--muted); font-size: .875rem; white-space: nowrap; }

.merchant { display: block; font-size: .8rem; color: var(--muted); }
.uncategorized { color: var(--muted); font-style: italic; }

.amount--out { color: var(--out); }
.amount--in { color: var(--in); font-weight: 600; }

/* --- pagination --- */

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  font-size: .9rem;
  color: var(--muted);
}

.pagination a { color: var(--accent); text-decoration: none; }
.pagination a:hover { text-decoration: underline; }

.empty { color: var(--muted); padding: 2rem; text-align: center; }

@media (max-width: 800px) {
  .filters__actions { margin-left: 0; }
  .account { display: none; }
}

/* --- navigation --- */

.site-nav { display: flex; gap: 1.25rem; margin-bottom: 1.5rem; font-size: .9rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding-bottom: .2rem; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text); }
.site-nav a.is-current { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* --- household switch --- */

/* Pushed to the right so it reads as "which data am I looking at", separate
   from the page links on the left. */
.household-switch { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.household-switch__label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.household-switch__form { display: inline; margin: 0; }

.household-switch__option {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  padding: .15rem .7rem;
}

.household-switch__option:hover { color: var(--text); border-color: var(--muted); }

.household-switch__option.is-current {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border-color: var(--accent);
  color: var(--text);
  cursor: default;
  font-weight: 600;
}

/* Standing reminder that the household boundary is not yet enforced by auth. */
.dev-warning {
  background: color-mix(in srgb, var(--out) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--out) 30%, var(--line));
  border-radius: 6px;
  color: var(--muted);
  font-size: .82rem;
  margin: -.75rem 0 1.25rem;
  padding: .45rem .8rem;
}

/* --- stat row --- */

.stat-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }

.stat {
  flex: 1 1 12rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.stat__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat__value { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat__note { font-size: .8rem; color: var(--muted); }

/* --- balance chart ---
   Colours are the validated data-viz palette slot 1 (blue) with the status red
   reserved for a negative balance. Both modes pass the six checks against
   their own surface; the dark steps are chosen for the dark band, not flipped. */

.chart {
  --series: #2a78d6;
  --series-alert: #e34948;
  margin: 0 0 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem;
}

@media (prefers-color-scheme: dark) {
  .chart { --series: #3987e5; --series-alert: #e66767; --series-2: #d95926; }
}

/* Second categorical slot, paired with --series. Validated against both
   surfaces: worst CVD separation 24.7 light / 26.8 dark, well clear of the
   floor, so the two series stay distinct for colourblind readers. */
.chart { --series-2: #eb6834; }

/* Zero here is the axis the bars stand on, not the "you are overdrawn" line the
   balance chart marks, so it is a plain rule rather than a dashed alert. */
.chart--stack .chart__zero { stroke: var(--line); stroke-dasharray: none; opacity: 1; }

.bar__seg--dividend { fill: var(--series); }
.bar__seg--capital-gain { fill: var(--series-2); }

/* Hover raises the whole year, not one segment, because the stack is read as a
   unit and the native title covers both. */
.bar:hover .bar__seg { fill-opacity: .82; }

/* The current year has not finished distributing. Lightened and labelled in
   the caption and table rather than hidden, so the series stays continuous. */
.bar--partial .bar__seg { fill-opacity: .45; }

.chart__value { font-size: 10px; font-weight: 600; fill: var(--muted); }
/* A clamped bar understates itself, so its real figure is not optional. */
.chart__value--clipped { fill: var(--text); }

/* Small multiples share a scale, so they are laid out in one column at equal
   width — side by side at different widths would break the comparison. */
.small-multiples { display: grid; gap: .5rem; }
.small-multiples__item .chart { margin-bottom: .5rem; }
.small-multiples h4 { font-size: .9rem; margin: .5rem 0 .35rem; }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0 0 .5rem; font-size: .8rem; color: var(--muted); }
.legend__item { align-items: center; display: inline-flex; gap: .35rem; }

.legend__swatch { border-radius: 2px; display: inline-block; height: 10px; width: 10px; }
.legend__swatch--dividend { background: var(--series); }
.legend__swatch--capital-gain { background: var(--series-2); }

.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }

/* Height follows width so the 960-wide viewBox fills the container. The balance
   chart stretches with preserveAspectRatio="none", which is fine for a line but
   would smear the labels on a bar chart, so this one scales proportionally.
 *
 * It has to sit after the blanket `.chart svg` rule above, not before it. The
 * two selectors have identical specificity, so ordering is the only thing
 * deciding them, and while this rule sat higher up the stack charts were
 * silently pinned to 240px — the viewBox then letterboxed inside that height,
 * which made the chart narrower every time the viewBox grew taller. The flow
 * chart escaped only by accident of being declared further down. */
.chart--stack svg { height: auto; width: 100%; }

.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__zero { stroke: var(--series-alert); stroke-width: 1; stroke-dasharray: 2 3; opacity: .5; }
.chart__axis { font-size: 10px; fill: var(--muted); }

.chart__area { fill: var(--series); opacity: .1; stroke: none; }
.chart__line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--projected { stroke-dasharray: 5 4; opacity: .85; }

.chart__checkpoint { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }

/* 2px surface ring so the marker reads against the line it sits on */
.chart__marker { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart__marker--alert { fill: var(--series-alert); }
.chart__label { font-size: 11px; font-weight: 600; fill: var(--text); }
.chart__label--alert { fill: var(--series-alert); }

.chart__caption {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--muted);
  padding: .35rem .25rem 0;
}

.chart__caption-mid { font-style: italic; }

/* --- projected rows --- */

.transactions tr.divider td {
  background: var(--bg);
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
  padding: .5rem;
  border-top: 2px solid var(--accent);
}

.row--projected td { opacity: .82; }
.row--projected .date { font-style: italic; }

.tag {
  display: inline-block;
  margin-left: .4rem;
  padding: .05rem .35rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.filters--inline { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filters--inline input[type="number"] { min-width: 6rem; }

/* --- chart hover layer --- */

.chart { position: relative; }

.chart__crosshair { stroke: var(--muted); stroke-width: 1; opacity: .55; pointer-events: none; }
.chart__marker--hover { pointer-events: none; }

.chart__tooltip {
  position: absolute;
  top: .35rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: .05rem;
  padding: .3rem .5rem;
  font-size: .78rem;
  line-height: 1.3;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  border-color: var(--edge);
  pointer-events: none;
  white-space: nowrap;
}

.chart__tooltip strong { font-variant-numeric: tabular-nums; font-size: .9rem; }
.chart__tooltip span { color: var(--muted); font-size: .72rem; }

/* One row per series, each keyed to its band by colour — the reason for
   stacking in the first place. Follows the cursor, so it is positioned from
   JS and only its appearance lives here. */
.chart-tip {
  position: absolute;
  z-index: 3;
  min-width: 13rem;
  max-width: min(26rem, 90%);
  padding: .45rem .55rem;
  font-size: .78rem;
  line-height: 1.45;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 12%);
  pointer-events: none;
  white-space: nowrap;
}

.chart-tip[hidden] { display: none; }

.chart-tip__heading {
  margin-bottom: .3rem;
  padding-bottom: .3rem;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

/* The value column is its own track so figures line up under each other
   however long the labels are. */
.chart-tip__row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: .45rem;
}

.chart-tip__row--total {
  margin-top: .3rem;
  padding-top: .3rem;
  font-weight: 600;
  border-top: 1px solid var(--line);
}

.chart-tip__swatch { border-radius: 2px; height: 10px; width: 10px; }

/* Net is the dashed line, so its key is dashed rather than a fourth hue that
   would read as a fourth series. */
.chart-tip__swatch--dashed {
  background: repeating-linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 5px);
}

/* The flow tooltips are pinned to the top of the figure and slide along it,
   rather than following the cursor as the performance ones do — the crosshair
   is already tracking the pointer, and a panel doing the same would jitter
   against it. */
.chart-tip--flow { top: .35rem; }

/* A year's whole band is hoverable, so the gap at zero and the space above a
   short bar are not dead. */
.bar__hit { fill: transparent; }
.chart-tip__label { overflow: hidden; text-overflow: ellipsis; }
.chart-tip__value { font-variant-numeric: tabular-nums; }

/* --- notice --- */

.notice {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 8px;
  padding: .7rem .9rem;
  margin: 0 0 1.25rem;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--text);
}

/* --- inline categorization --- */

.flash {
  background: color-mix(in srgb, var(--in) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--in) 35%, var(--line));
  border-radius: 6px;
  padding: .5rem .8rem;
  margin: 0 0 1rem;
  font-size: .85rem;
}

.categorize__form { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

.categorize__select {
  font: inherit;
  font-size: .82rem;
  padding: .15rem .3rem;
  max-width: 15rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 4px;
}

/* Recessive until you go looking for it — this column is read far more often
   than it is edited. */
.transactions tr:hover .categorize__select,
.categorize__select:focus { border-color: var(--line); }
.categorize__select:invalid, .categorize__select option[value=""] { color: var(--muted); }

.categorize__bulk {
  display: flex;
  align-items: center;
  gap: .2rem;
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

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

/* --- reconciliation --- */

.reconcile-period { margin-bottom: 1.75rem; }
.reconcile-period h2 { font-size: .95rem; margin: 0 0 .4rem; font-variant-numeric: tabular-nums; }
.reconcile-period__meta { color: var(--muted); font-size: .78rem; font-weight: 400; margin-left: .5rem; }

/* The two checks answer different questions, so they are labelled on every
   row rather than only in the prose above the table. */
.check-kind {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .03em;
  padding: .05rem .45rem;
  text-transform: uppercase;
}

.check-kind--position { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

table.reconcile .numeric { font-variant-numeric: tabular-nums; }
tr.is-break { background: color-mix(in srgb, var(--out) 8%, transparent); }
tr.is-break td { font-weight: 600; }

.filters__check { flex-direction: row; align-items: center; gap: .4rem; }
.in { color: var(--in); }
.out { color: var(--out); }

/* --- performance ---
   The validated eight-slot categorical palette, assigned in fixed order so a
   holding keeps its colour across every year, every chart and the table.
   Both modes pass the six checks against their own surface; the dark steps are
   chosen for the dark band rather than flipped. Three light steps sit below
   3:1 contrast, which the legend and the table below satisfy as relief. */

.chart {
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100;
  --cat-5: #e87ba4; --cat-6: #008300; --cat-7: #4a3aa7; --cat-8: #e34948;
  --cat-9: #6b6b66;
}

@media (prefers-color-scheme: dark) {
  .chart {
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
    --cat-5: #d55181; --cat-6: #008300; --cat-7: #9085e9; --cat-8: #e66767;
    --cat-9: #9a9a94;
  }
}

table.performance .numeric { font-variant-numeric: tabular-nums; }
table.performance td.total { font-weight: 600; }

/* Transfers: diverging bars and cumulative lines.
   ------------------------------------------------------------------ */

.chart--flow .chart__zero {
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-dasharray: none;
  opacity: .55;
}

/* Proportional scaling, so pointer position converts cleanly into viewBox
   units — the bar labels would smear under preserveAspectRatio="none". */
.chart--flow svg { height: auto; width: 100%; }

.chart--flow .bar__seg:hover { fill-opacity: .75; }

.chart__marker--in { fill: var(--flow-in); }
.chart__marker--out { fill: var(--flow-out); }
.chart__marker--net { fill: var(--flow-net); }

/* A transfer description is a line off a statement and can be long, so this
   one wraps where the balance chart's single figure never needs to. */
.chart__tooltip--flow {
  max-width: 22rem;
  white-space: normal;
}

/* A short dashed rule rather than a filled block: the net line is dashed, and
   the legend should look like the thing it names. */
.legend__swatch--dashed {
  background: repeating-linear-gradient(90deg,
    var(--flow-net) 0 4px, transparent 4px 7px);
  border-radius: 0;
  height: 2px;
  width: 16px;
}

.line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line--in { stroke: var(--flow-in); }
.line--out { stroke: var(--flow-out); }

/* Dashed, because a third line that a red-green viewer reads as a duplicate
   of one of the other two is worse than no third line. */
.line--net { stroke: var(--flow-net); stroke-dasharray: 5 4; }

.chart__label { font-size: 11px; font-weight: 600; }
.chart__label--in { fill: var(--flow-in); }
.chart__label--out { fill: var(--flow-out); }
.chart__label--net { fill: var(--flow-net); }

/* Expandable year rows.
   ------------------------------------------------------------------ */

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

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-head__actions { display: flex; gap: .5rem; }

/* The year cell is the control, so the whole thing is the hit target rather
   than a caret small enough to miss. */
.disclosure {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

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

.disclosure__caret {
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .12s ease;
}

.disclosure[aria-expanded="true"] .disclosure__caret { transform: rotate(90deg); }

.detail-row > td {
  padding: 0 0 .6rem 1.6rem;
  background: color-mix(in srgb, var(--text) 3%, var(--surface));
}

table.detail {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

table.detail th {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: .35rem .5rem;
}

table.detail th.numeric,
table.detail td.numeric { text-align: right; }

table.detail td {
  padding: .3rem .5rem;
  border-top: 1px solid var(--line);
}

.nowrap { white-space: nowrap; }

/* Statement column on the transactions list.
   ------------------------------------------------------------------ */

.transactions td.statement { font-size: .8rem; white-space: nowrap; }
.transactions td.statement a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--line); }
.transactions td.statement a:hover { color: var(--accent); border-bottom-color: currentColor; }
.transactions td.statement a.is-break { color: var(--out); }
.transactions td.statement .unchecked { color: var(--line); cursor: help; }

/* Console (development only, bin/console-server on 3006).
   ------------------------------------------------------------------ */

.console-households { display: flex; gap: .75rem; align-items: baseline; margin-bottom: 1.25rem; font-size: .875rem; }
.console-households a { color: var(--accent); text-decoration: none; }
.console-households a:hover { text-decoration: underline; }
.console-households__current { font-weight: 600; }

.console-tables { margin-top: 1.5rem; }
.console-tables th[scope="row"] { font-weight: 600; text-align: left; white-space: nowrap; }

/* An empty table is the useful signal here — it means an importer has not run
   for this household — so it recedes rather than reading as a real count. */
.console-tables__empty { color: var(--line); }

.console-tables__columns {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
  max-width: 52ch;
}

.console-tables code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

/* Console row browser: raw table contents.
   ------------------------------------------------------------------ */

/* A table with 20 columns of raw values will not fit, and must not be allowed
   to widen the page — it scrolls inside its own box instead. */
.console-scroll { overflow-x: auto; margin-top: 1.25rem; }

.console-rows { font-size: .8rem; min-width: 100%; }
.console-rows th, .console-rows td { white-space: nowrap; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; }
.console-rows td { font-variant-numeric: tabular-nums; }
.console-rows thead th a { color: inherit; text-decoration: none; }
.console-rows thead th a:hover { color: var(--accent); }
.console-rows thead th a.is-sorted { color: var(--text); }
.console-rows__arrow { margin-left: .25rem; font-size: .7em; }

/* Absent, not zero or empty — the distinction matters when reading an import. */
.console-rows__null { color: var(--line); font-style: italic; }

/* Balance history: statement anchors along the axis.
   ------------------------------------------------------------------ */

.chart__anchor { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart__anchor--break { stroke: var(--out); stroke-width: 2; opacity: 1; }

/* --- reconciliation -------------------------------------------------------
   No new colours. --in and --out already carry direction, --out already marks
   a break, --accent already marks focus. Reusing them means nothing here needs
   validating against either surface again; what changes is structure, which is
   what was actually hard to read.

   Rows get a band and a rule, columns get a rule where the arithmetic changes
   hands: opening | change | closing is one claim, and expected | verdict is
   the test of it. */

table.reconcile { border-collapse: separate; border-spacing: 0; width: 100%; }

table.reconcile thead th {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: .5rem .7rem;
  position: sticky;
  text-align: left;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

table.reconcile th.numeric, table.reconcile td.numeric { text-align: right; }
table.reconcile .numeric { font-variant-numeric: tabular-nums; }

table.reconcile tbody td {
  border-bottom: 1px solid var(--line);
  padding: .45rem .7rem;
  vertical-align: top;
}

/* Banding, not borders, for rows — a rule between every row competes with the
   column rules and the table stops having a grain. */
table.reconcile tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
table.reconcile tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Where one claim ends and the next begins. */
table.reconcile .col-edge { border-left: 1px solid var(--line); }

table.reconcile tfoot td {
  border-top: 2px solid var(--line);
  font-weight: 600;
  padding: .55rem .7rem;
}

/* Direction, on the one column that has one. */
.delta--in { color: var(--in); }
.delta--out { color: var(--out); }
.delta--none { color: var(--muted); }

/* A break is marked by weight and a tinted band, never by colour alone. */
table.reconcile tr.is-break { background: color-mix(in srgb, var(--out) 10%, transparent); }
table.reconcile tr.is-break td { font-weight: 600; }
table.reconcile tr.is-break:hover { background: color-mix(in srgb, var(--out) 16%, transparent); }

.verdict { font-size: .78rem; white-space: nowrap; }
.verdict--ok { color: var(--in); }
.verdict--break { color: var(--out); font-weight: 600; }
.verdict--none { color: var(--muted); }

/* The security column carries a ticker and a name; the ticker is the key and
   should read as one. */
table.reconcile .symbol { font-weight: 600; letter-spacing: .01em; }
table.reconcile .security { color: var(--muted); font-size: .84rem; }

/* A detail row is one cell spanning the table, so it needs its own inset to
   read as nested rather than as another row of the same table. */
table.reconcile .detail-row > td { background: var(--bg); padding: .6rem .9rem 1rem; }
table.reconcile table.detail { margin-top: .5rem; width: 100%; }
table.reconcile table.detail thead th { border-bottom: 1px solid var(--line); }
table.reconcile--expandable > tbody > tr:not(.detail-row):nth-of-type(4n+3) {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
/* The banding above counts detail rows too, so the plain nth-child rule stripes
   in pairs. Detail rows carry their own background and are excluded. */
table.reconcile--expandable > tbody > tr:nth-child(even):not(.detail-row) { background: none; }

/* --- account picker -------------------------------------------------------
   A row of links was hard to scan and harder to hit. Each account is now a
   rectangle with its own target, and accounts of a kind stack together — an
   IRA, another IRA and a 403(b) read as one group whoever has custody of them,
   which a flat alphabetical row could not show. */

.account-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* The stack. Groups sit side by side; accounts within one sit above each
   other, so the grouping is legible without a heading naming it. */
.account-picker__group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}


.account-pill__name { display: block; font-size: .92rem; }
.account-pill__meta { display: block; color: var(--muted); font-size: .74rem; }

/* --- account picker outlines ----------------------------------------------
   Scoped to the picker: --line is faint on purpose because it also draws the
   rules inside a table, where a strong stroke fights the banding and the table
   stops having a grain. A control you click is a different job.

   --edge clears 3:1 against both surfaces, which is the threshold for a
   boundary that carries meaning rather than decorating one. Flat: a border
   marks an edge without pretending the element floats above a surface it is
   not above. */

.account-pill {
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: 6px;
  color: var(--text);
  display: block;
  min-width: 11rem;
  padding: .4rem .7rem;
  text-decoration: none;
}

.account-pill:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--edge));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

/* Selection is carried by the rule, the fill and the weight together, so it
   survives being read without colour. */
.account-pill.is-current {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.account-pill.is-current .account-pill__name { font-weight: 700; }

.account-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A nav link whose screen still queries the old schema. Marked rather than
   hidden — these are the remaining work, and dropping them would make the
   migration look further along than it is.

   Colour alone does not say why, so the link carries a title and
   screen-reader text; the dotted underline gives it a second signal for
   anyone who cannot see the red. */
.site-nav a.is-unported {
  color: var(--flow-out);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.site-nav a.is-unported:hover { color: var(--flow-out); opacity: .8; }

/* --- who is signed in --- */

.whoami { align-items: center; display: inline-flex; gap: .5rem; margin-left: auto; }
.whoami__name { color: var(--muted); font-size: .8rem; }

/* Named rather than implied by a greyed-out control: a page that silently
   ignores clicks is worse than one that says why. */
.whoami__role {
  border: 1px solid var(--edge);
  border-radius: 3px;
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .02em;
  padding: .1rem .3rem;
  text-transform: uppercase;
}

.whoami__form { display: inline; }
.whoami__signout {
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: .78rem;
  padding: .15rem .5rem;
}
.whoami__signout:hover { border-color: var(--edge); color: var(--text); }

/* --- sign in / register --- */

.signin { margin: 3rem auto; max-width: 22rem; }
.signin h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.signin__form { display: flex; flex-direction: column; gap: .8rem; }
.signin__form label { display: flex; flex-direction: column; font-size: .85rem; gap: .25rem; }
.signin__form input[type="submit"] { cursor: pointer; margin-top: .4rem; padding: .45rem; }
.signin__errors { color: var(--series-alert); font-size: .82rem; margin: 0 0 .6rem; padding-left: 1.1rem; }
.signin .optional { color: var(--muted); font-weight: normal; }
