/* Plus Jakarta Sans (variable 200–800, latin) — bundled so it works offline. SIL OFL, see vendor/plus-jakarta-sans.LICENSE */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/plus-jakarta-sans.woff2") format("woff2-variations"), url("fonts/plus-jakarta-sans.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================================================
   Tokens — neutral base, green accent, amber highlight (matches the exp.t icon)
   ========================================================= */
:root {
  --bg: #F6F6F3;
  --surface: #FFFFFF;
  --sunken: #F1F1EE;
  --hover: #F3F3F0;
  --track: #ECECE8;
  --text: #18181B;
  --muted: #71716B;
  --border: #E6E6E1;
  --border-strong: #D5D5CF;
  --accent: #12805C;
  --accent-hover: #0E6E4F;
  --accent-soft: rgba(18, 128, 92, .10);
  --ring: rgba(18, 128, 92, .14);
  --on-accent: #FFFFFF;
  --amber: #E8930C;
  --danger: #C2332B;
  --danger-soft: rgba(194, 51, 43, .08);
  --warn: #B26B00;
  --scrim: rgba(17, 17, 15, .38);
  --shadow-sm: 0 1px 2px rgba(17, 17, 15, .05);
  --shadow: 0 1px 2px rgba(17, 17, 15, .04), 0 2px 8px rgba(17, 17, 15, .04);
  --shadow-pop: 0 8px 28px rgba(17, 17, 15, .14), 0 2px 6px rgba(17, 17, 15, .06);

  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px;
  --r: 10px;       /* controls */
  --r-lg: 14px;    /* cards, sheets */
  --tap: 44px;
  --topbar-h: 60px;
  --sidebar-w: 240px;
  --rail-w: 68px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371716B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --kb: 0px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E0E0D; --surface: #171716; --sunken: #121211; --hover: #1F1F1D; --track: #262624;
  --text: #EDEDEA; --muted: #9A9A93; --border: #262624; --border-strong: #34342F;
  --accent: #34D399; --accent-hover: #4ADEA8; --accent-soft: rgba(52, 211, 153, .12); --ring: rgba(52, 211, 153, .28); --on-accent: #06281B;
  --amber: #F5A524; --danger: #F2766C; --danger-soft: rgba(242, 118, 108, .10); --warn: #E9B44C;
  --scrim: rgba(0, 0, 0, .55); --shadow-sm: none; --shadow: none; --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9A93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E0E0D; --surface: #171716; --sunken: #121211; --hover: #1F1F1D; --track: #262624;
    --text: #EDEDEA; --muted: #9A9A93; --border: #262624; --border-strong: #34342F;
    --accent: #34D399; --accent-hover: #4ADEA8; --accent-soft: rgba(52, 211, 153, .12); --ring: rgba(52, 211, 153, .28); --on-accent: #06281B;
    --amber: #F5A524; --danger: #F2766C; --danger-soft: rgba(242, 118, 108, .10); --warn: #E9B44C;
    --scrim: rgba(0, 0, 0, .55); --shadow-sm: none; --shadow: none; --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
    --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9A93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

/* =========================================================
   Base
   ========================================================= */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: max(16px, 1em); }   /* iOS zooms into anything smaller */
input, select, textarea, button { -webkit-appearance: none; appearance: none; border-radius: 0; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[data-icon] { display: inline-grid; place-items: center; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
::selection { background: var(--accent-soft); }
.i.inline { width: 14px; height: 14px; vertical-align: -2px; }

.sidebar, .topbar, .tabbar, .sheet-head, .btn, .icon-btn, .tab, .text-btn, .cat-opt, .switch, .segmented, .item-main, .kpis {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* Sign-in paints first when there's no session on this device */
html.auth-first .shell, html.auth-first .tabbar { visibility: hidden; }
html.auth-first #auth { display: flex !important; }

/* =========================================================
   Controls
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn svg { width: 18px; height: 18px; stroke-width: 2.2; }
.btn:active { transform: scale(.98); background: var(--hover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.12); }
.btn.primary:active { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { min-height: 50px; font-size: 16px; width: 100%; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; flex: none; border-radius: var(--r); color: var(--text); transition: background .15s; }
.icon-btn:active { background: var(--hover); }
.text-btn { color: var(--accent); font-weight: 600; font-size: 14px; padding: var(--s2) var(--s1); min-height: 34px; border-radius: 8px; }
.text-btn:active { opacity: .65; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row2 > .field, .cat-head > .field { flex: 1 1 0; }
.field > label, .field > .label, .picker-label { font-size: 13px; font-weight: 600; color: var(--text); }
.field input, .share-row input, .input-ic {
  height: 48px; width: 100%; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); outline: 0; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder, .share-row input::placeholder, .search input::placeholder { color: var(--muted); opacity: .8; }
.field input:focus, .share-row input:focus, .input-ic:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.field input[aria-invalid="true"], .input-ic:has(input[aria-invalid="true"]) { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.field input[type="date"] { display: block; line-height: 46px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }
.input-ic { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; color: var(--muted); }
.input-ic > [data-icon] svg { width: 18px; height: 18px; }
.input-ic input { flex: 1; min-width: 0; height: 100%; border: 0 !important; box-shadow: none !important; padding: 0; background: none; color: var(--text); }
.reveal { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.reveal:active { background: var(--hover); }

/* Dropdowns: custom chevron, same height and radius as inputs */
select {
  height: 40px; padding: 0 36px 0 12px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface) var(--chev) no-repeat right 10px center / 16px; color: var(--text);
  font-weight: 500; cursor: pointer; box-shadow: var(--shadow-sm); outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }

/* Switch */
.switch {
  flex: 0 0 44px; width: 44px; height: 26px; border-radius: 13px; margin: 0; cursor: pointer;
  background: var(--border-strong); position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r); }
.segmented button { min-height: 32px; padding: 0 14px; font-size: 13.5px; font-weight: 500; color: var(--muted); border-radius: 7px; transition: background .15s, color .15s, box-shadow .15s; }
.segmented button.is-on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 0 0 1px var(--border); }

/* Cards */
.card, .panel, .figures {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}

/* =========================================================
   App shell
   ========================================================= */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-left: var(--safe-l); padding-right: var(--safe-r); }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--s3) var(--s3) var(--s5); }
.sidebar { display: none; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s2);
  min-height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) var(--s2) 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.02em; padding: 0 var(--s2); white-space: nowrap; display: none; }
.topbar.is-settings .page-title { display: block; }
.topbar.is-settings .month-nav, .topbar.is-settings .search-toggle { display: none; }
.month-nav { display: flex; align-items: center; }
.month-label { min-height: var(--tap); padding: 0 var(--s2); border-radius: var(--r); font-size: 18px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.month-label #yearText { color: var(--muted); font-weight: 500; }
.month-label:active { background: var(--hover); }
.month-label.not-current #monthText { color: var(--accent); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.search {
  display: none; align-items: center; gap: var(--s2); height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); color: var(--muted);
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.search svg { width: 17px; height: 17px; }
.search input { border: 0; outline: 0; background: none; width: 100%; min-width: 0; color: var(--text); height: 100%; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.search-cancel, .add-btn { display: none; }
@media (max-width: 767.98px) {
  .topbar.searching .month-nav, .topbar.searching .search-toggle, .topbar.searching .page-title { display: none; }
  .topbar.searching .topbar-end { flex: 1; margin-left: 0; padding-left: var(--s2); }
  .topbar.searching .search { display: flex; flex: 1; }
  .topbar.searching .search-cancel { display: inline-flex; align-items: center; }
  .has-query .figures, .has-query .home-side { display: none; }
}
@media (pointer: coarse) { .btn.sm, .text-btn { min-height: var(--tap); } .icon-btn { width: var(--tap); height: var(--tap); } }

/* User menu */
.user-menu { position: relative; display: none; }
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px; border: 1px solid transparent;
}
.avatar-btn[aria-expanded="true"] { border-color: var(--accent); }
.menu {
  position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 30; min-width: 250px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-head { display: flex; flex-direction: column; padding: 10px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-head span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head small { color: var(--muted); font-size: 13px; }
.menu button { display: block; width: 100%; min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.menu button:focus-visible { outline-offset: -2px; }
.menu button.danger { color: var(--danger); }

/* Bottom tab bar (phones) */
.tabbar {
  position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: var(--s1);
  padding: 6px var(--s2) calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 600; border-radius: var(--r); transition: color .15s, background .15s;
}
.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--accent); }
.tab:active { background: var(--hover); }
.tab-add { flex: 0 0 auto; width: 52px; min-height: 44px; margin: 0 var(--s1); background: var(--accent); color: var(--on-accent); border-radius: 14px; }
.tab-add svg { width: 24px; height: 24px; stroke-width: 2.4; }
.tab-add span:last-child { display: none; }
.tab-add:active { background: var(--accent-hover); }
.kb-open .tabbar { display: none; }

/* =========================================================
   Views
   ========================================================= */
.view { display: none; }
.view.is-active { display: block; }
.slide.in-next, .slide.in-prev { animation: fadeIn .18s var(--ease); }
@keyframes fadeIn { from { opacity: .3; } }

.panel { min-width: 0; padding: var(--s3); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 32px; margin-bottom: 12px; }
.panel-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.panel-meta { font-size: 13px; color: var(--muted); }

/* Figures */
.figures { display: flex; flex-wrap: wrap; margin-bottom: var(--s3); overflow: hidden; }
.fig { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; padding: 14px var(--s3); min-width: 0; border-top: 1px solid var(--border); }
.fig:not(.fig-main):not([hidden]) ~ .fig { border-left: 1px solid var(--border); }
.fig-main { flex: 1 0 100%; border-top: 0; padding: 20px var(--s3); }
.fig-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.fig-value { font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig-main .fig-value { font-size: 36px; letter-spacing: -.015em; line-height: 1.15; margin: 2px 0; }
.fig-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig-link { align-self: flex-start; padding-left: 0; }
.budget { display: flex; flex-direction: column; gap: 2px; }
.meter { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .4s var(--ease); }
.budget.warn .meter i { background: var(--amber); }
.budget.warn .fig-value { color: var(--warn); }
.budget.over .meter i { background: var(--danger); }
.budget.over .fig-value { color: var(--danger); }
@media (max-width: 767.98px) {
  .fig:not(.fig-main) {
    flex: 1 0 100%; border-left: 0 !important;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); align-items: baseline;
  }
  .fig:not(.fig-main) .fig-value { grid-column: 2; grid-row: 1; font-size: 16px; }
  .fig:not(.fig-main) .fig-sub, .fig:not(.fig-main) .meter { grid-column: 1 / -1; }
  .fig:not(.fig-main) .budget { display: contents; }
  .fig-link { grid-column: 2; grid-row: 1; padding: 0; min-height: 0; }
}

.splash { display: none; }
@media (min-width: 768px) { .fig-row { display: contents; } }

/* Home layout */
.home-grid { display: flex; flex-direction: column; gap: var(--s3); }
.home-side { display: flex; flex-direction: column; gap: var(--s3); order: -1; }

/* Categories */
.cat-row {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; column-gap: 12px;
  width: 100%; min-height: 50px; padding: 8px 10px; border-radius: var(--r); transition: background .15s;
}
.cat-row + .cat-row { margin-top: 2px; }
.cat-row:active { background: var(--hover); }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cat-pct { color: var(--muted); font-size: 13px; min-width: 36px; text-align: right; }
.cat-amt { font-weight: 700; text-align: right; }
.cat-bar { grid-column: 2 / -1; height: 4px; background: var(--track); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.cat-bar i { display: block; height: 100%; background: var(--c); border-radius: 2px; }
.cat-row.is-on { background: var(--accent-soft); }
.cats.filtering .cat-row:not(.is-on) { opacity: .55; }
.cats-more { margin-top: var(--s1); }
@media (min-width: 768px) and (max-width: 1099.98px) { .cats:not(.expanded) .cat-row.extra { display: none; } }

/* To collect */
.person { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 2px; }
.person + .person { border-top: 1px solid var(--border); }
.person .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person .grow b { font-weight: 600; }
.person .grow small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-amt { font-weight: 700; white-space: nowrap; }
.person.done .person-amt { color: var(--muted); text-decoration: line-through; }
.settle-btn { min-width: 112px; }
.settle-btn.is-done { color: var(--accent); background: var(--accent-soft); border-color: transparent; box-shadow: none; }

/* Transactions: grouped list (phones) */
.day + .day { margin-top: 12px; }
.day-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 10px 4px; text-transform: uppercase; letter-spacing: .03em; }
.items { list-style: none; margin: 0; padding: 0; }
.item { position: relative; overflow: hidden; border-radius: var(--r); transition: height .2s var(--ease), opacity .2s; }
.item + .item { margin-top: 1px; }
.item-under {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: var(--s3);
  background: var(--danger); color: #fff; font-weight: 600; font-size: 14px; opacity: .65;
}
.item:not(.swiping):not(.armed):not(.collapsing) .item-under { visibility: hidden; }
.item.armed .item-under { opacity: 1; }
.item-main {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 10px;
  background: var(--surface); touch-action: pan-y; cursor: pointer; transition: transform .25s var(--ease), background .15s;
}
.item-main:active { background: var(--hover); }
.item-main:focus-visible { outline-offset: -2px; }
.item.swiping .item-main { background: var(--surface); }
.item.collapsing { opacity: 0; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-text b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-amt { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; white-space: nowrap; }
.back { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.item.flash .item-main, .trow.flash td { animation: flash 1.4s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } }

/* Transactions: table (tablet/desktop) */
.tx-panel { padding-bottom: var(--s2); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  position: sticky; top: var(--topbar-h); z-index: 5; background: var(--surface);
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); padding: 0;
}
.table th button { display: flex; align-items: center; gap: var(--s1); width: 100%; min-height: 38px; padding: 0 10px; color: inherit; font-weight: inherit; letter-spacing: inherit; border-radius: 6px; }
.table th.num button { justify-content: flex-end; }
.table th[aria-sort] button { color: var(--text); }
.sort-ind { font-size: 11px; width: 10px; }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background .12s; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.trow { cursor: pointer; }
.trow:focus-visible { outline-offset: -2px; }
.c-date { white-space: nowrap; color: var(--muted); width: 1%; }
.c-desc { max-width: 0; width: 50%; font-weight: 500; }
.c-desc span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-desc small { color: var(--muted); font-weight: 400; }
.c-cat { white-space: nowrap; }
.c-cat .dot { margin-right: var(--s2); vertical-align: 0; }
.c-amt { font-weight: 700; }
.c-back { color: var(--accent); font-weight: 600; }
.c-back.none { color: var(--muted); font-weight: 400; }

.empty { padding: var(--s5) var(--s3); text-align: center; color: var(--muted); }
.empty p + .btn { margin-top: var(--s3); }
.muted-row { color: var(--muted); font-size: 14px; padding: var(--s2) 10px; }

/* =========================================================
   Sheets: bottom sheet on phones, side panel from 768px
   ========================================================= */
.backdrop { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); overscroll-behavior: none; }
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: var(--kb);
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--safe-t) - var(--s3));
  max-height: calc(var(--vvh, 100dvh) - var(--safe-t) - var(--s3));
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-pop);
  padding-left: var(--safe-l); padding-right: var(--safe-r);
  transform: translateY(100%); visibility: hidden; overscroll-behavior: none;
  transition: transform .28s var(--ease), visibility 0s .28s;
}
.sheet.show { transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s; }
.sheet.dragging { transition: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: var(--s2) auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s1) var(--s2) var(--s2) 20px; touch-action: none; flex: none; }
.sheet-head h3 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; outline: none; }
.sheet-body {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 20px; padding: var(--s2) 20px 0;
}
.sheet-body > * { flex-shrink: 0; }
.sheet-actions {
  position: sticky; bottom: 0; z-index: 1; margin: auto -20px 0; display: flex; gap: var(--s2); justify-content: flex-end;
  padding: 12px 20px calc(12px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--border);
}
.kb-open .sheet-actions { padding-bottom: 12px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .btn.danger { margin-right: auto; }

.amount-input {
  display: flex; align-items: center; gap: var(--s2); height: 64px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--sunken);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.amount-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); background: var(--surface); }
#amountField.has-error .amount-input { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.amount-input span { color: var(--muted); font-size: 20px; font-weight: 600; }
.field .amount-input input, .field .amount-input input:focus { border: 0; box-shadow: none; border-radius: 0; }
.amount-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; padding: 0; font-size: 30px; font-weight: 700; letter-spacing: -.02em; box-shadow: none; }

.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.cat-opt {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r); font-size: 14px; font-weight: 500; min-width: 0; background: var(--surface);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.cat-opt .e { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); flex: none; }
.cat-opt .e svg { width: 16px; height: 16px; stroke-width: 2; }
.cat-opt span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-opt:active { background: var(--hover); }
.cat-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }

.row2 { display: flex; gap: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); cursor: pointer; min-height: var(--tap); padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); }
.switch-row b { display: block; font-weight: 600; }
.switch-row small { color: var(--muted); font-size: 13px; }

.split-box { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 14px; background: var(--sunken); }
.split-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; cursor: pointer; font-weight: 600; }
.split-box.off .split-rows { opacity: .45; }
.split-row { display: flex; align-items: center; gap: var(--s2); padding: 4px 0; font-size: 14px; }
.split-row .grow { flex: 1; }
.split-row small { color: var(--muted); }
.split-row.total { border-top: 1px solid var(--border); margin-top: var(--s1); padding-top: var(--s2); font-weight: 700; }

.cat-head { display: flex; align-items: flex-end; gap: 12px; }
.picker-label { margin-bottom: -12px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2); }
.swatch { height: 36px; border-radius: var(--r); background: var(--c); transition: box-shadow .15s; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s1); max-height: 220px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.icon-opt { height: var(--tap); display: grid; place-items: center; border-radius: var(--r); border: 1px solid transparent; color: var(--muted); }
.icon-opt[aria-checked="true"] { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.cat-ic { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: var(--r); color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 12%, transparent); }
.cat-ic svg { width: 18px; height: 18px; stroke-width: 2; }
.cat-ic.big { width: 48px; height: 48px; flex-basis: 48px; }
.shares { display: flex; flex-direction: column; gap: var(--s2); margin-top: -12px; }
.share-row { display: flex; gap: var(--s2); align-items: center; }
.sh-name { flex: 1; min-width: 0; }
.sh-pct { position: relative; flex: 0 0 92px; }
.sh-pct input { padding-right: 30px; text-align: right; }
.sh-pct span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.sh-del { flex: 0 0 var(--tap); height: var(--tap); display: grid; place-items: center; color: var(--muted); border-radius: var(--r); }
.add-share { display: inline-flex; align-items: center; gap: var(--s2); align-self: flex-start; min-height: var(--tap); color: var(--accent); font-weight: 600; font-size: 14px; margin-top: -12px; }
.add-share svg { width: 18px; height: 18px; }
.share-note { font-size: 13px; color: var(--muted); margin-top: -12px; }
.share-note.error { color: var(--danger); }

/* Toast */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(80px + var(--safe-b) + var(--kb));
  display: flex; align-items: center; gap: var(--s3); max-width: calc(100% - var(--s5));
  padding: 8px 8px 8px 16px; min-height: 48px; border-radius: 12px;
  background: #18181B; color: #FAFAF9; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-pop);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: transform .2s var(--ease), opacity .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast button { color: #6EE7B7; font-weight: 700; min-height: 36px; padding: 0 10px; flex: none; border-radius: 8px; }

/* =========================================================
   Stats
   ========================================================= */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: var(--s3); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kpi small { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--danger) !important; } .down { color: var(--accent) !important; }
.stats-grid { display: grid; gap: var(--s3); }
.card { padding: var(--s3); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.card-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.card-head span { font-size: 13px; color: var(--muted); }
.chart-empty { color: var(--muted); padding: var(--s4) 0; text-align: center; }

.donut-wrap { display: flex; align-items: center; gap: var(--s4); }
.donut { position: relative; flex: 0 0 150px; height: 150px; }
.donut svg { width: 150px; height: 150px; transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center small { color: var(--muted); font-size: 12px; font-weight: 500; }
.donut-center b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 40px; align-items: center; gap: 10px; font-size: 14px; }
.legend-row i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.legend-row em { font-style: normal; font-weight: 600; }
.legend-row b { font-weight: 500; color: var(--muted); text-align: right; font-size: 13px; }
.legend-more { font-size: 13px; color: var(--muted); padding-left: 20px; }
@media (max-width: 479.98px) {
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut { align-self: center; }
}

.chart { --h: 180px; padding-left: 44px; }
.plot { position: relative; height: var(--h); display: flex; align-items: flex-end; gap: 10px; }
.gl { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); pointer-events: none; }
.gl:last-of-type { border-top-style: solid; border-color: var(--border-strong); }
.gl em { position: absolute; right: 100%; transform: translateY(-50%); padding-right: 8px; font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.avg { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--amber); z-index: 2; pointer-events: none; }
.avg em { position: absolute; right: 0; top: -20px; padding: 0 4px; font-style: normal; font-size: 11px; background: var(--surface); color: var(--warn); font-weight: 600; border-radius: 4px; white-space: nowrap; }
.col { position: relative; z-index: 1; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px 6px 0 0; min-width: 0; }
.col i { display: block; width: 100%; max-width: 40px; min-height: 3px; border-radius: 6px 6px 2px 2px; background: color-mix(in srgb, var(--accent) 30%, var(--track)); transition: background .15s; }
.col.current i { background: var(--accent); }
.col.later i { background: var(--track); }
button.col:focus-visible { outline-offset: 2px; }
.xlabels { display: flex; gap: 10px; margin-top: 8px; }
.xlabels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 0; }
.chart.days .plot, .chart.days .xlabels { gap: 3px; }
.chart.days .col i { border-radius: 3px 3px 1px 1px; }
.chart.days .xlabels span { overflow: visible; }

/* =========================================================
   Settings
   ========================================================= */
#view-settings { max-width: 760px; margin: 0 auto; }
.group { margin-bottom: 28px; }
.group-head { display: grid; grid-template-columns: 1fr auto; align-items: end; column-gap: var(--s2); margin-bottom: 12px; }
.group-head .group-desc { grid-column: 1; grid-row: 2; }
.group-head .text-btn { grid-column: 2; grid-row: 1 / span 2; }
.group-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin: 0 2px 2px; }
.group-desc { font-size: 13.5px; color: var(--muted); margin: 0 2px 12px; }
.group-head .group-desc { margin-bottom: 0; }
.card.list { padding: 4px 0; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px var(--s3); min-height: 56px; width: 100%; text-align: left; position: relative; transition: background .15s; }
.row + .row, #nPrefs .row:first-child { border-top: 1px solid var(--border); }
.row.action:active, .row.tap:active { background: var(--hover); }
.row small { color: var(--muted); }
.row.danger { color: var(--danger); font-weight: 600; }
.row input:not(.switch) {
  height: 40px; max-width: 150px; padding: 0 12px; text-align: right; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); outline: 0; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.row input:not(.switch):focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.row select { min-width: 104px; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 500; }
.row .grow small { font-size: 13px; font-weight: 400; white-space: normal; }
#acEmail, .row .grow > span:not(:only-child) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > .grow { overflow: hidden; }
.row .grow + small { flex: 0 0 auto; }
.row .chev { width: 18px; height: 18px; color: var(--muted); }
.row-ic { width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--r); display: grid; place-items: center; color: var(--text); background: var(--sunken); border: 1px solid var(--border); }
.row-ic svg { width: 18px; height: 18px; }
.row.danger .row-ic { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.row .grow small svg { width: 12px; height: 12px; }
.mini-btn { font-size: 13.5px; font-weight: 600; color: var(--text); border: 1px solid var(--border-strong); background: var(--surface); min-height: 34px; padding: 0 12px; border-radius: 8px; box-shadow: var(--shadow-sm); }
.mini-btn.danger { color: var(--danger); }
.footnote { color: var(--muted); font-size: 13px; margin: 10px 4px 0; }
#nHour { min-width: 0; }
#nPrefs .row { padding-left: var(--s3); }
.row.busy { opacity: .6; pointer-events: none; }
.sync-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--muted); }
.sync-dot.ok { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sync-dot.syncing { background: var(--amber); animation: blink 1s ease-in-out infinite; }
.sync-dot.offline, .sync-dot.pending { background: var(--amber); }
.sync-dot.error { background: var(--danger); }
@keyframes blink { 50% { opacity: .35; } }

/* =========================================================
   Sign in
   ========================================================= */
.auth { position: fixed; inset: 0; z-index: 70; display: flex; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.auth.leaving { animation: fadeOut .2s var(--ease) forwards; }
@keyframes fadeOut { to { opacity: 0; } }
.auth-brand { display: none; }
.auth-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: calc(10vh + var(--safe-t)) 20px calc(var(--s4) + var(--safe-b) + var(--kb)); }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin-bottom: var(--s4); }
.auth h1 { font-size: 28px; font-weight: 750; letter-spacing: -.03em; margin-bottom: 6px; }
.auth-sub { color: var(--muted); margin-bottom: var(--s4); }
.auth form { display: flex; flex-direction: column; gap: var(--s3); }
.auth form .btn { margin-top: var(--s1); }
.auth-alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: var(--s3); border-radius: var(--r);
  font-size: 14px; color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}
.auth-alert svg { width: 18px; height: 18px; margin-top: 1px; }
.auth-alert.info { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.auth-alert:not([hidden]) { animation: pop .18s var(--ease); }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-switch { color: var(--muted); font-size: 14px; margin-top: var(--s4); text-align: center; }
@media (min-width: 900px) {
  .auth-brand {
    display: flex; flex-direction: column; flex: 0 0 44%; max-width: 560px;
    padding: 48px; background: #121211; color: #F3F3EF;
  }
  .auth-brand img { width: 80px; height: 80px; border-radius: 20px; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
  .auth-tag { font-size: 40px; font-weight: 750; letter-spacing: -.035em; line-height: 1.1; margin-top: auto; }
  .auth-tag-sub { margin-top: var(--s3); color: #A3A39C; max-width: 380px; font-size: 16px; }
  .auth-main { align-items: center; padding-top: var(--s5); }
  .auth-logo { display: none; }
}

/* =========================================================
   Tablet ≥ 768px
   ========================================================= */
@media (min-width: 768px) {
  .shell { flex-direction: row; }
  .tabbar { display: none; }
  .sidebar {
    position: sticky; top: 0; z-index: 25; align-self: flex-start; display: flex; flex-direction: column; flex: none;
    width: var(--rail-w); height: 100vh; height: 100dvh; padding: var(--safe-t) 0 calc(var(--s3) + var(--safe-b));
    background: var(--surface); border-right: 1px solid var(--border); transition: width .2s var(--ease);
  }
  .sb-head { display: flex; align-items: center; justify-content: center; min-height: var(--topbar-h); padding: 0 12px; }
  .brand { display: none; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.03em; white-space: nowrap; }
  .brand img { width: 36px; height: 36px; border-radius: 10px; }
  .sb-nav { display: flex; flex-direction: column; gap: 4px; padding: var(--s2) 12px; }
  .nav-item {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 42px; padding: 0 11px;
    font-size: 14.5px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden;
  }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .lbl { display: none; }
  .sb-foot { margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 var(--s3); font-size: 13px; color: var(--muted); min-height: 36px; }
  .shell.sb-open .sidebar { width: var(--sidebar-w); }
  .shell.sb-open .brand { display: flex; }
  .shell.sb-open .lbl { display: block; }
  .shell.sb-open .sb-head { justify-content: space-between; padding-left: 18px; }
  .shell.sb-open .sb-foot { justify-content: flex-start; padding-left: 22px; }

  .topbar { padding: var(--safe-t) var(--s4) 0; gap: var(--s2); }
  .page-title { display: block; padding: 0; }
  .month-nav { margin-left: var(--s1); }
  .topbar-end { flex: 1; min-width: 0; justify-content: flex-end; }
  .search-toggle, .search-cancel { display: none !important; }
  .search { display: flex; flex: 0 1 280px; min-width: 120px; }
  .add-btn { display: inline-flex; min-height: 40px; width: 40px; padding: 0; flex: none; }
  .add-btn .lbl-add { display: none; }
  .user-menu { display: block; }
  .user-menu[hidden] { display: none; }

  .content { padding: var(--s4); }
  .fig-value { font-size: 20px; line-height: 1.4; }
  .panel { padding: 20px; }
  .home-grid, .home-side { gap: 20px; }
  .home-side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .home-side > .panel:only-child { grid-column: 1 / -1; }

  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-card.wide { grid-column: 1 / -1; }
  .card { padding: 20px; }

  @media (hover: hover) {
    .icon-btn:hover, .month-label:hover, .menu button:hover, .cat-row:hover, .trow:hover td, .table th button:hover, .item-main:hover, .row.action:hover, .row.tap:hover, .reveal:hover { background: var(--hover); }
    .nav-item:not(.is-active):hover { background: var(--hover); color: var(--text); }
    .btn:hover { background: var(--hover); border-color: var(--border-strong); }
    .btn.primary:hover { background: var(--accent-hover); }
    .text-btn:hover { background: var(--accent-soft); }
    .segmented button:not(.is-on):hover { color: var(--text); }
    .col:hover i { background: var(--accent); }
    .cat-opt:hover { border-color: var(--border-strong); }
    select:hover, .search:hover { border-color: var(--muted); }
  }

  .sheet {
    left: auto; top: 0; bottom: 0; width: 460px; max-width: 100%; max-height: none; height: 100vh; height: 100dvh;
    border-radius: 0; border-left: 1px solid var(--border);
    padding-top: var(--safe-t); padding-right: var(--safe-r); padding-left: 0; transform: translateX(100%);
  }
  .grabber { display: none; }
  .sheet-head { min-height: var(--topbar-h); padding: 0 var(--s2) 0 var(--s4); border-bottom: 1px solid var(--border); }
  .sheet-body { padding: var(--s4) var(--s4) 0; }
  .sheet-actions { margin: auto calc(-1 * var(--s4)) 0; padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-b)); }
  .sheet-actions .btn { flex: none; min-width: 100px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: calc(var(--s4) + var(--safe-b)); }
}

/* =========================================================
   Desktop ≥ 1100px
   ========================================================= */
@media (min-width: 1100px) {
  .shell:not(.sb-closed) .sidebar { width: var(--sidebar-w); }
  .shell:not(.sb-closed) .brand { display: flex; }
  .shell:not(.sb-closed) .lbl { display: block; }
  .shell:not(.sb-closed) .sb-head { justify-content: space-between; padding-left: 18px; }
  .shell:not(.sb-closed) .sb-foot { justify-content: flex-start; padding-left: 22px; }
  .content { padding: var(--s4) var(--s5); }
  .add-btn { width: auto; padding: 0 var(--s3); }
  .add-btn .lbl-add { display: inline; }
  .figures { flex-wrap: nowrap; }
  .fig, .fig-main { flex: 1 1 0; border-top: 0; padding: 18px 20px; }
  .fig:not(.fig-main) { border-left: 1px solid var(--border); }
  .fig-main .fig-value { font-size: 30px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s4); align-items: start; }
  .home-side { order: 0; display: flex; align-items: stretch; position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
  .cats-more { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* A settings card whose rows are all hidden (e.g. notifications blocked) disappears */
.card.list:not(:has(> :not([hidden]))) { display: none; }


/* =========================================================
   PHONES (< 768px) — app-style layout. Desktop/tablet rules above are untouched.
   ========================================================= */
@media (max-width: 767.98px) {
  :root { --hero: #121211; --hero-2: #1C1C1A; --hero-text: #F5F5F2; --hero-muted: #A3A39C; }
  body { background: var(--bg); }

  /* Splash */
  .splash {
    position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--hero);
    transition: opacity .35s var(--ease), visibility 0s .35s;
  }
  .splash img { width: 96px; height: 96px; border-radius: 24px; animation: splashIn .5s var(--ease) both; }
  .splash.hide { opacity: 0; visibility: hidden; }
  @keyframes splashIn { from { opacity: 0; transform: scale(.92); } }

  /* Dark app header (continues into the hero) */
  .topbar {
    background: var(--hero); color: var(--hero-text); border-bottom: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none; padding-left: var(--s2); padding-right: var(--s2);
  }
  .topbar .icon-btn { color: var(--hero-text); }
  .topbar .icon-btn:active, .month-label:active { background: rgba(255,255,255,.08); }
  .month-label { font-size: 19px; }
  .month-label #yearText { color: var(--hero-muted); }
  .month-label.not-current #monthText { color: #6EE7B7; }
  .page-title { color: var(--hero-text); font-size: 22px; }
  .topbar .search { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: var(--hero-muted); box-shadow: none; }
  .topbar .search input { color: var(--hero-text); }
  .topbar .search:focus-within { border-color: #34D399; box-shadow: none; }
  .search-cancel { color: #6EE7B7; }

  .content { padding: 0 0 var(--s4); }
  .view > .slide, #view-settings, #statsSlide { padding: 0 var(--s3); }
  #view-home > .slide { padding: 0; }

  /* Hero: total + budget on the dark background */
  .figures { display: block; background: none; border: 0; box-shadow: none; border-radius: 0; overflow: visible; margin: 0 0 var(--s3); }
  .fig-main {
    background: var(--hero); color: var(--hero-text); border-radius: 0 0 28px 28px;
    padding: 6px 24px 64px; border: 0;
  }
  .fig-main .fig-label { color: var(--hero-muted); font-size: 14px; }
  .fig-main .fig-value { font-size: 40px; font-weight: 800; letter-spacing: -.015em; margin: 4px 0 2px; }
  .fig-main .fig-sub { color: var(--hero-muted); }

  /* Stat cards: horizontal scroller overlapping the hero */
  .fig-row {
    display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-top: -44px; padding: 0 var(--s3) 4px; scroll-padding-left: var(--s3);
  }
  .fig-row::-webkit-scrollbar { display: none; }
  .fig-row .fig {
    flex: 0 0 auto; min-width: 168px; max-width: 78%; display: flex !important; flex-direction: column; gap: 2px;
    padding: 14px 16px; border: 1px solid var(--border) !important; border-radius: 18px; background: var(--surface);
    box-shadow: 0 6px 20px rgba(17,17,15,.08); scroll-snap-align: start;
  }
  .fig-row .fig[hidden] { display: none !important; } /* the rule above would otherwise show empty cards */
  .fig-row .fig .fig-value { font-size: 20px; font-weight: 750; }
  .fig-row .budget { display: flex; }
  .fig-row .fig-link { padding: 0; min-height: 0; margin-top: 4px; }
  #shareFig .fig-label::before, #collectFig .fig-label::before, #budgetFig .fig-label::before {
    content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px;
  }
  #shareFig .fig-label::before { background: var(--accent); }
  #collectFig .fig-label::before { background: #F5A524; }
  #budgetFig .fig-label::before { background: #60A5FA; }

  /* Sections */
  .home-grid { gap: var(--s4); padding: 0 var(--s3); }
  .home-side { display: contents; }
  .home-side > .panel:first-child { order: 1; }
  .tx-panel { order: 2; }
  #collectBox { order: 3; }
  .panel-head h2 { font-size: 18px; font-weight: 750; letter-spacing: -.02em; }

  /* Categories: horizontal chips */
  .home-side > .panel:first-child { background: none; border: 0; box-shadow: none; padding: 0; }
  .cats {
    display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
    margin: 0 calc(-1 * var(--s3)); padding: 2px var(--s3) 6px; scroll-padding-left: var(--s3);
  }
  .cats::-webkit-scrollbar { display: none; }
  .cat-row {
    flex: 0 0 auto; width: 148px; min-height: 0; padding: 14px; border-radius: 18px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    grid-template-columns: auto 1fr; grid-template-areas: "dot name" "amt amt" "bar bar" "pct pct";
    row-gap: 4px; column-gap: 8px; scroll-snap-align: start; text-align: left;
  }
  .cat-row + .cat-row { margin-top: 0; }
  .cat-row .dot { grid-area: dot; }
  .cat-name { grid-area: name; font-size: 13.5px; color: var(--muted); }
  .cat-amt { grid-area: amt; text-align: left; font-size: 17px; font-weight: 750; margin-top: 4px; }
  .cat-bar { grid-area: bar; grid-column: 1 / -1; margin-top: 6px; }
  .cat-pct { grid-area: pct; text-align: left; min-width: 0; font-size: 12px; }
  .cat-row.is-on { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .cat-row.extra { display: grid !important; }
  .cats-more { display: none; }
  .cats .muted-row { padding: 0; }

  /* To collect */
  .home-side > .panel { border-radius: 20px; }
  .person { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 6px; padding: 12px 0; align-items: center; }
  .person .grow { grid-column: 1; grid-row: 1 / span 2; }
  .person-amt { grid-column: 2; grid-row: 1; font-size: 16px; text-align: right; }
  .settle-btn { grid-column: 2; grid-row: 2; min-width: 0; min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

  /* Transactions */
  .tx-panel { border-radius: 20px; padding: var(--s3) 12px var(--s2); }
  .tx-panel .panel-head { padding: 0 4px; }
  .day-head { padding: 0 8px 6px; font-size: 12px; }
  .day + .day { margin-top: var(--s3); }
  .item-main { min-height: 64px; padding: 10px 8px; gap: 12px; }
  .item + .item .item-main { box-shadow: inset 0 1px 0 var(--border); }
  .tx-ic { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 14px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
  .tx-ic svg { width: 20px; height: 20px; stroke-width: 2; }
  .item-text b { font-size: 15.5px; }
  .item-amt { font-size: 15.5px; }

  /* Bottom bar: pinned to the screen (sticky drifts with the phone's sliding address bar and
     bounces with the page on iPhone). Four equal slots; Add is a green tile in the third. */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    height: calc(64px + var(--safe-b)); padding: 0 calc(6px + var(--safe-r)) var(--safe-b) calc(6px + var(--safe-l));
    background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(17, 17, 15, .04); transform: translateZ(0);
  }
  .main-col { padding-bottom: calc(64px + var(--safe-b)); }
  .tab { min-height: 0; height: 64px; gap: 4px; font-size: 11.5px; border-radius: 12px; }
  .tab svg { width: 23px; height: 23px; }
  .tab > span:first-child { height: 32px; display: grid; place-items: center; } /* same icon box for every slot so labels line up */
  .tab[data-view="home"] { order: 1; } .tab[data-view="stats"] { order: 2; } .tab-add { order: 3; } .tab[data-view="settings"] { order: 4; }
  .tab-add {
    width: auto; height: 64px; min-height: 0; margin: 0; background: none; color: var(--accent); border-radius: 12px;
  }
  .tab-add > span:first-child {
    width: 46px; height: 32px; border-radius: 11px; display: grid; place-items: center;
    background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  .tab-add svg { width: 21px; height: 21px; stroke-width: 2.5; }
  .tab-add span:last-child { display: block; }
  .tab-add:active { background: var(--hover); }
  .tab-add:active > span:first-child { background: var(--accent-hover); }

  /* Stats + settings spacing under the dark header */
  #statsSlide, #view-settings { padding-top: var(--s3); }
  .kpi, .card { border-radius: 18px; }
  .card.list { border-radius: 18px; }

  .toast { bottom: calc(76px + var(--safe-b) + var(--kb)); }
}
@media (max-width: 767.98px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --hero: #000000; }
}
@media (max-width: 767.98px) { :root[data-theme="dark"] { --hero: #000000; } }

/* Narrow phones (≤ 400px): give labels room */
@media (max-width: 400px) {
  .row > .row-ic { display: none; }
  .row { gap: 10px; padding-left: 14px; padding-right: 14px; }
  .row .grow { white-space: nowrap; }
  .row input:not(.switch) { max-width: 120px; }
  .segmented button { padding: 0 10px; }
  .row2 { flex-direction: column; }
  .cat-opt { padding: 0 10px; gap: 8px; }
}

/* Suggestion card (install the app) — phones only */
.tip { display: none; }
@media (max-width: 767.98px) {
  .tip {
    position: fixed; z-index: 55; left: 12px; right: 12px; bottom: calc(76px + var(--safe-b));
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 8px 14px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-pop);
    transform: translateY(16px); opacity: 0; transition: transform .25s var(--ease), opacity .2s;
  }
  .tip[hidden] { display: none; }
  .tip.show { transform: none; opacity: 1; }
  .tip > img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
  .tip-body { flex: 1; min-width: 0; }
  .tip-body b { display: block; font-size: 16px; font-weight: 700; }
  .tip-body p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
  .tip-ios .kbd { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; color: var(--text); white-space: nowrap; }
  .tip-ios .kbd svg { width: 15px; height: 15px; color: #0A84FF; }
  .tip-actions { display: flex; gap: 8px; margin-top: 12px; }
  .tip-actions .btn { flex: 1; min-height: 38px; border-radius: 10px; }
  .tip-x { width: 32px; height: 32px; margin-top: -6px; color: var(--muted); }
  .tip-x svg { width: 18px; height: 18px; }
  .kb-open .tip { display: none; }
}

/* Import */
.imp-step { display: flex; flex-direction: column; gap: 16px; }
.imp-step[hidden] { display: none; }
.imp-help { color: var(--muted); font-size: 14px; }
.imp-help b { color: var(--text); font-weight: 600; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 24px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--sunken); transition: border-color .15s, background .15s;
}
.drop svg { width: 26px; height: 26px; color: var(--accent); margin-bottom: 4px; }
.drop b { font-weight: 700; }
.drop small { color: var(--muted); font-size: 13px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
textarea {
  width: 100%; min-height: 110px; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); outline: 0; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; line-height: 1.4;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.imp-template { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding-left: 0; }
.imp-template svg { width: 16px; height: 16px; }
.imp-summary { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--accent-soft); }
.imp-summary b { font-size: 18px; font-weight: 750; color: var(--accent); }
.imp-summary span { color: var(--text); font-size: 14px; }
.imp-summary.empty-plan { background: var(--danger-soft); }
.imp-summary.empty-plan b { color: var(--danger); }
.imp-map { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.imp-map select, #impFmt { width: 100%; height: 44px; }
.imp-preview { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.imp-preview:empty { display: none; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.imp-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; background: var(--sunken); }
.imp-table td { padding: 8px 10px; border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-table th:first-child, .imp-table td:first-child { width: 28%; }
.imp-table .num { text-align: right; width: 26%; font-weight: 600; }
.imp-table .muted { color: var(--muted); }
.imp-more { font-size: 13px; color: var(--muted); padding: 8px 10px; border-top: 1px solid var(--border); }
.imp-skipped { font-size: 13px; color: var(--warn); }
.imp-skipped:empty { display: none; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 400px) { .imp-map { grid-template-columns: 1fr; } .imp-table th:nth-child(3), .imp-table td:nth-child(3) { display: none; } }

/* "Check your email" after sign-up / sign-in link */
.auth-sent { display: flex; flex-direction: column; }
.auth-sent[hidden] { display: none; }
.auth-sent-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 20px; color: var(--accent); background: var(--accent-soft); }
.auth-sent-ic svg { width: 28px; height: 28px; }
.auth-sent h1 { outline: none; }
.auth-sent .auth-sub b { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.auth-card:has(#authSent:not([hidden])) .auth-logo { display: none; }
.auth-steps b { font-weight: 600; }
.auth-steps { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.auth-steps li { counter-increment: step; display: flex; gap: 12px; align-items: center; font-size: 14.5px; }
.auth-steps li::before { content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.auth-sent .btn + .btn { margin-top: 10px; }
.auth-sent .auth-alert { margin-bottom: 16px; }
.auth-hint { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: center; }
