/* Chorebank design tokens
   Palette: --navy (chrome/nav), --ink (body text), --paper (page bg),
            --gold (chorecoin accent), --green (credit), --red (alert/pending)
   Type:    'Inter' for UI/body, 'Space Grotesk' for balances & headline numerals
*/
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Brand accent — swapped per [data-theme] preset */
  --navy: #10243E;
  --navy-light: #1B3A63;
  --nav-bg-2: #1E3E68;
  --gold: #B8892B;
  --gold-soft: #F4E6C8;
  --accent-glow: rgba(184,137,43,0.35);

  /* Page/card surface — swapped by [data-mode="dark"] / prefers-color-scheme */
  --ink: #2A3444;
  --muted: #64748B;
  --paper: #F3F6FA;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --shadow: 0 1px 2px rgba(16,36,62,0.06), 0 8px 24px rgba(16,36,62,0.06);
  --badge-neutral-bg: #E9EEF5;
  /* Heading/accent text on page/card surfaces (h2/h3, ghost buttons, brand
     wordmark on the login card). Follows the accent theme's navy in light
     mode; pinned to a fixed light color in dark mode, since a dark-themed
     navy would be nearly invisible on a dark card. */
  --heading: var(--navy);

  /* Status colors — constant across accent themes and light/dark mode */
  --green: #1E8A5D;
  --green-soft: #E4F5EC;
  --red: #B3261E;
  --red-soft: #FBE7E5;

  /* Navy chrome (topbar/sidebar) text tones — intentionally not swapped by
     light/dark mode; the chrome is always a dark surface by design */
  --nav-text: #DCE6F5;
  --nav-text-dim: #9FB3CE;
  --nav-text-dimmer: #7C93B3;
  --nav-link: #C4D3E8;
  --nav-hover-bg: rgba(255,255,255,0.07);
  --nav-active-bg: rgba(255,255,255,0.12);
  --nav-badge-bg: rgba(255,255,255,0.16);
  --nav-hover-bg-strong: rgba(255,255,255,0.14);
  --nav-border: rgba(255,255,255,0.08);

  --texture-dot: rgba(16,36,62,0.05);

  --radius: 14px;
}

/* ---------- Accent themes (admin-selected, household-wide) ---------- */

[data-theme="forest"] {
  --navy: #14302A; --navy-light: #1F4A3F; --nav-bg-2: #1F4A3F;
  --gold: #B8862E; --gold-soft: #F0E4C4; --accent-glow: rgba(184,134,46,0.35);
}
[data-theme="berry"] {
  --navy: #33122E; --navy-light: #4A1F42; --nav-bg-2: #4A1F42;
  --gold: #B85C79; --gold-soft: #F4D9E0; --accent-glow: rgba(184,92,121,0.35);
}
[data-theme="slate"] {
  --navy: #1E2530; --navy-light: #333D4D; --nav-bg-2: #333D4D;
  --gold: #B06A3A; --gold-soft: #EFE0D0; --accent-glow: rgba(176,106,58,0.35);
}

/* ---------- Light/dark mode (personal, per-browser) ---------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --ink: #E4E9F2; --muted: #92A2B8; --paper: #0A0F17; --card: #1C293B;
    --border: #344258; --badge-neutral-bg: #263349; --heading: #E4E9F2;
    --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.35);
    --texture-dot: rgba(255,255,255,0.05);
  }
}
[data-mode="dark"] {
  --ink: #E4E9F2; --muted: #92A2B8; --paper: #0A0F17; --card: #1C293B;
  --border: #344258; --badge-neutral-bg: #263349; --heading: #E4E9F2;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.35);
  --texture-dot: rgba(255,255,255,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .num {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
}

.num, .amount, .tx-amount, .chore-value {
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

button, input, select {
  font-family: inherit;
  font-size: 1rem;
}

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

input[type=checkbox] {
  accent-color: var(--navy);
  width: 15px;
  height: 15px;
}

input[type=color] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  background: #FAFBFD;
  cursor: pointer;
}

/* ---------- Login page ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #16345A 0%, var(--navy) 55%, #0B1A2E 100%);
  padding: 24px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand .coin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(145deg, var(--gold), #8C6A1E);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.25);
}

/* A logo image can be any aspect ratio (wordmark, icon, etc.) — drop the
   fixed circular coin badge so the whole thing shows instead of getting
   cropped to a small circle. Height stays consistent with the surrounding
   chrome; width grows to fit. */
.coin.has-logo-image {
  width: auto;
  min-width: 0;
  border-radius: 8px;
  overflow: visible;
  background: none;
  box-shadow: none;
  padding: 0;
}

#brandLogoPreview {
  width: 52px;
  height: 52px;
  font-size: 1.3rem;
}

#brandLogoPreview.has-logo-image {
  width: auto;
  max-width: 220px;
}

.brand h1 {
  font-size: 1.35rem;
  margin: 0;
  color: var(--heading);
  letter-spacing: -0.01em;
}

.field { position: relative; margin-bottom: 16px; }

/* ---------- Autocomplete dropdown (search boxes) ---------- */

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 300px;
  overflow-y: auto;
  z-index: 30;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--paper); }
.autocomplete-item .ac-label { font-weight: 600; }
.autocomplete-item .ac-sub { color: var(--muted); font-size: 0.78rem; margin-left: auto; white-space: nowrap; }
.autocomplete-empty { padding: 14px; color: var(--muted); font-size: 0.85rem; text-align: center; }

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #FAFBFD;
}

.field input:focus { border-color: var(--navy-light); background: white; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 9px;
  padding: 12px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--navy-light) 0%, var(--navy) 100%);
  color: white; width: 100%;
  box-shadow: 0 2px 8px rgba(16,36,62,0.28);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(16,36,62,0.35); transform: translateY(-1px); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, #8C6A1E 100%);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-danger { background: linear-gradient(135deg, #C6362D 0%, var(--red) 100%); color: white; }
.btn-danger:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--heading); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--paper); border-color: var(--heading); }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.error-banner {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.87rem;
  margin-bottom: 14px;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 18px;
  line-height: 1.5;
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
  min-height: 0;
}
/* A grid item's default min-width is auto (its content's min-content size),
   which lets wide, unbreakable content (e.g. the cheque's nowrap labels)
   grow the whole "main" track past the viewport instead of just scrolling
   inside it. min-width: 0 lets the track shrink to the grid's own sizing. */
.app-body > .main { min-width: 0; }

/* ---------- Impersonation banner ---------- */

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: repeating-linear-gradient(135deg, #B3261E, #B3261E 12px, #8C1D16 12px, #8C1D16 24px);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 16px;
  position: sticky;
  top: 0;
  z-index: 60;
}
.impersonation-banner #returnToAdminBtn {
  background: white;
  color: var(--red);
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(115deg, var(--navy) 0%, var(--nav-bg-2) 130%);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  color: var(--nav-text);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar .brand { margin-bottom: 0; }
.topbar .brand h1 { color: white; font-size: 1.1rem; }
.topbar .brand .coin { width: 30px; height: 30px; font-size: 0.85rem; }
.topbar .brand .coin.has-logo-image { width: auto; max-width: 160px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.last-login {
  font-size: 0.76rem;
  color: var(--nav-text-dim);
  text-align: right;
  line-height: 1.35;
}
.last-login strong { color: var(--nav-text); font-weight: 600; }

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--nav-hover-bg);
  color: var(--nav-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--nav-hover-bg-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn .count {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--gold);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--navy);
}

.profile-menu { position: relative; }

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: var(--nav-hover-bg);
  color: var(--nav-text);
  padding: 5px 12px 5px 5px;
  border-radius: 20px;
  cursor: pointer;
}
.profile-trigger:hover { background: var(--nav-hover-bg-strong); }
.profile-trigger .avatar-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.7rem;
  background: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}
.profile-trigger .who-text { text-align: left; line-height: 1.2; }
.profile-trigger .name { font-size: 0.82rem; font-weight: 600; color: white; display: block; }
.profile-trigger .role { font-size: 0.68rem; color: var(--nav-text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.profile-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 180px;
  overflow: hidden;
  z-index: 50;
}
.profile-dropdown.open { display: block; }
.profile-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 16px;
  border: none;
  background: none;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--ink);
}
.profile-dropdown button:hover { background: var(--paper); }

.notif-menu { position: relative; }

.notif-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 300px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
}
.notif-dropdown-header h4 { margin: 0; font-size: 0.85rem; }
.notif-dropdown-header button {
  border: none; background: none; color: var(--navy); font-size: 0.75rem; cursor: pointer; font-weight: 600;
}
.notif-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--paper); }
.notif-item.unread { background: var(--gold-soft); }
.notif-item.unread:hover { background: var(--gold-soft); }
.notif-message { font-size: 0.82rem; color: var(--ink); line-height: 1.35; }
.notif-time { font-size: 0.68rem; color: var(--muted); margin-top: 3px; }

/* ---------- Sidebar ---------- */

.sidebar {
  background: linear-gradient(190deg, var(--navy) 0%, var(--nav-bg-2) 140%);
  color: var(--nav-text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,0.12);
  position: relative;
  z-index: 10;
}

.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nav-text-dimmer);
  padding: 0 12px;
  margin-bottom: 6px;
}

/* An expandable nav group (e.g. "Accounts"), collapsed via a class toggle
   on the header button itself rather than JS-driven inline styles. */
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 12px;
  margin-bottom: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nav-text-dimmer);
}
.nav-group-toggle .chevron { width: 14px; height: 14px; flex-shrink: 0; transition: transform 0.15s ease; }
.nav-group-toggle:not(.expanded) .chevron { transform: rotate(-90deg); }
.nav-group-toggle:not(.expanded) + .nav-subgroup { display: none; }
.nav-subgroup { display: flex; flex-direction: column; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 15px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--nav-link);
  text-decoration: none;
  margin-bottom: 2px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-link svg {
  width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85;
  box-sizing: content-box;
  padding: 4px;
  border-radius: 7px;
  transition: opacity 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--nav-hover-bg); color: white; }
.nav-link:hover svg { background: var(--nav-hover-bg-strong); }
.nav-link.active { background: var(--nav-active-bg); color: white; font-weight: 600; }
.nav-link.active svg { opacity: 1; background: var(--gold); color: var(--navy); }
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.sidebar-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--nav-border); }

.main {
  padding: 32px 40px 100px;
  max-width: 1000px;
  position: relative;
  background-image: radial-gradient(circle at 1px 1px, var(--texture-dot) 1px, transparent 0);
  background-size: 24px 24px;
  background-attachment: fixed;
}

/* ---------- Bank disclosure footer ---------- */

.bank-disclosure {
  max-width: 1000px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--muted);
  font-style: italic;
}

/* ---------- Dashboard KPI row (Overview) ---------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 2px rgba(16,36,62,0.05), 0 12px 22px -12px rgba(16,36,62,0.2);
}
.kpi-card .kpi-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-card .kpi-icon svg { width: 20px; height: 20px; }
.kpi-card .kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.15;
}
.kpi-card .kpi-label { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ---------- Quick actions ---------- */

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.quick-actions .btn { width: auto; }

/* ---------- Masked account number ---------- */

.masked-acct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: 0.04em;
}
.masked-acct .reveal-icon { font-size: 0.72em; opacity: 0.75; }

/* ---------- Youth account badge ---------- */

.youth-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--nav-badge-bg);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.topbar .youth-badge { background: rgba(46,158,199,0.25); color: #9FE0F5; }

.main h2 {
  margin: 0 0 6px;
  font-size: 2.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--heading);
}
.main .subtitle { color: var(--muted); font-size: 1rem; margin-bottom: 32px; }

/* ---------- Stat cards (Overview account tiles) — mini bank cards, not
   flat panels: same gradient/texture/glow language as the full balance-card,
   scaled down, with each person's avatar color as the glow accent. ---------- */

.stat-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--nav-bg-2) 100%);
  color: white;
  border: none;
  border-radius: 18px;
  padding: 22px 22px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(16,36,62,0.22), 0 22px 40px -14px rgba(16,36,62,0.45);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.09) 1px, transparent 0);
  background-size: 16px 16px;
  pointer-events: none;
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -24px; bottom: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent, var(--gold)) 0%, transparent 72%);
  opacity: 0.4;
}
.stat-card > * { position: relative; }
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 14px rgba(16,36,62,0.28), 0 30px 54px -12px rgba(16,36,62,0.55);
}

.view { display: none; }
.view.active { display: block; }

/* ---------- Balance card ---------- */

.balance-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--nav-bg-2) 55%, var(--navy-light) 100%);
  color: white;
  border-radius: 24px;
  padding: 34px 36px 32px;
  position: relative;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: 0 2px 4px rgba(16,36,62,0.2), 0 24px 20px -14px rgba(16,36,62,0.35), 0 40px 64px -20px rgba(16,36,62,0.55), inset 0 1px 0 rgba(255,255,255,0.14);
}
.balance-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.09) 1px, transparent 0);
  background-size: 18px 18px;
  pointer-events: none;
}
.balance-card::after {
  content: '';
  position: absolute;
  right: -30px;
  bottom: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
}
.balance-card > * { position: relative; }
.balance-card .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nav-text-dim);
}
.balance-card .amount {
  font-size: 3.6rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin: 8px 0 2px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.balance-card .amount .unit { font-size: 1.05rem; font-weight: 600; color: var(--nav-text); }
.balance-card .acct-num { font-size: 0.82rem; color: var(--nav-text-dim); letter-spacing: 0.04em; margin-top: 10px; }
.balance-card .total-note { font-size: 0.78rem; color: var(--nav-text-dim); margin-top: 2px; }
.balance-card .as-of { font-size: 0.7rem; color: var(--nav-text-dimmer); margin-top: 12px; }

.sparkline-wrap { margin: 12px 0 4px; height: 40px; opacity: 0.9; }
.sparkline-wrap svg { display: block; width: 100%; height: 100%; }

/* ---------- Cards / lists ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(16,36,62,0.05), 0 16px 32px -12px rgba(16,36,62,0.22);
  padding: 26px 28px;
  margin-bottom: 22px;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  box-shadow: 0 6px 14px rgba(16,36,62,0.1), 0 28px 52px -12px rgba(16,36,62,0.32);
  transform: translateY(-4px);
  border-color: var(--heading);
}
.card h3 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--heading);
}

.tx-row, .chore-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}
.tx-row:last-child, .chore-row:last-child { border-bottom: none; }
.tx-row:hover, .chore-row:hover { background: var(--paper); }

.tx-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  margin-right: 12px;
  flex-shrink: 0;
}
.tx-icon.credit { background: var(--green-soft); color: var(--green); }
.tx-icon.debit { background: var(--red-soft); color: var(--red); }
.tx-icon.adjustment { background: var(--gold-soft); color: var(--gold); }

.tx-main { display: flex; align-items: center; flex: 1; min-width: 0; }
.tx-desc { font-weight: 500; font-size: 0.93rem; }
.tx-date { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.tx-amount { font-weight: 700; font-family: 'Space Grotesk', sans-serif; white-space: nowrap; }
.tx-amount.credit { color: var(--green); }
.tx-amount.debit, .tx-amount.adjustment.neg { color: var(--red); }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 20px;
}
.badge.open { background: var(--badge-neutral-bg); color: var(--muted); }
.badge.pending { background: var(--gold-soft); color: var(--gold); }
.badge.approved { background: var(--green-soft); color: var(--green); }
.badge.rejected { background: var(--red-soft); color: var(--red); }
.badge.expired { background: var(--red-soft); color: var(--red); }

.chore-row .chore-info { flex: 1; min-width: 0; }
.chore-row .chore-title { font-weight: 600; font-size: 0.95rem; }
.chore-row .chore-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.chore-row .chore-value { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--gold); margin-right: 14px; white-space: nowrap; }
.chore-row .actions { display: flex; gap: 8px; }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--muted);
  font-size: 0.9rem;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
}

/* ---------- Forms within cards ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.kid-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.kid-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3), 0 1px 3px rgba(0,0,0,0.2);
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--navy);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  z-index: 50;
  max-width: 320px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

table.log-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.log-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--border); }
table.log-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.log-table code { font-size: 0.78rem; color: var(--muted); }
table.log-table tbody tr { transition: background 0.12s ease; }
table.log-table tbody tr:hover { background: var(--paper); }

.progress-track {
  background: var(--border);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
  margin: 10px 0;
}
.progress-fill {
  background: linear-gradient(90deg, var(--gold), #8C6A1E);
  height: 100%;
  border-radius: 20px;
  transition: width 0.3s ease;
}

@media (max-width: 760px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-direction: row; overflow-x: auto; padding: 10px; }
  .nav-group { display: flex; align-items: center; margin-bottom: 0; margin-right: 4px; }
  .nav-group-label { display: none; }
  .sidebar-footer { display: none; }
  .last-login { display: none; }
  .nav-link { white-space: nowrap; }
  .topbar .youth-badge { display: none; }
  .profile-trigger { padding: 5px; }
  .profile-trigger .who-text { display: none; }
  .quick-actions { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .quick-actions .btn { flex-shrink: 0; }
  .main { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* A printable cheque, sized like a real personal cheque (roughly 6in x 2.75in).
   Payee/amount/date/memo are left blank — that's the whole point, the kid
   writes those in by hand after printing. */
.cheque-scroll { overflow-x: auto; }
.cheque {
  width: 6in;
  min-width: 6in;
  padding: 0.3in 0.4in;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  background: var(--card);
}
.cheque-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.cheque-name { font-weight: 700; font-size: 1.05rem; }
.cheque-handle { color: var(--muted); font-size: 0.8rem; }
.cheque-number { font-size: 0.95rem; letter-spacing: 1px; }
.cheque-row { display: flex; align-items: baseline; gap: 10px; margin: 14px 0; font-size: 0.85rem; }
.cheque-row > span:first-child { color: var(--muted); }
.cheque-line { flex: 1; border-bottom: 1px solid var(--ink); min-height: 1.2em; }

/* Date, like on a real cheque, is a short line tucked in the top-right
   corner — not a line stretching the full width. */
.cheque-date-row { justify-content: flex-end; }
.cheque-date-row .cheque-line { flex: 0 0 auto; width: 1.6in; }

/* "Pay to the order of" and the amount box share one row, same as a real
   cheque — the box is small, just enough to write a number in. */
.cheque-payee-row .cheque-currency-mark { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.cheque-box { border: 1px solid var(--ink); border-radius: 4px; width: 1.2in; flex: 0 0 auto; min-height: 1.6em; }

.cheque-words-row .cheque-words-line { flex: 1; border-bottom: 1px solid var(--ink); min-height: 1.2em; }
.cheque-words-row .cheque-words-suffix { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

/* Memo and Signature sit side by side, each sized to what it actually
   needs — not two lines each spanning the whole cheque. */
.cheque-bottom-row { justify-content: space-between; gap: 24px; margin-top: 28px; }
.cheque-memo-group, .cheque-signature-group {
  display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; width: 45%;
}
.cheque-memo-group .cheque-line, .cheque-signature-group .cheque-line { flex: 1; }

.cheque-micr { margin-top: 22px; text-align: center; letter-spacing: 3px; font-family: monospace; color: var(--muted); font-size: 0.9rem; }

@media print {
  body * { visibility: hidden; }
  #chequeArea, #chequeArea * { visibility: visible; }
  #chequeArea {
    position: absolute; top: 0; left: 0;
    border: 1px solid #000; color: #000; background: #fff;
    box-shadow: none;
  }
  .no-print { display: none !important; }
}

/* ---------- Modal popups (Send money, Print a cheque) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  position: relative;
}
.modal-box.modal-wide { max-width: 680px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--heading); }

@media print {
  .modal-overlay { position: static; background: none; padding: 0; display: block !important; }
  .modal-box { box-shadow: none; border: none; max-height: none; overflow: visible; padding: 0; }
}
