@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
  --bg-app: #E7E9E2;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F6F7F3;
  --bg-input: #FAFBF8;
  --ink: #16181B;
  --ink-2: #3D423B;
  --ink-3: #6B7068;
  --ink-4: #7A7F78;
  --ink-5: #9A9F97;
  --line: #ECEDE8;
  --line-soft: #F1F2EE;
  --line-input: #E1E3DC;
  --accent-lime: #D4F27A;
  --accent-lime-soft: #EEF7D2;
  --hero-lime: #E3F5B0;
  --danger: #B42318;
  --member-j-bg: #E6EEF9;
  --member-j-fg: #24508A;
  --member-t-bg: #F6E8F1;
  --member-t-fg: #8A2D63;
  --member-s-bg: #E8F0EC;
  --member-s-fg: #16181B;
  --status-healthy-bg: #E4F5C4;
  --status-healthy-fg: #2F4A0B;
  --status-healthy-bar: #9BD14B;
  --status-moderate-bg: #FFF0C2;
  --status-moderate-fg: #6E4B00;
  --status-moderate-bar: #E0A82E;
  --status-approaching-bg: #FFE2CC;
  --status-approaching-fg: #8F3509;
  --status-approaching-bar: #EA7A2B;
  --status-over-bg: #FDE2DF;
  --status-over-fg: #A3170F;
  --status-over-bar: #B42318;
  --status-none-bg: #F1F3F0;
  --status-none-fg: #5B605A;
  --assigned-green: #2E7D4F;
  --segment-track: #E9EAE4;
  --shadow-nav: 0 8px 24px rgba(16, 24, 20, .12);
  --shadow-sheet: 0 -8px 30px rgba(16, 24, 20, .15);
  --shadow-seg: 0 1px 3px rgba(16, 24, 20, .12);
  --radius-card: 22px;
  --radius-sheet: 24px;
  --radius-input: 12px;
  --radius-pill: 999px;
  --sidebar: 220px;
  --font: "DM Sans", system-ui, sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  color: var(--ink);
  background: var(--bg-app);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; overflow-x: clip; }
body { min-height: 100dvh; background: var(--bg-app); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: #174A37; }
img, svg { max-width: 100%; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: white; padding: 8px; z-index: 5; }

.app-shell { min-height: 100dvh; }
.sidebar { display: none; }
.workspace { min-width: 0; }
.content {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 16px 16px calc(170px + env(safe-area-inset-bottom));
}

/* —— Bottom nav (mobile) —— */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow-nav);
  z-index: 30;
  backdrop-filter: blur(10px);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 16px;
  padding: 4px 2px;
}
.tabbar a .tab-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}
.tabbar a.is-active .tab-icon { background: var(--accent-lime); color: var(--ink); }
.tabbar a.is-active { color: var(--ink); }
.add-expense-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 32px));
  height: 52px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  border-radius: 26px;
  background: var(--accent-lime);
  color: var(--ink) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(120, 150, 30, .25);
  z-index: 31;
  border: none;
  text-decoration: none;
}
.add-expense-bar-icon {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.fab { display: none !important; }

h1 { font-size: 22px; font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.eyebrow { color: var(--ink-4); font-size: 11px; font-weight: 400; margin-bottom: 4px; letter-spacing: 0; text-transform: none; }
.lede, .hint { color: var(--ink-3); font-size: 12.5px; }
.page-head, .section-head, .sheet-head, .detail-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px;
}
.page-head-left { min-width: 0; }
.page-sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.desktop-only { display: none; }
.back { color: var(--ink-3); font-size: 13px; display: inline-flex; margin-bottom: 8px; }

/* —— Buttons —— */
.button, button.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  font-size: 15px; font-weight: 700;
  cursor: pointer; text-decoration: none;
}
.button-accent { background: var(--accent-lime); border-color: var(--accent-lime); color: var(--ink); }
.button-move { background: var(--ink); border-color: var(--ink); color: #fff; min-height: 50px; width: 100%; }
.button-secondary { background: #fff; border-color: var(--line); color: var(--ink); min-height: 44px; font-weight: 600; }
.button-ghost { background: transparent; border-color: transparent; color: var(--ink); min-height: 44px; }
.button-danger { background: transparent; color: var(--danger); border-color: #FDE2DF; }
.button:disabled { opacity: .4; pointer-events: none; }
.button-sm { min-height: 40px; padding: 0 14px; font-size: 13.5px; }
.icon-button {
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); flex: none;
}

/* —— Month + member —— */
.month-nav {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 12px;
}
.month-nav-label { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 140px; }
.month-nav-label strong { font-size: 15px; font-weight: 700; }
.month-tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--bg-subtle); color: var(--ink);
}
.month-tag.is-past { color: var(--ink-3); background: transparent; }
.month-tag.is-planning { color: var(--member-j-fg); background: var(--member-j-bg); }

.segment, .week-row, .chip-row { display: flex; gap: 6px; margin-bottom: 12px; }
.segment {
  background: var(--segment-track);
  padding: 3px;
  border-radius: 22px;
  gap: 2px;
}
.segment-item, .week-chip, .chip {
  flex: 1; text-align: center; color: var(--ink-2);
  border-radius: 999px; padding: 8px 6px; min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13.5px;
  background: transparent;
}
.segment-item.is-active {
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}
.week-chip.is-active {
  background: #fff; color: var(--ink); box-shadow: var(--shadow-seg);
}
.week-chip {
  flex-direction: column; gap: 2px;
  background: var(--bg-surface); border: 1px solid var(--line); border-radius: 14px;
}
.week-chip small { color: var(--ink-3); font-size: 11px; font-weight: 400; }
.chip {
  flex: none; background: var(--accent-lime-soft); color: var(--ink);
  padding: 8px 12px; border: 1px solid transparent;
}
.chip.is-active { background: var(--ink); color: #fff; }
.chip-outline {
  background: #fff; border: 1px solid var(--line); color: var(--ink); border-radius: 999px;
  padding: 8px 12px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.chip-outline.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* —— Cards / metrics —— */
.summary, .report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 12px;
}
.summary-cell {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.summary-cell + .summary-cell { border-left: 1px solid #EEF1EC; }
.summary-cell span { font-size: 12px; color: var(--ink-3); }
.summary-cell strong {
  font-size: 13.5px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.summary-cell.metric-available strong { color: var(--assigned-green); }
.summary-cell.is-negative strong { color: var(--danger); }
.budget-actions {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px;
}
.budget-actions-spacer { flex: 1; }
.apply-defaults-btn,
.move-budget-btn {
  height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 18px; border: 1px solid var(--ink);
  background: #fff; color: var(--ink);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  min-height: 36px;
  cursor: pointer;
}
.apply-defaults-btn { border-color: #D5DAD3; color: var(--ink-2); }
.metric, .panel, .panel-link, .form-card, .account-card, .auth-card, .hero-card, .week-card, .list-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.panel, .panel-link, .hero-card, .week-card, .list-card { display: block; margin-bottom: 12px; color: inherit; }
.hero-card {
  background: var(--hero-lime);
  border-color: transparent;
  border-radius: 24px;
  padding: 18px 18px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.hero-card .display-money { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.hero-sub { font-size: 12px; color: #5F6656; margin: 0; }
.hero-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid rgba(22, 24, 27, .10);
  padding-top: 8px;
  margin-top: 2px;
}
.hero-split span { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.hero-split small { font-size: 11.5px; opacity: .8; }
.hero-split strong {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.week-card .display-money { font-size: 24px; font-weight: 600; margin: 4px 0 0; }
.week-meta { font-size: 12px; color: #8A8F87; margin: 0; }
.metric span, .metric small { display: block; color: var(--ink-4); font-size: 11px; font-weight: 400; }
.metric strong, .cat-nums, .txn-amt, .display-money { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; white-space: nowrap; }
.metric strong { font-size: 14px; font-weight: 700; color: var(--ink); }
.metric-available strong { color: var(--assigned-green); }
.display-money { display: block; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 8px; }
.is-negative { color: var(--danger) !important; }
.inline-metrics { display: flex; flex-wrap: wrap; gap: 12px; color: var(--ink-3); font-size: 12.5px; }
.panel-label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.home-grid { display: grid; gap: 12px; margin-bottom: 4px; }
.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--member-j-bg); color: var(--member-j-fg);
  font-weight: 700; font-size: 14px; flex: none;
}
.avatar.is-t { background: var(--member-t-bg); color: var(--member-t-fg); }

/* —— Category rows —— */
.cat-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 12px 8px 12px 12px;
  margin-bottom: 8px;
  position: relative;
  min-height: 52px;
}
.section > .cat-row:last-child { margin-bottom: 0; }
.cat-main { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.cat-copy { min-width: 0; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cat-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.cat-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 0 6px 0 46px;
  align-items: end;
}
.cat-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cat-field small { font-size: 11px; color: #7A7F78; }
/* Spent = plain text (v3); Assigned input keeps its own chrome */
.cat-field .field-value {
  height: 36px; display: flex; align-items: center;
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: none; background: transparent; padding: 0;
  color: var(--ink-2);
}
.cat-field .assigned-val {
  color: var(--assigned-green);
  border: 1px solid var(--line-input);
  border-radius: 12px;
  padding: 0 10px;
  background: var(--bg-input);
}
.cat-progress {
  height: 4px; background: #F0F1EC; border-radius: 2px; overflow: hidden; margin-right: 4px;
}
.cat-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--status-healthy-bar); }
.status-watch .cat-progress > span { background: var(--status-approaching-bar); }
.status-used_up .cat-progress > span { background: var(--status-moderate-bar); }
.status-overspent .cat-progress > span,
.status-unbudgeted .cat-progress > span { background: var(--status-over-bar); }
.cat-nums {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-left: 46px;
  grid-column: 1 / -1;
}
.cat-nums span { font-size: 14px; font-weight: 600; white-space: nowrap; }
.cat-nums small { display: block; color: var(--ink-4); font-size: 11px; font-weight: 400; margin-bottom: 2px; }
.cat-nums .assigned-val { color: var(--assigned-green); }
.section-pinned { font-size: 13px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.02em; }
.mark {
  width: 36px; height: 36px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.status-pill {
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; white-space: nowrap;
  background: var(--status-healthy-bg); color: var(--status-healthy-fg);
}
.status-healthy .status-pill, .status-healthy .left-pill { background: var(--status-healthy-bg); color: var(--status-healthy-fg); }
.status-watch .status-pill, .status-watch .left-pill { background: var(--status-approaching-bg); color: var(--status-approaching-fg); }
.status-used_up .status-pill, .status-used_up .left-pill { background: var(--status-moderate-bg); color: var(--status-moderate-fg); }
.status-overspent .status-pill, .status-overspent .left-pill,
.status-unbudgeted .status-pill, .status-unbudgeted .left-pill { background: var(--status-over-bg); color: var(--status-over-fg); }
.left-pill {
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; white-space: nowrap;
  background: var(--status-healthy-bg); color: var(--status-healthy-fg);
}
.bar { display: block; height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--status-healthy-bar); border-radius: inherit; }
.status-healthy .bar > span { background: var(--status-healthy-bar); }
.status-watch .bar > span { background: var(--status-approaching-bar); }
.status-used_up .bar > span { background: var(--status-moderate-bar); }
.status-overspent .bar > span, .status-unbudgeted .bar > span { background: var(--status-over-bar); }
.hero-card .bar { background: rgba(22, 24, 27, .12); }
.hero-card .bar > span { background: var(--ink); }
.week-card .bar > span { background: #E0A82E; }

.overflow { position: relative; justify-self: end; align-self: start; }
.overflow summary {
  width: 36px; height: 36px; list-style: none; cursor: pointer;
  text-align: center; border-radius: 999px; line-height: 36px; color: var(--ink-4);
}
.overflow summary::-webkit-details-marker { display: none; }
.overflow[open] { z-index: 3; }
.overflow a {
  position: absolute; right: 0; display: block; background: white;
  border: 1px solid var(--line); padding: 10px 12px;
  color: inherit; min-width: 180px; min-height: 40px; font-weight: 600;
}
.overflow a:nth-of-type(1) { top: 36px; border-radius: 14px 14px 0 0; }
.overflow a:nth-of-type(2) { top: 76px; }
.overflow a:nth-of-type(3) { top: 116px; border-radius: 0 0 14px 14px; }

/* —— Lists —— */
.txn-list, .break-list, .manage-list, .plain-list, .pocket-list { list-style: none; padding: 0; margin: 0; }
.txn-list a, .break-list a, .manage-list li {
  display: flex; gap: 12px; align-items: center;
  color: inherit; padding: 12px 0; border-bottom: 1px solid var(--line-soft); min-height: 56px;
}
.txn-list li:last-child a, .break-list li:last-child a { border-bottom: 0; }
.txn-copy, .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.txn-copy strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-copy small, .manage-list small { color: var(--ink-3); font-size: 12px; }
.txn-date { width: 48px; color: var(--ink-3); font-size: 12px; }
.txn-amt { font-weight: 700; font-size: 14px; white-space: nowrap; }
.is-refund { color: var(--assigned-green); }
.empty { padding: 24px 8px; color: var(--ink-3); }
.empty h2 { font-size: 15px; }
.toast {
  border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
  background: var(--ink); color: #fff; font-size: 14px;
}
.toast-error { background: var(--status-over-bg); color: var(--status-over-fg); }
.toast-success { background: var(--ink); color: #fff; }
.section { margin-bottom: 8px; }
.section-head a { color: var(--ink); font-size: 13.5px; font-weight: 500; }

/* —— Forms —— */
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-3); font-weight: 500; }
input, select, textarea {
  min-height: 48px; border-radius: var(--radius-input);
  border: 1px solid var(--line-input);
  background: var(--bg-input); padding: 10px 12px; width: 100%;
  color: var(--ink); font-weight: 600;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink); background: #fff;
}
.amount-input {
  font-size: 32px; font-weight: 700; letter-spacing: -0.03em;
  text-align: center; border: none; background: transparent; min-height: 48px;
}
.amount-input:focus { background: transparent; }
.check { flex-direction: row; align-items: center; min-height: 44px; color: var(--ink); font-weight: 600; }
.check input { width: auto; min-height: 0; }
fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.form-card { margin-bottom: 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.inline-form input, .inline-form select { width: auto; min-width: 0; flex: 1; }
.assign-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.action-row, .settings-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.danger-zone { margin-top: 14px; }
.optional { color: var(--ink-3); font-weight: 400; }

.owner-block { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.owner-block summary { cursor: pointer; font-weight: 650; min-height: 44px; }
.account-card header { display: flex; gap: 8px; align-items: baseline; }
.account-card header b { margin-left: auto; font-variant-numeric: tabular-nums; }
.pocket-list li { display: flex; justify-content: space-between; padding: 6px 0 6px 12px; color: var(--ink-3); }

.manage-grid { display: grid; gap: 16px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.icon-choice { border: 1px solid var(--line); border-radius: 12px; padding: 8px; align-items: center; }
.icon-choice input { position: absolute; opacity: 0; }
.icon-choice:has(input:checked) { border-color: var(--ink); background: var(--accent-lime-soft); }
.swatch-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.swatch-button, .swatch { width: 28px; height: 28px; border-radius: 999px; border: 1px solid var(--line); padding: 0; }
.swatch { display: inline-block; }
.preview { display: flex; gap: 8px; align-items: center; border-radius: 16px; padding: 14px; font-weight: 650; }
.limit-table { display: grid; gap: 8px; }
.split { display: grid; gap: 8px; }
.check-scroll { max-height: 220px; overflow: auto; }
.sheet {
  width: min(480px, 100%);
  max-height: min(92dvh, 900px);
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  margin-top: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-sheet);
}
.sheet::backdrop { background: rgba(16, 24, 20, .35); }
.sheet-actions { display: flex; justify-content: space-between; gap: 8px; position: sticky; bottom: 0; background: white; padding-top: 8px; }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 999px; background: #D9DCD5;
  margin: 0 auto 12px;
}
.saved-row { display: grid; gap: 6px; margin-top: 8px; }
.donut {
  width: min(180px, 70%);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto;
}
.donut-hole {
  width: 62%; aspect-ratio: 1; border-radius: 50%;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.donut-hole span { font-size: 11.5px; color: #7A7F78; }
.donut-hole strong { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.report-donut-card { text-align: center; }
.report-overview { display: grid; gap: 12px; margin-bottom: 12px; }
.type-pills {
  display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px;
  padding-bottom: 2px;
}
.type-pill {
  flex: none;
  padding: 8px 12px; min-height: 36px;
  border-radius: 999px;
  border: 1px solid #D5DAD3;
  background: #fff; color: var(--ink);
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.type-pill.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.weekly-split { display: grid; gap: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 12px; list-style: none; padding: 0; }
.legend li { display: flex; gap: 6px; align-items: center; }
.trend { display: flex; align-items: flex-end; gap: 8px; min-height: 180px; overflow-x: auto; padding-top: 12px; }
.trend-col { flex: 1; min-width: 36px; text-align: center; }
.trend-stack { width: 100%; border-radius: 8px 8px 2px 2px; overflow: hidden; display: flex; flex-direction: column-reverse; background: var(--bg-subtle); min-height: 4px; }
.pager { display: flex; justify-content: space-between; margin-top: 12px; }
.auth-body { display: grid; place-items: center; padding: 24px 16px; background: var(--bg-app); min-height: 100dvh; }
.auth-card { width: min(100%, 420px); }
.text-link { font-weight: 600; font-size: 13.5px; }

/* —— Expense sheet layout —— */
.expense-sheet { max-width: 480px; margin: 0 auto; }
.expense-amount-wrap { text-align: center; padding: 8px 0 16px; }
.cat-pick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 6px;
  margin-bottom: 14px;
}
.cat-pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: none; background: transparent; padding: 4px; cursor: pointer;
  color: var(--ink); font-size: 11.5px; font-weight: 500; min-height: 44px;
}
.cat-pick .mark { width: 42px; height: 42px; transition: box-shadow .15s ease; }
.cat-pick.is-selected .mark {
  background: #16181B !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #16181B;
}
.cat-pick.is-selected { font-weight: 700; }
.cat-pick span:last-child {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 10px;
}
.keypad button {
  min-height: 52px; border: none; border-radius: 14px;
  background: #F1F3F0; color: var(--ink);
  font-size: 20px; font-weight: 500; cursor: pointer;
  user-select: none;
}
.keypad button:active { background: #ECEDE8; }
.date-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 0; }
.expense-form-compact { gap: 10px; }
.expense-sheet-head { margin-bottom: 4px; }
.expense-meta-row { display: flex; flex-direction: column; gap: 8px; }
.pay-chip-row { overflow-x: auto; flex-wrap: nowrap; }
.expense-desc { margin: 0; }
.expense-desc input { min-height: 44px; }
.expense-sticky-footer {
  position: sticky; bottom: 0;
  background: #fff;
  padding-top: 8px;
  padding-bottom: env(safe-area-inset-bottom);
  margin-top: auto;
}
.expense-amount-wrap { padding: 4px 0 8px; }

:focus-visible { outline: 3px solid var(--accent-lime); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (min-width: 860px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    position: sticky; top: 0; height: 100dvh;
    padding: 20px 14px; border-right: 1px solid var(--line); background: var(--bg-surface);
  }
  .brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; padding: 4px 8px 16px; }
  .brand strong { font-size: 16px; font-weight: 700; display: block; }
  .brand small { display: block; color: var(--ink-3); font-size: 12px; }
  .brand-mark {
    width: 36px; height: 36px; border-radius: 12px;
    background: var(--ink); color: #fff; display: grid; place-items: center; flex: none;
  }
  .side-nav, .side-secondary { display: flex; flex-direction: column; gap: 4px; }
  .side-nav a, .side-secondary a {
    text-decoration: none; color: var(--ink); padding: 0 12px; border-radius: 14px;
    display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 600; font-size: 14px;
  }
  .side-nav a.is-active { background: var(--ink); color: #fff; }
  .side-add {
    background: var(--ink); color: #fff !important; justify-content: center;
    margin: 10px 0 8px; border-radius: 999px; min-height: 44px; font-weight: 600;
  }
  .side-profile {
    margin-top: auto; display: flex; gap: 10px; align-items: center;
    padding: 10px 8px; border-radius: 12px; color: inherit;
  }
  .side-profile strong { display: block; font-size: 14px; }
  .side-profile small { display: block; color: var(--ink-3); font-size: 12px; }
  .tabbar, .fab, .add-expense-bar { display: none !important; }
  .content { padding: 24px 24px 40px; }
  .weekly-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .report-overview { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; align-items: start; }
  .desktop-only { display: inline-flex; }
  .home-grid { grid-template-columns: 1.4fr 1fr; gap: 14px; }
  .split { grid-template-columns: 1fr 1fr; }
  .cat-row { align-items: start; }
  .report-grid { grid-template-columns: 280px 1fr; }
  .manage-grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); align-items: start; }
  .sheet { border-radius: var(--radius-sheet); margin: auto; box-shadow: var(--shadow-nav); }
}

@media (max-width: 359px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .cat-nums { margin-left: 0; }
}

/* —— Sheet overlay (Add expense) —— */
body.has-sheet-overlay { overflow: hidden; }
body.has-sheet-overlay .app-shell.is-dimmed { filter: none; opacity: .45; pointer-events: none; }
dialog.expense-dialog[open], .expense-dialog[open] {
  display: block;
  position: fixed;
  z-index: 50;
}
.sheet-scrim { pointer-events: auto; z-index: 40; }
.sheet-scrim {
  position: fixed; inset: 0; background: rgba(16,24,20,.4);
  z-index: 40; pointer-events: auto;
}
.expense-dialog.sheet,
dialog.expense-dialog {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: auto;
  width: 100%;
  max-width: 100%;
  max-height: min(92dvh, 900px);
  margin: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  padding: 0;
  background: #fff;
  box-shadow: var(--shadow-sheet);
  z-index: 50;
  animation: ys-up .2s ease-out;
}
.expense-dialog .expense-sheet {
  padding: 10px 16px 12px;
  overflow: auto;
  max-height: min(92dvh, 900px);
  display: flex;
  flex-direction: column;
  min-height: min(92dvh, 800px);
}
.expense-dialog .expense-form-compact {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
@keyframes ys-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* —— Day groups (Expenses) —— */
.day-groups { display: flex; flex-direction: column; gap: 8px; }
.day-group { background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.day-header, .sticky-day {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg-subtle);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  position: sticky; top: 0; z-index: 2;
}
.day-header strong { font-variant-numeric: tabular-nums; color: var(--ink); }
.day-group .txn-list a { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.day-group .txn-list li:last-child a { border-bottom: 0; }
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input[type=search] { flex: 1; min-height: 44px; }
.txn-list .is-transfer .txn-amt, .txn-list li.is-transfer .txn-copy small { color: var(--ink-4); }
.txn-list .is-move .txn-amt { color: var(--ink); }

/* —— Assign inline —— */
.assign-inline { margin: 0; }
.assign-input {
  min-height: 36px !important; height: 36px; width: 100%; max-width: none;
  border-radius: 12px; border: 1px solid var(--line-input);
  background: var(--bg-input); padding: 6px 10px;
  font-size: 14px; font-weight: 600; color: var(--assigned-green); font-variant-numeric: tabular-nums;
}
.cat-field .assign-input { max-width: none; }
.assign-input:focus { border-color: var(--ink); background: #fff; outline: none; }
.owner-expand { margin-top: 6px; }
.owner-expand summary { cursor: pointer; color: var(--ink-3); font-size: 12px; }
.owner-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.member-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.member-jimmy { background: var(--member-j-bg); color: var(--member-j-fg); }
.member-thoeng { background: var(--member-t-bg); color: var(--member-t-fg); }
.member-shared { background: var(--member-s-bg); color: var(--member-s-fg); }
.cat-icon-link { flex: none; }
.cat-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; grid-column: 1; }

/* —— Reports —— */
.report-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.report-tab { padding: 10px 2px 12px; color: var(--ink-3); font-weight: 600; border-bottom: 2px solid transparent; }
.report-tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-summary { color: var(--ink-3); font-size: 12.5px; flex: 1; min-width: 120px; }
.rank-bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.rank-bars a { display: grid; gap: 6px; color: inherit; }
.rank-meta { display: flex; align-items: center; gap: 8px; }
.rank-dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.rank-amt { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-amt small { color: var(--ink-3); font-weight: 500; margin-right: 6px; }
.rank-track { display: block; height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.rank-track > span { display: block; height: 100%; border-radius: inherit; }
.trends-grid { display: grid; gap: 6px; }
.trends-totals, .trends-plot, .trends-labels {
  display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 12px; align-items: end;
}
.trends-total { text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-3); opacity: .55; font-variant-numeric: tabular-nums; }
.trends-total.is-selected { color: var(--ink); opacity: 1; }
.trends-plot { position: relative; min-height: 150px; height: 150px; align-items: end; border-bottom: 1px solid var(--line); }
.trends-avg { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--ink); opacity: .3; pointer-events: none; }
.trends-bar {
  display: flex; flex-direction: column-reverse; width: 100%; max-width: 40px; margin: 0 auto;
  border-radius: 8px 8px 0 0; overflow: hidden; background: var(--bg-subtle); opacity: .55; min-height: 4px;
}
.trends-bar.is-selected { opacity: 1; }
.trends-labels a {
  text-align: center; font-size: 12px; color: var(--ink-3); opacity: .55; font-weight: 600;
  min-height: 28px; display: flex; align-items: center; justify-content: center;
}
.trends-labels a.is-selected { color: var(--ink); opacity: 1; font-weight: 700; }

/* Trends month-by-category rows — horizontal rows, not a cramped stacked block */
.break-list.trend-cats { display: flex; flex-direction: column; margin-top: 4px; }
.break-list.trend-cats li,
.break-list.trend-cats a {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 14px 0;
  border-top: 1px solid #F1F2EE; border-bottom: 0;
  color: inherit; text-decoration: none;
}
.break-list.trend-cats li:first-child { border-top: 1px solid #F1F2EE; }
.break-list.trend-cats .grow {
  flex: 1; min-width: 0; display: block;
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.break-list.trend-cats .trend-share {
  font-size: 12px; color: var(--ink-4); flex: none;
}
.break-list.trend-cats .trend-amt {
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; min-width: 96px; text-align: right; flex: none;
}

/* —— Weekly —— */
.weekly-tabs-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.weekly-tabs-row .segment { flex: 1; margin-bottom: 0; }
.week-summary-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.week-chip.is-active { border-color: var(--ink); background: var(--accent-lime-soft); box-shadow: none; }
.break-list li.is-zero { opacity: .5; }
.drag-handle { color: var(--ink-5); cursor: grab; font-size: 18px; width: 32px; text-align: center; }
.weekly-tab-editor li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.weekly-tab-editor li strong { flex: 1; }
.banner-note {
  background: #FFF8DE; color: #6E4B00; border-radius: 14px; padding: 10px 12px;
  font-size: 12.5px; margin-bottom: 12px;
}

/* Phone nav closer to mockups: dark dock */
@media (max-width: 859px) {
  .tabbar {
    background: #16181B; border-color: transparent; color: #fff;
    width: min(440px, calc(100% - 20px));
    height: 64px;
    padding: 6px 4px;
    border-radius: 32px;
    gap: 0;
  }
  .tabbar a {
    color: #A3A8A0;
    height: 52px;
    margin: 0 2px;
    border-radius: 0;
    background: transparent;
    gap: 2px;
    padding: 0 2px;
  }
  /* Active: lime CIRCLE behind icon only; label stays below outside the circle. */
  .tabbar a.is-active {
    background: transparent;
    color: #fff;
  }
  .tabbar a.is-active .tab-icon {
    background: var(--accent-lime);
    color: #16181B;
  }
  .add-expense-bar { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .content { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
}

@media (min-width: 860px) {
  .expense-dialog.sheet, dialog.expense-dialog {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100% - 48px));
    max-height: min(90dvh, 820px);
    border-radius: 24px;
    box-shadow: var(--shadow-nav);
    animation: none;
  }
  .sheet-scrim { background: rgba(16,24,20,.35); }
  .home-grid { grid-template-columns: 1.45fr 1fr; }
}
