/* ==========================================================================
   DreamFundSL — Design tokens
   Direction: a digital passbook, retoned to the DreamFundSL brand mark —
   deep navy structure with a teal-to-blue sidebar, leaf-green for growth
   and money coming in, warm coral for money going out, and sun-gold for
   progress. Signature element: the ledger-rule under every amount, like a
   line in a bank passbook.
   ========================================================================== */

:root {
  --ink-900: #0a1f3d;
  --ink-800: #0f2c53;
  --ink-700: #17416f;
  --parchment: #f4f8f8;
  --parchment-dim: #e8eff0;
  --card: #ffffff;
  --line: #dbe6e6;
  --line-strong: #c1d2d3;
  --teal: #0f9a94;
  --teal-dim: #e0f3f1;
  --green: #16a866;
  --green-dim: #e2f6ec;
  --coral: #d9603b;
  --coral-dim: #fbe9e2;
  --gold: #d1972e;
  --gold-dim: #f8ecd3;
  --blue: #2f6fed;
  --blue-dim: #e5edfd;
  --text-primary: #142033;
  --text-muted: #5c6b78;
  --text-faint: #93a1ab;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(10, 31, 61, 0.08), 0 1px 1px rgba(10, 31, 61, 0.05);
  --shadow-md: 0 6px 20px rgba(10, 31, 61, 0.12);

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  background: var(--parchment);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

.amount, .tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

::selection { background: var(--gold-dim); }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

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

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

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #0f6f6b 0%, var(--ink-800) 38%, var(--ink-900) 100%);
  color: #dfe4ee;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}
.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: #fff;
}
.accent-green { color: var(--green); }
.brand-sub {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a93a8;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #b7bfd1;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: var(--ink-700);
  color: #fff;
}
.nav-item .dot { display: none; }
.nav-item .nav-icon {
  display: block;
  width: 18px; height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
  margin-top: 8px;
}
/* Sign-out moved up: sits right under the profile chip, above the nav
   menu, so it never scrolls out of reach behind a long nav list. */
.sidebar-footer-top {
  margin-top: 0;
  margin-bottom: 14px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
}
/* Profile chip pinned to the top of the sidebar, right under the brand —
   the person's own picture + name is the first thing they see, and it
   doubles as the entry point into the Profile page. */
.user-chip-top {
  padding: 10px;
  margin-bottom: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}
.user-chip-top:hover { background: rgba(255,255,255,0.08); }
.user-chip-top .user-meta::after {
  content: "Edit profile →";
  display: block;
  font-size: 10.5px;
  color: var(--gold);
  margin-top: 2px;
  opacity: 0.9;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold);
  color: var(--ink-900);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
  padding: 0;
  border: 2px solid transparent;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.user-avatar:hover, .user-avatar:focus-visible { border-color: rgba(255,255,255,0.4); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Small camera badge hinting the avatar is clickable/editable. */
.user-avatar::after {
  content: "";
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink-700);
  border: 2px solid var(--ink-900);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h3l2-2h6l2 2h3v11H4z'/%3E%3Ccircle cx='12' cy='13.5' r='3.2'/%3E%3C/svg%3E");
  background-size: 60%;
  background-repeat: no-repeat;
  background-position: center;
}
/* Big picture for the top-of-sidebar profile chip. */
.user-avatar-lg {
  width: 56px; height: 56px; font-size: 22px;
}
.user-avatar-lg::after { width: 18px; height: 18px; }
.user-meta { min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #8a93a8; }
.logout-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 10px; border-radius: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,0.14);
  color: #b7bfd1; font-size: 12.5px; font-weight: 600;
}
.logout-btn:hover { color: #fff; border-color: rgba(216,96,59,0.5); background: rgba(217,96,59,0.12); }
.logout-icon { width: 15px; height: 15px; flex-shrink: 0; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 34px 60px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-version {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--parchment-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.sync-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.sync-dot-ok { background: #2e9e5b; }
.sync-dot-error { background: #d64545; }
.sync-dot-active {
  background: #d9a72e;
  animation: sync-pulse 1.2s ease-in-out infinite;
}
@keyframes sync-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.sync-sheet-link {
  color: var(--accent-green, #2e9e5b);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.sync-sheet-link:hover { text-decoration: underline; }

.notif-wrap { position: relative; }

.notif-bell {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.notif-bell:hover { color: var(--ink-900); border-color: var(--line-strong); }
.notif-bell svg { width: 19px; height: 19px; }

.notif-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  border: 2px solid var(--parchment);
}

.notif-panel {
  position: absolute; top: 46px; right: 0;
  width: 340px; max-width: calc(100vw - 32px);
  max-height: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 13.5px; color: var(--ink-900);
  flex-shrink: 0;
}
.notif-panel-head-actions { display: flex; align-items: center; gap: 12px; }
.notif-mark-read {
  background: none; border: none; color: var(--teal);
  font-size: 11.5px; font-weight: 600; padding: 0;
}
.notif-mark-read:hover { text-decoration: underline; }
.notif-gear {
  background: none; border: none; padding: 0; display: flex;
  color: var(--text-faint);
}
.notif-gear:hover { color: var(--ink-900); }
.notif-gear svg { width: 16px; height: 16px; }
.notif-list { overflow-y: auto; padding: 6px; }
.notif-panel-foot { border-top: 1px solid var(--line); padding: 8px 14px; text-align: center; flex-shrink: 0; }
.notif-see-all { background: none; border: none; color: var(--teal); font-size: 12.5px; font-weight: 600; padding: 4px; }
.notif-see-all:hover { text-decoration: underline; }

.notif-item {
  display: flex; align-items: flex-start; gap: 2px;
  border-radius: 8px;
  position: relative;
}
.notif-item:hover { background: var(--parchment); }
.notif-item.unread { background: var(--teal-dim); }
.notif-item.unread:hover { background: #d3ede9; }
.notif-item-main {
  flex: 1; min-width: 0;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 4px 10px 8px;
  text-align: left; background: none; border: none; cursor: pointer;
}
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.notif-dot.critical { background: var(--coral); }
.notif-dot.warning { background: var(--gold); }
.notif-dot.info { background: var(--teal); }
.notif-dot.positive { background: var(--green); }
.notif-item-text { display: flex; flex-direction: column; min-width: 0; }
.notif-item-title { font-weight: 500; font-size: 13px; color: var(--text-primary); }
.notif-item.unread .notif-item-title { font-weight: 700; }
.notif-item-message { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.notif-item-time { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.notif-dismiss {
  flex-shrink: 0; width: 26px; height: 26px; margin: 8px 6px 0 0;
  border: none; background: none; border-radius: 50%;
  color: var(--text-faint); font-size: 18px; line-height: 1;
  opacity: 0;
}
.notif-item:hover .notif-dismiss, .notif-dismiss:focus-visible { opacity: 1; }
.notif-dismiss:hover { background: var(--parchment-dim); color: var(--text-primary); }
@media (hover: none) { .notif-dismiss { opacity: 1; } } /* touch screens have no hover */

/* Notifications page */
.notif-page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.notif-filter { width: 180px; }
.notif-page-actions { display: flex; gap: 8px; }
.notif-page-list { padding: 6px; }
.notif-page-list .notif-item-title { font-size: 14px; }
.notif-page-list .notif-item-message { font-size: 13px; }
.notif-check-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; font-weight: 500 !important; cursor: pointer; }
.notif-check-row input { width: 16px; height: 16px; accent-color: var(--teal); }
.notif-pref-card { padding: 4px 8px; }
.notif-pref-table { width: 100%; border-collapse: collapse; }
.notif-pref-table th {
  text-align: center; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted); padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}
.notif-pref-table th:first-child { text-align: left; }
.notif-pref-table td { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.notif-pref-table td:first-child { text-align: left; }
.notif-pref-table tr:last-child td { border-bottom: none; }
.notif-pref-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); }
.notif-pref-label { font-weight: 600; font-size: 14px; }
.notif-pref-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.notif-pref-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.notif-run-result { margin-left: 12px; font-size: 13px; color: var(--text-muted); }

@media (max-width: 640px) {
  .notif-panel { position: fixed; top: auto; bottom: 76px; left: 12px; right: 12px; width: auto; max-width: none; }
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink-900);
  margin: 0;
}
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.header-meta { text-align: right; }
.header-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 600; color: var(--ink-900);
}
.header-logins { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  position: relative;
  overflow: hidden;
}
.stat-label-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stat-icon-badge {
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-badge svg { width: 15px; height: 15px; }
.icon-income { background: var(--teal-dim); color: var(--teal); }
.icon-expense { background: var(--coral-dim); color: var(--coral); }
.icon-savings { background: var(--gold-dim); color: var(--gold); }
.icon-cash { background: var(--parchment-dim); color: var(--ink-800); }
.icon-safe { background: var(--teal-dim); color: var(--teal); }
.stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); font-weight: 600;
}
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 600;
  margin: 6px 0 10px;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value.positive { color: var(--teal); }
.stat-value.negative { color: var(--coral); }
.kpi-change {
  font-size: 11.5px; font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.kpi-change.positive { color: var(--teal); }
.kpi-change.negative { color: var(--coral); }
/* signature: ledger-rule, like a passbook line */
.stat-card::after {
  content: "";
  display: block;
  height: 1px;
  background-image: linear-gradient(to right, var(--line-strong) 60%, transparent 0%);
  background-size: 8px 1px;
  background-repeat: repeat-x;
  margin-top: 2px;
}
.stat-card.income .stat-value { color: var(--teal); }
.stat-card.expense .stat-value { color: var(--coral); }
.stat-card.savings .stat-value { color: var(--gold); }

/* Small inline "edit" action on a stat card (used by Cash in Hand). */
.stat-edit {
  position: absolute;
  top: 14px; right: 14px;
  background: none; border: none;
  font-size: 11px; font-weight: 600;
  color: var(--teal);
  padding: 2px 4px;
  cursor: pointer;
}
.stat-edit:hover { text-decoration: underline; }

/* ---------- Dashboard charts ---------- */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 800px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.donut-center-label {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.chart-legend {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  min-width: 140px;
}
.chart-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-primary);
}
.chart-legend .swatch {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.chart-legend .legend-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.compare-rows { display: flex; flex-direction: column; gap: 14px; }
.compare-row .compare-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; margin-bottom: 5px;
}
.compare-row .compare-cat { font-weight: 600; color: var(--text-primary); }
.compare-row .compare-amounts { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 11.5px; }
.compare-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--parchment-dim);
  overflow: hidden;
}
.compare-fill { height: 100%; border-radius: 4px; background: var(--teal); }
.compare-fill.over { background: var(--coral); }
.compare-budget-mark {
  position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink-900);
}

.trend-chart-wrap { overflow-x: auto; }

/* ---------- Sections / tables ---------- */

.section { margin-bottom: 28px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600; color: var(--ink-900); margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.section-title svg {
  width: 18px; height: 18px; flex-shrink: 0;
  color: var(--teal);
}

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--parchment-dim); }
td.amount-cell { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
td.amount-cell.positive { color: var(--teal); }
td.amount-cell.negative { color: var(--coral); }
.type-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.type-pill.income { background: var(--teal-dim); color: var(--teal); }
.type-pill.expense { background: var(--coral-dim); color: var(--coral); }
.type-pill.savings { background: var(--gold-dim); color: var(--gold); }
.type-pill.banking { background: var(--blue-dim); color: var(--blue); }
.status-pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.status-pill.unpaid { background: var(--coral-dim); color: var(--coral); }
.status-pill.paid { background: var(--teal-dim); color: var(--teal); }
.status-pill.overdue { background: var(--ink-900); color: #fff; }

/* Emergency Fund status */
.ef-status-pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; display: inline-block; }
.ef-status-pill.critical { background: var(--coral-dim); color: var(--coral); }
.ef-status-pill.building { background: var(--gold-dim); color: var(--gold); }
.ef-status-pill.healthy { background: var(--teal-dim); color: var(--teal); }
.ef-status-pill.funded { background: var(--ink-900); color: #fff; }
.ef-status-pill.unset { background: var(--parchment-dim); color: var(--text-muted); }

/* ---------- Financial Health ---------- */

.fh-hero { display: flex; }
.fh-hero-score { display: flex; align-items: center; gap: 18px; }

.fh-score-badge {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.fh-score-badge-lg { width: 76px; height: 76px; font-size: 26px; }
.fh-score-badge.excellent, .fh-score-badge.very-healthy { background: var(--green-dim); color: var(--green); }
.fh-score-badge.healthy { background: var(--gold-dim); color: var(--gold); }
.fh-score-badge.needs-attention { background: var(--gold-dim); color: var(--coral); }
.fh-score-badge.at-risk, .fh-score-badge.critical { background: var(--coral-dim); color: var(--coral); }
.fh-score-badge.unset { background: var(--parchment-dim); color: var(--text-muted); }

.fh-level-pill { font-size: 11.5px; font-weight: 600; padding: 4px 11px; border-radius: 20px; display: inline-block; }
.fh-level-pill.excellent, .fh-level-pill.very-healthy { background: var(--green-dim); color: var(--green); }
.fh-level-pill.healthy { background: var(--gold-dim); color: var(--gold); }
.fh-level-pill.needs-attention { background: var(--gold-dim); color: var(--coral); }
.fh-level-pill.at-risk, .fh-level-pill.critical { background: var(--coral-dim); color: var(--coral); }
.fh-level-pill.unset { background: var(--parchment-dim); color: var(--text-muted); }

/* Score History dimension switcher -- small pill tabs above the chart so
   "Overall" can be swapped for a single dimension (Emergency, Savings,
   etc.) without navigating away. */
.fh-dim-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.fh-dim-tab {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: #fff; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.fh-dim-tab.active { background: var(--teal-dim); color: var(--teal); border-color: transparent; }

.fh-hero-opportunity {
  font-size: 14px; font-weight: 500; color: var(--text-primary);
  margin-top: 8px; line-height: 1.45; max-width: 46ch;
}

.fh-dim-list { display: flex; flex-direction: column; gap: 16px; }
.fh-dim-row { border-radius: 8px; padding: 4px 8px; margin: -4px -8px; transition: background 1.8s ease; }
.fh-dim-row-highlight { background: var(--gold-dim); transition: background 0.2s ease; }
.card-highlight-target { transition: background 1.8s ease; border-radius: var(--radius); }
.card-highlight-target.card-highlight-active { background: var(--gold-dim); transition: background 0.2s ease; }
.fh-dim-label { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.fh-dim-points { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-muted); }

.fh-factor-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.fh-factor-list li { font-size: 13px; line-height: 1.5; display: flex; gap: 8px; align-items: baseline; }
.fh-factor-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; margin-top: 4px; }
.fh-factor-dot.helping { background: var(--green); }
.fh-factor-dot.reducing { background: var(--coral); }
.fh-factor-dot.insufficient { background: var(--text-faint); }

.fh-action-grid { display: flex; flex-direction: column; gap: 14px; }
.fh-action-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--parchment);
}
.fh-action-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink-900); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
}
.fh-action-title { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }

.fh-trend { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.fh-trend.up { color: var(--green); }
.fh-trend.down { color: var(--coral); }
.fh-trend.flat { color: var(--text-muted); }

.fh-score-delta { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; }

.fh-dim-points-row { display: flex; align-items: center; gap: 8px; }

.fh-change-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.fh-change-list li { font-size: 13px; line-height: 1.5; display: flex; gap: 10px; align-items: baseline; }
.fh-change-amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; flex-shrink: 0; min-width: 34px; }
.fh-change-amount.up { color: var(--green); }
.fh-change-amount.down { color: var(--coral); }

.fh-next-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--parchment);
}
.fh-next-title { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.fh-next-metrics { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 2px; }
.fh-next-metric { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.fh-next-metric-label { color: var(--text-muted); }
.fh-next-metric-value { font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Smart Budget Advisor ---------- */

.advisor-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 780px) { .advisor-grid { grid-template-columns: 1fr; } }

.advisor-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  border-left: 4px solid var(--line-strong);
}
.advisor-card.advisor-over { border-left-color: var(--coral); background: var(--coral-dim); }
.advisor-card.advisor-watch { border-left-color: var(--gold); background: var(--gold-dim); }
.advisor-card.advisor-ok { border-left-color: var(--teal); }
.advisor-card.advisor-good { border-left-color: var(--green); }
.advisor-card.advisor-closed { border-left-color: var(--line-strong); }
.advisor-card.advisor-muted { border-left-color: var(--line-strong); opacity: 0.85; }

.advisor-headline { font-weight: 600; font-size: 13.5px; color: var(--text-primary); margin-top: 2px; }

.advisor-stats {
  display: flex; gap: 16px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.advisor-stat { display: flex; flex-direction: column; gap: 2px; }
.advisor-stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.advisor-stat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.advisor-stat-value.negative { color: var(--coral); }
.advisor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text-primary);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal);
}
.segmented {
  display: flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden;
}
.segmented button {
  flex: 1; padding: 9px 0; background: #fff; border: none;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-right: 1px solid var(--line-strong);
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--ink-900); color: #fff; }
.segmented button.active.income { background: var(--teal-dim); color: var(--teal); }
.segmented button.active.expense { background: var(--coral-dim); color: var(--coral); }
.segmented button.active.savings { background: var(--gold-dim); color: var(--gold); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 7px; border: none;
  font-size: 13.5px; font-weight: 600;
}
.btn-primary { background: var(--ink-900); color: #fff; }
.btn-primary:hover { background: var(--ink-700); }
.btn-secondary { background: #fff; border: 1px solid var(--line-strong); color: var(--text-primary); }
.btn-secondary:hover { background: var(--parchment-dim); }
.btn-danger { background: var(--coral-dim); color: var(--coral); }
.btn-danger:hover { background: #f6d3c4; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Alerts / messages ---------- */

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--teal-dim); color: var(--teal); }
.alert-error { background: var(--coral-dim); color: var(--coral); }
.alert-warning { background: var(--gold-dim); color: var(--ink-900); border: 1px solid var(--gold); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 13.5px;
}

.progress-track {
  height: 6px; border-radius: 4px; background: var(--parchment-dim);
  overflow: hidden; margin-top: 6px;
}
.progress-fill { height: 100%; background: var(--gold); border-radius: 4px; }
.progress-fill.over { background: var(--coral); }
.progress-fill.insufficient {
  background: repeating-linear-gradient(135deg, var(--parchment-dim), var(--parchment-dim) 6px, var(--line-strong) 6px, var(--line-strong) 12px);
}

/* ---------- Login screen ---------- */

.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f8a83 0%, var(--ink-800) 45%, var(--ink-900) 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--parchment);
  border-radius: 14px;
  padding: 34px 30px;
  box-shadow: var(--shadow-md);
}
.login-brand-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600; color: var(--ink-900);
  margin-bottom: 2px;
  text-align: center;
}
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; text-align: center; }

.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 6px; color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Utility ---------- */

.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; }
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters-row select, .filters-row input { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; font-size: 13px; }

/* ---------- Banking (redesigned: premium fintech dashboard) ---------- */
/* All rules below are scoped to classes used only on the Banking page, so
   this redesign cannot affect the look of any other page in the app. */

.bnk-page { max-width: 1440px; }

.bnk-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.bnk-title { font-family: var(--font-body); font-size: 30px; font-weight: 700; color: var(--ink-900); line-height: 1.15; margin: 0; }
.bnk-subtitle { font-family: var(--font-body); font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.bnk-add-btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--ink-900); color: #fff; border: none; border-radius: 9px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; transition: background 180ms ease-out, transform 150ms ease-out; white-space: nowrap;
}
.bnk-add-btn:hover { background: var(--ink-800); }
.bnk-add-btn:active { transform: scale(0.98); }
.bnk-add-btn svg { width: 16px; height: 16px; }

.bnk-tabs { display: flex; gap: 2px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.bnk-tabs button {
  padding: 10px 4px; margin-right: 22px; background: none; border: none; border-bottom: 2px solid transparent;
  font-family: var(--font-body); font-size: 14px; font-weight: 500; color: var(--text-muted);
  white-space: nowrap; cursor: pointer; transition: color 150ms ease-out, border-color 150ms ease-out;
}
.bnk-tabs button.active { color: var(--ink-900); font-weight: 600; border-bottom-color: var(--teal); }
.bnk-tabs button:hover { color: var(--text-primary); }

/* Hero — Total Balance */
.bnk-hero {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 30px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.bnk-hero-label { font-family: var(--font-body); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.bnk-hero-amount { font-family: var(--font-body); font-size: 38px; font-weight: 700; color: var(--ink-900); margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.bnk-hero-amount.negative { color: var(--coral); }
.bnk-hero-meta { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* Secondary financial summary */
.bnk-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.bnk-summary-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm);
}
.bnk-summary-label-row { display: flex; align-items: center; gap: 6px; }
.bnk-summary-label-row svg { width: 14px; height: 14px; color: var(--text-faint); flex-shrink: 0; }
.bnk-summary-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.bnk-summary-value { font-family: var(--font-body); font-size: 20px; font-weight: 600; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.bnk-summary-value.negative { color: var(--coral); }

/* Sections */
.bnk-section { margin-bottom: 32px; }
.bnk-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.bnk-section-title { font-family: var(--font-body); font-size: 19px; font-weight: 600; color: var(--ink-900); margin: 0; }
.bnk-section-link { font-family: var(--font-body); font-size: 13px; font-weight: 600; color: var(--teal); background: none; border: none; cursor: pointer; padding: 0; white-space: nowrap; }
.bnk-section-link:hover { text-decoration: underline; }

.bnk-group-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 10px; }
.bnk-group-head:first-child { margin-top: 0; }
.bnk-group-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bnk-group-total { font-family: var(--font-body); font-size: 13.5px; font-weight: 600; color: var(--ink-900); font-variant-numeric: tabular-nums; }

/* Account cards */
.bnk-account-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (min-width: 1300px) { .bnk-account-grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 980px) { .bnk-account-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .bnk-account-grid { grid-template-columns: 1fr; } }

/* Compact account chips on the Banking Overview (Tier "Your Accounts") --
   a condensed alternative to the full bnk-account-card grid, used to keep
   the Overview scannable in one screenful; the full cards still appear on
   the Accounts tab. */
.bnk-chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.bnk-account-chip {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px 7px 8px; cursor: pointer; font-family: var(--font-body);
  box-shadow: var(--shadow-sm); transition: border-color 150ms ease-out, transform 150ms ease-out;
}
.bnk-account-chip:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.bnk-account-chip.archived { opacity: 0.55; }
.bnk-chip-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.bnk-chip-balance { font-size: 13px; font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.bnk-chip-balance.negative { color: var(--coral); }

/* Two-column "30-Day Cash Flow" + "Recent Transactions" layout on the
   Banking Overview. */
.bnk-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .bnk-two-col { grid-template-columns: 1fr; } }

.bnk-account-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 7px; box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms ease-out, border-color 200ms ease-out, transform 200ms ease-out;
}
.bnk-account-card:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); transform: translateY(-1px); }
.bnk-account-card:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
.bnk-account-card.archived { opacity: 0.55; }
.bnk-account-card.not-yours { opacity: 0.8; }
.bnk-account-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.bank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; color: #fff;
  font-family: var(--font-body); font-weight: 700; font-size: 10.5px; letter-spacing: .02em;
  flex-shrink: 0; line-height: 1;
}
.bank-badge-sm { width: 22px; height: 22px; border-radius: 7px; font-size: 8.5px; }
.member-avatar-sm {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover;
}
.member-avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-dim); color: var(--gold);
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
}
.bank-name-cell { display: flex; align-items: center; gap: 8px; }
.bank-select-preview { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.bank-select-preview .bank-badge-label { font-size: 12px; color: var(--text-muted); }

.bnk-type-badge { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 9px; border-radius: 20px; flex-shrink: 0; }
.bnk-type-badge.savings { background: var(--teal-dim); color: var(--teal); }
.bnk-type-badge.current, .bnk-type-badge.cash { background: #e4edfb; color: #1d5c8a; }
.bnk-type-badge.fixed-deposit { background: #efe7fb; color: #6a3fa0; }
.bnk-type-badge.credit-card { background: var(--gold-dim); color: var(--gold); }

.bnk-account-owner { font-family: var(--font-body); font-size: 15px; font-weight: 600; color: var(--ink-900); margin-top: 2px; }
.bnk-account-meta { font-size: 12.5px; color: var(--text-muted); }
.bnk-account-balance { font-family: var(--font-body); font-size: 21px; font-weight: 700; color: var(--ink-900); margin-top: 4px; font-variant-numeric: tabular-nums; }
.bnk-account-balance.negative { color: var(--coral); }
.bnk-balance-caption { font-size: 11.5px; font-weight: 600; color: var(--text-faint); text-transform: none; }
.bnk-credit-usage { margin-top: 8px; }
.bnk-credit-usage-label { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; line-height: 1.4; }
.bnk-account-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: 8px; }
.bnk-account-note { font-size: 11px; color: var(--text-faint); display: inline-flex; align-items: center; gap: 4px; }
.bnk-account-note svg { width: 11px; height: 11px; flex-shrink: 0; }
.bnk-account-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Money Movement */
.bnk-mm-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px 24px; box-shadow: var(--shadow-sm); }
.bnk-mm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.bnk-mm-stat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.bnk-mm-stat-value { font-family: var(--font-body); font-size: 19px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; color: var(--ink-900); }
.bnk-mm-stat-value.income { color: var(--green); }
.bnk-mm-stat-value.expense { color: var(--coral); }
.bnk-mm-caption { font-size: 12px; color: var(--text-faint); margin-top: 10px; text-align: center; }
@media (max-width: 600px) { .bnk-mm-stats { grid-template-columns: 1fr; gap: 12px; } }

/* Recent Transactions */
.bnk-tx-day-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 16px 0 8px; }
.bnk-tx-day-label:first-child { margin-top: 0; }
.bnk-tx-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); transition: background 150ms ease-out; border-radius: 8px; }
.bnk-tx-row:last-child { border-bottom: none; }
.bnk-tx-row:hover { background: var(--parchment); }
.bnk-tx-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bnk-tx-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bnk-tx-icon.in { background: var(--green-dim); color: var(--green); }
.bnk-tx-icon.out { background: var(--coral-dim); color: var(--coral); }
.bnk-tx-icon svg { width: 16px; height: 16px; }
.bnk-tx-desc { font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bnk-tx-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bnk-tx-amount { font-family: var(--font-body); font-size: 14.5px; font-weight: 700; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.bnk-tx-amount.in { color: var(--green); }
.bnk-tx-amount.out { color: var(--coral); }

/* Skeleton loaders */
.bnk-skel { background: linear-gradient(90deg, var(--parchment-dim) 25%, var(--line) 37%, var(--parchment-dim) 63%); background-size: 400% 100%; animation: bnkShimmer 1.4s ease infinite; border-radius: 14px; }
@keyframes bnkShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .bnk-skel { animation: none; } }

.bnk-empty { text-align: center; padding: 28px 16px; color: var(--text-muted); font-size: 14px; }
.bnk-empty-title { font-weight: 600; color: var(--ink-900); margin-bottom: 4px; }

@media (max-width: 640px) {
  .bnk-hero { padding: 20px; }
  .bnk-hero-amount { font-size: 30px; }
  .bnk-add-btn { padding: 10px 14px; }
}
@media (max-width: 420px) {
  .bnk-add-btn .bnk-add-label { display: none; }
  .bnk-add-btn { padding: 10px; }
}

/* ---------- Profile page ---------- */

.profile-avatar-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.user-avatar-xl {
  width: 88px; height: 88px; font-size: 32px;
  background: var(--gold); color: var(--ink-900);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  border: 2px solid transparent; overflow: hidden; position: relative;
  padding: 0; cursor: pointer; flex-shrink: 0;
}
.user-avatar-xl:hover, .user-avatar-xl:focus-visible { border-color: var(--line-strong); }
.user-avatar-xl img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar-xl::after {
  content: "";
  position: absolute; right: 2px; bottom: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink-800);
  border: 2px solid #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h3l2-2h6l2 2h3v11H4z'/%3E%3Ccircle cx='12' cy='13.5' r='3.2'/%3E%3C/svg%3E");
  background-size: 55%;
  background-repeat: no-repeat;
  background-position: center;
}
.profile-name { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--ink-900); }
.profile-role-pill {
  display: inline-block; margin-top: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--teal-dim); color: var(--teal);
  padding: 3px 9px; border-radius: 20px;
}
.profile-avatar-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Profile picture alignment control */
.avatar-align-panel { margin-top: 12px; }
.avatar-align-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.avatar-align-preview {
  width: 140px; height: 140px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  border: 2px solid var(--line-strong); background: var(--parchment-dim);
}
.avatar-align-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-align-controls { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }
.avatar-align-controls input[type="range"] { width: 100%; }

/* Savings goal assignment + activity log */
.assignee-checkbox-group { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 6px; }
.assignee-checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: normal; }
.assignee-checkbox input { margin: 0; }
.goal-activity-panel { padding: 10px; overflow-x: auto; }
.goal-activity-panel table { font-size: 12px; }

/* ---------- Cash in hand (dashboard breakdown) ---------- */
/* One box per family member, instead of a flat list — easier to scan and
   matches the boxed-card language used everywhere else in the dashboard. */

.cash-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.cash-box {
  background: var(--parchment-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.cash-box.is-you { background: var(--teal-dim); border-color: rgba(15,154,148,0.25); }
.cash-box-name {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cash-box-you-pill {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em;
  background: var(--teal); color: #fff;
  padding: 1px 6px; border-radius: 20px; text-transform: none;
}
.cash-box-amount { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: var(--ink-900); }
.cash-box .stat-edit { position: static; align-self: flex-start; padding: 0; }

/* ---------- Dashboard: savings goals & debt reminders ---------- */

.goal-mini { padding: 12px 2px; border-bottom: 1px dashed var(--line); }
.goal-mini:last-child { border-bottom: none; }
.goal-mini-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; gap: 10px; }
.goal-mini-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.goal-mini-figures { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.debt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 2px; border-bottom: 1px dashed var(--line);
}
.debt-row:last-child { border-bottom: none; }
.debt-row-main { min-width: 0; }
.debt-row-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.debt-row-due { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.debt-row-amount { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--ink-900); white-space: nowrap; flex-shrink: 0; }
.recurring-pill {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--gold-dim); color: var(--gold); padding: 2px 7px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 3px;
}
.recurring-pill svg { width: 10px; height: 10px; }

/* Dashboard Tier 2 — "What needs attention?" alert list */
.attention-list { display: flex; flex-direction: column; }
.attention-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 2px; border-bottom: 1px dashed var(--line);
  font-size: 13.5px; font-weight: 500; color: var(--text-primary);
}
.attention-row:last-child { border-bottom: none; }
.attention-icon { flex-shrink: 0; font-size: 14px; line-height: 1.4; }
.attention-warning .attention-icon { color: var(--coral); }
.attention-positive .attention-icon { color: var(--green); }
.attention-info .attention-icon { color: var(--text-muted); }
.attention-text { line-height: 1.4; }
.attention-clickable { cursor: pointer; border-radius: 8px; margin: 0 -6px; padding-left: 8px; padding-right: 8px; transition: background 0.15s ease; }
.attention-clickable:hover { background: var(--parchment-dim); }

.rec-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.rec-row:last-child { border-bottom: none; }
.rec-row-main { flex: 1 1 220px; min-width: 0; }
.rec-row-name { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.rec-row-amount {
  text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 13px; white-space: nowrap;
}
.rec-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ==========================================================================
   Mobile view
   The app shell becomes a fixed-height flex column: a slim top bar (brand
   + sign-out) and a fixed icon tab bar pinned to the bottom of the
   viewport, with only `.main` scrolling in between. Both bars stay put
   regardless of scroll position — true fixed positioning, not sticky.
   ========================================================================== */

@media (max-width: 800px) {
  html, body { height: 100%; }

  .app-shell {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Top strip: just the brand + sign-out now — the nav lives in a fixed
     bar at the bottom of the screen instead (see .nav below). */
  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .brand {
    flex: 0 0 auto;
    border-bottom: none;
    border-right: none;
    padding: 0;
    margin-bottom: 0;
  }

  /* Compact sign-out chip — signing out needs to stay reachable on mobile. */
  .sidebar-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
  .logout-icon { display: none; } /* mobile sign-out chip stays text-only, compact */
  .user-chip { padding: 0; gap: 8px; }
  /* Compact on mobile: the top strip is a slim horizontal bar, so the big
     bordered profile chip collapses back to just the avatar. Tapping it
     still opens the Profile page; the file input on the avatar itself
     still opens the picture picker (handled in JS via stopPropagation). */
  .user-chip-top {
    padding: 0; margin-bottom: 0; border: none; background: none; border-radius: 0;
  }
  .user-chip-top:hover { background: none; }
  .user-meta { display: none; }
  .user-avatar { width: 28px; height: 28px; font-size: 12px; }
  .user-avatar-lg { width: 32px; height: 32px; font-size: 13px; }
  .logout-btn {
    width: auto;
    margin-top: 0;
    padding: 6px 12px;
    white-space: nowrap;
  }

  /* Bottom icon tab bar — fixed to the viewport (not just the app shell),
     so it always stays put regardless of scroll position. Scrolls
     horizontally only if a very narrow screen can't fit every icon. */
  .nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 2px;
    background: var(--ink-900);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 58px;
    padding: 6px 2px;
    border-radius: 10px;
  }
  .nav-item.active { background: var(--ink-700); }
  .nav-item .dot { display: none; }
  .nav-item .nav-icon { display: block; width: 20px; height: 20px; flex-shrink: 0; }
  .nav-item .nav-text { font-size: 9px; line-height: 1.15; white-space: nowrap; }

  /* Only this area scrolls — the bars above and below never move. Extra
     bottom padding keeps content clear of the fixed tab bar. */
  .main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 16px calc(76px + env(safe-area-inset-bottom));
  }

  .page-header { margin-bottom: 18px; }
  .page-title { font-size: 21px; }
  .header-meta { text-align: left; }
  .header-clock { font-size: 18px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }

  /* Cards/sections that hold a `.spread` (label + a button on the right,
     e.g. the Banking / Emergency Fund quick-access cards) wrap instead of
     crushing the button against the figures. */
  .spread { flex-wrap: wrap; row-gap: 10px; }
  .spread > button { flex: 0 0 auto; }

  .filters-row { gap: 8px; }
  .filters-row select, .filters-row input, .filters-row button {
    flex: 1 1 140px;
    min-width: 0;
  }

  /* Tables: let the table size to its own content and scroll inside its
     card, rather than forcing every column to shrink to illegibility. */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { width: auto; min-width: 100%; }
  thead th, tbody td { padding: 9px 10px; font-size: 12.5px; white-space: nowrap; }
  thead th { font-size: 10px; }

  .bnk-account-balance, .invbox-card-title { font-size: 18px; }

  .login-card { padding: 28px 22px; }
}

@media (max-width: 420px) {
  .invbox-board { padding: 10px; }
  .invbox-cell-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
  .stat-grid { grid-template-columns: 1fr; }
  .main { padding: 14px 12px calc(76px + env(safe-area-inset-bottom)); }
  .card-pad { padding: 14px 16px; }
  .page-title { font-size: 19px; }
  .btn { padding: 9px 14px; }
}

/* ---------- Investment Box ---------- */

.invbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.invbox-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.invbox-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.invbox-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-900);
}

.invbox-detail {
  background: var(--card);
}

.invbox-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.invbox-goal-badge {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  white-space: nowrap;
}

/* Cells keep a readable minimum size and wrap onto more rows instead of
   shrinking to fit a fixed column count -- a 20-column grid on a phone left
   each cell ~10px wide, too small to show the amount. */
.invbox-cell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.invbox-board {
  margin-top: 18px;
  padding: 16px;
  background: var(--parchment-dim);
  border: 2px solid var(--gold);
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}

.invbox-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-800);
  background: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  min-height: 44px; /* comfortable tap target */
  width: 100%;
  min-width: 0;
  padding: 4px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}

/* Amounts with decimals or thousands separators ("1,500", "1,234.50"). */
.invbox-cell.long { font-size: 11px; letter-spacing: -0.2px; }

.invbox-cell:hover:not(:disabled) {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.invbox-cell.saved {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.7);
}

.invbox-cell:disabled {
  cursor: default;
  opacity: 0.85;
}
