/* আমারদিন (AmarDin) — one small stylesheet, system fonts, no images.
   Colours are tokens on <html>: data-mode = light|dark (set by a tiny script before first paint) and
   data-palette = indigo|teal|clay|leaf|rose. Tints are made from the "r g b" triplets, so every palette
   only has to name its few colours. Nothing here needs blur, filters or big shadows: it stays smooth on
   cheap phones. */
:root {
  --bg: #f4f5fa; --card: #ffffff; --field: #f6f7fb; --ink: #0f172a; --ink2: #334155; --muted: #5b6577; --line: #e4e7f0;
  --danger: #dc2626; --danger-rgb: 220 38 38;
  --brand: #4f46e5; --brand-rgb: 79 70 229; --brand-ink: #ffffff; --accent: #b45309; --accent-rgb: 217 119 6;
  --hero-a: #4f46e5; --hero-b: #7c3aed;
  --c1: #4f46e5; --c2: #f59e0b; --c3: #10b981; --c4: #ec4899; --c5: #0ea5e9; --c6: #84cc16; --c-other: #a8b0c0;
  --soft: rgb(var(--brand-rgb) / .09); --bar: var(--brand); --bar-bg: rgb(var(--brand-rgb) / .12);
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 10px 26px -18px rgb(15 23 42 / .22);
  --r: 18px;
  color-scheme: light;
}
:root[data-mode="dark"] {
  --bg: #0e1016; --card: #171a23; --field: #1d212c; --ink: #eef0f6; --ink2: #c9cddb; --muted: #969cb0; --line: #272b39;
  --danger: #f87171; --danger-rgb: 248 113 113;
  --brand: #a5b4fc; --brand-rgb: 165 180 252; --brand-ink: #11132b; --accent: #fbbf24; --accent-rgb: 251 191 36;
  --hero-a: #4338ca; --hero-b: #6d28d9;
  --c1: #818cf8; --c2: #fbbf24; --c3: #34d399; --c4: #f472b6; --c5: #38bdf8; --c6: #a3e635; --c-other: #596072;
  --soft: rgb(var(--brand-rgb) / .14); --bar-bg: rgb(var(--brand-rgb) / .16);
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 26px -18px rgb(0 0 0 / .8);
  color-scheme: dark;
}
/* palettes (the indigo one is the base above) */
:root[data-palette="teal"] { --brand: #0f766e; --brand-rgb: 15 118 110; --hero-a: #0f766e; --hero-b: #0891b2; --c1: #0f766e; --c3: #6366f1; --c5: #84cc16; --c6: #0ea5e9; }
:root[data-palette="teal"][data-mode="dark"] { --brand: #5eead4; --brand-rgb: 94 234 212; --brand-ink: #062a27; --hero-a: #0f766e; --hero-b: #0e7490; --c1: #2dd4bf; --c3: #818cf8; --c5: #a3e635; --c6: #38bdf8; --bg: #0c1413; --card: #142120; --field: #182827; --line: #233634; }
:root[data-palette="clay"] { --brand: #b4532a; --brand-rgb: 180 83 42; --accent: #0f766e; --accent-rgb: 15 118 110; --hero-a: #b4532a; --hero-b: #d97706; --c1: #b4532a; --c2: #0d9488; --c3: #6366f1; --c4: #eab308; --c5: #ec4899; --c6: #0ea5e9; }
:root[data-palette="clay"][data-mode="dark"] { --brand: #fdba74; --brand-rgb: 253 186 116; --brand-ink: #2a1608; --accent: #5eead4; --accent-rgb: 94 234 212; --hero-a: #9a3412; --hero-b: #c2410c; --c1: #fb923c; --c2: #2dd4bf; --c3: #818cf8; --c4: #facc15; --c5: #f472b6; --c6: #38bdf8; --bg: #15100d; --card: #201813; --field: #261d17; --line: #3a2c24; }
:root[data-palette="leaf"] { --brand: #2f6b3f; --brand-rgb: 47 107 63; --accent: #a16207; --hero-a: #15803d; --hero-b: #4d7c0f; --c1: #2f6b3f; --c3: #6366f1; --c5: #0ea5e9; --c6: #f97316; }
:root[data-palette="leaf"][data-mode="dark"] { --brand: #86efac; --brand-rgb: 134 239 172; --brand-ink: #0a2414; --accent: #fbbf24; --hero-a: #166534; --hero-b: #3f6212; --c1: #4ade80; --c3: #818cf8; --c5: #38bdf8; --c6: #fb923c; --bg: #0c130e; --card: #141f17; --field: #18261c; --line: #24372a; }
:root[data-palette="rose"] { --brand: #be185d; --brand-rgb: 190 24 93; --accent: #0e7490; --accent-rgb: 14 116 144; --hero-a: #be185d; --hero-b: #e11d48; --c1: #be185d; --c2: #0891b2; --c3: #f59e0b; --c4: #6366f1; --c5: #10b981; --c6: #a855f7; }
:root[data-palette="rose"][data-mode="dark"] { --brand: #f9a8d4; --brand-rgb: 249 168 212; --brand-ink: #2b0a19; --accent: #67e8f9; --accent-rgb: 103 232 249; --hero-a: #9d174d; --hero-b: #be123c; --c1: #f472b6; --c2: #22d3ee; --c3: #fbbf24; --c4: #818cf8; --c5: #34d399; --c6: #c084fc; --bg: #140c10; --card: #20141a; --field: #27181f; --line: #3a2630; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Bengali', 'Hind Siliguri', 'Nirmala UI', 'Vrinda', sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.2rem; line-height: 1.15; }
h2 { font-size: 1.05rem; margin-bottom: .35rem; }
h3 { font-size: .92rem; margin: 16px 0 6px; }
p { margin: 0 0 .75rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); font-size: .88rem; }
.small { font-size: .78rem; }
.hidden { display: none !important; }
.spacer, .grow { flex: 1; min-width: 0; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; min-height: 58px;
  padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.logo { width: 36px; height: 36px; flex: none; }
.brand h1 em { font-style: normal; color: var(--brand); }
.brand .by { display: block; font-size: .7rem; color: var(--muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbtn { position: relative; flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink2); }
.hbtn.lang { width: auto; min-width: 44px; padding: 0 10px; font-size: .8rem; font-weight: 700; }
.sync .dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--card); display: none; }
.sync[data-state="ok"] { color: var(--brand); }
.sync[data-state="pending"] .dot { display: block; background: rgb(var(--accent-rgb)); }
.sync[data-state="error"] .dot, .sync[data-state="denied"] .dot, .sync[data-state="none"] .dot { display: block; background: var(--danger); }
.sync[data-state="offline"] { color: var(--muted); opacity: .6; }

main { max-width: 720px; margin: 0 auto; padding: 14px 14px 8px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; margin-top: 0; }
.row.between h2 { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: .55rem 1rem; border-radius: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; text-align: center; }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.small { min-height: 36px; padding: .25rem .8rem; font-size: .88rem; border-radius: 11px; }
.btn.small .ic { width: 16px; height: 16px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: rgb(var(--danger-rgb) / .35); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: none; color: var(--muted); }
.icon-btn:active { background: var(--soft); }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--brand); font-size: .88rem; text-decoration: underline; text-underline-offset: 3px; }

input, select, textarea { width: 100%; min-height: 46px; padding: .55rem .75rem; border-radius: 13px; border: 1px solid var(--line); background: var(--field); }
textarea { display: block; resize: vertical; min-height: 68px; font-size: 1.04rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--soft); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--brand); flex: none; }
.field { display: block; margin-top: 10px; font-size: .84rem; color: var(--muted); }
.field input, .field select { margin-top: 4px; color: var(--ink); font-size: 1rem; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: .86rem; color: var(--ink2); white-space: nowrap; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--field); }
.seg button { border: 0; background: none; border-radius: 999px; padding: .32rem .85rem; font-size: .84rem; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--brand); font-weight: 700; box-shadow: 0 1px 3px rgb(15 23 42 / .12); }
.seg.wide { display: flex; margin-bottom: 12px; }
.seg.wide button { flex: 1; padding: .5rem .5rem; font-size: .92rem; }

.list:empty { display: none; }
.empty { text-align: center; color: var(--muted); padding: 18px 0 10px; font-size: .92rem; }
.amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.path { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; background: var(--soft); color: var(--brand); white-space: nowrap; }
.tag.warn, .badge.warn { background: rgb(var(--accent-rgb) / .16); color: var(--accent); }
.badge { font-size: .74rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: var(--soft); color: var(--brand); white-space: nowrap; }
.badge.bad { background: rgb(var(--danger-rgb) / .13); color: var(--danger); }
.up { color: var(--danger); } .down { color: var(--brand); }

/* ---------- add tab ---------- */
.card.composer { padding: 0; overflow: hidden; }
.hero { display: flex; align-items: center; gap: 14px; padding: 18px 16px; color: #fff; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); }
.mic { flex: none; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; border: 0; background: #fff; color: var(--hero-a);
  box-shadow: 0 0 0 6px rgb(255 255 255 / .22), 0 10px 22px -8px rgb(0 0 0 / .45); }
.mic .ic { width: 32px; height: 32px; stroke-width: 2; }
.mic.on { color: #dc2626; }
.hero-text { min-width: 0; }
.hero-text strong { display: block; font-size: 1.06rem; line-height: 1.3; }
.hero-text small { display: block; margin-top: 3px; font-size: .82rem; line-height: 1.35; opacity: .88; }
#micState.err { display: inline-block; padding: 3px 8px; border-radius: 9px; background: rgb(0 0 0 / .28); font-size: .92rem; font-weight: 600; }
.composer-body { padding: 12px 16px 16px; }
.composer-body textarea { margin-top: 10px; }

.pv-line { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--field); }
.pv-line.unknown { border-color: rgb(var(--accent-rgb) / .7); }
.pv-line.compact { display: flex; align-items: center; gap: 2px; padding: 2px 4px 2px 12px; }
.pv-sum { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px 0; border: 0; background: none; text-align: left; }
.pv-sum .nm { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-sum .nm small { color: var(--muted); font-weight: 400; }
.pv-sum .path { display: block; }
.pv-sum > .ic { width: 16px; height: 16px; color: var(--muted); opacity: .7; }
.pv-line.compact .icon-btn { width: 40px; height: 40px; }
.pv-head { display: flex; align-items: center; gap: 8px; margin: -4px -6px 4px 0; font-size: .8rem; color: var(--muted); }
.pv-head .raw { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-head .icon-btn { width: 36px; height: 36px; }
.pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv-grid .full { grid-column: 1 / -1; }
.pv-grid label, .pv-grid .lbl { display: block; font-size: .78rem; color: var(--muted); min-width: 0; }
.pv-grid input, .pv-grid select, .pick { margin-top: 3px; color: var(--ink); font-size: 1rem; background: var(--card); }
.pv-grid .qty { display: grid; grid-template-columns: minmax(0, 1fr) 86px; gap: 6px; }
.pick { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 46px; padding: .5rem .75rem; border-radius: 13px; border: 1px solid var(--line); text-align: left; }
.pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .ic { width: 18px; height: 18px; color: var(--muted); }
.pick.need { border-color: rgb(var(--accent-rgb) / .8); color: var(--accent); font-weight: 600; }
.pick.need .ic { color: inherit; }
#addLineBtn { margin-top: 10px; }
.date-in { width: auto; min-height: 40px; padding: .3rem .6rem; font-size: .92rem; }
.save-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.save-bar small { display: block; font-size: .78rem; color: var(--muted); }
.save-bar strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.save-bar .btn { min-width: 46%; min-height: 50px; font-size: 1.05rem; }

.first ol { margin: 6px 0 0; padding-left: 1.3rem; color: var(--ink2); }
.first li { margin: 4px 0; }

.glance { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.glance:empty { display: none; }
.g { min-width: 0; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.g small { display: block; font-size: .8rem; color: var(--muted); }
.g strong { display: block; font-size: 1.32rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.g .mini { height: 6px; margin-top: 8px; border-radius: 6px; background: var(--bar-bg); overflow: hidden; }
.g .mini i { display: block; height: 100%; border-radius: 6px; background: var(--bar); }
.g .mini.over i { background: var(--danger); }
.g .sub { font-size: .76rem; color: var(--muted); margin-top: 4px; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { display: flex; flex-direction: column; align-items: flex-start; min-width: 92px; padding: .45rem .8rem; border-radius: 14px; border: 1px solid var(--line); background: var(--field); }
.quick button b { font-size: .95rem; font-weight: 600; }
.quick button small { color: var(--brand); font-weight: 600; font-size: .8rem; }
.quick button:active { background: var(--soft); }

.erow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.erow:last-child { border-bottom: 0; }
.erow .nm { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erow .nm small { color: var(--muted); font-weight: 400; }
.erow .path { display: block; }
.erow > .ic { width: 16px; height: 16px; color: var(--muted); opacity: .55; }
.li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }

/* ---------- history ---------- */
.controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.controls > select, .controls > input { flex: 1; min-width: 150px; background: var(--card); }
#hsMonth { flex: 0 0 44%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 10px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); font-size: .85rem; }
.chip.on { background: var(--soft); border-color: transparent; color: var(--brand); font-weight: 600; }
.chip .ic { width: 14px; height: 14px; }
.hs-day { display: flex; justify-content: space-between; gap: 8px; margin: 16px 4px 6px; font-size: .86rem; font-weight: 600; color: var(--muted); }
.hs-group { padding: 0 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); content-visibility: auto; contain-intrinsic-size: auto 180px; }
#hsMore { display: flex; margin: 14px auto 4px; }

/* ---------- reports ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { min-width: 0; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.kpi span { display: block; font-size: .8rem; color: var(--muted); }
.kpi b { display: block; font-size: 1.32rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi:first-child { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); }
.kpi:first-child span { color: inherit; opacity: .85; }
.kpi:first-child .up, .kpi:first-child .down { color: inherit; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 8px; font-size: .95rem; }
.crumbs button { border: 0; background: none; color: var(--brand); padding: 4px 4px; border-radius: 8px; }
.crumbs button:last-of-type { color: var(--ink); font-weight: 700; }
.crumbs .sep { color: var(--muted); }
.bar-row { display: block; width: 100%; padding: 8px 0; border: 0; background: none; text-align: left; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; }
.bar-top .name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-top .name small { color: var(--muted); font-weight: 400; }
.bar-row .name::after { content: ' ›'; color: var(--muted); }
.bar-track { height: 9px; margin-top: 5px; border-radius: 6px; background: var(--bar-bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--hero-a), var(--hero-b)); }
.bar-fill.over { background: var(--danger); }
.bar-fill.warn { background: rgb(var(--accent-rgb)); }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th:first-child, .tbl td:first-child { text-align: left; white-space: normal; padding-left: 0; }
.tbl th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.tbl td small { display: block; color: var(--muted); font-size: .78rem; }
.tbl tbody tr[data-item] { cursor: pointer; }
.tbl tfoot td { border: 0; text-align: center; padding-top: 12px; }

.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-svg { display: block; min-width: 100%; height: auto; max-height: 240px; }
.chart-svg .axis { stroke: var(--line); }
.chart-svg text { font-family: inherit; text-anchor: middle; fill: var(--muted); }
.chart-svg .lbl { font-size: 14px; }
.chart-svg .val { font-size: 13px; fill: var(--ink); font-weight: 600; }
.chart-svg .col { cursor: pointer; outline: none; }
.chart-svg .hit { fill: transparent; }
.chart-svg .col.sel .hit, .chart-svg .col:focus-visible .hit { fill: var(--soft); }
.chart-svg .col.sel .lbl { fill: var(--brand); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 16px; margin: 4px 0 8px; }
.donut-wrap:empty { display: none; }
.donut-svg { flex: none; width: 132px; height: 132px; }
.donut-svg .d-big { font-size: 15px; font-weight: 700; fill: var(--ink); text-anchor: middle; font-family: inherit; }
.donut-svg .d-small { font-size: 10px; fill: var(--muted); text-anchor: middle; font-family: inherit; }
.donut-legend { display: grid; gap: 4px; min-width: 0; flex: 1; font-size: .85rem; }
.donut-legend div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.donut-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend i { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.donut-legend b { margin-left: auto; padding-left: 8px; font-variant-numeric: tabular-nums; }

.im-controls { flex-wrap: wrap; margin: 4px 0 10px; }
.im-controls input { background: var(--field); }
.im-wrap { margin: 0 -16px; padding: 0 16px; }
.tbl.im th, .tbl.im td { vertical-align: top; }
.tbl.im th:first-child, .tbl.im td:first-child { position: sticky; left: 0; z-index: 1; min-width: 116px; max-width: 150px; background: var(--card); }
.tbl.im td .q { display: block; font-weight: 600; }
.tbl.im td .a { display: block; font-size: .78rem; color: var(--muted); }
.tbl.im td .none { color: var(--line); }
.tbl.im .ch { margin-left: 2px; font-size: .72rem; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { padding-bottom: 2px; font-size: .72rem; color: var(--muted); text-align: center; }
.cal .c { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; aspect-ratio: 1; padding: 3px 5px; border: 0; border-radius: 9px; background: var(--bar-bg); color: var(--ink); text-align: left; }
.cal .c .n { font-size: .7rem; opacity: .85; }
.cal .c .v { align-self: flex-end; font-size: .62rem; font-weight: 700; white-space: nowrap; }
.cal .c.l1 { background: rgb(var(--brand-rgb) / .3); }
.cal .c.l2 { background: rgb(var(--brand-rgb) / .52); }
.cal .c.l3 { background: rgb(var(--brand-rgb) / .78); color: var(--brand-ink); }
.cal .c.l4 { background: var(--brand); color: var(--brand-ink); }
.cal .c.today { outline: 2px solid rgb(var(--accent-rgb)); outline-offset: 1px; }
.cal .blank { visibility: hidden; }

.staples { display: grid; gap: 10px; }
.staple { padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; }
.staple .head { display: flex; justify-content: space-between; gap: 8px; }
.staple .meta { font-size: .84rem; color: var(--muted); }
.staple .soon { color: var(--accent); font-weight: 600; }

.shop-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.shop-row:last-child { border-bottom: 0; }
.shop-row.done .grow > div:first-child { text-decoration: line-through; color: var(--muted); }
.budget-list { display: grid; gap: 12px; }
.budget-item .over { color: var(--danger); font-weight: 600; white-space: normal; }
.budget-item .path { white-space: normal; margin-top: 3px; }

/* ---------- settings ---------- */
.fold > summary { position: relative; display: block; padding-right: 28px; list-style: none; cursor: pointer; font-weight: 700; font-size: 1.02rem; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary small { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); }
.fold > summary::after { content: ''; position: absolute; right: 6px; top: 50%; width: 9px; height: 9px; margin-top: -7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.fold[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.fold[open] > summary { margin-bottom: 12px; }
.fold.danger > summary { color: var(--danger); }
.sync-line { margin: 0 0 4px; font-size: .9rem; font-weight: 600; }
.sync-line[data-state="ok"] { color: var(--brand); }
.sync-line[data-state="error"], .sync-line[data-state="denied"] { color: var(--danger); }
.budgets { display: grid; gap: 8px; }
.budget-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px; align-items: center; gap: 10px; }
.budget-row.total { padding-bottom: 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
.setup { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 13px; }
.setup summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.setup[open] summary { margin-bottom: 8px; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px dashed var(--line); }
.tree > ul { padding-left: 0; border: 0; }
.tree li { margin: 2px 0; }
.tree button { border: 0; background: none; padding: 5px 6px; border-radius: 8px; text-align: left; }
.tree button:active { background: var(--soft); }
.tree small { color: var(--muted); }
.fam-invite { margin: 0 0 12px; padding: 12px; border-radius: 13px; background: var(--soft); }
#famForm input { flex: 1; min-width: 0; }
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.palette { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; border-radius: 15px; border: 2px solid var(--line); background: var(--field); font-size: .85rem; text-align: left; }
.palette.on { border-color: var(--brand); }
.palette .sw { width: 100%; height: 30px; border-radius: 9px; }
.foot { margin: 18px 0 6px; text-align: center; font-size: .78rem; color: var(--muted); }
.foot a { color: inherit; }

/* ---------- login ---------- */
body.locked main, body.locked .tabs, body.locked #syncState { display: none !important; }
.auth { max-width: 440px; margin: 0 auto; padding: 24px 14px 40px; }
.auth-card { padding: 22px 18px; }
.auth-card h2 { font-size: 1.35rem; }
.btn.google { width: 100%; margin-top: 8px; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.pw .icon-btn { position: absolute; right: 2px; top: 5px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.auth-msg { min-height: 1.4em; margin: 12px 0 8px; font-size: .9rem; }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: var(--brand); }

/* ---------- bottom tabs, sheets, toast ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; border: 0; background: none; color: var(--muted); font-size: .74rem; }
.tabs b { font-weight: 500; }
.tabs .pill { display: grid; place-items: center; width: 58px; height: 30px; border-radius: 999px; }
.tabs .ic { width: 22px; height: 22px; }
.tabs button.active { color: var(--brand); }
.tabs button.active b { font-weight: 700; }
.tabs button.active .pill { background: var(--soft); }

dialog.sheet { width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; margin: auto auto 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  border: 0; border-radius: 22px 22px 0 0; background: var(--card); color: var(--ink); overflow-y: auto; overscroll-behavior: contain; }
dialog.sheet::backdrop { background: rgb(8 10 20 / .5); }
.sheet-actions { margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .spacer { display: none; }
.sheet-actions .btn.primary { flex: 1 1 100%; min-height: 50px; font-size: 1.05rem; }
.ih-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.ih-stats div { padding: 8px 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--field); font-size: .82rem; color: var(--muted); }
.ih-stats b { display: block; font-size: 1.05rem; color: var(--ink); }
.cat-list { margin-top: 4px; }
dialog.sheet [tabindex="-1"]:focus { outline: none; }
.cat-opt { display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 12px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.cat-opt .pp { color: var(--muted); font-size: .85rem; }
.cat-opt small { margin-left: auto; padding-left: 8px; color: var(--muted); font-size: .76rem; }
.cat-opt.new { align-items: center; color: var(--brand); font-weight: 600; }
.cat-opt:active { background: var(--soft); }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100% - 28px); padding: .6rem 1rem; border-radius: 13px;
  background: var(--ink); color: var(--bg); font-size: .94rem; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { margin-left: 10px; padding: .15rem .7rem; border-radius: 9px; border: 1px solid currentColor; background: none; color: inherit; font-weight: 700; }
.install-bar { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 11; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  max-width: calc(100% - 24px); padding: 5px 5px 5px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.install-bar .btn { min-height: 40px; padding: .35rem 1rem; border-radius: 999px; white-space: nowrap; }
.install-bar .icon-btn { width: 40px; height: 40px; border-radius: 50%; }
body.locked .install-bar { bottom: 16px; }

@media (min-width: 640px) {
  main { padding-top: 20px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  dialog.sheet { margin: auto; border-radius: 22px; }
}
@media (max-width: 380px) {
  .top { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .brand .by { display: none; }
  .hero { gap: 12px; padding: 16px 14px; }
  .mic { width: 66px; height: 66px; }
}
@media (prefers-reduced-motion: no-preference) {
  .mic.on { animation: pulse 1.2s ease-in-out infinite; }
  dialog.sheet[open] { animation: rise .18s ease-out; }
  .tabs .pill, .btn { transition: background-color .15s, transform .08s; }
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes rise { from { transform: translateY(28px); } }

/* printing the month summary */
.print-only { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  body { padding: 0; background: #fff; }
  #printArea { display: block !important; color: #000; font-size: 13px; }
  #printArea h1 { font-size: 20px; margin-bottom: 8px; }
  #printArea table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
  #printArea td { border-bottom: 1px solid #ccc; padding: 4px 6px; text-align: left; }
  #printArea td:last-child { text-align: right; }
}
