/*
 * Kali Puja Club Cash Manager: global stylesheet.
 * Flat, sharp-cornered, no shadows, no gradients. 8px spacing grid. Mobile first.
 * Developed by Cognition Venture (https://cognitionventure.com)
 */

:root {
  --primary: #0F172A; --on-primary: #FFFFFF;
  --income: #16A34A; --expense: #DC2626; --warning: #CA8A04;
  --income-soft: #DCFCE7; --expense-soft: #FEE2E2; --warning-soft: #FEF9C3;
  --bg: #F8FAFC; --surface: #FFFFFF; --border: #E2E8F0; --text: #0F172A; --muted: #64748B;
  --zebra: #F8FAFC; --hover: #F1F5F9; --scrim: rgba(15, 23, 42, .45);
  --side-w: 248px; --bar-h: 64px; --nav-h: 64px;
  color-scheme: light;
}
[data-theme="dark"] {
  --primary: #F8FAFC; --on-primary: #0F172A;
  --income: #22C55E; --expense: #EF4444; --warning: #EAB308;
  --income-soft: #052E16; --expense-soft: #450A0A; --warning-soft: #422006;
  --bg: #0B1120; --surface: #111827; --border: #1F2937; --text: #E5E7EB; --muted: #94A3B8;
  --zebra: #0F172A; --hover: #1E293B; --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; box-shadow: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; flex: none; vertical-align: middle; }
.ic.sm { width: 16px; height: 16px; }
.ic.xs { width: 12px; height: 12px; }
.ic.lg { width: 28px; height: 28px; }
.cap { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.m0 { margin: 0; }
.mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.upper { text-transform: uppercase; }
.in-c { color: var(--income); } .out-c { color: var(--expense); } .warn-c { color: var(--warning); }
.strong { font-weight: 700; }
.dim { opacity: .6; }
form.inline { display: inline; margin: 0; }
.only-d { display: none !important; }

/* ---------- App shell (mobile first) ---------- */
body.app { padding-top: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); min-height: 100vh; }
.appbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--bar-h); padding: env(safe-area-inset-top, 0px) 16px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.ev { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ev-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 700; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-right { display: flex; align-items: center; gap: 8px; }
.cih { text-align: right; line-height: 1.2; }
.cih b { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; }
.ib { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; flex: none; text-decoration: none; padding: 0; }
.ib:hover { background: var(--hover); }
.ib.sm { width: 32px; height: 32px; }
.main { max-width: 1280px; margin: 0 auto; padding: 16px 16px 32px; position: relative; }
.side { display: none; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }
.navb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--nav-h); border-top: 2px solid transparent; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; }
.navb.on { color: var(--text); border-top-color: var(--primary); }
.fab-slot { display: flex; justify-content: center; align-items: flex-start; }
.fab { width: 56px; height: 56px; margin-top: -18px; background: var(--primary); color: var(--on-primary); border: 4px solid var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.fab .ic { width: 26px; height: 26px; stroke-width: 2.5; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.credit { margin: 32px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.credit a { color: var(--muted); font-weight: 600; }

/* Desktop: sidebar replaces bottom nav */
@media (min-width: 1024px) {
  .only-d { display: inline-flex !important; }
  .tbl-wrap.only-d { display: block !important; }
  .only-m { display: none !important; }
  body.app { padding-left: var(--side-w); padding-bottom: 0; }
  body.app.coll { --side-w: 64px; }
  .appbar { left: var(--side-w); padding: 0 32px; }
  .ev-btn { font-size: 18px; }
  .cih b { font-size: 18px; }
  .nav { display: none; }
  .main { padding: 24px 32px 48px; }
  .side { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); z-index: 21; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
  .brand { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: var(--bar-h); border-bottom: 1px solid var(--border); }
  .brand b { display: block; font-size: 14px; line-height: 1.2; }
  .brand small { font-size: 11px; color: var(--muted); }
  .side nav { display: flex; flex-direction: column; padding: 8px 0; flex: 1; }
  .side nav a, .side .lo { display: flex; align-items: center; gap: 12px; padding: 9px 16px; margin: 0 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-left: 2px solid transparent; }
  .side nav a:hover, .side .lo:hover { background: var(--hover); color: var(--text); }
  .side nav a.on { color: var(--text); background: var(--hover); border-left-color: var(--primary); }
  .side nav a .badge { margin-left: auto; }
  .side-foot { padding: 12px 8px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
  .side-foot p { margin: 8px 16px 0; }
  .side-foot p a { color: var(--muted); font-weight: 600; }
  body.coll .side .lbl, body.coll .brand div, body.coll .side nav a .badge, body.coll .side-foot p { display: none; }
  body.coll .side nav a, body.coll .side .lo { justify-content: center; padding: 10px 0; }
  body.coll .brand { justify-content: center; padding: 12px 0; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 32px; }
}
.mark { width: 32px; height: 32px; background: var(--primary); color: var(--on-primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: none; object-fit: contain; }
.mark.lg { width: 48px; height: 48px; font-size: 18px; }
img.mark { background: var(--surface); border: 1px solid var(--border); }

/* ---------- Components ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--hover); }
.btn.inc { background: var(--income); border-color: var(--income); color: #fff; }
.btn.danger { background: var(--expense); border-color: var(--expense); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 12px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.is-off { opacity: .45; cursor: not-allowed; }
.card { background: var(--surface); border: 1px solid var(--border); padding: 16px; }
.card h3, .sec-h { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.h-norm { text-transform: none !important; letter-spacing: 0 !important; font-size: 17px !important; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-h.tight { margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border: 1px solid currentColor; white-space: nowrap; line-height: 1.5; }
.pill.ok { color: var(--income); } .pill.warn { color: var(--warning); } .pill.bad { color: var(--expense); } .pill.mute { color: var(--muted); }
.pill.solid { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; align-items: center; justify-content: center; background: var(--expense); color: #fff; font-size: 11px; font-weight: 700; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-h h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.big-sm { font-size: 18px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; margin-bottom: 8px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border); background: var(--surface); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border: 1px solid var(--warning); background: var(--warning-soft); font-size: 14px; }
.alert .ic { margin-top: 2px; color: var(--warning); }
.alert.bad { border-color: var(--expense); background: var(--expense-soft); }
.alert.bad .ic { color: var(--expense); }
.al-body { flex: 1; min-width: 0; }
.al-body b { display: block; }
.al-body .btn { margin-top: 8px; }
.offline { display: flex; align-items: center; gap: 8px; padding: 10px 16px; margin: 0 0 16px; background: var(--expense); color: #fff; font-size: 13px; font-weight: 600; }
.ptr { height: 0; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.ptr span { padding-bottom: 8px; display: flex; align-items: center; gap: 6px; }

/* ---------- Dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 16px; }
.hero { background: var(--primary); color: var(--on-primary); padding: 24px 20px; border: 1px solid var(--primary); }
.hero .cap { color: inherit; opacity: .7; }
.big { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 8px 0 16px; }
.big .ps { font-size: 18px; opacity: .6; }
.hero-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 1px solid color-mix(in srgb, var(--on-primary) 20%, transparent); padding-top: 12px; font-size: 13px; }
.hero-split span { display: block; opacity: .7; font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); background: var(--surface); }
.tile { padding: 12px 10px; border-right: 1px solid var(--border); min-width: 0; }
.tile:last-child { border-right: 0; }
.tile b { display: block; font-size: 13px; font-weight: 700; margin-top: 4px; white-space: nowrap; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tiles.two .tile b, .tiles.four .tile b { font-size: 15px; }
.tiles.four { grid-template-columns: repeat(2, 1fr); }
.tiles.four .tile:nth-child(2) { border-right: 0; }
.tiles.four .tile:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
@media (min-width: 600px) {
  .tile { padding: 14px 12px; }
  .tile b { font-size: 16px; }
  .tiles.four { grid-template-columns: repeat(4, 1fr); }
  .tiles.four .tile { border-bottom: 0 !important; border-right: 1px solid var(--border) !important; }
  .tiles.four .tile:last-child { border-right: 0 !important; }
}
.qa { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.qa a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 4px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; text-decoration: none; }
.qa a:hover { background: var(--hover); }
.ico { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; flex: none; }
.qa .ico { width: 40px; height: 40px; }
.ico.in { background: var(--income-soft); color: var(--income); }
.ico.out { background: var(--expense-soft); color: var(--expense); }
.ico.neu { background: var(--hover); color: var(--text); }
.who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; background: var(--hover); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }
.who b { display: block; font-size: 16px; }
.who small { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.kv b { display: block; font-size: 16px; font-weight: 700; }
.hb-status { display: flex; align-items: center; gap: 16px; }
.hb-count { font-size: 28px; font-weight: 800; line-height: 1; }
@media (min-width: 600px) {
  .dash { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
  .dash > * { grid-column: span 1; }
  .dash > .d-full, .dash > .d-wide { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .dash { grid-template-columns: repeat(12, 1fr); }
  .dash > * { grid-column: span 12; }
  .dash > .d-hero { grid-column: span 5; align-self: stretch; }
  .dash > .d-stats { grid-column: span 7; }
  .dash > .d-third { grid-column: span 4; }
  .dash > .d-wide { grid-column: span 8; }
  .qa { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Lists ---------- */
.list { background: var(--surface); border: 1px solid var(--border); }
.swipe { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); }
.swipe:last-of-type { border-bottom: 0; }
.acts { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.acts form { display: flex; margin: 0; }
.acts a, .acts button { width: 72px; border: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; }
.acts .a-edit { background: var(--muted); color: var(--surface); }
.acts .a-del { background: var(--expense); color: #fff; }
.row { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; background: var(--surface); text-decoration: none; touch-action: pan-y; transition: transform .2s ease; }
a.row:hover { background: var(--hover); }
.row.static { cursor: default; }
.rm { min-width: 0; display: block; text-decoration: none; }
.rt { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row.sp .rt { font-weight: 700; }
.rs { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ra { text-align: right; }
.amt { display: block; font-weight: 700; white-space: nowrap; }
.amt.in { color: var(--income); } .amt.out { color: var(--expense); }
.rv { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.grp { margin-top: 16px; }
.grp.first { margin-top: 0; margin-bottom: 16px; }
.grp-h { display: flex; justify-content: space-between; align-items: baseline; padding: 0 0 8px; }
.list-foot { display: flex; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); font-weight: 700; }
.need-tag { display: block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.rep-x { display: inline-flex; gap: 4px; }
.rep-x a, .rep-x button { border: 1px solid var(--border); background: var(--surface); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: 4px 8px; text-decoration: none; }
.rep-x a:hover { background: var(--hover); }
.bin-row { grid-template-columns: auto 1fr; }
.bin-row .btn-row { grid-column: 1 / -1; }
@media (min-width: 600px) { .bin-row { grid-template-columns: auto 1fr auto; } .bin-row .btn-row { grid-column: auto; } }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; border: 1px solid var(--border); background: var(--surface); max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:nth-child(even) td { background: var(--zebra); }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--hover); }
.r { text-align: right; }
.nw { white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 1px solid var(--border); border-bottom: 0; background: var(--surface); }
td.acts-c { white-space: nowrap; text-align: right; padding-block: 8px; }
td .ib { width: 32px; height: 32px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }

/* ---------- Day strip and tabs ---------- */
.days { display: flex; border: 1px solid var(--border); background: var(--surface); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.dayb { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-right: 1px solid var(--border); text-decoration: none; }
.dayb:last-child { border-right: 0; }
.dayb .wd { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dayb .dn { font-size: 20px; font-weight: 800; line-height: 1.1; }
.dayb .st { font-size: 10px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.dayb.on { background: var(--primary); color: var(--on-primary); }
.dayb.on .wd, .dayb.on .st { color: inherit; opacity: .75; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabb { flex: none; padding: 12px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabb.on { color: var(--text); border-bottom-color: var(--primary); }
.tabb .c { font-size: 11px; margin-left: 6px; opacity: .75; }

/* ---------- Day Book ---------- */
.dbh { display: grid; gap: 16px; }
.dbh-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.dbh-top h2 { margin: 0; font-size: 20px; }
.hand-hist { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.hand-hist > div { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hh-top { align-items: center; }
.two-col { display: grid; gap: 16px; align-items: start; }
@media (min-width: 600px) { .two-col { grid-template-columns: 1fr 1fr; } }
.calc { border: 1px solid var(--border); background: var(--surface); }
.calc > div { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.calc > div:last-child { border-bottom: 0; }
.calc .tot { font-weight: 800; font-size: 16px; background: var(--hover); }
.diff { padding: 12px 14px; font-weight: 600; font-size: 14px; border: 1px solid var(--border); }
.diff.ok { border-color: var(--income); color: var(--income); background: var(--income-soft); }
.diff.short { border-color: var(--warning); background: var(--warning-soft); }
.dl { display: grid; grid-template-columns: auto 1fr; border: 1px solid var(--border); background: var(--surface); margin: 0; }
.dl dt, .dl dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.dl dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.dl dd { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }
.need-box { padding: 14px; border: 1px solid var(--border); background: var(--hover); }
.need-box .cap { margin-bottom: 4px; display: block; }
.need-box p { margin: 0; font-size: 16px; font-weight: 600; }
.big-amt { font-size: 28px; font-weight: 800; }
.bill-big { max-width: 200px; border: 1px solid var(--border); display: block; }
.denoms { display: grid; grid-template-columns: 1fr; gap: 0; border: 1px solid var(--border); margin-top: 12px; }
.den { display: grid; grid-template-columns: 72px 1fr 110px; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.den input { min-height: 40px !important; padding: 6px 10px !important; }
.den b { text-align: right; }
.den-sum { display: flex; justify-content: space-between; padding: 10px; font-weight: 800; background: var(--hover); }
details.more-box summary, details.cancel-box summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
details.cancel-box { border-top: 1px solid var(--border); padding-top: 12px; }
details.cancel-box form { margin-top: 12px; }

/* ---------- Handbook ---------- */
.gal { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 600px) { .gal { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; } }
.ph { border: 1px solid var(--border); background: var(--surface); }
.ph-img { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.ph img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.ph-l { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12.5px; }
.ph-n { padding: 0 10px 8px; font-size: 12px; color: var(--muted); }
.ph-acts { display: flex; gap: 6px; padding: 0 10px 10px; flex-wrap: wrap; }
.hb-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .tr { width: 44px; height: 24px; border: 1px solid var(--border); background: var(--hover); position: relative; flex: none; transition: background .15s; }
.switch .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--muted); transition: transform .15s; }
.switch input:checked + .tr { background: var(--income); border-color: var(--income); }
.switch input:checked + .tr::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + .tr { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .tr { opacity: .5; }

/* ---------- Budget, accounts, menu ---------- */
.meter { height: 8px; background: var(--border); margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--income); max-width: 100%; }
.meter.warn i { background: var(--warning); } .meter.over i { background: var(--expense); }
.bud { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.bud-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: 14px; }
.bud-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 6px; }
@media (min-width: 1024px) { .bud-list { display: grid; grid-template-columns: 1fr 1fr; } .bud-list .bud:nth-child(odd) { border-right: 1px solid var(--border); } }
.acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 1024px) { .acc-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.acc { display: flex; flex-direction: column; gap: 4px; }
.acc-top { display: flex; justify-content: space-between; align-items: center; }
.acc-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.acc b { font-size: 17px; font-weight: 800; }
.acc small { color: var(--muted); font-size: 12px; }
.small-link { font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; margin-top: 4px; }
.recon { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.recon > div { display: flex; justify-content: space-between; gap: 8px; }
.recon .eq { border-top: 1px solid var(--border); padding-top: 8px; font-weight: 700; }
.menu { background: var(--surface); border: 1px solid var(--border); }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 14px; padding: 14px 16px; background: none; border: 0; border-bottom: 1px solid var(--border); text-align: left; cursor: pointer; font-size: 15px; font-weight: 500; text-decoration: none; }
.menu > :last-child { border-bottom: 0; }
.menu a:hover, .menu button:hover { background: var(--hover); }
.menu .chev { margin-left: auto; color: var(--muted); }
.menu small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.cat-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.cat-row .check { font-size: 13px; }
.search { display: flex; gap: 8px; }
.search input, .search select { flex: 1; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.logo-prev { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); background: #fff; }
.chart-box { max-width: 560px; }
details.purge { display: inline-block; }
details.purge summary { list-style: none; }
details.purge summary::-webkit-details-marker { display: none; }
.purge-f { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.purge-f input { min-height: 36px !important; padding: 6px 10px !important; flex: 1; min-width: 140px; }

/* ---------- Forms ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > label, .fld > .lb { font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.req { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--expense); }
.opt { font-size: 11px; font-weight: 500; color: var(--muted); }
input[type=text], input[type=search], input[type=time], input[type=date], input[type=number], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.fld.bad input, .fld.bad textarea, .fld.bad select, .fld.bad .money { outline: 2px solid var(--expense); outline-offset: -2px; }
.money { display: flex; align-items: stretch; border: 1px solid var(--border); background: var(--surface); }
.money span { display: flex; align-items: center; padding: 0 12px; border-right: 1px solid var(--border); font-weight: 700; color: var(--muted); }
.money input { border: 0 !important; font-size: 22px !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.money:focus-within { outline: 2px solid var(--primary); outline-offset: -2px; }
.money input:focus { outline: none; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.err { margin: 0; font-size: 12.5px; color: var(--expense); font-weight: 600; }
.seg { display: flex; border: 1px solid var(--border); background: var(--surface); }
.seg label { flex: 1; position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 8px; text-align: center; font-size: 13px; font-weight: 600; border-right: 1px solid var(--border); color: var(--muted); height: 100%; }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--primary); color: var(--on-primary); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -4px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap label { flex: 1 1 33%; }
.seg.wrap span { border-bottom: 1px solid var(--border); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.bill-prev { display: flex; gap: 8px; flex-wrap: wrap; }
.bill-prev img { width: 72px; height: 96px; object-fit: cover; border: 1px solid var(--border); }
.filebtn { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1px dashed var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; background: var(--surface); text-align: center; padding: 8px; }
.filebtn.tall { min-height: 104px; flex-direction: column; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.page-form { max-width: 560px; background: var(--surface); border: 1px solid var(--border); }
.page-form .sh-f { position: static; }

/* ---------- Bottom sheet / side panel ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s; z-index: 40; }
.scrim.open { opacity: 1; visibility: visible; transition: opacity .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: var(--surface); border-top: 1px solid var(--border); transform: translateY(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; z-index: 41; padding-bottom: env(safe-area-inset-bottom, 0px); }
.sheet.open { transform: none; visibility: visible; transition: transform .25s ease; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; background: var(--border); margin: 8px auto 0; flex: none; }
@media (min-width: 1024px) {
  .sheet { left: auto; top: 0; width: 480px; max-height: none; border-top: 0; border-left: 1px solid var(--border); transform: translateX(100%); }
  .sheet::before { display: none; }
}
.sheet > form, .sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sh-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex: none; }
.sh-h h2 { margin: 0; font-size: 18px; font-weight: 700; }
.sh-b { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; flex: 1; min-height: 0; }
.sh-f { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--surface); flex: none; flex-wrap: wrap; }
.sh-f > .btn, .sh-f > form { flex: 1; }
.sh-f > form .btn { width: 100%; }
.fab-menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.fab-menu a { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-weight: 700; font-size: 15px; }
.fab-menu a small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.fab-menu a:hover { background: var(--hover); }
.sheet-loading { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- Toast and viewer ---------- */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--primary); color: var(--on-primary); font-size: 14px; font-weight: 600; transform: translateY(16px); opacity: 0; visibility: hidden; transition: transform .2s, opacity .2s, visibility 0s .2s; }
.toast.open { transform: none; opacity: 1; visibility: visible; transition: transform .2s, opacity .2s; }
.toast.bad { background: var(--expense); color: #fff; }
.toast .t-msg { flex: 1; }
.toast button, .toast a { background: none; border: 1px solid currentColor; color: inherit; padding: 6px 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; text-decoration: none; white-space: nowrap; }
body.plain .toast { bottom: 16px; }
@media (min-width: 1024px) { .toast { left: auto; right: 24px; bottom: 24px; width: 400px; } }
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; }
.vw-top, .vw-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #222; }
.vw-nav { border-top: 1px solid #222; border-bottom: 0; font-size: 13px; color: #aaa; }
.vw-top small { color: #aaa; display: block; font-size: 12px; }
.viewer .ib { background: #000; color: #fff; border-color: #333; }
.vw-stage { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: pan-x pan-y pinch-zoom; min-height: 0; }
.vw-stage img { max-width: 100%; max-height: 100%; cursor: zoom-in; user-select: none; -webkit-user-drag: none; }
.vw-stage.zoom { display: block; }
.vw-stage.zoom img { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }

/* ---------- Auth pages ---------- */
body.plain { min-height: 100vh; }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; background: var(--surface); border: 1px solid var(--border); padding: 24px; }
.auth.wide .auth-box { max-width: 560px; }
.auth-box h1 { margin: 0; font-size: 20px; }
.auth-box p { margin: 4px 0 0; }

/* ---------- Receipt page ---------- */
.receipt-page { max-width: 600px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.receipt-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .appbar, .nav, .side, .fab, .sheet, .scrim, .toast, .credit, .btn, .back, .ptr { display: none !important; }
  body.app { padding: 0 !important; }
  .tbl-wrap { overflow: visible; border: 0; }
}
