/* Rising Dough — v2 chrome.
 * Loads after tokens.css + fonts.css + tailwind.css + legacy app.css.
 * Rules here win via specificity + later cascade order. Scope is
 * intentionally bounded: rail, screen chrome, hero, segmented tabs,
 * tables, pills, pace tags, buttons.  See ADR-0050..0056. */

/* ─── Baseline overrides ──────────────────────────────────────────── */
html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.25rem, 1.6rem + 2vw, 3.5rem); line-height: 1.05; }
h2 { font-size: clamp(1.5rem, 1.2rem + 0.8vw, 2rem); line-height: 1.15; }
h3 { font-size: 1.125rem; line-height: 1.25; }

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

.rd-eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mute);
  font-weight: 500;
}

/* ─── App shell ───────────────────────────────────────────────────── */
body.rd {
  background: var(--paper);
}

.rd-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100dvh;
}

.rd-rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 2rem 1.5rem;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.rd-wordmark {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}

nav[aria-label="Primary navigation"] { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.rd-nav { display: flex; flex-direction: column; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.rd-nav__item { display: flex; align-items: center; justify-content: space-between; }

.rd-nav__link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-control);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  position: relative;
}
.rd-nav__link:hover { background: var(--sunk); }
.rd-nav__link[aria-current="page"] { background: var(--sunk); }

.rd-nav__link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -0.6rem;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.rd-nav__shortcut {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--mute);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.3rem;
}

.rd-rail__footer {
  margin-top: auto;
  padding-top: 0.875rem;
  border-top: 1px solid var(--line);
}
.rd-rail__footer .rd-nav__link { border-radius: 0; }

.rd-main {
  padding: 2.25rem 2.5rem 3rem;
  min-width: 0;
  max-width: 1280px;
}

/* ─── Screen header ───────────────────────────────────────────────── */
.rd-screen-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 2rem;
  margin-bottom: 1.5rem;
}
.rd-screen-header__title h1 { margin: 0.25rem 0 0; }

.rd-screen-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-self: end;
}

/* ─── Segmented tabs ──────────────────────────────────────────────── */
.rd-segmented {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 0.2rem;
}

.rd-segmented__item {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--mute);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.rd-segmented__item:hover { color: var(--ink); }

.rd-segmented__item[aria-selected="true"],
.rd-segmented__item--active {
  background: var(--ink);
  color: var(--paper);
}

.rd-segmented__item .rd-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: inherit;
  opacity: 0.85;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.rd-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.rd-btn:hover { background: var(--sunk); }
.rd-btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.rd-btn--primary:hover { background: oklch(40% 0.14 265); }
.rd-btn--ghost { background: transparent; border-color: transparent; }
.rd-btn--ghost:hover { background: var(--sunk); }
.rd-btn--sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.rd-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.05rem 0.3rem;
  background: color-mix(in oklab, currentColor 12%, transparent);
  border-radius: 4px;
  margin-left: 0.4rem;
}
.rd-btn--primary kbd { background: rgb(255 255 255 / 0.22); }

/* ─── Pills ───────────────────────────────────────────────────────── */
.rd-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--sunk);
  color: var(--mute);
}
.rd-pill--expense { background: var(--expense-soft); color: var(--expense); }
.rd-pill--income  { background: var(--income-soft);  color: var(--income); }
.rd-pill--transit { background: var(--transit-soft); color: var(--transit); }
.rd-pill--adjust  { background: var(--adjust-soft);  color: var(--adjust); }
.rd-pill--muted   { background: var(--sunk); color: var(--mute); opacity: 0.65; }

.rd-pill[data-hue] {
  background: oklch(94% 0.045 var(--hue, 0));
  color: oklch(40% 0.13 var(--hue, 0));
}

/* ─── Direction badge ─────────────────────────────────────────────── */
.rd-dir {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.rd-dir--expense { color: var(--expense); }
.rd-dir--income  { color: var(--income); }
.rd-dir--transit { color: var(--transit); }
.rd-dir--adjust  { color: var(--adjust); }

/* ─── Pace tag ────────────────────────────────────────────────────── */
.rd-pace {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--income-soft);
  color: var(--income);
}
.rd-pace--tight    { background: var(--adjust-soft); color: var(--adjust); }
.rd-pace--over-limit { background: var(--expense-soft); color: var(--expense); }

/* ─── Overdue chip ────────────────────────────────────────────────── */
.rd-overdue {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--expense);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
}

/* ─── Hero ────────────────────────────────────────────────────────── */
.rd-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.6fr);
  gap: 1.5rem;
  align-items: start;
}

.rd-hero {
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.rd-hero__label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mute);
  margin-bottom: 0.5rem;
}

.rd-hero__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.rd-hero__amount {
  font-family: var(--font-display);
  font-size: clamp(4rem, 2.8rem + 5vw, 6rem);
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "lnum", "tnum";
}

.rd-hero__cur {
  font-size: 1.1rem;
  color: var(--mute);
  letter-spacing: 0;
  text-transform: none;
}
.rd-hero__meta { margin-top: 0.3rem; color: var(--mute); font-size: 0.9rem; }

.rd-hero__legend {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink);
}
.rd-hero__legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.rd-hero__legend-item--total { color: var(--mute); }

.rd-hero__swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.6rem;
  border-radius: 2px;
  background: var(--ink);
}
.rd-hero__swatch--spent { background: var(--ink); }

.rd-hero__swatch--committed {
  background: repeating-linear-gradient(135deg, var(--ink) 0 2px, var(--sunk) 2px 5px);
}
.rd-hero__swatch--left { background: var(--accent-soft, var(--sunk)); border: 1px solid var(--accent, var(--line)); }

.rd-hero__period {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--mute);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.rd-afford {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.rd-afford__row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.rd-afford__label { font-weight: 600; }

.rd-afford__input-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--accent, var(--line));
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft, var(--sunk));
}

.rd-afford__input {
  width: 5rem;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 1rem;
  text-align: right;
}
.rd-afford__input:focus { outline: none; }
.rd-afford__preview { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.rd-afford__new { font-size: 1.05rem; font-weight: 600; }
.rd-afford__delta { font-size: 0.8rem; }
.rd-afford__pace { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.1rem 0.4rem; border-radius: 999px; }
.rd-afford__pace--on_track { color: var(--income); background: var(--income-soft); }
.rd-afford__pace--tight { color: var(--adjust); background: var(--adjust-soft); }
.rd-afford__pace--over_limit { color: var(--expense); background: var(--expense-soft); }

/* ─── Net worth card (right side of hero) ─────────────────────────── */
.rd-netcard {
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.rd-netcard__header { margin-bottom: 0.6rem; }

.rd-netcard__total {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-top: 0.35rem;
}
.rd-netcard__total .cur { font-family: var(--font-mono); font-size: 0.75rem; color: var(--mute); font-weight: 400; margin-left: 0.35rem; }
.rd-netcard__split { font-size: 0.75rem; margin-top: 0.15rem; }
.rd-netcard__rows { display: grid; gap: 0.1rem; margin-top: 0.85rem; font-size: 0.85rem; }

.rd-netcard__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.4rem 0;
  color: var(--ink);
}
.rd-netcard__row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-netcard__row .num { color: var(--ink); }
.rd-netcard__row .num.neg { color: var(--expense); }
.rd-netcard__row--liab .num { color: var(--expense); }

.rd-netcard__links {
  display: flex;
  justify-content: space-between;
  margin-top: 0.6rem;
  font-size: 0.8rem;
}
.rd-netcard__links a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* ─── Upcoming panel ──────────────────────────────────────────────── */
.rd-panel {
  margin-top: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.rd-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.rd-panel__title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; margin: 0; }
.rd-panel__filters { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* /today Upcoming extras (segmented hero bar, day grouping, "showing N of M"). */
.rd-hero__progress { margin-top: 0.75rem; }
.rd-committed { color: var(--committed, var(--accent)); font-weight: 500; }

.rd-upcoming-table tr.rd-upcoming-group th {
  background: var(--paper);
  padding: 0.75rem 0.9rem 0.4rem;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
}

.rd-upcoming-more {
  margin: 0.75rem 1.25rem 1.25rem;
  color: var(--mute);
  font-size: 0.85rem;
}
.rd-upcoming-more a { color: var(--accent); }

/* F-02 inline row-expand promote form. */
.rd-inline-promote {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.5rem 0;
  background: color-mix(in oklab, var(--accent) 4%, transparent);
}
.rd-inline-promote .rd-field--inline { flex-direction: column; gap: 0.2rem; min-width: 0; }
.rd-inline-promote .rd-field__label { font-size: 0.65rem; }

.rd-inline-promote input[type="date"],
.rd-inline-promote input[type="text"] {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font-family: var(--font-mono);
}

.rd-inline-promote__actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}
.upcoming-row--editing td { background: color-mix(in oklab, var(--accent) 4%, var(--paper)); }

/* ─── Table-row ───────────────────────────────────────────────────── */
.rd-table { width: 100%; border-collapse: collapse; }

.rd-table th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}

.rd-table th.num,
.rd-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.rd-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 0.9rem;
}
.rd-table tr:last-child td { border-bottom: 0; }
.rd-table .rd-cat { white-space: nowrap; }
.rd-table .rd-desc { font-weight: 500; }
.rd-table .rd-desc small { display: block; font-weight: 400; color: var(--mute); font-size: 0.78rem; margin-top: 0.1rem; }
.rd-table tr.rd-row--overdue td:first-child { position: relative; }
.rd-table tr.rd-row--overdue td { background: color-mix(in oklab, var(--expense) 6%, transparent); }

.rd-day-head td {
  background: var(--paper);
  padding: 0.5rem 0.9rem 0.35rem;
  font-size: 0.75rem;
  color: var(--mute);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.rd-day-head td .net { float: right; font-family: var(--font-mono); }

/* Ledger summary strips (Monthly in/out · Planned total). */
.rd-recurring-strip,
.rd-planned-strip {
  display: flex;
  gap: 2rem;
  align-items: baseline;
  padding: 0.9rem 1.1rem;
  margin: 0.9rem 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.rd-recurring-strip strong,
.rd-planned-strip strong { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; }
.rd-planned-strip { font-size: 0.9rem; }

/* Empty-state card for Planned / Recurring tabs. */
.rd-empty-state {
  margin: 1.25rem 0;
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  text-align: center;
}
.rd-empty-state strong { display: block; font-family: var(--font-display); font-size: 1.25rem; margin-bottom: 0.4rem; }
.rd-empty-state p { max-width: 32rem; margin: 0 auto 1rem; }

/* Fallback neutral pill. */
.rd-pill--neutral { background: var(--sunk); color: var(--mute); }

/* ─── Plan · Analytics bento + list treatment (ADR-0056 §6) ──────── */
.rd-analytics__chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
}

.rd-analytics-bundle {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1.25rem;
}
.rd-analytics__right { display: flex; flex-direction: column; gap: 1.25rem; }

@media (width <= 900px) {
  .rd-analytics-bundle { grid-template-columns: 1fr; }
}

.rd-analytics__spend-body { padding: 0.5rem 1.25rem 1.25rem; }
.rd-analytics__flow-body { padding: 1rem 1.25rem 1.25rem; }

.rd-analytics__badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--mute);
}

.rd-analytics__spend-list { list-style: none; padding: 0; margin: 0; }

.rd-analytics__row {
  display: grid;
  grid-template-columns: minmax(8rem, 10rem) minmax(0, 1fr) 6rem 7rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.4rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--line) 50%, transparent);
}
.rd-analytics__row:hover { background: color-mix(in oklab, var(--accent) 4%, transparent); }
.rd-analytics__row--head { padding: 0.3rem 0.4rem; font-size: 0.72rem; border-bottom: 1px solid var(--line); }
.rd-analytics__row--head:hover { background: transparent; }

.rd-analytics__row > strong,
.rd-analytics__row > .rd-analytics__delta { text-align: right; }

.rd-analytics__row--head > .rd-eyebrow:nth-child(3),
.rd-analytics__row--head > .rd-eyebrow:nth-child(4) { text-align: right; }

.rd-analytics__bar {
  position: relative;
  height: 8px;
  background: var(--sunk);
  border-radius: 4px;
  overflow: hidden;
}

.rd-analytics__bar::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--pct, 0%);
  background: var(--ink);
}
.rd-analytics__delta { font-size: 0.75rem; font-family: var(--font-mono); }
.rd-analytics__delta--over { color: var(--expense); }
.rd-analytics__delta--under { color: var(--income); }
.rd-analytics__delta--flat { color: var(--mute); }

.rd-analytics__largest-list { list-style: none; padding: 0 1.25rem 1.25rem; margin: 0; display: grid; gap: 0; }

.rd-analytics__largest-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  border-top: 1px solid var(--line);
}
.rd-analytics__largest-list li:first-child { border-top: 0; }

.rd-analytics__footer { margin: 1rem 0 0; font-size: 0.85rem; }

/* ─── Plan · Forecast layout extras ──────────────────────────────── */
.rd-forecast__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.rd-forecast__summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.rd-forecast__sum-item { display: flex; flex-direction: column; align-items: flex-start; }

.rd-forecast__sum-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.rd-forecast__table-title { margin: 2rem 0 0.5rem; font-family: var(--font-display); font-weight: 500; font-size: 1.1rem; }
.rd-forecast__net--neg { color: var(--expense); background: var(--expense-soft); }
.rd-forecast__eom strong { font-weight: 700; }

/* ─── Amount styling ──────────────────────────────────────────────── */
.rd-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.rd-amount--expense { color: var(--expense); }
.rd-amount--income  { color: var(--income); }
.rd-amount__currency { font-size: 0.7em; color: var(--mute); margin-left: 0.25rem; }
.rd-amount__formula  { font-family: var(--font-display); font-style: italic; margin-left: 0.3rem; color: var(--mute); }

/* ─── Filter chip row ─────────────────────────────────────────────── */
.rd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.rd-chips__search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.rd-chips__search input {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  min-width: 12rem;
}

.rd-chip-select {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-control);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}

.rd-chip-select::after {
  content: "▾";
  color: var(--mute);
  font-size: 0.7em;
  margin-left: 0.15rem;
}

kbd.rd-kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0 0.25rem;
  background: var(--sunk);
  border-radius: 4px;
  color: var(--mute);
}

/* ─── Period header ───────────────────────────────────────────────── */
.rd-period {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
}
.rd-period__label { color: var(--mute); font-size: 0.85rem; }
.rd-period__range  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.9rem; }

.rd-period__bar {
  height: 8px;
  background: var(--sunk);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.rd-period__bar > span {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink);
}

.rd-period__bar > span.committed {
  background: repeating-linear-gradient(45deg, var(--mute), var(--mute) 3px, transparent 3px, transparent 7px);
}

.rd-period__amt {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  line-height: 1;
}
.rd-period__amt small { display: block; font-size: 0.7rem; color: var(--mute); font-family: var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.25rem; }

/* ─── Progress bar ────────────────────────────────────────────────── */
.rd-progress {
  display: inline-block;
  width: 100%;
  min-width: 180px;
  max-width: 320px;
  height: 8px;
  background: var(--sunk);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  vertical-align: middle;
}

.rd-period__bar .rd-progress { width: 100%; max-width: none; height: 10px; border-radius: 5px; }

.rd-progress__spent {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink);
}

.rd-progress__committed {
  position: absolute; top: 0; bottom: 0;
  background: repeating-linear-gradient(45deg, var(--mute), var(--mute) 3px, transparent 3px, transparent 6px);
}
.rd-progress--over .rd-progress__spent { background: var(--expense); }

/* ─── Toast root ──────────────────────────────────────────────────── */
#toast-root {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rd-toast {
  background: var(--ink);
  color: var(--paper);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-overlay);
}

.rd-toast__undo {
  color: var(--paper);
  background: transparent;
  border: 1px solid rgb(255 255 255 / 0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ─── Cheatsheet modal ────────────────────────────────────────────── */
.rd-cheatsheet {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay);
  max-width: 32rem;
}
.rd-cheatsheet dl { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; margin: 0.75rem 0 0; }
.rd-cheatsheet dt { font-family: var(--font-mono); color: var(--mute); font-size: 0.85rem; }
.rd-cheatsheet dd { margin: 0; font-size: 0.9rem; }

/* ─── Sparkline ───────────────────────────────────────────────────── */
.rd-sparkline { width: 90px; height: 24px; display: inline-block; vertical-align: middle; }
.rd-sparkline path.area { fill: var(--accent-soft); }
.rd-sparkline path.line { fill: none; stroke: var(--accent); stroke-width: 1.25; }

/* ─── Charts (ADR-0054) ───────────────────────────────────────────── */
.rd-chart {
  margin: 0;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.rd-chart__caption {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.rd-chart__svg {
  width: 100%;
  height: auto;
  display: block;
}

.rd-chart__svg--line  { height: 240px; }
.rd-chart__svg--bars  { height: 260px; }
.rd-chart__svg--hbars { height: auto; }

.rd-chart__gridline {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.rd-chart__y-label,
.rd-chart__x-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--mute);
}

.rd-chart__line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.rd-chart__area {
  fill: var(--accent-soft);
  opacity: 0.55;
}

.rd-chart__dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}

.rd-chart__bar--income  { fill: var(--income); }
.rd-chart__bar--expense { fill: var(--expense); }
.rd-chart__bar--hbar    { fill: var(--accent); }
.rd-chart__bar-track    { fill: var(--sunk); }

.rd-chart__hbar-label {
  font-family: var(--font-body);
  font-size: 12px;
  fill: var(--ink);
  dominant-baseline: middle;
}

.rd-chart__hbar-value {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--mute);
  dominant-baseline: middle;
  text-anchor: end;
}

.rd-chart__fallback {
  margin-top: 1rem;
  font-size: 0.85rem;
}
.rd-chart__fallback summary { cursor: pointer; color: var(--mute); }
.rd-chart__fallback[open] summary { color: var(--ink); }
.rd-chart__fallback table { margin-top: 0.75rem; }

.rd-chart__legend {
  display: inline-flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--mute);
}

.rd-chart__legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.rd-chart__legend-swatch--income  { background: var(--income); }
.rd-chart__legend-swatch--expense { background: var(--expense); }

/* ─── Heatmap cell ────────────────────────────────────────────────── */
.rd-heat {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 2.5rem;
  height: 34px;
  padding: 0 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  background: color-mix(in oklab, var(--expense) var(--weight, 0%), var(--surface));
  color: var(--ink);
  border: 0;
  border-radius: 3px;
}
.rd-heat--one-off { font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }

.rd-heat--recurring {
  font-style: italic;
  background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in oklab, var(--accent) 12%, transparent) 4px 5px);
}
.rd-heat--unset { color: var(--mute); background: transparent; border: 1px dashed var(--line); }

/* ─── Legacy `.ledger` table ↦ Rising Dough look ──────────────────── */
.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ledger th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}

.ledger td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.ledger .text-right,
.ledger th.text-right,
.ledger td.text-right {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ledger-scroll {
  overflow-x: auto;

  /* Anchor absolutely-positioned descendants (.sr-only th labels) so they
   * don't escape the scroller and widen the document (T-VIS). */
  position: relative;
}

/* Category chip inside legacy ledger rows ↦ pill. */
.ledger .category-chip,
.ledger .category-pill {
  display: inline-flex;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--expense-soft);
  color: var(--expense);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── Legacy `.panel` card ↦ Rising Dough look ────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.5rem;
}
.panel__hero { font-family: var(--font-display); font-size: 1.5rem; }

/* ─── Legacy segmented control ↦ rd-segmented ─────────────────────── */
.segmented {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 0.2rem;
}

.segmented__btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--mute);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.segmented__btn--active,
.segmented__btn[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

/* ─── Last-checked chip ───────────────────────────────────────────── */
.rd-checked {
  display: inline-flex;
  padding: 0.1rem 0.5rem;
  background: var(--sunk);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  color: var(--mute);
}
.rd-checked--today { background: var(--income-soft); color: var(--income); }
.rd-checked--warn { background: color-mix(in oklab, var(--adjust) 20%, transparent); color: var(--adjust); }
.rd-checked--stale { background: color-mix(in oklab, var(--expense) 15%, transparent); color: var(--expense); }

/* ─── Credit-card utilisation bar (ADR-0056 §7) ──────────────────── */
.rd-credit-bar {
  display: block;
  margin-top: 0.4rem;
  max-width: 32rem;
}

.rd-credit-bar__track {
  display: block;
  position: relative;
  height: 6px;
  background: var(--sunk);
  border-radius: 3px;
  overflow: hidden;
}

.rd-credit-bar__track::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--used-pct, 0%);
  background: var(--expense);
}

.rd-credit-bar__meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--mute);
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

/* Colour-swatch dot used in Settings · Categories to indicate per-category
 * colour overrides vs direction-default. */
.rd-swatch-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--swatch, var(--mute));
  margin-right: 0.4rem;
  vertical-align: middle;
  border: 1px solid color-mix(in oklab, var(--ink) 15%, transparent);
}

/* .rd-settings-anchor styles live near the manual-audit #52 section below. */

/* F-04 Add entry overlay — tabs + footer hint. */
.rd-add-entry-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.rd-add-entry-tabs .rd-segmented__item { border: 0; background: transparent; cursor: pointer; }

.rd-add-entry__hint {
  padding: 0.75rem 1.25rem 1.25rem;
  margin: 0;
  font-size: 0.8rem;
}

/* ─── Mobile tab bar (Phase 6 stub, hidden desktop) ───────────────── */
.rd-tabbar { display: none; }

@media (width <= 640px) {
  /* minmax(0, 1fr), not 1fr: a bare 1fr has an `auto` minimum so wide tables
   * (.ledger-scroll) blow the single column past the viewport (T-VIS). */
  .rd-shell { grid-template-columns: minmax(0, 1fr); }
  .rd-rail { display: none; }
  .rd-main { padding: 1rem 1rem 5rem; }

  /* Stack title / actions and allow the segmented tabs to scroll horizontally
   * when the number of tabs or action buttons exceeds the viewport width. */
  .rd-screen-header {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .rd-screen-header__actions {
    justify-self: start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .rd-segmented {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .rd-chips { flex-wrap: wrap; }

  .rd-hero-grid { grid-template-columns: 1fr; }

  .rd-tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 0.4rem 0;
    z-index: 20;
  }

  .rd-tabbar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: var(--mute);
    text-decoration: none;
    padding: 0.3rem;
  }
  .rd-tabbar__item[aria-current="page"] { color: var(--ink); }

  .rd-tabbar__add {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 999px;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: -1.25rem;
    box-shadow: var(--shadow-overlay);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
  }

  /* L-02 — Make row action controls meet the 44 px tap-target floor without
   * forcing the whole desktop table to grow. */
  .rd-actions .rd-btn,
  .rd-actions button,
  .rd-actions [data-kebab-trigger] {
    min-height: 44px;
    min-width: 44px;
    padding-inline: 0.75rem;
  }
}

/* L-03/L-04 — Accounts hero stacks and liability pill flows under the account
 * name on narrow widths so numbers never collide and the pill doesn't wrap
 * mid-word. Scoped to the hero + first row cell to avoid affecting other
 * dense tables. */
@media (width <= 640px) {
  /* Fortune hero: stack columns vertically so Assets/Liabilities don't
   * overlap the headline total. */
  .rd-accounts-hero { grid-template-columns: 1fr !important; gap: 0.75rem !important; }

  .rd-table .rd-desc { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .rd-table .rd-desc > .rd-pill { white-space: nowrap; }
}

/* ─── View Transitions (feature-detected, reduced-motion safe) ────── */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: var(--dur);
    animation-timing-function: var(--ease);
  }
}

/* ─── Form chrome (overlays: Create account / Create category / …) ─ */
.rd-form { display: grid; gap: 1rem; }
.rd-form-row { display: grid; gap: 1rem; }
.rd-form-row--2col { grid-template-columns: 1fr 1fr; }
.rd-field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }

.rd-field__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mute);
  font-weight: 600;
}

.rd-field__label em {
  font-style: normal;
  color: var(--mute);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
}

.rd-field__help {
  font-size: 0.8rem;
  color: var(--mute);
  margin: -0.25rem 0 0;
  line-height: 1.4;
}

.rd-field input[type="text"],
.rd-field input[type="date"],
.rd-field input[type="number"],
.rd-field input:not([type]) {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
}

.rd-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.rd-field input:disabled { background: var(--sunk); color: var(--mute); }

.rd-field__suffix { position: relative; display: block; }

.rd-field__suffix input,
.rd-field__suffix input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding-right: 3.5rem;
  text-align: right;
  font-family: var(--font-mono);
}

.rd-field input[type="text"],
.rd-field input[type="date"] { box-sizing: border-box; width: 100%; }

.rd-field__suffix::after {
  content: attr(data-suffix);
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mute);
  font-size: 0.75rem;
  pointer-events: none;
  letter-spacing: 0.03em;
}

.rd-toggle-card {
  background: var(--sunk);
  border-radius: var(--radius-card);
  padding: 0.9rem 1rem;
}

.rd-toggle {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  align-items: center;
  gap: 0.9rem;
  cursor: pointer;
  margin: 0;
}

.rd-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.rd-toggle__switch {
  width: 2.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
}

.rd-toggle__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform var(--dur) var(--ease);
}
.rd-toggle input:checked + .rd-toggle__switch { background: var(--accent); }
.rd-toggle input:checked + .rd-toggle__switch::after { transform: translateX(1rem); }

.rd-toggle input:focus-visible + .rd-toggle__switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.rd-toggle__title { font-weight: 600; color: var(--ink); display: block; }
.rd-toggle__hint { color: var(--mute); font-size: 0.8rem; display: block; margin-top: 0.1rem; }

.rd-slideover-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 1.25rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.rd-field--fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.rd-field--fieldset > legend { padding: 0; }

.rd-segmented--radio { width: 100%; }

.rd-segmented--radio .rd-segmented__item {
  position: relative;
  flex: 1;
  justify-content: center;
  cursor: pointer;
  padding: 0.5rem 1rem;
}

.rd-segmented--radio .rd-segmented__item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.rd-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.rd-swatches__default {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  margin-right: 0.25rem;
}

.rd-swatches__default input { position: absolute; opacity: 0; pointer-events: none; }
.rd-swatches__default.is-selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }

.rd-swatch {
  position: relative;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: var(--swatch, var(--mute));
  cursor: pointer;
  transition: transform var(--dur) var(--ease);
}

.rd-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.rd-swatch:hover { transform: scale(1.08); }

.rd-swatch.is-selected {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

.rd-cat-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--sunk);
  border-radius: var(--radius-card);
}

.rd-cat-preview .rd-eyebrow { margin-right: auto; }

/* ─── Reconcile slide-over (T-R39) ─────────────────────────────────── */
.rd-reconcile-steps {
  display: flex;
  gap: 0.9rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--mute);
  flex-wrap: wrap;
}

.rd-reconcile-steps__item { display: inline-flex; gap: 0.3rem; align-items: baseline; }
.rd-reconcile-steps__item--active { color: var(--accent); font-weight: 500; }

.rd-reconcile-grid { align-items: end; }

.rd-reconcile-figure {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.rd-reconcile-figure small {
  font-size: 0.55em;
  color: var(--mute);
  font-family: var(--font-mono);
  margin-left: 0.25rem;
}

.rd-reconcile-delta {
  background: oklch(96% 0.08 85);
  border: 1px solid oklch(90% 0.1 85);
  border-radius: var(--radius-card);
  padding: 0.9rem 1rem;
  color: var(--ink);
}

.rd-reconcile-delta__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.rd-reconcile-delta__head strong { font-weight: 500; }

.rd-reconcile-delta__head span {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--expense);
}

.rd-reconcile-delta__hint {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--mute);
  line-height: 1.4;
}

.rd-reconcile-prev { display: grid; gap: 0.4rem; }
.rd-reconcile-prev ul { list-style: none; padding: 0; margin: 0; }

.rd-reconcile-prev li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.rd-reconcile-prev li:last-child { border-bottom: 0; }

.rd-reconcile-header { align-items: flex-start; }
.rd-reconcile-header .rd-eyebrow { margin-bottom: 0.2rem; }

/* ─── Recently deleted (T-R70) ─────────────────────────────────────── */
.rd-recently-deleted { margin-top: 1.75rem; }
.rd-recently-deleted h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }

.rd-recently-deleted .rd-count {
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--mute);
}

/* ─── Plan · Year heatmap (T-R31) ──────────────────────────────────── */
.rd-plan-year__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 0.5rem;
}

.rd-plan-year__header h2 { margin: 0; }
.rd-plan-year__nav { display: flex; gap: 0.4rem; }

.rd-plan-year__table { border-spacing: 2px 2px; border-collapse: separate; }

.rd-plan-year__table th:not(:first-child),
.rd-plan-year__table td:not(:first-child) { text-align: right; padding: 0; }
.rd-plan-year__table td.rd-plan-year__cell { padding: 0; }

.rd-plan-year__table thead th:first-child,
.rd-plan-year__table tbody td:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; padding-right: 0.75rem; }

/* Heatmap tier accents layered on top of the base .rd-heat defined above.
 * ADR-0051 §5.3 — one-off bold+outline, recurring italic+hatch, default plain,
 * unset dash. Hatch via background-image; keep contrast low so the amount
 * stays the primary signal. */
.rd-plan-year__cell .rd-heat--one-off {
  font-weight: 600;
  outline: 1px solid color-mix(in oklab, var(--accent) 60%, transparent);
  outline-offset: -1px;
}

.rd-plan-year__cell .rd-heat--recurring {
  font-style: italic;
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0 3px,
    color-mix(in oklab, var(--ink) 8%, transparent) 3px 4px
  );
}
.rd-plan-year__cell .rd-heat--unset { color: var(--mute); }

/* B-02 — Heatmap cells become buttons so the ⌨/🖱 interaction fires the
 * override popover. Preserve plain-cell visual while giving a focus ring. */
.rd-plan-year__cell-btn {
  display: inline-flex;
  width: 100%;
  justify-content: flex-end;
  align-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.rd-plan-year__cell-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.rd-plan-year__cell-btn:hover .rd-heat { filter: brightness(0.95); }

.rd-plan-year__cell { position: relative; }

.rd-year-popover-slot:not(:empty) {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 60;
  min-width: 18rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 30px rgb(30 20 10 / 0.14);
  padding: 0.75rem 0.9rem;
  text-align: left;
}

/* T-R54 — Mobile cards swap for the Plan · Year heatmap. */
.rd-plan-year__cards { display: none; }

.rd-year-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 0.75rem 0.9rem;
  margin-top: 0.75rem;
}

.rd-year-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.rd-year-card__name { font-weight: 500; }
.rd-year-card__total { color: var(--mute); font-family: var(--font-mono); font-size: 0.9rem; }

.rd-year-card__strip {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.2rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.rd-year-card__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  color: var(--mute);
}

.rd-year-card__m { font-family: var(--font-mono); font-size: 0.6rem; text-transform: uppercase; }

.rd-year-card .rd-heat {
  width: 100%;
  min-width: 0;
  padding: 0.4rem 0.1rem;
  font-size: 0.65rem;
  text-align: center;
  justify-content: center;
}

.rd-year-card__cell-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: 100%;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.rd-year-card__cell-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── Bulk-select toolbar (T-R69) ──────────────────────────────────── */
.rd-bulk-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.55rem 0.9rem;
  margin: 0.75rem 0;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-overlay);
}

.rd-bulk-toolbar .rd-btn { background: color-mix(in oklab, var(--paper) 10%, transparent); color: var(--paper); border-color: color-mix(in oklab, var(--paper) 20%, transparent); }
.rd-bulk-toolbar .rd-btn:hover { background: color-mix(in oklab, var(--paper) 20%, transparent); }
.rd-bulk-toolbar [data-bulk-delete] { background: var(--expense); border-color: var(--expense); color: var(--paper); }
.rd-bulk-toolbar [data-bulk-delete]:hover { background: color-mix(in oklab, var(--expense) 90%, white); }

.rd-bulk-check { width: 2rem; }
.rd-bulk-check input { cursor: pointer; }

/* ─── Table scroll wrapper (T-R53, extended for tablet by audit-2) ────── */

/* Position:relative anchors absolute descendants (e.g. .sr-only) to this
 * container, so they don't bleed into the document scrollWidth. */
.rd-table-scroll {
  width: 100%;
  max-width: 100%;
  position: relative;
}

/* Tablet (≤1024 px): the wide ledger / plan-year tables overflow the main
 * column. Scope horizontal scroll + sticky first column at tablet widths so
 * no viewport-level horizontal scrollbar appears. */
@media (width <= 1024px) {
  .rd-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .rd-table-scroll .rd-table thead th:first-child,
  .rd-table-scroll .rd-table tbody td:first-child {
    position: sticky;
    left: 0;
    background: var(--paper);
    z-index: 1;
    box-shadow: 1px 0 0 var(--line);
  }
}

@media (width <= 640px) {
  .rd-table-scroll .rd-table { min-width: 36rem; }

  /* T-VIS6 — /accounts: drop Trend / Checked / Txns so Account + Balance
   * (with planned sub-line) + Actions fit 375 px without sideways scroll. */
  .rd-table-scroll .rd-table--accounts { min-width: 0; table-layout: auto; }

  .rd-table--accounts .rd-col-trend,
  .rd-table--accounts .rd-col-checked,
  .rd-table--accounts .rd-col-txns { display: none; }

  .rd-table--accounts th,
  .rd-table--accounts td { padding-inline: 0.5rem; }
  .rd-table--accounts td.num { text-align: right; white-space: normal; }
  .rd-table--accounts .rd-acct-planned { white-space: normal; }
  .rd-table--accounts .rd-actions { padding-inline: 0.25rem; text-align: right; }
  .rd-table--accounts .rd-actions .rd-btn { display: block; margin-inline-start: auto; margin-bottom: 0.25rem; }
  .rd-table--accounts .rd-desc > .rd-pill { white-space: normal; }

  /* T-R54 — Swap the Plan · Year heatmap table for per-category cards. */
  .rd-plan-year__scroll { display: none; }
  .rd-plan-year__cards { display: block; }

  /* Mobile bottom-sheet variant lives in app.css @media (width <= 640px). */
  .slide-over::before {
    content: "";
    display: block;
    width: 2.5rem;
    height: 4px;
    margin: 0.5rem auto 0;
    background: var(--line);
    border-radius: 999px;
  }
}

/* ─── New entry chip row (per overlay-13-add-fixed.html) ──────────── */
.rd-entry-chips {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.rd-entry-chip {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--mute);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.rd-entry-chip:hover { color: var(--ink); background: var(--sunk); }

.rd-entry-chip--active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ─── Utility atoms shared with the designer handoff tokens ───────── */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cur { color: var(--mute); font-size: 0.72em; margin-left: 0.3em; font-weight: 400; }
.mut { color: var(--mute); }
.pos { color: var(--income); }
.neg { color: var(--expense); }

/* ─── Plan · Budget top bar + override card (manual-audit #34, #35) ─ */
.rd-period-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, auto);
  gap: 2rem;
  align-items: center;
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.rd-period-bar__range { font-family: var(--font-display); font-size: 1.1rem; margin-top: 0.15rem; }
.rd-period-bar__anchor { font-size: 0.75rem; margin-top: 0.1rem; }
.rd-period-bar__anchor a { color: var(--ink); text-underline-offset: 2px; }

.rd-period-bar__left,
.rd-period-bar__bar,
.rd-period-bar__right { min-width: 0; }
.rd-period-bar__right { text-align: right; overflow-wrap: anywhere; }

@media (width <= 640px) {
  /* T-VIS4: stack the three columns so the per-day figure and meta lines fit 375px. */
  .rd-period-bar {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    padding: 1rem;
  }
  .rd-period-bar__right { text-align: left; }
}
.rd-period-bar__perday { font-size: 1.6rem; letter-spacing: -0.02em; }
.rd-period-bar__meta { font-size: 0.75rem; margin-top: 0.15rem; }

.rd-override {
  width: min(28rem, 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 1rem 1.1rem;
  box-shadow: 0 10px 25px -20px rgb(0 0 0 / 0.25);
}
.rd-override__title { font-weight: 600; margin-bottom: 0.6rem; }
.rd-override__tiers { width: 100%; margin-bottom: 0.75rem; }
.rd-override__row { display: flex; align-items: center; gap: 0.5rem; }

.rd-override__input {
  flex: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-family: var(--font-mono);
}

.rd-override__input input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: inherit;
  padding: 0;
}
.rd-override__input input:focus { outline: none; }
.rd-override__hint { font-size: 0.75rem; margin: 0.6rem 0 0; }

/* Standalone variant: used inside the Ledger/Recurring override modal
   (`partials/recurring/_override_form.html`) so the card fills the modal
   body and sheds its own border — the modal shell already supplies one. */
.rd-override--standalone {
  width: 100%;
  border: 0;
  padding: 0;
  box-shadow: none;
  background: transparent;
}

.rd-override__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.rd-override__head .rd-override__title { margin-bottom: 0; }
.rd-override__period { flex-shrink: 0; }

/* Inside the Ledger/Recurring override modal the parent `.slide-over` is a
   scroll container, so the period-nav popover's default absolute positioning
   gets clipped. Switch the slide-over host to `overflow: visible` only when
   it hosts the standalone override card — the card is short enough that the
   modal shell never needs its own scroll in this case, and the popover now
   paints above the amount row unobstructed. */
.slide-over:has(.rd-override--standalone) { overflow: visible; }

/* ─── Plan · Year legend + unset collapse (manual-audit #38-#41) ──── */
.rd-year-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 0 0.9rem;
  font-size: 0.75rem;
  color: var(--mute);
}
.rd-year-legend__item { display: inline-flex; align-items: center; gap: 0.4rem; }

.rd-year-swatch {
  display: inline-block;
  width: 1.1rem;
  height: 0.6rem;
  border-radius: 2px;
  background: var(--sunk);
  border: 1px solid var(--line);
}
.rd-year-swatch--oneoff { background: var(--expense-soft); border-color: var(--expense); font-weight: 700; }

.rd-year-swatch--recurring {
  background: repeating-linear-gradient(135deg, var(--line) 0 2px, transparent 2px 5px);
}
.rd-year-swatch--default { background: var(--sunk); }
.rd-year-swatch--unset { background: transparent; border-style: dashed; }

.rd-year-unset { margin-top: 1rem; }
.rd-year-unset summary { cursor: pointer; font-size: 0.85rem; color: var(--mute); }
.rd-year-unset__list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.4rem; }

.rd-year-unset__list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.rd-plan-year__hint { font-size: 0.8rem; margin: 1rem 0 0; }

/* Compact multi-select source dropdown (recurring formula). Trigger
   button shows a comma list of picked categories; panel floats over
   layout via position:absolute, never pushing row height. */
.rd-formula__sources { position: relative; }
.rd-src-select { position: relative; width: 100%; }

.rd-src-select__trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
  min-height: 1.9rem;
  text-align: left;
}
.rd-src-select__trigger:hover { background: var(--sunk); }
.rd-src-select__trigger[aria-expanded="true"] { border-color: var(--accent); }

.rd-src-select__trigger > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.rd-src-select__panel {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 70;
  min-width: 100%;
  width: max-content;
  max-width: 20rem;
  max-height: 14rem;
  overflow-y: auto;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  box-shadow: 0 10px 30px rgb(30 20 10 / 0.14);
}

.rd-src-select__opt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
}
.rd-src-select__opt:hover { background: var(--sunk); }
.rd-src-select__opt input { margin: 0; }

/* Allow panel to escape term card. */
.rd-formula__term,
.rd-formula__term-grid,
.rd-formula__terms,
.rd-formula { overflow: visible; }

/* ─── Ledger · Recurring expand (visual-audit V.33) ───────────────── */
.rd-rec-chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0 0.3rem;
  background: transparent;
  border: 0;
  color: var(--mute);
  font-family: var(--font-mono);
  cursor: pointer;
  margin-left: 0.3rem;
}
.rd-rec-chev:hover { color: var(--ink); }
.rd-rec-row--expanded td { background: var(--sunk); }
.rd-rec-row--expanded td:first-child { font-weight: 600; }

.rd-rec-expand-row > td {
  background: var(--sunk);
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}

.rd-rec-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 2rem;
  padding: 0.5rem 0 0.5rem 70px;
}

@media (width <= 960px) {
  .rd-rec-panel { grid-template-columns: 1fr; }
}
.rd-rec-panel .rd-eyebrow { margin-bottom: 0.4rem; }

.rd-rec-panel__formula {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.rd-rec-formula-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 0.6rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--line);
  align-items: baseline;
}

.rd-rec-formula-row--total {
  font-weight: 600;
  border-bottom: 0;
  margin-top: 0.3rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}
.rd-rec-over-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }

.rd-rec-over-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.85rem;
}
.rd-rec-over-item > span:first-child { display: inline-flex; gap: 0.5rem; align-items: baseline; }
.rd-rec-overrides { font-size: 0.75rem; }

/* ─── Budget override inline slot (visual-audit V.8) ─────────────── */

/* T-D49: the form lives in a per-row slot (<tr><td colspan>) under its row. */
.rd-override-slot-row > td:empty { display: none; }

/* T-D49a: a closed slot row must take zero height and draw no border at any
   viewport; it only exists while the form is swapped in. */
.rd-override-slot-row:not(:has(.rd-override)) { display: none; }
.rd-override-slot-row > td { padding: 0.5rem 0.75rem 0.9rem; }
.rd-override-slot-row .rd-override { margin: 0 0 0 auto; }

@media (width <= 1024px) {
  /* Table scrolls horizontally here: keep the form inside the viewport. */
  .rd-table-scroll .rd-table tbody .rd-override-slot-row > td:first-child {
    position: static;
    box-shadow: none;
  }

  .rd-override-slot-row .rd-override {
    position: sticky;
    left: 0.75rem;
    width: min(28rem, calc(100vw - 3.5rem));
  }
}

@media (width <= 640px) {
  /* Table is wider than the viewport: pin the form to the visible left edge. */
  .rd-override-slot-row .rd-override { margin: 0; width: calc(100vw - 3.5rem); }
  .rd-override-slot-row .rd-override__row { flex-wrap: wrap; }
  .rd-override-slot-row .rd-override__input { flex: 1 1 100%; }
  .rd-override-slot-row .rd-override__row .rd-btn { flex: 1 1 0; justify-content: center; }
}

/* ─── Settings · categories (visual-audit V.6) ────────────────────── */
.rd-cat-group { margin-top: 1.25rem; }

.rd-cat-group__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.rd-cat-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 7rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
.rd-cat-row:first-child { border-top: 0; }

.rd-cat-row__actions a {
  color: var(--mute);
  text-decoration: none;
  margin: 0 0.25rem;
  cursor: pointer;
}
.rd-cat-row__actions a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.rd-swatch-dot--mute { background: var(--line); }

/* ─── Settings · income anchor bar (manual-audit #52, #54) ─────────── */
.rd-settings-anchor {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  flex-wrap: wrap;
}
.rd-settings-anchor form { display: inline-flex; align-items: center; margin: 0; }
.rd-settings-anchor select { min-width: 10rem; }
.rd-settings-anchor small { font-size: 0.75rem; }

/* ─── Accounts row name + type inline (visual-audit V.5) ──────────── */
.rd-acct-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
}
.rd-acct-type { margin-left: 0.4rem; font-size: 0.75rem; }

/* ─── Accounts hero (manual-audit #51) ────────────────────────────── */
.rd-accounts-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 1fr 1fr 1fr;
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.rd-accounts-hero__amount {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem);
  letter-spacing: -0.02em;
}
.rd-accounts-hero__hint { font-size: 0.75rem; margin-top: 0.25rem; }
.rd-accounts-hero__sub { font-size: 1.35rem; margin-top: 0.2rem; }

/* ADR-0089 — planned net sub-line under an account balance */
.rd-acct-planned { font-size: 0.75rem; margin-top: 0.15rem; white-space: nowrap; }

@media (width <= 640px) {
  .rd-accounts-hero { grid-template-columns: 1fr; }
}

/* ─── Plan · period selector in header slot (manual-audit #32-#33) ── */
.rd-period-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 0.1rem;
}

.rd-period-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--mute);
  text-decoration: none;
  border-radius: var(--radius-control);
}
.rd-period-nav__btn:hover { background: var(--sunk); color: var(--ink); }

.rd-period-nav__label {
  padding: 0 0.65rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.rd-period-nav__label::-webkit-details-marker { display: none; }

.rd-period-nav__picker { position: relative; }

.rd-period-nav__popover {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow, 0 10px 30px rgb(30 20 10 / 0.14));
  padding: 0.6rem;
  min-width: 15rem;
}

.rd-period-nav__year {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.rd-period-nav__year a { color: var(--mute); text-decoration: none; padding: 0 0.4rem; }
.rd-period-nav__year a:hover { color: var(--ink); }

.rd-period-nav__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.2rem;
}

.rd-period-nav__cell {
  padding: 0.4rem 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 4px;
}
.rd-period-nav__cell:hover { background: var(--sunk); }
.rd-period-nav__cell--active { background: var(--ink); color: var(--paper); }

/* ─── Ledger · pagination + formula breakdown ─────────────────────── */
.rd-pagination {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.rd-pagination__state { color: var(--mute); font-size: 0.8rem; }

.rd-formula-breakdown {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}
.rd-formula-breakdown__table { width: 100%; font-size: 0.8rem; }
.rd-formula-breakdown__table td { padding: 0.15rem 0.4rem; }

/* ─── Ledger · tabs + chips (desktop-02-ledger-actual.html:5-6) ───── */
.rd-ledger-tabs {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.rd-ledger-tabs__hint { font-size: 0.75rem; }

.rd-ledger-chips {
  margin-top: 1rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
}
.rd-ledger-chips > label { display: inline-flex; align-items: center; }

.rd-ledger-chips .rd-chip-select {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 0.85rem;
}
.rd-ledger-chips .rd-chips__search { flex: 0 0 15rem; margin-left: auto; }
.rd-ledger-recently { margin-top: 1.25rem; font-size: 0.8rem; }
.rd-ledger-recently a { color: var(--accent); text-underline-offset: 2px; }

@media (width <= 1200px) {
  /* 1024-wide tablets: the nowrap chip row + 15rem search overflowed (T-VIS). */
  .rd-ledger-chips { flex-wrap: wrap; }
  .rd-ledger-chips .rd-chips__search { flex: 1 1 100%; margin-left: 0; }
}

/* ─── Today · Upcoming (grid rows, per desktop-01-today.html:16-22) ─ */
.rd-panel__head-left { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; min-width: 0; }
.rd-upcoming { padding: 0.5rem 1.25rem 0.75rem; }

.rd-upcoming__group {
  padding: 0.9rem 0 0.3rem;
}

.rd-upcoming__row {
  display: grid;
  grid-template-columns: 52px 1fr 160px 150px minmax(220px, auto);
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}
.rd-upcoming__group + .rd-upcoming__row { border-top: 0; }
.rd-upcoming__row--overdue { background: color-mix(in oklab, var(--expense) 12%, transparent); }
.rd-upcoming__row--due { background: color-mix(in oklab, var(--adjust) 12%, transparent); }
.rd-upcoming__date { font-size: 0.78rem; }
.rd-upcoming__desc { display: flex; align-items: baseline; gap: 0.4rem; min-width: 0; overflow: hidden; }
.rd-upcoming__name { font-weight: 500; }
.rd-upcoming__acct { font-size: 0.8rem; }
.rd-upcoming__cat { justify-self: start; }
.rd-upcoming__amt { text-align: right; }
.rd-upcoming__actions { display: inline-flex; gap: 0.4rem; justify-content: flex-end; }
.rd-upcoming__more { padding: 0.75rem 1.25rem; font-size: 0.85rem; margin: 0; }
.rd-upcoming__empty { padding: 1.25rem; }

/* Inline promote card (per overlay in desktop-01-today.html:19). */
.rd-promote-inline {
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 0.75rem 0.9rem;
  margin: 0.25rem 1.25rem;
}

.rd-promote-inline__grid {
  display: grid;
  grid-template-columns: 52px 1.3fr 130px 150px auto;
  gap: 0.75rem;
  align-items: end;
}
.rd-promote-inline__meta { font-size: 0.72rem; margin-bottom: 0.25rem; }

.rd-promote-inline__chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
}
.rd-promote-inline__label { font-size: 0.7rem; margin-bottom: 0.2rem; }

.rd-promote-inline__input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

.rd-promote-inline__amount {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 0 0 3px #fff;
}

.rd-promote-inline__input--amount {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: right;
  width: 5.5rem;
}
.rd-promote-inline__input--amount:focus { outline: none; }
.rd-promote-inline__actions { display: inline-flex; gap: 0.4rem; justify-content: flex-end; }
.rd-promote-inline__note { font-size: 0.75rem; margin: 0.6rem 0 0; }

@media (width <= 640px) {
  .rd-upcoming__row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-areas:
      "date desc amt"
      "date cat  cat"
      "date actions actions";
  }
  .rd-upcoming__date { grid-area: date; }
  .rd-upcoming__desc { grid-area: desc; flex-wrap: wrap; }
  .rd-upcoming__cat { grid-area: cat; }
  .rd-upcoming__amt { grid-area: amt; }
  .rd-upcoming__actions { grid-area: actions; flex-wrap: wrap; justify-content: flex-start; }
  .rd-promote-inline__grid { grid-template-columns: 1fr; }
}

/* ─── Recurring amount source + formula builder ───────────────────── */
.rd-amount-source__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.rd-amount-source__head .rd-field__label { margin: 0; }
.rd-amount-source__panel { margin-top: 0.25rem; }

.rd-formula {
  background: var(--sunk);
  border-radius: var(--radius-control);
  padding: 0.85rem 1rem;
}

.rd-formula__terms {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.rd-formula__term { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 0.6rem 0.7rem; }

.rd-formula__term-grid {
  display: grid;
  grid-template-columns: auto 1fr 7rem auto;
  gap: 0.5rem;
  align-items: center;
}
.rd-formula__sign { display: inline-flex; gap: 0.25rem; }
.rd-formula__coef { margin: 0; }

.rd-formula__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}
.rd-formula__note { font-size: 0.75rem; margin: 0; }

.rd-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.65rem;
  min-height: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--mute);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}
.rd-chip:hover { color: var(--ink); }

.rd-chip:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.rd-chip:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.rd-chip--check { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.02em; }

.rd-field--inline { display: inline-flex; margin: 0; }
.rd-field--inline > .rd-field__suffix { width: 100%; }

@media (width <= 640px) {
  .rd-formula__term-grid { grid-template-columns: 1fr; }
  .rd-formula__sign { justify-content: flex-start; }
}
