/* nongJam3 stylesheet. Tokens first, then layout, then components.
   Mobile first: the tab bar layout is the default, the sidebar starts at 768px. */

:root {
  --ground: #f5f4f0;
  --surface: #ffffff;
  --ink: #17191c;
  --muted: #5f636a;
  --line: #e3e1db;
  --field: #ffffff;
  --field-line: #8a8d93;
  --accent: #1f6f50;
  --on-accent: #ffffff;
  --accent-ink: #1a6247;
  --accent-soft: #e6f1ec;
  --m1: #1f6f50;
  --m2: #3568b8;
  --neg: #b42318;
  --on-neg: #ffffff;
  --neg-soft: #fcebe9;
  --warn-bg: #fdf4e7;
  --warn-line: #f0dcbc;
  --warn-ink: #8a4b08;
  --scrim: rgba(10, 12, 14, 0.55);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121417;
    --surface: #1b1e23;
    --ink: #eceae4;
    --muted: #a3a7ae;
    --line: #2c3037;
    --field: #15181c;
    --field-line: #6b717a;
    --accent: #3fa37a;
    --on-accent: #0c1a14;
    --accent-ink: #6fcda4;
    --accent-soft: #1d3229;
    --m1: #3fa37a;
    --m2: #7fb0ff;
    --neg: #ff8a80;
    --on-neg: #2b0b08;
    --neg-soft: #35201e;
    --warn-bg: #2a2116;
    --warn-line: #4a3a22;
    --warn-ink: #f0b866;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #121417;
  --surface: #1b1e23;
  --ink: #eceae4;
  --muted: #a3a7ae;
  --line: #2c3037;
  --field: #15181c;
  --field-line: #6b717a;
  --accent: #3fa37a;
  --on-accent: #0c1a14;
  --accent-ink: #6fcda4;
  --accent-soft: #1d3229;
  --m1: #3fa37a;
  --m2: #7fb0ff;
  --neg: #ff8a80;
  --on-neg: #2b0b08;
  --neg-soft: #35201e;
  --warn-bg: #2a2116;
  --warn-line: #4a3a22;
  --warn-ink: #f0b866;
  color-scheme: dark;
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--ground);
}
h1, h2, h3, p, dl, dd, figure { margin: 0; }
a { color: var(--accent-ink); }
a:hover { color: var(--ink); }
input, select, button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.icon { flex: 0 0 auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.warn { color: var(--warn-ink); }
.nowrap { white-space: nowrap; }

/* Shell: tab bar under 768px, sidebar from 768px up */

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1 1 auto; min-width: 0; padding: 20px 16px 24px; }
.page { display: flex; flex-direction: column; gap: 16px; }
.sidebar { display: none; }

.tabbar {
  position: sticky; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 4px max(10px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 48px; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.tabbar a[aria-current="page"] { font-weight: 650; color: var(--accent-ink); }

@media (min-width: 768px) {
  .shell { flex-direction: row; }
  .tabbar { display: none; }
  .main { flex: 999 1 560px; padding: 32px 40px 48px; }
  .page { max-width: 1040px; margin-inline: auto; gap: 24px; }
  .sidebar {
    position: sticky; top: 0; height: 100vh; align-self: flex-start;
    flex: 1 1 220px; max-width: 240px; padding: 24px 16px;
    display: flex; flex-direction: column; gap: 24px;
    background: var(--surface); border-right: 1px solid var(--line);
  }
}

.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links.bottom { margin-top: auto; }
.side-links a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: 10px; color: var(--ink); font-size: 15px; font-weight: 500; text-decoration: none;
}
.side-links a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.side-theme { display: flex; flex-direction: column; gap: 6px; }
.side-theme > span {
  padding: 0 4px; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Wordmark and the jar */

.wordmark { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--ink); text-decoration: none; }
.wordmark-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.wordmark-sub { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.jar-tile { fill: var(--accent); }
.jar-mark { fill: var(--on-accent); }
.jar-ring { fill: none; stroke: var(--on-accent); }

/* Page headers */

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.page-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-head .actions { display: flex; flex-flow: row wrap; gap: 12px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { font-size: 14px; color: var(--muted); }
.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding-right: 8px;
  font-weight: 600; text-decoration: none;
}
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (min-width: 768px) {
  .page-head { align-items: flex-end; }
  .page-head > div > .subtitle:not(.below) { order: -1; }
  .page-title { font-size: 28px; }
  .subtitle { font-size: 13px; }
}

/* Cards and sections */

.card {
  display: flex; flex-direction: column; gap: 16px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.card.flush { gap: 0; padding: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card.flush > .card-head { padding: 18px 20px 10px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.note { font-size: 13px; color: var(--muted); }
.link { font-size: 14px; font-weight: 600; text-decoration: none; }
@media (min-width: 768px) { .card { padding: 22px; } }

/* Buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-weight: 600; white-space: nowrap; text-decoration: none;
}
.btn:hover { color: var(--ink); border-color: var(--field-line); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { border-color: var(--accent); color: var(--on-accent); filter: brightness(1.08); }
.btn-danger { border-color: var(--neg); background: var(--neg); color: var(--on-neg); }
.btn-danger:hover { border-color: var(--neg); color: var(--on-neg); filter: brightness(1.08); }
.btn-small { min-height: 44px; padding: 0 14px; border-radius: 10px; }
.btn.wrap { white-space: normal; text-align: center; padding-top: 10px; padding-bottom: 10px; }
.note code { overflow-wrap: anywhere; }
.btn .icon { color: inherit; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.btn-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.btn-line .note { flex: 1 1 260px; }
@media (max-width: 767.98px) { .btn-line > .btn { flex: 1 1 100%; } }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}

/* Forms */

form { margin: 0; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 14px; font-weight: 600; }
.input, .money {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--field-line); border-radius: 12px; background: var(--field); font-size: 16px;
}
select.input { padding: 0 12px; }
.money { display: flex; align-items: center; gap: 6px; }
.money > span { color: var(--muted); }
.money input { flex: 1 1 auto; min-width: 0; height: 46px; padding: 0; border: 0; background: transparent; font-size: 16px; }
.money input:focus-visible { outline: none; }
.money:focus-within { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.money.big { min-height: 64px; font-size: 28px; font-weight: 650; }
.money.big input { height: 62px; font-size: 28px; font-weight: 650; }
.help { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--neg); }
.has-error .input, .has-error .money { border: 2px solid var(--neg); }
fieldset { margin: 0; min-width: 0; padding: 0; border: 0; }
fieldset.card > legend {
  float: left; width: 100%; margin: 0 0 16px; padding: 0;
  font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
fieldset.card > legend + * { clear: both; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: 1 / -1; }
.split { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; }
.split > .form, .split > form { flex: 1 1 400px; max-width: 520px; min-width: 0; }
.split > aside { flex: 1 1 240px; max-width: 340px; min-width: 0; }
.aside { display: flex; flex-direction: column; gap: 10px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; }
.rules { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.aside .rules { gap: 6px; font-size: 14px; color: var(--ink); }

/* Segmented controls: links with aria-current, or radios with :has() */

.seg {
  display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 4px; padding: 3px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--ground);
}
.seg > a, .seg > label {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 6px;
  border: 1px solid transparent; border-radius: 9px; color: var(--muted);
  font-size: 15px; font-weight: 500; text-align: center; text-decoration: none; cursor: pointer;
}
.seg > a[aria-current="true"], .seg > label:has(input:checked) {
  border-color: var(--field-line); background: var(--surface); color: var(--ink); font-weight: 650;
}
.seg > label:has(input:focus-visible) { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices > label {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 10px 12px;
  border: 1px solid var(--field-line); border-radius: 12px; background: var(--field); cursor: pointer;
}
.choices > label > span:first-of-type { font-size: 13px; color: var(--muted); }
.choices > label > span:last-of-type { font-weight: 600; }
.choices > label:has(input:checked) { border-color: var(--accent-ink); background: var(--accent-soft); }
.choices > label:has(input:focus-visible) { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* Alerts and flashes */

.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 14px;
}
.alert > .icon { margin-top: 0; color: var(--accent-ink); }
.alert-error { border-color: var(--neg); background: var(--neg-soft); }
.alert-error > .icon { color: var(--neg); }
.alert-warn { border-color: var(--warn-line); background: var(--warn-bg); }
.alert-warn > .icon, .alert-warn b { color: var(--warn-ink); }
.alert-info { color: var(--muted); }

/* Account picture, menu and sheet: a <details> with no JavaScript */

.avatar {
  flex: 0 0 auto; display: inline-flex; overflow: hidden;
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft);
}
.avatar svg { width: 100%; height: 100%; }
.avatar-fill { fill: var(--accent-ink); }
.avatar.lg { width: 56px; height: 56px; }
.avatar.md { width: 40px; height: 40px; }
.account { position: relative; }
.account > summary { list-style: none; cursor: pointer; }
.account > summary::-webkit-details-marker { display: none; }
.account-round {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
}
.account-round .avatar { width: 38px; height: 38px; }
.account-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}
.account-row > span:nth-child(2) { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 650; }
.account-row > .icon { color: var(--muted); }
/* The open summary's ::before covers the page, so a tap outside closes the menu. */
.account[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 40; cursor: default; }
.sheet .account[open] > summary::before, .account.sheet[open] > summary::before { background: var(--scrim); }
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 41;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 15px; text-align: left; text-decoration: none;
}
.menu-item:hover { background: var(--ground); color: var(--ink); }
.menu-item > .icon { color: var(--muted); }
.account.sheet .menu {
  position: fixed; top: auto; left: 0; right: 0; bottom: 0; gap: 4px;
  padding: 10px 12px max(18px, env(safe-area-inset-bottom));
  border-width: 1px 0 0; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}
.account.sheet .menu-item { min-height: 52px; }
.grab { align-self: center; width: 36px; height: 4px; margin: 2px 0 8px; border-radius: 2px; background: var(--line); }
.sheet-who { display: flex; align-items: center; gap: 12px; padding: 0 10px 10px; font-size: 17px; font-weight: 650; }
.sheet-theme { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 4px 10px; font-size: 15px; }
.sheet .btn, .account.sheet .btn { margin-top: 6px; }

/* Theme controls */

.theme-seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--ground);
}
.account.sheet .theme-seg { grid-template-columns: repeat(3, 56px); }
.theme-seg button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0;
  border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted);
}
.theme-seg button[aria-pressed="true"] { border-color: var(--field-line); background: var(--surface); color: var(--ink); }
.quick-theme .to-light { display: none; }
:root[data-theme="dark"] .quick-theme .to-light { display: inline-flex; }
:root[data-theme="dark"] .quick-theme .to-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .quick-theme .to-light { display: inline-flex; }
  :root:not([data-theme="light"]) .quick-theme .to-dark { display: none; }
}

/* Sign-out dialog: a :target overlay */

.overlay {
  position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;
  padding: 16px; background: var(--scrim);
}
.overlay:target { display: flex; }
.dialog {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 24px 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.dialog h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.dialog p { font-size: 15px; color: var(--muted); }
.dialog form { width: 100%; margin-top: 6px; }

/* Pages without navigation */

.bare { min-height: 100vh; display: flex; flex-direction: column; }
.bare-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 16px 0; }
.bare-head .wordmark { padding: 0; }
.bare-head > .btn-line { margin-left: auto; }
.bare-main { flex: 1 1 auto; display: flex; flex-direction: column; padding: 20px 16px 48px; }
.bare-body { width: 100%; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.bare-body.wide { max-width: 880px; }
.bare-body.mid { max-width: 760px; }
.login-mark { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 8px; text-align: center; }
.login-mark .wordmark-name { font-size: 22px; }
.login-mark svg { width: 64px; height: 64px; }
@media (min-width: 768px) {
  .login-mark svg { width: 72px; height: 72px; }
  .login-title { margin-top: -6px; text-align: center; }
}
@media (min-width: 768px) {
  .bare-head { padding: 20px 32px; }
  .bare-main { justify-content: center; padding: 24px 16px 64px; }
  .bare-main.top { justify-content: flex-start; }
}
.refused { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding-top: 24px; }
.refused-badge {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 16px; background: var(--neg-soft); color: var(--neg);
}
.address { max-width: 420px; gap: 8px; }
.address h2 { font-size: 14px; font-weight: 600; color: var(--muted); }
.address code { font-size: 24px; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 768px) {
  .refused { flex-direction: row; align-items: center; gap: 20px; padding-top: 0; }
  .refused-badge { width: 64px; height: 64px; border-radius: 18px; }
  .address code { font-size: 28px; }
}
.address .unknown { font-size: 17px; font-weight: 600; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; }

/* Summary */

.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; align-items: start; }
.stack-4 { display: flex; flex-direction: column; gap: 4px; }
.big-money { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.split-bar { display: block; border-radius: 6px; overflow: hidden; }
.fill-m1 { fill: var(--m1); }
.fill-m2 { fill: var(--m2); }
.fill-surface { fill: var(--surface); }
.shares { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.shares > div { display: flex; align-items: flex-start; gap: 10px; }
.shares dt { font-size: 13px; color: var(--muted); }
.shares dd { font-size: 20px; font-weight: 650; }
.dot { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 6px; border-radius: 5px; }
.dot.m1 { background: var(--m1); }
.dot.m2 { background: var(--m2); }
.eyebrow.accent { color: var(--accent-ink); }
@media (min-width: 768px) { .big-money { font-size: 40px; } }
@media (max-width: 767.98px) {
  .sr-narrow { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Transactions */

.filters { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.filters > summary {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px;
  font-size: 15px; font-weight: 600; list-style: none; cursor: pointer;
}
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary > .icon:first-child { color: var(--accent-ink); }
.filters > summary > .icon:last-child { color: var(--muted); }
.filters[open] > summary > .icon:last-child { transform: rotate(180deg); }
.badge { margin-left: auto; font-size: 13px; font-weight: 400; color: var(--muted); }
.filter-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  padding: 14px; border-top: 1px solid var(--line);
}
.input.compact, .money.compact { min-height: 44px; padding: 0 10px; border-radius: 10px; font-size: 15px; }
.money.compact { gap: 8px; }
.money.compact > .icon { color: var(--muted); }
.money.compact input { height: 42px; font-size: 15px; }
.filter-bar { flex-flow: row wrap; align-items: flex-end; gap: 12px; padding: 16px; }
.filter-bar .field > label { font-size: 13px; }
.grow-2 { flex: 2 1 220px; }
.grow-1 { flex: 1 1 140px; }
.grow-s { flex: 1 1 100px; }
.filter-actions { display: flex; gap: 8px; }
.btn-plain { border-color: transparent; background: transparent; color: var(--accent-ink); }
.btn-plain:hover { border-color: transparent; color: var(--ink); }
.seg-compact > a { min-height: 44px; padding: 0 14px; font-size: 14px; }
.seg-labelled { display: flex; align-items: center; gap: 10px; }
.seg-start { align-self: stretch; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-top: 1px solid var(--line); }
.row-link { display: flex; gap: 12px; padding: 12px 16px; color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--ink); background: var(--ground); }
.date-stack { flex: 0 0 36px; display: flex; flex-direction: column; align-items: center; padding-top: 2px; }
.date-stack > span:first-child { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.date-stack > span:last-child { font-size: 20px; font-weight: 650; line-height: 1.1; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { align-self: flex-end; font-size: 13px; white-space: nowrap; }
.amount { white-space: nowrap; }
.empty { padding: 4px 20px 20px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn.disabled { background: transparent; color: var(--muted); }
.btn.disabled:hover { border-color: var(--line); }
@media (min-width: 768px) {
  .list-head { padding: 14px 20px; }
  .seg-start { align-self: flex-start; }
  .seg-start > label { padding: 0 22px; }
}

/* Tables */

/* position: relative keeps visually hidden cells inside the scroll box, not widening the page. */
.table-wrap { position: relative; overflow-x: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { font-size: 13px; font-weight: 600; color: var(--muted); }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .num { text-align: right; white-space: nowrap; }
.table td.action { padding-top: 0; padding-bottom: 0; vertical-align: middle; }
.strong { font-weight: 600; }
.cell-title { display: block; font-weight: 600; color: var(--ink); text-decoration: none; }
.cell-title:hover { text-decoration: underline; }
.icon-link { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; color: var(--muted); }
.icon-link:hover { background: var(--ground); color: var(--ink); }
.table.compact { min-width: 0; font-size: 14px; }
.table.compact th, .table.compact td { padding: 8px 12px; }
.table.compact thead th { padding-top: 6px; padding-bottom: 6px; font-size: 12px; border-top: 0; }
.table.compact tbody th { font-weight: 600; white-space: nowrap; }
@media (max-width: 420px) {
  .table.compact { font-size: 13px; }
  .table.compact th, .table.compact td { padding-left: 6px; padding-right: 6px; }
  .table.compact th:first-child, .table.compact td:first-child { padding-left: 10px; }
  .table.compact th:last-child, .table.compact td:last-child { padding-right: 10px; }
}
.table caption {
  padding: 10px 12px 4px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Transaction and bill forms: radios plus :has() pick the fields that apply */

.grid-2-wide { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 768px) {
  .grid-2-wide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-wide.card { display: grid; }
}
.pick-kind:has(input[name="kind"][value="transfer"]:checked) .for-shared,
.pick-kind:not(:has(input[name="kind"][value="transfer"]:checked)) .for-transfer { display: none; }
.pick-kind:not(:has(input[name="kind"][value="expense"]:checked)) .save-expense,
.pick-kind:not(:has(input[name="kind"][value="income"]:checked)) .save-income,
.pick-kind:not(:has(input[name="kind"][value="transfer"]:checked)) .save-transfer { display: none; }
.form-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 768px) {
  .form-actions { display: flex; }
  .form-actions .btn-primary { order: -1; padding: 0 22px; }
  .form-actions .btn { padding: 0 20px; }
}
.danger-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--neg); font-weight: 600; text-decoration: none; }
.danger-link:hover { color: var(--neg); text-decoration: underline; }
.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv.total { padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.split > .aside { gap: 12px; }

/* Delete confirmation */

.measure { max-width: 600px; display: flex; flex-direction: column; gap: 16px; }
.item-card { gap: 6px; }
.item-card .note { font-size: 14px; }
.item-top { display: flex; justify-content: space-between; gap: 12px; font-size: 18px; font-weight: 650; }
.danger-box {
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px;
  border: 1px solid var(--neg); border-radius: 12px; background: var(--neg-soft);
}
.danger-box > p { font-size: 13px; }
.danger-head { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 650; }
.danger-head > .icon { color: var(--neg); }
.table-wrap.inset { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.confirm-actions { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 768px) {
  .measure { gap: 20px; }
  .confirm-actions { flex-flow: row wrap; }
  .confirm-actions .btn { padding: 0 22px; }
}

/* Forecast and upcoming bills on Summary */

.forecast { gap: 20px; }
.outlook { display: flex; flex-direction: column; gap: 8px; }
.outlook-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.status { font-size: 17px; font-weight: 650; white-space: nowrap; }
.status.ok { color: var(--accent-ink); }
.status.warn { color: var(--warn-ink); }
.fbar { display: block; overflow: visible; }
.fill-accent { fill: var(--accent); }
.fill-warn { fill: var(--warn-ink); }
.outlook-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.top-rule { padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.card.flush > .card-head { padding: 18px 20px 14px; }
.timeline { list-style: none; margin: 0; padding: 4px 20px 8px; }
.timeline > li { position: relative; margin-left: 7px; padding: 0 0 8px 26px; border-left: 2px solid var(--line); }
.timeline-dot {
  position: absolute; left: -8px; top: 3px; width: 14px; height: 14px; border-radius: 7px;
  border: 3px solid var(--surface); background: var(--accent);
}
.timeline-date { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.timeline ul { list-style: none; margin: 0; padding: 0; }
.timeline ul > li { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: baseline; gap: 5px; padding: 2px 8px; border-radius: 6px; background: var(--ground); font-size: 12px; }
.chip > span { color: var(--muted); }
.chip > b { font-weight: 600; }
.timeline-note { padding: 10px 20px 18px; }

/* Bills */

.row-link.stacked { flex-direction: column; gap: 3px; }
.row-top.small { font-size: 13px; font-weight: 400; }
.cell-title + .note { display: block; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
fieldset.card > legend { grid-column: 1 / -1; }
.pick-cadence:has(input[name="cadence"][value="weekly"]:checked) .for-monthly,
.pick-cadence:not(:has(input[name="cadence"][value="weekly"]:checked)) .for-weekly { display: none; }
.split.single > form { max-width: none; }
.split > form.wide-form { flex: 2 1 480px; max-width: none; }
.side { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 768px) { .side { max-width: 340px; } }
.posted-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px;
  border-top: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.posted-row:hover { background: var(--ground); color: var(--ink); }

/* IOUs */

.owed { display: flex; flex-direction: column; gap: 2px; }
.owed-amount { font-size: 22px; font-weight: 650; }
.pbar { display: block; }
.fill-line { fill: var(--line); }
.iou-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.iou-card { gap: 10px; color: var(--ink); text-decoration: none; }
.iou-card:hover { color: var(--ink); border-color: var(--field-line); }
.row-top.baseline { align-items: baseline; }
.empty-card { color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  background: var(--ground); color: var(--muted); font-size: 12px; font-weight: 600;
}
.tag.ok { background: var(--accent-soft); color: var(--accent-ink); }
.title-badge { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.title-badge > .tag { order: -1; }
@media (min-width: 768px) {
  .title-badge { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .title-badge > .tag { order: 0; }
}
.section-title { font-size: 17px; font-weight: 650; }
.progress-figures { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.progress-figures > div { display: flex; flex-direction: column; gap: 2px; }
.figure { font-size: 20px; font-weight: 650; }
.main-col { flex: 2 1 420px; min-width: 0; }
.stack-2 { display: flex; flex-direction: column; gap: 2px; }
.card-foot { padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.measure.wide { max-width: 640px; }
.banner { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--accent-soft); }
.initials { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--accent-ink); }
.initials > span {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); font-weight: 700;
}
.banner-title { font-size: 17px; font-weight: 650; }
.fields-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.span-all { grid-column: 1 / -1; }
@media (min-width: 768px) { .banner { padding: 18px 22px; } }

/* Activity */

.stack-12 { display: flex; flex-direction: column; gap: 12px; }
.filter-stack { display: flex; flex-direction: column; gap: 14px; padding: 14px; border-top: 1px solid var(--line); }
.chip-choices, .chip-links { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-choices > label, .chip-links > a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--ground);
  color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.chip-choices > label:has(input:checked), .chip-links > a[aria-current="true"] {
  border-color: var(--field-line); background: var(--surface); color: var(--ink); font-weight: 650;
}
.chip-choices > label:has(input:focus-visible) { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.chip-choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip-remove {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 14px; text-decoration: none;
}
.chip-remove > .icon { color: var(--muted); }
.filter-card { gap: 14px; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.chip-row > .note { flex: 0 0 120px; }
.date-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.date-row .field { flex: 0 1 180px; }
.date-row .field > label { font-size: 13px; }
.day-head {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 16px 6px;
  border-top: 1px solid var(--line); background: var(--ground);
  font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.rows.log > li { display: flex; gap: 10px; padding: 9px 16px; }
.log-what { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.log-what .cell-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows.log .note b { color: var(--ink); font-weight: 600; }
.initial {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  margin-top: 2px; border-radius: 13px; color: var(--surface); font-size: 12px; font-weight: 700;
}
.initial.m1 { background: var(--m1); }
.initial.m2 { background: var(--m2); }
.initial.system { background: var(--ground); color: var(--muted); border: 1px solid var(--line); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.who .initial { margin-top: 0; }
.block { display: block; }
.gone { color: var(--muted); }
.log-tag {
  flex: 0 0 auto; padding: 1px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.log-tag.added, .log-tag.repaid { background: var(--accent-soft); color: var(--accent-ink); }
.log-tag.edited { background: var(--ground); color: var(--ink); }
.log-tag.deleted { background: var(--neg-soft); color: var(--neg); }
.log-tag.posted { background: var(--ground); color: var(--muted); }
.log-tag.recomputed, .log-tag.warned { background: var(--warn-bg); color: var(--warn-ink); }

/* Visibility helpers come last so they win over component display rules. */

/* Cards that hold a list for phones and a table for wide screens pick by
   their own width, so a tablet gets the list until the table fits. */
.cq { container-type: inline-size; }
@container (max-width: 639.98px) { .cq-wide { display: none !important; } }
@container (min-width: 640px) { .cq-narrow { display: none !important; } }

@media (max-width: 767.98px) { .only-wide { display: none !important; } }
@media (min-width: 768px) { .only-narrow { display: none !important; } }
