/* ============ Tokens ============ */
:root {
  color-scheme: light;
  --bg: #f3f2ee;
  --surface: #fdfdfb;
  --surface-2: #f2f1ec;
  --surface-3: #e9e7e0;
  --border: #e4e2da;
  --text: #121212;
  --text-2: #4d4c48;
  --muted: #7c7b75;
  --grid: #ebe9e2;
  --muted-line: #b9b7ae;
  --accent: #1d5fb3;
  --accent-soft: #e5eefb;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #15803d;
  --good-bg: #e3f4e8;
  --bad: #c0362c;
  --bad-bg: #fbe7e4;
  --warn: #b7791f;
  --warn-bg: #fdf2d8;
  --warn-ink: #7a4b00;
  --side: #121826;
  --side-2: #1b2334;
  --side-text: #c9cfdc;
  --side-muted: #7f8aa3;
  --shadow: 0 1px 2px rgba(20, 20, 10, .04), 0 2px 8px rgba(20, 20, 10, .03);
  --shadow-lg: 0 20px 50px rgba(10, 15, 30, .18);
  --radius: 16px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --surface-3: #262b35;
    --border: #272c36;
    --text: #eef0f3;
    --text-2: #c2c6ce;
    --muted: #8a909c;
    --grid: #232832;
    --muted-line: #5b6170;
    --accent: #4b93ec;
    --accent-soft: #1b2a40;
    --accent-ink: #0b0f16;
    --series-1: #3987e5;
    --series-2: #e0703f;
    --good: #4cc27e;
    --good-bg: #16301f;
    --bad: #f07a6f;
    --bad-bg: #3a1b18;
    --warn: #e7b04a;
    --warn-bg: #362a12;
    --warn-ink: #f2c66d;
    --side: #0b0d11;
    --side-2: #161a22;
    --shadow: none;
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  }
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 15.5px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 13px; font-weight: 650; margin: 0 0 8px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num, .r { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.up::before { content: "▲ "; font-size: .75em; } .down::before { content: "▼ "; font-size: .75em; }
.up.good, .down.good { color: var(--good); } .up.bad, .down.bad { color: var(--bad); }
[hidden] { display: none !important; }

/* ============ Sidebar ============ */
.sidebar {
  align-self: start;
  position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 18px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16.5px; color: #fff; padding: 2px 8px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); display: grid; place-items: center; color: #fff; }
.badge { font-size: 10.5px; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: #4a3a10; color: #f6cf6e; letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--side-text); font-weight: 500; position: relative; }
.nav a:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.nav a.on { background: var(--side-2); color: #fff; }
.nav a.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #4b93ec; }
.ni { width: 18px; height: 18px; display: inline-grid; place-items: center; opacity: .85; }
.ni svg { width: 18px; height: 18px; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: #f07a6f; margin-left: auto; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-btn { justify-content: center; background: var(--side-2) !important; color: var(--side-text) !important; border-color: transparent !important; }
.side-btn:hover { color: #fff !important; }
.side-btn.primary { background: #2563eb !important; color: #fff !important; }
.side-status { font-size: 11.5px; color: var(--side-muted); text-align: center; min-height: 16px; }

/* ============ Layout ============ */
.main { padding: 22px 36px 80px; max-width: 1360px; width: 100%; margin: 0 auto; position: relative; }
.view-inner { display: flex; flex-direction: column; gap: 18px; }
.view-inner.building { position: absolute; left: 36px; right: 36px; top: 22px; visibility: hidden; pointer-events: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 2px; }
.lede { margin: 0; color: var(--text-2); font-size: 15px; max-width: 760px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.g-1-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .sub, p.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.link { font-size: 13px; font-weight: 600; white-space: nowrap; }
.note { margin: 12px 0 0; font-size: 13px; color: var(--text-2); }
.loading { display: flex; gap: 6px; justify-content: center; padding: 120px 0; }
.loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-line); animation: blink 1s infinite alternate; }
.loading span:nth-child(2) { animation-delay: .2s; } .loading span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { to { opacity: .2; } }

/* ============ Buttons & inputs ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.tiny { padding: 3px 9px; font-size: 11.5px; border-radius: 7px; }
.btn.lg { padding: 11px 20px; font-size: 14.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 26px; height: 26px; font-size: 13px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
select, input:not([type]), input[type="search"], input[type="text"], input[type="number"], input[type="date"], .input {
  font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; min-height: 36px;
}
select:focus, input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 0; border-color: var(--accent); }
.input { width: 100%; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button, .seg label span { font: inherit; font-size: 12.5px; font-weight: 600; border: 0; background: none; color: var(--text-2); padding: 5px 11px; border-radius: 8px; cursor: pointer; display: block; white-space: nowrap; }
.seg button.on, .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg.wide { display: flex; } .seg.wide label { flex: 1; text-align: center; } .seg.wide span { text-align: center; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; display: inline-block; width: 36px; height: 21px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(15px); }

/* chips & pills */
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; vertical-align: middle; }
.chip.ok { background: var(--good-bg); color: var(--good); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.muted { background: var(--surface-2); color: var(--muted); }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.small { font-size: 11px; padding: 1px 7px; }
.count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 0 7px; border-radius: 99px; margin-left: 4px; }
.count.hot { background: var(--accent); color: var(--accent-ink); }

/* ============ Alerts & callouts ============ */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 16px; border-radius: 12px; font-size: 13.5px; background: var(--warn-bg); color: var(--warn-ink); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.callout { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-radius: 14px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); flex-wrap: wrap; }

/* ============ KPIs ============ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { position: relative; overflow: hidden; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; transition: transform .12s, box-shadow .12s; }
a.kpi:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.kpi-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.025em; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .meter { margin-top: 10px; }
.kpi.hero { background: linear-gradient(145deg, #1d4ed8, #1e3a8a); border-color: transparent; color: #fff; }
.kpi.hero .kpi-label, .kpi.hero .kpi-foot { color: rgba(255,255,255,.78); }
.kpi.hero .kpi-value { font-size: 30px; }
.kpi.hero .up, .kpi.hero .down { color: #fff; font-weight: 600; }
.kpi-spark { position: absolute; right: 14px; top: 14px; opacity: .9; color: rgba(255,255,255,.75); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi.hero { background: linear-gradient(145deg, #1e4fae, #172b5c); } }

/* meter */
.meter { display: block; height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; }

/* ============ Charts ============ */
.chart { position: relative; height: 240px; }
.chart.sm { height: 170px; }
.chart.lg { height: 300px; }
.chart svg { display: block; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .axis text.sel { fill: var(--text); font-weight: 700; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--muted-line); stroke-width: 1; }
.chart .ref { stroke: var(--warn); stroke-width: 1.25; stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--warn); font-size: 11px; font-weight: 600; }
.chart .cross { stroke: var(--muted-line); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; }
.chart .grp .hit:hover, .chart .grp .hit.on { fill: var(--surface-2); }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 0 24px; font-size: 13px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); }
.sw.ghost { background: none; border-top: 2px dashed var(--muted-line); height: 0; width: 14px; border-radius: 0; }
.sw.line { background: none; border-top: 2px dashed var(--warn); height: 0; width: 14px; border-radius: 0; }
.sw.dot.good { background: var(--good); border-radius: 50%; }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: #0f1320; color: #f3f4f7; border-radius: 10px;
  padding: 9px 12px; font-size: 12.5px; line-height: 1.55; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  font-variant-numeric: tabular-nums; min-width: 160px; max-width: 280px;
}
.tooltip .row { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.tooltip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: #c5cad6; }
.spark { display: block; }

/* ============ Overview pieces ============ */
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; }
.flow > div:not(.flow-op) { display: flex; flex-direction: column; }
.flow-label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.flow-val { font-size: 18px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.flow-val.strong { color: var(--accent); }
.flow-op { color: var(--muted); font-size: 18px; font-weight: 300; }
.event-list, .timeline { display: flex; flex-direction: column; }
.event { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-top: 1px solid var(--grid); border-radius: 10px; cursor: default; }
.event[data-edit-recurring], .event[data-account] { cursor: pointer; }
.event[data-edit-recurring]:hover, .event[data-account]:hover { background: var(--surface-2); }
.event:first-child { border-top: 0; }
.event-date { text-align: center; line-height: 1.05; background: var(--surface-2); border-radius: 10px; padding: 5px 0; }
.event-date span { display: block; font-size: 10px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.event-date b { font-size: 17px; font-weight: 700; }
.event.in .event-date { background: var(--good-bg); }
.event.in .event-date span, .event.in .event-date b { color: var(--good); }
.event.overdue .event-date { background: var(--bad-bg); }
.event.overdue .event-date b, .event.overdue .event-date span { color: var(--bad); }
.event.paid, .event.skipped { opacity: .72; }
.event-name { font-weight: 600; }
.event-sub { font-size: 12px; color: var(--muted); }
.event-match { font-size: 11.5px; color: var(--good); margin-top: 2px; }
.event-match.muted { color: var(--muted); }
.event-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.event-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.event-actions { display: flex; gap: 4px; }
.empty-mini { padding: 24px 6px; color: var(--muted); }
.cat-mini { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cat-mini-row { display: grid; grid-template-columns: minmax(130px, 40%) 1fr auto; gap: 12px; align-items: center; color: var(--text); font-size: 13px; text-decoration: none !important; }
.cat-mini-row .num { min-width: 70px; text-align: right; }
.acct-groups-mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px 22px; }
.agm-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; color: var(--text-2); padding-bottom: 6px; border-bottom: 1px solid var(--grid); margin-bottom: 2px; }
.agm-row { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; font: inherit; color: var(--text); padding: 7px 4px; border-radius: 8px; cursor: pointer; text-align: left; }
.agm-row:hover { background: var(--surface-2); }
.agm-row .num { margin-left: auto; font-weight: 600; }
.agm-row .ellipsis { flex: 1; }

/* logos */
.inst-logo { border-radius: 8px; flex: none; object-fit: contain; background: #fff; }
.inst-logo.initials { display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px; letter-spacing: .02em; }
.m-logo { display: inline-grid; place-items: center; flex: none; border-radius: 10px; background: var(--surface-2); font-size: 15px; overflow: hidden; }
.m-logo img { width: 100%; height: 100%; object-fit: cover; }

/* transaction list */
.tx-list { display: flex; flex-direction: column; }
.tx-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 6px; border: 0; border-top: 1px solid var(--grid); background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; border-radius: 10px; width: 100%; }
.tx-row:first-child { border-top: 0; }
.tx-row:hover { background: var(--surface-2); }
.tx-main { display: flex; flex-direction: column; min-width: 0; }
.tx-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 650; font-variant-numeric: tabular-nums; }
.tx-amt.pos { color: var(--good); }
.tx-list.compact .tx-row { padding: 6px 4px; }

/* ============ Plan ============ */
.plan-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ps { padding: 16px 18px; display: flex; flex-direction: column; border-left: 1px solid var(--grid); min-width: 0; }
.ps:first-child { border-left: 0; }
.ps.strong { background: var(--accent-soft); }
.ps-label { font-size: 12px; color: var(--muted); font-weight: 550; }
.ps-val { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ps.strong .ps-val { color: var(--accent); }
.ps-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-group { margin-bottom: 10px; }
.tl-head { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 6px 4px; border-bottom: 1px solid var(--grid); }
.paid-recent { margin-top: 10px; }
.paid-recent summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 8px 6px; }
.calendar { user-select: none; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { aspect-ratio: 1 / 1.05; border: 1px solid var(--grid); background: var(--surface); border-radius: 10px; padding: 4px 5px; display: flex; flex-direction: column; align-items: flex-start; gap: 0; font: inherit; color: var(--text); cursor: pointer; min-width: 0; overflow: hidden; position: relative; }
.cal-day:hover { border-color: var(--muted-line); }
.cal-day.past { opacity: .55; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.sel { background: var(--accent-soft); border-color: var(--accent); }
.cal-day.low { background: color-mix(in srgb, var(--warn-bg) 70%, var(--surface)); }
.cal-n { font-size: 12px; font-weight: 650; }
.cal-in { font-size: 10.5px; font-weight: 650; color: var(--good); line-height: 1.2; }
.cal-out { font-size: 10.5px; font-weight: 650; color: var(--text-2); line-height: 1.2; }
.cal-out.over { color: var(--bad); }
.cal-dots { position: absolute; bottom: 4px; right: 5px; display: flex; gap: 2px; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--series-2); }
.cal-dots i.in { background: var(--good); } .cal-dots i.paid { background: var(--muted-line); }
.day-detail { margin-top: 12px; }
.dd-head { display: flex; justify-content: space-between; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--grid); font-size: 13px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { font: inherit; font-weight: 600; font-size: 14px; border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 9px; cursor: pointer; }
.tabs button.on { background: var(--surface-2); color: var(--text); }
.suggest-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.suggest-head p { margin: 0; }
.suggest { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 12px; align-items: center; padding: 11px 4px; border-top: 1px solid var(--grid); }
.suggest-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--surface-2); display: grid; place-items: center; font-size: 18px; }
.suggest-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.settings-grid .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.inactive td { opacity: .55; }
.table .desc { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 420px; }
.table .desc > div { min-width: 0; }
.table td.pad { padding: 30px; }

/* filters */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filterbar input[type="search"] { flex: 1 1 240px; }
.active-filter { font-size: 13px; padding: 6px 10px; background: var(--accent-soft); border-radius: 9px; display: inline-flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.tx-totals { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); padding: 10px 2px 12px; border-bottom: 1px solid var(--border); }

/* ============ Accounts ============ */
.acct-cols { align-items: start; }
.group-total { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.acct-cards { display: flex; flex-direction: column; gap: 10px; }
.acct-card { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.acct-card:hover { border-color: var(--muted-line); box-shadow: 0 4px 14px rgba(0,0,0,.05); }
.acct-card.dim { opacity: .5; }
.ac-head { display: flex; align-items: center; gap: 10px; }
.ac-name { flex: 1; min-width: 0; }
.ac-bal { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.ac-meta { font-size: 12px; color: var(--muted); }
.ac-util { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 6px; }
.ac-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--grid); font-size: 12.5px; }
.ac-facts > div { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.ac-facts span:first-child { color: var(--muted); min-width: 64px; }
.group-foot { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.conn-list { display: flex; flex-direction: column; }
.conn { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--grid); flex-wrap: wrap; }
.conn:first-child { border-top: 0; }
.conn-main { flex: 1; min-width: 200px; }

/* ============ Spending ============ */
.month-nav select { min-width: 160px; }
.cat-table { display: flex; flex-direction: column; }
.cat-row { display: grid; grid-template-columns: minmax(170px, 1.3fr) minmax(100px, 1.2fr) 90px 80px 80px; gap: 12px; align-items: center; padding: 10px 34px 10px 6px; border: 0; background: none; font: inherit; color: var(--text); text-align: left; width: 100%; cursor: pointer; border-radius: 10px; }
.cat-row.head { cursor: default; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); border-radius: 0; }
.cat-block { position: relative; border-bottom: 1px solid var(--grid); }
.cat-block > .cat-row:hover { background: var(--surface-2); }
.cat-edit { position: absolute; right: 4px; top: 9px; }
.cat-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cat-name .muted { font-weight: 400; }
.cat-ic { width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); display: inline-grid; place-items: center; font-size: 14px; flex: none; }
.cat-bar { display: flex; flex-direction: column; gap: 3px; }
.cat-detail { padding: 4px 40px 12px 42px; display: flex; flex-direction: column; gap: 4px; }
.cat-sub { display: grid; grid-template-columns: 1fr auto 90px; gap: 12px; font-size: 13px; padding: 3px 0; }
.cat-sub .num { text-align: right; }
.cat-add { padding: 12px 6px 2px; }
.merch-list { display: flex; flex-direction: column; }
.merch { display: grid; grid-template-columns: 20px auto 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--grid); color: var(--text); text-decoration: none !important; border-radius: 9px; }
.merch:first-child { border-top: 0; }
.merch:hover { background: var(--surface-2); }
.merch-rank { color: var(--muted); font-size: 12px; text-align: center; }
.merch-name { display: flex; flex-direction: column; min-width: 0; }
.merch-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merch .num { font-weight: 650; }

/* investments */
.alloc { display: flex; flex-direction: column; gap: 10px; }
.alloc-row { display: grid; grid-template-columns: 110px 1fr 50px 80px; gap: 12px; align-items: center; font-size: 13px; }
.alloc-row .num { text-align: right; }

/* ============ Drawer & modal ============ */
.drawer { position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 24, 0); transition: background .18s; }
.drawer.open { background: rgba(10, 14, 24, .35); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.wide .drawer-panel { width: min(560px, 100vw); }
.drawer.open .drawer-panel { transform: none; }
.drawer-body { overflow-y: auto; padding: 14px 24px 40px; flex: 1; }
.drawer-head { display: flex; justify-content: flex-end; margin: 0 -10px 4px 0; }
.drawer-section { margin-top: 22px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--grid); }
.tx-hero, .acct-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.tx-hero > div { flex: 1; min-width: 0; }
.tx-hero-name, .acct-hero-name { font-size: 19px; font-weight: 700; letter-spacing: -.015em; }
.tx-hero-amt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tx-hero-amt.pos { color: var(--good); }
.big-balance { font-size: 34px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.util { margin: 12px 0 4px; }
.util-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.util-bar span { display: block; height: 100%; background: var(--series-1); border-radius: 99px; }
.util-bar span.warn { background: var(--warn); } .util-bar span.bad { background: var(--bad); }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 16px 0 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.facts select { width: 100%; }
.mini-list { display: flex; flex-direction: column; font-size: 13px; }
.mini-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--grid); }
.drawer .chart.sm { margin-top: 14px; }
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(10, 14, 24, 0); transition: background .16s; }
.modal.open { background: rgba(10, 14, 24, .45); }
.modal-panel { width: min(600px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98); opacity: 0; transition: .16s; }
.modal.open .modal-panel { transform: none; opacity: 1; }
.form { padding: 20px 24px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 19px; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--grid); }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field em { font-weight: 400; font-style: normal; color: var(--muted); }
.field small { font-weight: 400; color: var(--muted); font-size: 12px; }
.field input, .field select { width: 100%; font-weight: 400; }
.money-input { position: relative; }
.money-input i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-weight: 500; }
.money-input input { padding-left: 22px; }
.form-error { color: var(--bad); margin: 0; font-size: 13px; }

.empty-state { text-align: center; padding: 34px 20px; color: var(--text-2); }
.empty-title { font-size: 16px; font-weight: 650; color: var(--text); margin-bottom: 4px; }
.empty-state p { margin: 0 auto 14px; max-width: 440px; color: var(--muted); }
.setup { max-width: 640px; margin: 60px auto; padding: 32px 36px; }
.setup ol { padding-left: 20px; } .setup li { margin: 6px 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f1320; color: #f3f4f7; padding: 11px 18px; border-radius: 12px; font-weight: 500; z-index: 120; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .plan-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ps:nth-child(4) { border-left: 0; }
  .ps:nth-child(n+4) { border-top: 1px solid var(--grid); }
}
@media (max-width: 1000px) {
  .g-1-1, .g-3-2 { grid-template-columns: minmax(0, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; padding-bottom: 64px; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 0; }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; align-items: center; }
  .nav a.on::before { display: none; }
  .nav-dot { position: absolute; top: 4px; right: 22%; margin: 0; }
  .main { padding: 18px 16px 40px; }
  .view-inner.building { left: 16px; right: 16px; top: 18px; }
  h1 { font-size: 24px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi-value { font-size: 21px; }
  .plan-summary { grid-template-columns: 1fr 1fr; }
  .ps { border-left: 0 !important; border-top: 1px solid var(--grid); }
  .ps:nth-child(-n+2) { border-top: 0; }
  .ps.strong { grid-column: 1 / -1; }
  .acct-groups-mini { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .cat-row { grid-template-columns: minmax(120px, 1fr) 80px 70px; padding-right: 30px; }
  .cat-row > :nth-child(2), .cat-row > :nth-child(5) { display: none; }
  .cat-detail { padding-left: 10px; padding-right: 10px; }
  .suggest { grid-template-columns: 36px 1fr auto; }
  .suggest .btn-row { grid-column: 1 / -1; justify-content: flex-end; }
  .event { grid-template-columns: 40px 1fr auto; gap: 10px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 10px; }
  .flow-val { font-size: 16px; }
  .ac-facts { grid-template-columns: 1fr; }
  .tx-totals { gap: 12px; }
  .drawer-body { padding: 12px 16px 40px; }
  .cal-in, .cal-out { font-size: 9px; }
}

/* ============ Login ============ */
body.locked .sidebar, body.locked .main { visibility: hidden; }
.login { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% 0%, #1d3b75 0%, transparent 60%), var(--side); }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 32px 28px 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: stretch; }
.login-card h1 { margin: 4px 0 0; }
.login-card p { margin: 0; }
.login-card input { font-size: 16px; padding: 11px 14px; text-align: center; }
.brand-mark.big { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto; }
.side-btn.ghost { background: transparent !important; color: var(--side-muted) !important; }
.login-card .btn { justify-content: center; }

/* ============ Top bar (all sizes) ============ */
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 36px; min-height: 58px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-brand, .tb-title { display: none; }
.tb-title { font-weight: 700; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.sync-status { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.sync-btn { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); color: var(--accent); }
.sync-btn:hover { background: var(--accent-soft); }
.sync-btn:disabled { color: var(--muted); }
.menu-wrap { position: relative; }
#menuBtn { font-size: 20px; letter-spacing: 1px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; }
.menu button { display: block; width: 100%; text-align: left; font: inherit; font-weight: 500; padding: 10px 12px; border: 0; background: none; color: var(--text); border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.badge { background: var(--warn-bg); color: var(--warn-ink); }
.side-foot .side-status { text-align: left; padding: 0 8px; line-height: 1.4; }
.nl .short { display: none; }
.item-cards { display: none; }

/* ============ Phones ============ */
@media (max-width: 760px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 14px 8px; min-height: 0; }
  .tb-brand { display: inline-grid; place-items: center; }
  .tb-title { display: inline; }
  .tb-connect, .sync-status { display: none; }
  .sync-btn { padding: 8px 12px; }
  .sidebar { padding-bottom: calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px rgba(0,0,0,.18); }
  .nav a { min-height: 52px; justify-content: center; font-size: 11px; }
  .nav a .ni svg { width: 21px; height: 21px; }
  .nl .long { display: none; } .nl .short { display: inline; }
  .main { padding: 16px 14px 32px; }
  .view-inner { gap: 14px; }
  .view-inner.building { left: 14px; right: 14px; top: 16px; }
  h1 { font-size: 23px; }
  .lede { font-size: 14px; }
  .page-head { align-items: stretch; }
  .head-actions { width: 100%; }
  .head-actions .seg { flex: 1 1 100%; }
  .head-actions .seg button { flex: 1; }
  .head-actions > .btn { flex: 1; justify-content: center; }
  .card { padding: 15px 14px; border-radius: 14px; }
  .card-head { margin-bottom: 10px; }
  .chart { height: 200px; } .chart.lg { height: 240px; } .chart.sm { height: 160px; }
  /* Never let iPhone zoom into inputs */
  select, input, .input, textarea { font-size: 16px !important; }
  /* Overview money flow as a 2x2 grid */
  .flow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .flow-op { display: none; }
  .flow-val { font-size: 17px; }
  .alert, .callout { flex-direction: column; align-items: flex-start; }
  /* Tables become cards */
  .desktop-only, .hide-m { display: none !important; }
  .item-cards { display: flex; flex-direction: column; gap: 8px; }
  .item-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; }
  .item-card.inactive { opacity: .55; }
  .ic-top { display: flex; justify-content: space-between; gap: 10px; }
  .ic-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
  .tx-table { display: none; }
  .tx-row { padding: 10px 4px; }
  .filterbar { gap: 8px; }
  .filterbar input[type="search"] { flex: 1 1 100%; }
  .filterbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .seg-dir { flex: 1 1 100%; } .seg-dir button { flex: 1; }
  .tx-totals { font-size: 12.5px; gap: 6px 14px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
  .tabs button { white-space: nowrap; }
  .event-actions .btn.tiny { padding: 6px 11px; font-size: 12.5px; }
  .event-right { min-width: 96px; }
  .btn { min-height: 38px; }
  .icon-btn { width: 38px; height: 38px; }
  /* Forms slide up from the bottom, full width */
  .modal { padding: 0; align-items: end; }
  .modal-panel { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); transform: translateY(30px); }
  .form { padding: 16px 16px 18px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn-row { flex: 1; justify-content: flex-end; }
  .seg.wide { flex-wrap: wrap; } .seg.wide label { flex: 1 1 45%; }
  .drawer-panel, .drawer.wide .drawer-panel { width: 100vw; }
  .drawer-head { position: sticky; top: -12px; background: var(--surface); z-index: 2; margin: -12px -16px 6px; padding: 8px 10px; }
  .drawer-body { padding-top: calc(12px + env(safe-area-inset-top)); }
  .big-balance { font-size: 30px; }
  .month-nav { width: 100%; } .month-nav select { flex: 1; }
  .suggest-head .btn { width: 100%; justify-content: center; }
  .conn .btn-row { width: 100%; justify-content: flex-end; }
  .login-card { padding: 28px 20px 20px; }
}
@media (max-width: 380px) {
  .nav a { font-size: 10px; padding: 6px 2px; }
  .kpi-value { font-size: 19px; }
  .badge { display: none; }
}

.badge { white-space: nowrap; }
.kpi > *:not(.kpi-spark) { position: relative; z-index: 1; }
.kpi-spark { z-index: 0; opacity: .55; top: auto !important; bottom: 12px; }
@media (max-width: 760px) {
  .page-head h1:not(.greet) { display: none; }
  .page-head .lede { margin-top: 0; }
}

/* ============ Phones: bigger, easier-to-read text ============ */
@media (max-width: 760px) {
  body { font-size: 15.5px; line-height: 1.5; }
  .small, .sub, .card-head .sub, p.sub { font-size: 13.5px; }
  h2 { font-size: 17px; }
  .lede { font-size: 15px; }
  .kpi { padding: 14px 15px; }
  .kpi-label { font-size: 13.5px; }
  .kpi-value { font-size: 24px; }
  .kpi.hero .kpi-value { font-size: 32px; }
  .kpi-foot { font-size: 13px; }
  .chart .axis text { font-size: 12.5px; }
  .chart .ref-label { font-size: 12px; }
  .legend { font-size: 13px; }
  .tooltip { font-size: 14px; padding: 10px 13px; }
  .flow-label { font-size: 12.5px; } .flow-val { font-size: 19px; }
  .ps-label { font-size: 13px; } .ps-val { font-size: 23px; } .ps-sub { font-size: 12.5px; white-space: normal; }
  .event { grid-template-columns: 46px 1fr auto; padding: 12px 4px; }
  .event-name { font-size: 15.5px; }
  .event-sub, .event-match { font-size: 13px; }
  .event-amt { font-size: 16px; }
  .event-date b { font-size: 19px; } .event-date span { font-size: 11px; }
  .tl-head { font-size: 12.5px; padding: 14px 4px 6px; }
  .tx-name { font-size: 15.5px; }
  .tx-sub { font-size: 13px; }
  .tx-amt { font-size: 15.5px; }
  .m-logo { width: 38px !important; height: 38px !important; font-size: 18px; }
  .agm-head { font-size: 13.5px; }
  .agm-row { padding: 11px 4px; font-size: 15px; }
  .cat-mini-row { font-size: 15px; grid-template-columns: minmax(120px, 44%) 1fr auto; }
  .cat-row { font-size: 15px; padding-top: 13px; padding-bottom: 13px; }
  .cat-sub { font-size: 14px; }
  .merch { padding: 11px 4px; font-size: 15px; }
  .acct-card { padding: 15px; }
  .ac-bal { font-size: 26px; }
  .ac-facts { font-size: 14px; gap: 8px; }
  .ac-meta { font-size: 13.5px; }
  .item-card { padding: 14px; } .ic-top { font-size: 16px; } .ic-sub { font-size: 13.5px; }
  .suggest-main b { font-size: 15.5px; }
  .chip { font-size: 12px; padding: 3px 9px; }
  .pill { font-size: 13px; }
  .facts { font-size: 15px; }
  .mini-list { font-size: 14.5px; }
  .tx-hero-name, .acct-hero-name { font-size: 21px; }
  .cal-n { font-size: 13.5px; }
  .cal-in, .cal-out { font-size: 10px; font-weight: 700; }
  .cal-day { padding: 4px 3px; border-radius: 9px; }
  .dd-head { font-size: 14.5px; }
  .field { font-size: 14px; }
  .tabs button { font-size: 15px; padding: 8px 12px; }
  .seg button, .seg label span { font-size: 14px; padding: 8px 12px; }
  .btn { font-size: 14.5px; }
  .btn.small { font-size: 14px; padding: 8px 12px; }
  .alloc-row { font-size: 14.5px; grid-template-columns: 90px 1fr 46px; }
  .alloc-row .num.muted { display: none; }
  .table { font-size: 14.5px; }
}

/* ============ Home: hello, balance strip, quick actions, coming up ============ */
.hello { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.hello-date { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.hello .lede { margin-top: 4px; }
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 19px; color: #fff; background: linear-gradient(135deg, #6366f1, #2563eb); box-shadow: 0 4px 14px rgba(37,99,235,.3); }
.avatar:hover { filter: brightness(1.08); }
.hero-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi.safe { background: linear-gradient(145deg, #0f766e, #115e59); border-color: transparent; color: #fff; }
.kpi.safe .kpi-label, .kpi.safe .kpi-foot { color: rgba(255,255,255,.8); }
.strip-dots { display: none; }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none !important; box-shadow: var(--shadow); transition: transform .1s, background .12s; }
.qa:hover { background: var(--surface-2); }
.qa:active { transform: scale(.96); }
.qa-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 19px; background: var(--accent-soft); color: var(--accent); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 2px 2px 10px; }
.section-title h2 { font-size: 18px; }
.up-strip-wrap { display: none; }
.up-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.up-strip::-webkit-scrollbar, .hero-strip::-webkit-scrollbar { display: none; }
.up-card { flex: 0 0 158px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 13px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; box-shadow: var(--shadow); cursor: pointer; }
.up-card:active { transform: scale(.98); }
.up-card.in { border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.up-card.overdue { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.up-when { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.up-name { font-weight: 600; font-size: 14.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.up-amt { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Page enter animation + pull to refresh */
.view-inner.enter { animation: pageIn .28s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view-inner.enter { animation: none; } }
.ptr { position: fixed; left: 50%; top: calc(58px + env(safe-area-inset-top)); width: 38px; height: 38px; margin-top: -40px; border-radius: 50%; background: var(--surface); box-shadow: 0 4px 14px rgba(0,0,0,.18); display: grid; place-items: center; color: var(--muted); font-size: 20px; z-index: 14; opacity: 0; transform: translate(-50%, 0); transition: opacity .15s; pointer-events: none; }
.ptr.show { opacity: 1; }
.ptr.ready { color: var(--accent); }

/* ============ Phones: app experience ============ */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .hello h1.greet { font-size: 27px; line-height: 1.15; }
  .hello .lede { font-size: 14.5px; }
  .coming-card { display: none; }
  .up-strip-wrap { display: block; }
  /* Swipeable balance cards */
  .hero-strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin: 0 -14px; padding: 2px 14px 4px; scroll-padding: 0 14px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .hero-strip .kpi { flex: 0 0 84%; scroll-snap-align: start; min-height: 138px; padding: 18px 20px; border-radius: 20px; }
  .hero-strip .kpi .kpi-value { font-size: 34px; }
  .hero-strip .kpi:not(.hero):not(.safe) .kpi-value { font-size: 30px; }
  .hero-strip .kpi-label { font-size: 14px; }
  .hero-strip .kpi-foot { font-size: 13px; }
  .strip-dots { display: flex; justify-content: center; gap: 6px; margin-top: -4px; }
  .strip-dots i { width: 6px; height: 6px; border-radius: 99px; background: var(--muted-line); transition: width .2s, background .2s; }
  .strip-dots i.on { width: 18px; background: var(--accent); }
  .quick { gap: 8px; }
  .qa { padding: 10px 2px; font-size: 12px; border-radius: 14px; }
  .qa-ic { width: 42px; height: 42px; font-size: 20px; }
  /* Bigger, easier reading */
  h2 { font-size: 17.5px; }
  .card-head .sub, p.sub { font-size: 13px; }
  .kpi-value { font-size: 25px; }
  .kpi-label { font-size: 13.5px; }
  .tx-name, .event-name { font-size: 15.5px; }
  .tx-sub, .event-sub { font-size: 13px; }
  .tx-amt, .event-amt { font-size: 16px; }
  .m-logo { width: 40px !important; height: 40px !important; font-size: 18px; border-radius: 12px; }
  .tx-row { padding: 11px 4px; gap: 12px; }
  .event { padding: 12px 4px; }
  .event-date { padding: 6px 0; }
  .event-date b { font-size: 19px; }
  .ps-val { font-size: 23px; }
  .ps-label, .ps-sub { font-size: 12.5px; }
  .ac-bal { font-size: 25px; }
  .group-total { font-size: 21px; }
  .acct-card { padding: 15px; border-radius: 16px; }
  .hbar, .cat-mini-row { font-size: 14.5px; }
  .cat-row { font-size: 15px; padding-top: 12px; padding-bottom: 12px; }
  .merch { padding: 10px 4px; }
  .agm-row { padding: 10px 4px; font-size: 15px; }
  .chart .axis text { font-size: 12px; }
  .chart svg { touch-action: pan-y; }
  .note { font-size: 14px; }
  .chip { font-size: 12px; padding: 3px 9px; }
  .table td { padding: 12px 8px; font-size: 14.5px; }
  .facts { font-size: 15px; }
  .tooltip { font-size: 13.5px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); left: 14px; right: 14px; transform: none; text-align: center; }
  /* Card press feedback like a native app */
  .kpi:active, .acct-card:active, .tx-row:active, .event[data-edit-recurring]:active, .item-card:active, .merch:active { transform: scale(.985); transition: transform .08s; }
  .nav a.on { color: #fff; }
  .nav a.on .ni { background: rgba(75,147,236,.22); border-radius: 10px; width: 44px; height: 28px; }
}
@media (max-width: 760px) { .topbar .badge { display: none; } .tb-title { overflow: hidden; text-overflow: ellipsis; } }

/* ============ Never let long text widen the page (phones zoom out when that happens) ============ */
html, body { overflow-x: hidden; max-width: 100%; }
.content, .main { min-width: 0; max-width: 100vw; }
.main { overflow-x: clip; }
body { overflow-wrap: break-word; }
.alert > span, .callout > div, .conn-main, .conn-main *, .lede, .event-main, .event-name, .event-sub, .event-match,
.ic-top b, .ic-sub, .facts dd, .tx-hero-name, .acct-hero-name, .suggest-main, .note, .empty-state p, .card-head > div,
.up-name, .ps-sub, .kpi-foot, .ac-name, .mini-list span, .cat-sub span:first-child, .merch-name, .hello-text, .dd-head {
  overflow-wrap: anywhere; min-width: 0;
}
.alert > span { flex: 1 1 auto; }
.event-main, .ac-name, .conn-main, .suggest-main { overflow: hidden; }

.qa-ic svg { display: block; }
.qa:nth-child(1) .qa-ic { background: #e0edff; color: #1d5fb3; }
.qa:nth-child(2) .qa-ic { background: #e3f4e8; color: #15803d; }
.qa:nth-child(3) .qa-ic { background: #fdf2d8; color: #9a6400; }
.qa:nth-child(4) .qa-ic { background: #fde8f0; color: #b4235a; }
.qa:nth-child(5) .qa-ic { background: #ece9fd; color: #5b47d6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .qa:nth-child(1) .qa-ic { background: #1b2a40; color: #7cb3f5; }
  :root:not([data-theme="light"]) .qa:nth-child(2) .qa-ic { background: #16301f; color: #6fd39a; }
  :root:not([data-theme="light"]) .qa:nth-child(3) .qa-ic { background: #362a12; color: #f2c66d; }
  :root:not([data-theme="light"]) .qa:nth-child(4) .qa-ic { background: #3a1626; color: #f28bb3; }
  :root:not([data-theme="light"]) .qa:nth-child(5) .qa-ic { background: #241f45; color: #a99cf5; }
}
.qa .qa-ic { transition: transform .15s; }
.qa[data-quick-sync] .qa-ic svg { transition: transform .5s; }
body:has(#syncBtn.spinning) .qa[data-quick-sync] .qa-ic svg { animation: spin 1s linear infinite; }

.tb-titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.tb-sub { display: none; font-size: 11.5px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub.warn { color: var(--warn); }
@media (max-width: 760px) { .tb-sub { display: block; } }
