/* TriPlan design tokens. Two axes: data-style (friendly | pro) × theme (light | dark).
   Friendly: soft, rounded, colourful category icons, generous spacing.
   Pro: compact, square-ish, hairline borders, tabular figures, denser tables. */
:root {
  --bg: #F3F6FA; --surface: #FFFFFF; --surface-2: #EDF2F7; --surface-3: #E3EAF2;
  --ink: #142033; --ink-2: #566278; --ink-3: #8A94A6; --line: #DDE4EC;
  --brand: #0E9384; --brand-ink: #FFFFFF; --brand-soft: #D8F3EE;
  --accent: #FF7A59; --accent-soft: #FFE6DD;
  --pos: #12996A; --pos-soft: #DCF5EA; --neg: #D9434A; --neg-soft: #FCE4E5; --warn: #B7791F; --warn-soft: #FDF1DA;
  --radius: 18px; --radius-sm: 12px; --radius-xs: 9px;
  --shadow: 0 1px 2px rgba(20, 32, 51, .06), 0 8px 24px -12px rgba(20, 32, 51, .18);
  --border: 1px solid transparent;
  --gap: 14px; --pad: 16px; --row: 60px;
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "Vazirmatn", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --c-transport: #3D7DF2; --c-stay: #8A6CF0; --c-food: #F2774B; --c-fun: #E2557A; --c-shopping: #D89A1C; --c-health: #1DAF8E; --c-other: #7C879B;
}
:root[data-style="pro"] {
  --bg: #F6F7F9; --surface: #FFFFFF; --surface-2: #F1F3F6; --surface-3: #E7EAEF;
  --ink: #0E1420; --ink-2: #4B5565; --ink-3: #8790A0; --line: #E1E5EB;
  --brand: #0B6E63; --brand-soft: #E1F0EE; --accent: #E0613F; --accent-soft: #FBE7E1;
  --radius: 10px; --radius-sm: 7px; --radius-xs: 5px;
  --shadow: none; --border: 1px solid var(--line);
  --gap: 10px; --pad: 12px; --row: 48px;
  --font-num: "IBM Plex Mono", "Vazirmatn", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1420; --surface: #161E2D; --surface-2: #1D2738; --surface-3: #253146;
    --ink: #EEF2F8; --ink-2: #A3AEC2; --ink-3: #75809A; --line: #2A3549;
    --brand: #2EC4AE; --brand-ink: #06201C; --brand-soft: #123B37; --accent: #FF8F72; --accent-soft: #3D231C;
    --pos: #3DD39A; --pos-soft: #12372B; --neg: #FF6B70; --neg-soft: #3D1C20; --warn: #F0B54A; --warn-soft: #3A2C12;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
  :root[data-style="pro"]:not([data-theme="light"]) { --bg: #0B0F17; --surface: #121823; --surface-2: #19202D; --line: #252E3D; --shadow: none; }
}
:root[data-theme="dark"] {
  --bg: #0E1420; --surface: #161E2D; --surface-2: #1D2738; --surface-3: #253146;
  --ink: #EEF2F8; --ink-2: #A3AEC2; --ink-3: #75809A; --line: #2A3549;
  --brand: #2EC4AE; --brand-ink: #06201C; --brand-soft: #123B37; --accent: #FF8F72; --accent-soft: #3D231C;
  --pos: #3DD39A; --pos-soft: #12372B; --neg: #FF6B70; --neg-soft: #3D1C20; --warn: #F0B54A; --warn-soft: #3A2C12;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}
:root[data-theme="dark"][data-style="pro"] { --bg: #0B0F17; --surface: #121823; --surface-2: #19202D; --line: #252E3D; --shadow: none; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; min-height: 100vh; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-xs); }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; font-weight: 800; }
h1 { font-size: clamp(24px, 5vw, 30px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); font-size: 13px; }
.hint { color: var(--ink-3); font-size: 12.5px; }
.err { color: var(--neg); font-weight: 700; font-size: 13.5px; min-height: 1.3em; }
.ok-line { color: var(--pos); font-weight: 700; font-size: 13.5px; }
.link { background: none; border: 0; padding: 0; font-weight: 700; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }

.app { max-width: 1080px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 12px calc(104px + env(safe-area-inset-bottom, 0px)); }
.app.no-tabs { padding-bottom: 40px; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: start; min-width: 0; }
.logo { width: 38px; height: 38px; flex: none; }
.brand-name { display: block; font-weight: 800; font-size: 18px; line-height: 1.1; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.top-sp { flex: 1; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; flex: none; background: var(--surface); border: var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); color: var(--ink); transition: transform 140ms var(--ease-out), background-color 160ms ease; }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 20px; height: 20px; }
.chip-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: var(--border); border-radius: 999px; padding: 4px 12px 4px 4px; padding-inline: 4px 12px; box-shadow: var(--shadow); font-weight: 700; font-size: 14px; min-height: 40px; max-width: 42vw; transition: transform 140ms var(--ease-out); }
.chip-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn:active { transform: scale(.97); }

/* ---------- avatars ---------- */
.av { --c: var(--brand); width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; line-height: 1; }
[data-style="pro"] .av { border-radius: var(--radius-xs); }
.av.sm { width: 24px; height: 24px; font-size: 11px; }
.av.lg { width: 44px; height: 44px; font-size: 17px; }
.stack { display: inline-flex; }
.stack .av { box-shadow: 0 0 0 2px var(--surface); margin-inline-start: -6px; }
.stack .av:first-child { margin-inline-start: 0; }

/* ---------- buttons ---------- */
.btn { --bg: var(--surface-2); --fg: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--bg); color: var(--fg); border: var(--border); border-color: transparent; border-radius: var(--radius-sm); padding: 9px 16px; min-height: 44px; font-weight: 700; font-size: 15px; white-space: nowrap; transition: transform 140ms var(--ease-out), background-color 160ms ease, opacity 160ms ease; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { --bg: var(--brand); --fg: var(--brand-ink); }
.btn.accent { --bg: var(--accent); --fg: #fff; }
.btn.danger { --bg: var(--neg-soft); --fg: var(--neg); }
.btn.ghost { --bg: transparent; border: 1px solid var(--line); }
.btn.soft { --bg: var(--brand-soft); --fg: var(--brand); }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: 13.5px; border-radius: var(--radius-xs); }
.btn.lg { min-height: 54px; font-size: 17px; padding: 12px 22px; }
.btn.block { width: 100%; }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--pad); min-width: 0; }
.stackv { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.sec { margin-top: 26px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.sec-h .act { font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
@media (max-width: 640px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { .grid2.collapse { grid-template-columns: minmax(0, 1fr); } }
.cols { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); }
.field > span { font-weight: 700; font-size: 13.5px; color: var(--ink-2); }
.input { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 46px; transition: border-color 160ms ease; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
select.input { padding-inline-end: 8px; }
textarea.input { min-height: 72px; resize: vertical; }
.amount-in { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.amount-in input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 34px; font-weight: 800; font-family: var(--font-num); padding: 0; outline: none; }
.amount-in select { border: 0; background: var(--surface-2); border-radius: var(--radius-xs); font-weight: 700; padding: 6px 8px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; border-radius: calc(var(--radius-sm) - 3px); padding: 6px 12px; font-weight: 700; font-size: 13.5px; white-space: nowrap; min-height: 34px; color: var(--ink-2); transition: background-color 160ms ease, color 160ms ease; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.seg.ad-tabs { display: flex; flex-wrap: wrap; overflow: visible; }
.seg.ad-tabs button { flex: 1 0 auto; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13.5px; min-height: 36px; white-space: nowrap; flex: none; transition: background-color 160ms ease, border-color 160ms ease, transform 140ms var(--ease-out); }
[data-style="pro"] .chip { border-radius: var(--radius-xs); }
.chip:active { transform: scale(.96); }
.chip .av { width: 22px; height: 22px; font-size: 10px; margin-inline-start: -6px; }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--ink); }
.chip.cat[aria-pressed="true"] { background: color-mix(in srgb, var(--cc) 16%, var(--surface)); border-color: var(--cc); }
.chip svg { width: 18px; height: 18px; color: var(--cc, currentColor); }
.chip:disabled { opacity: .45; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--surface-3); position: relative; flex: none; transition: background-color 180ms ease; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 200ms var(--ease-out); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked::after { transform: translateX(-18px); }
.split-rows { display: grid; gap: 8px; }
.split-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 110px; gap: 10px; align-items: center; }
#ex-payers .split-row { grid-template-columns: auto minmax(0, 1fr) 96px auto; }
.split-row .input { min-height: 40px; padding: 6px 10px; text-align: end; }
.sum-line { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; padding: 4px 2px; }
.sum-line.bad { color: var(--neg); }
.sum-line.good { color: var(--pos); }

/* ---------- category icon ---------- */
.cat-ic { --cc: var(--c-other); width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--cc) 15%, var(--surface)); color: var(--cc); }
.cat-ic svg { width: 22px; height: 22px; }
[data-style="pro"] .cat-ic { width: 30px; height: 30px; border-radius: var(--radius-xs); }
[data-style="pro"] .cat-ic svg { width: 17px; height: 17px; }

/* ---------- hero / home ---------- */
.hero { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #164E9E)); color: #fff; border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; position: relative; overflow: hidden; }
[data-style="pro"] .hero { background: var(--surface); color: var(--ink); border: var(--border); }
.hero::after { content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.08); pointer-events: none; }
[data-style="pro"] .hero::after { display: none; }
.hero .label { opacity: .85; font-size: 13px; font-weight: 700; }
.hero .big { font-size: clamp(30px, 8vw, 40px); font-weight: 800; line-height: 1.1; font-family: var(--font-num); }
.hero .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.hero .pill-lite { background: rgba(255,255,255,.18); border-radius: 999px; padding: 2px 10px; font-weight: 700; }
[data-style="pro"] .hero .pill-lite { background: var(--surface-2); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .btn.on-hero { --bg: #fff; --fg: var(--brand); }
[data-style="pro"] .hero .btn.on-hero { --bg: var(--brand); --fg: var(--brand-ink); }
.hero .btn.on-hero-ghost { --bg: rgba(255,255,255,.16); --fg: #fff; }
[data-style="pro"] .hero .btn.on-hero-ghost { --bg: var(--surface-2); --fg: var(--ink); }
.mybal { display: flex; align-items: center; gap: 12px; }
.mybal .amt { font-weight: 800; font-size: 20px; font-family: var(--font-num); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap); }
.tile { background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 2px; min-width: 0; }
.tile .k { font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.tile .v { font-size: 20px; font-weight: 800; font-family: var(--font-num); overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--ink-3); }

/* ---------- lists ---------- */
.list { display: grid; background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px var(--pad); min-height: var(--row); border: 0; background: transparent; width: 100%; text-align: start; min-width: 0; transition: background-color 140ms ease; }
.li + .li { border-top: 1px solid var(--line); }
button.li:active { background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { button.li:hover { background: var(--surface-2); } }
.li .main { flex: 1; min-width: 0; display: grid; line-height: 1.4; }
.li .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .s { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .end { text-align: end; display: grid; line-height: 1.35; flex: none; }
.li .amt { font-weight: 800; font-family: var(--font-num); white-space: nowrap; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 6px; font-weight: 800; font-size: 13.5px; color: var(--ink-2); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 0 8px; background: var(--surface-2); color: var(--ink-2); line-height: 1.7; white-space: nowrap; }
[data-style="pro"] .badge { border-radius: 4px; }
.badge.personal { background: var(--warn-soft); color: var(--warn); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.owner { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; display: grid; justify-items: center; gap: 10px; padding: 36px 16px; }
.empty svg.ill { width: 120px; height: 120px; }
.empty h2 { font-size: 19px; }
.filters { display: grid; gap: 10px; margin-bottom: 8px; }
.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--ink-3); }
.search .input { padding-inline-start: 38px; }

/* ---------- balances ---------- */
.bal-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; margin-top: 6px; }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 99px; }
.bar-fill.pos { background: var(--pos); inset-inline-start: 50%; }
.bar-fill.neg { background: var(--neg); inset-inline-end: 50%; }
.bar-mid { position: absolute; top: -2px; bottom: -2px; inset-inline-start: 50%; width: 2px; background: var(--line); }
.owe { display: grid; gap: 8px; }
.owe-card { display: grid; gap: 8px; }
.owe-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.owe-line .arrow { color: var(--ink-3); }
.settle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.settle .grow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.matrix-wrap { overflow-x: auto; border-radius: var(--radius); border: var(--border); background: var(--surface); box-shadow: var(--shadow); }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: 12px; color: var(--ink-2); font-weight: 800; background: var(--surface-2); position: sticky; top: 0; }
.tbl td.n { text-align: end; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .tbl tbody tr:hover td { background: var(--surface-2); } }
.tbl tfoot td { font-weight: 800; background: var(--surface-2); }

/* ---------- charts ---------- */
.donut-wrap { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; } }
.donut { width: 150px; height: 150px; }
.donut text { fill: var(--ink); font-family: var(--font); }
.legend { display: grid; gap: 6px; width: 100%; }
.legend button { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; border: 0; background: transparent; padding: 4px 6px; border-radius: var(--radius-xs); text-align: start; font-size: 13.5px; }
.legend button[aria-pressed="true"] { background: var(--surface-2); }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--cc); }
.legend .pc { color: var(--ink-3); font-size: 12px; min-width: 38px; text-align: end; }
.bars { display: grid; gap: 6px; }
.bars .b { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12.5px; }
.bars .t { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bars .f { height: 100%; background: var(--brand); border-radius: 4px; transform-origin: left; }
[dir="rtl"] .bars .f { transform-origin: right; margin-inline-start: auto; }
.daybars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; overflow-x: auto; }
.daybars .col { flex: 1 0 26px; display: grid; justify-items: center; gap: 4px; height: 100%; align-content: end; }
.daybars .stick { width: 100%; max-width: 30px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.daybars .col span { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }

/* ---------- FAB ---------- */
.fab { position: fixed; z-index: 21; inset-inline-end: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent); transition: transform 160ms var(--ease-out); }
[data-style="pro"] .fab { border-radius: 14px; width: 54px; height: 54px; }
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center; padding: 8px max(10px, env(safe-area-inset-left, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-right, 0px)); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar nav { display: grid; grid-template-columns: repeat(5, 1fr); width: min(560px, 100%); gap: 2px; }
.tab { display: grid; justify-items: center; gap: 1px; border: 0; background: transparent; padding: 5px 2px; border-radius: var(--radius-sm); color: var(--ink-3); font-weight: 700; font-size: 11.5px; min-height: 52px; transition: color 160ms ease, background-color 160ms ease; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--brand); }
.tab[aria-current="page"] svg { stroke-width: 2.4; }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(8, 14, 26, .45); opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease-out); }
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; z-index: 41; inset: auto 0 0 0; margin: 0 auto; width: min(600px, 100%); max-height: min(92vh, 860px); display: flex; flex-direction: column; background: var(--surface); border-radius: 22px 22px 0 0; transform: translateY(105%); transition: transform 380ms var(--ease-drawer); padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -10px 40px -10px rgba(0,0,0,.3); }
[data-style="pro"] .sheet { border-radius: 12px 12px 0 0; }
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-grab { padding: 10px 0 4px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet-grab i { width: 42px; height: 5px; border-radius: 99px; background: var(--line); }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px max(18px, env(safe-area-inset-right, 0px)) 22px max(18px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.sheet-body h2 { font-size: 21px; }
.sheet-foot { position: sticky; bottom: -22px; background: var(--surface); padding: 10px 0 4px; margin-bottom: -6px; display: grid; gap: 8px; }
.confirm { display: grid; gap: 10px; border-top: 1px dashed var(--line); padding-top: 12px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 60; inset: auto 0 calc(92px + env(safe-area-inset-bottom, 0px)) 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; background: var(--ink); color: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); transition: opacity 240ms var(--ease-out), transform 300ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translateY(12px) scale(.97); } }
.toast.out { opacity: 0; transform: translateY(8px); transition-duration: 180ms; }
.toast svg { width: 20px; height: 20px; flex: none; }

/* ---------- landing / auth ---------- */
.landing { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); max-width: 1000px; margin: 0 auto; }
@media (min-width: 880px) { .landing { grid-template-columns: 1.1fr .9fr; align-items: center; min-height: 74vh; } }
.pitch { display: grid; gap: 14px; }
.pitch h1 { font-size: clamp(32px, 7vw, 52px); line-height: 1.1; letter-spacing: -.02em; }
.pitch p { font-size: 16.5px; color: var(--ink-2); margin: 0; max-width: 34em; }
.pitch-art { width: min(420px, 100%); }
.feat { display: flex; flex-wrap: wrap; gap: 8px; }
.feat span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px; }
.auth-card { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-inline-end: 64px; }
.pw-wrap button { position: absolute; inset-inline-end: 6px; top: 50%; translate: 0 -50%; border: 0; background: var(--surface-2); border-radius: var(--radius-xs); font-size: 12px; font-weight: 800; padding: 4px 8px; }
.cap { min-height: 65px; display: grid; place-items: center; }
.note { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; color: var(--ink-2); }
.banner { display: flex; align-items: center; gap: 10px; background: var(--warn-soft); color: var(--ink); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 700; font-size: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.trips { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.trip-card { text-align: start; display: grid; gap: 8px; color: var(--ink); transition: transform 160ms var(--ease-out); }
.trip-card:active { transform: scale(.98); }
.trip-card .top-line { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.trip-card .sum { font-size: 22px; font-weight: 800; font-family: var(--font-num); }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live { background: var(--pos-soft); color: var(--pos); }
.pill.soon { background: var(--warn-soft); color: var(--warn); }
.pill.past { background: var(--surface-2); color: var(--ink-3); }
.invite { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite code { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; background: var(--surface-2); border-radius: var(--radius-xs); padding: 8px 10px; direction: ltr; overflow-wrap: anywhere; flex: 1; min-width: 0; user-select: all; }
.people-list .li { padding-block: 8px; }
.hh { font-size: 12px; font-weight: 800; color: var(--ink-3); padding: 10px var(--pad) 2px; }
.foot { margin-top: 40px; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.boot { min-height: 60vh; display: grid; place-items: center; }
.boot .logo { width: 56px; height: 56px; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); opacity: .7; } }
.view-enter { animation: viewIn 240ms var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
.ad-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.ad-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.who-col { display: grid; flex: 1; min-width: 160px; line-height: 1.45; }
.who-col .muted, .who-col .hint { overflow-wrap: anywhere; }
.role { font-size: 11.5px; font-weight: 800; border-radius: 6px; padding: 0 8px; background: var(--surface-2); color: var(--ink-2); line-height: 1.8; }
.role.owner { background: var(--accent-soft); color: var(--accent); }
.role.admin { background: var(--brand-soft); color: var(--brand); }
.code-box { display: grid; gap: 8px; margin-top: 6px; }
.code-box code { font-size: 16px; letter-spacing: .08em; }
.ad-confirm { flex-basis: 100%; display: grid; gap: 8px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.opt-row > span { font-weight: 700; }
.style-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-preview button { border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px; text-align: start; display: grid; gap: 6px; font-weight: 800; }
.style-preview button[aria-pressed="true"] { border-color: var(--brand); }
.style-preview .sw { height: 34px; border-radius: 8px; background: linear-gradient(135deg, #0E9384, #2B6CB0); }
.style-preview .sw.pro { border-radius: 3px; background: repeating-linear-gradient(0deg, var(--surface-2) 0 7px, var(--line) 7px 8px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
/* scroll rows inside a height-limited grid must keep their own height */
.sheet-body, .stackv, .filters { grid-auto-rows: max-content; }
.chips.scroll { flex-shrink: 0; min-height: 44px; }
.pitch-art { direction: ltr; }

/* ---------- add expense: steps, mode cards, items, live result, AI box ---------- */
.step { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; padding-top: 4px; }
.step + .step { border-top: 1px solid var(--line); padding-top: 14px; }
.step h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; }
[data-style="pro"] .step-n { border-radius: 6px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode-card { display: flex; align-items: flex-start; gap: 10px; text-align: start; border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 64px; transition: border-color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out); }
.mode-card:active { transform: scale(.98); }
.mode-card svg { width: 22px; height: 22px; flex: none; color: var(--ink-3); margin-top: 2px; }
.mode-card span { display: grid; gap: 2px; min-width: 0; }
.mode-card strong { font-size: 14px; }
.mode-card small { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.mode-card[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.mode-card[aria-pressed="true"] svg { color: var(--brand); }
@media (max-width: 360px) { .mode-grid { grid-template-columns: minmax(0, 1fr); } }
.items { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.item-row { display: grid; gap: 8px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px; }
.item-top { display: grid; grid-template-columns: minmax(0, 1fr) 112px auto; gap: 8px; align-items: center; }
.item-top .input { min-height: 42px; background: var(--surface); }
.item-top .price { text-align: end; }
.icon-btn.sm { width: 34px; height: 34px; font-size: 18px; font-weight: 700; }
.item-who { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.who-dot { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px 3px 3px; padding-inline: 3px 10px; font-weight: 700; font-size: 12.5px; min-height: 32px; transition: background-color 150ms ease, border-color 150ms ease; }
.who-dot { --c: var(--brand); }
.who-dot span { white-space: nowrap; }
.who-dot[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 18%, var(--surface)); border-color: var(--c); }
.who-dot[aria-pressed="true"]::after { content: "✓"; font-size: 11px; color: var(--c); }
.rest { display: grid; gap: 8px; border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px; }
.result { display: grid; gap: 10px; border-radius: var(--radius-sm); padding: 12px; border: 1.5px solid var(--line); }
.result.ok { border-color: color-mix(in srgb, var(--pos) 50%, var(--line)); background: var(--pos-soft); }
.result.bad { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: var(--warn-soft); }
.res-msg { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; }
.res-msg svg { width: 20px; height: 20px; flex: none; }
.result.ok .res-msg { color: var(--pos); }
.result.bad .res-msg { color: var(--warn); }
.res-list { display: flex; flex-wrap: wrap; gap: 6px; }
.res-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border-radius: 999px; padding: 3px 10px 3px 3px; padding-inline: 3px 10px; font-size: 13px; }
.res-chip strong { font-family: var(--font-num); }
.ai-box { border: 1.5px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 10px; }
.ai-box > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.ai-box > summary::-webkit-details-marker { display: none; }
.ai-box > summary svg { width: 24px; height: 24px; color: var(--accent); flex: none; }
.ai-box > summary span { display: grid; }
.ai-box > summary small { color: var(--ink-2); font-size: 12px; }
.ai-box[open] { gap: 10px; }
.ai-box textarea { background: var(--surface); }
.more-box > summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.note svg { width: 18px; height: 18px; vertical-align: -4px; margin-inline-end: 4px; color: var(--accent); }
.chain-row { flex-wrap: wrap; }
.chain-row .input { min-height: 38px; flex: 1; min-width: 140px; }
