/* =========================================================================
   Family Finance Manager — Design system & layout
   Light + dark themes · responsive from 320px phones to wide desktops
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", "Noto Sans Bengali", "Hind Siliguri", Arial, sans-serif;
  --radius: 18px; --radius-sm: 12px; --radius-xs: 9px;
  --sidebar-w: 264px; --sidebar-wc: 84px; --topbar-h: 72px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --bg: #f4f6fb; --bg-2: #eef1f8; --surface: #ffffff; --surface-2: #f8f9fd; --surface-3: #eef1f7;
  --border: #e6e9f2; --border-strong: #d5dae6;
  --text: #0f172a; --text-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --primary: #4f46e5; --primary-2: #6366f1; --primary-soft: #eef0ff; --primary-ink: #3730a3;
  --success: #10b981; --success-soft: #e7f8f1; --success-ink: #047857;
  --danger: #f43f5e; --danger-soft: #feeef1; --danger-ink: #be123c;
  --warning: #f59e0b; --warning-soft: #fff6e0; --warning-ink: #b45309;
  --info: #0ea5e9; --info-soft: #e6f6fd; --info-ink: #0369a1;
  --violet: #8b5cf6; --violet-soft: #f2edff; --violet-ink: #6d28d9;
  --neutral-soft: #eef1f6; --neutral-ink: #475569;
  --grid: rgba(148, 163, 184, .18);
  --tooltip: #0f172a;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -6px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .25);
  --hero: linear-gradient(135deg, #4338ca 0%, #6d28d9 55%, #a21caf 120%);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0a0f1d; --bg-2: #0d1324; --surface: #121a2d; --surface-2: #162036; --surface-3: #1c2740;
  --border: #212c45; --border-strong: #2c3a58;
  --text: #e8edf7; --text-2: #c3cde0; --muted: #8e9bb5; --faint: #64718c;
  --primary: #818cf8; --primary-2: #a5b4fc; --primary-soft: rgba(129, 140, 248, .14); --primary-ink: #c7d2fe;
  --success: #34d399; --success-soft: rgba(52, 211, 153, .13); --success-ink: #6ee7b7;
  --danger: #fb7185; --danger-soft: rgba(251, 113, 133, .13); --danger-ink: #fda4af;
  --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .13); --warning-ink: #fcd34d;
  --info: #38bdf8; --info-soft: rgba(56, 189, 248, .13); --info-ink: #7dd3fc;
  --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .14); --violet-ink: #c4b5fd;
  --neutral-soft: rgba(148, 163, 184, .14); --neutral-ink: #cbd5e1;
  --grid: rgba(148, 163, 184, .1);
  --tooltip: #020617;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px -10px rgba(0, 0, 0, .5);
  --shadow-lg: 0 30px 70px -10px rgba(0, 0, 0, .7);
  --hero: linear-gradient(135deg, #3730a3 0%, #5b21b6 60%, #86198f 130%);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; transition: background .3s, color .3s; overflow-x: hidden; }
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
.ic { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.amt, .kpi-val, .hero-val, b, .tabular { font-variant-numeric: tabular-nums; }
.amt-pos { color: var(--success) !important; } .amt-neg { color: var(--danger) !important; } .amt-warn { color: var(--warning) !important; } .amt-neutral { color: var(--info) !important; }
.w-100 { width: 100%; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 18px; }
.is-hidden { display: none !important; }
.print-only { display: none; }
::selection { background: var(--primary-soft); }

/* ---------- Boot ---------- */
.boot { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); transition: opacity .45s var(--ease), visibility .45s; }
.boot.done { opacity: 0; visibility: hidden; }
.boot-logo { animation: pop .8s var(--spring) both; filter: drop-shadow(0 12px 24px rgba(79, 70, 229, .35)); }
.boot-text { font-weight: 700; font-size: 18px; letter-spacing: -.01em; animation: fadeUp .6s .15s var(--ease) both; }
.boot-bar { width: 140px; height: 4px; background: var(--border); border-radius: 9px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; background: var(--primary); border-radius: 9px; animation: slide 1.1s ease-in-out infinite; }
.boot-error { text-align: center; padding: 24px; } .boot-error button { margin-top: 12px; padding: 8px 18px; border-radius: 10px; border: 0; background: var(--primary); color: #fff; }

/* ---------- Animations ---------- */
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow { 0%, 100% { opacity: .55; transform: translate(0, 0) scale(1); } 50% { opacity: .85; transform: translate(-20px, 10px) scale(1.1); } }

/* ---------- Buttons ---------- */
.btn { --b: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--b); background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap; transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s, color .2s; position: relative; user-select: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .6); }
[data-theme="dark"] .btn-primary { color: #0b1020; }
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 10px 22px -8px rgba(79, 70, 229, .7); }
.btn-ghost { --b: var(--border); background: var(--surface); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); }
[data-theme="light"] .btn-soft { color: var(--primary); }
.btn-soft:hover { filter: brightness(.97); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger-ink); }
[data-theme="light"] .btn-danger-soft { color: var(--danger); }
.btn-light { background: rgba(255, 255, 255, .9); color: #111827; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 50px; font-size: 15px; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); transition: background .2s, transform .15s, color .2s; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: all .2s; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.col-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input { width: 100%; height: 44px; padding: 0 13px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s, background .2s; font-size: 15px; min-width: 0; }
textarea.input { height: auto; padding: 10px 13px; resize: vertical; min-height: 64px; }
select.input { appearance: none; -webkit-appearance: none; 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='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%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; text-overflow: ellipsis; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input:disabled { opacity: .65; }
input[type="date"].input, input[type="time"].input, input[type="month"].input { min-height: 44px; }
.field.has-error .input { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.field-err { color: var(--danger); font-size: 12.5px; font-weight: 600; animation: fadeUp .25s var(--ease); }
.input-wrap { position: relative; } .input-wrap .input { padding-right: 46px; }
.input-btn { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 38px; border: 0; background: none; color: var(--muted); border-radius: 9px; display: grid; place-items: center; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input, .radio-card input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.check.sub { padding: 2px 4px 0 30px; font-size: 13px; }
.amount-input { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface-2); padding-left: 16px; transition: border-color .2s, box-shadow .2s; --tone: var(--primary); }
.amount-input:focus-within { border-color: var(--tone); box-shadow: 0 0 0 4px var(--primary-soft); }
.amount-input b { font-size: 24px; color: var(--tone); font-weight: 700; }
.amount-input .input { border: 0; background: transparent; height: 58px; font-size: 28px; font-weight: 700; box-shadow: none !important; letter-spacing: -.01em; }
.amount-input.tone-danger { --tone: var(--danger); } .amount-input.tone-success { --tone: var(--success); } .amount-input.tone-info { --tone: var(--info); } .amount-input.tone-violet { --tone: var(--violet); } .amount-input.tone-warning { --tone: var(--warning); }
.quick-amts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.readonly-val { padding: 10px 13px; border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 700; }
.hint { display: block; position: relative; padding-left: 36px !important; font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; line-height: 1.45; }
.hint > .ic { position: absolute; left: 12px; top: 11px; width: 17px; height: 17px; color: var(--info); }
.hint.warn { background: var(--warning-soft); border-color: transparent; color: var(--text-2); } .hint.warn .ic { color: var(--warning); }
.hint.ok { background: var(--success-soft); border-color: transparent; } .hint.ok .ic { color: var(--success); }
.file-btn { cursor: pointer; }

/* Segmented control with sliding glider */
.segmented { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-3); border-radius: 13px; padding: 4px; margin-bottom: 16px; isolation: isolate; }
.segmented button { position: relative; z-index: 1; border: 0; background: none; height: 38px; border-radius: 10px; font-weight: 600; font-size: 13.5px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: color .25s; white-space: nowrap; padding: 0 8px; }
.segmented button .ic { width: 16px; height: 16px; }
.segmented button.active { color: var(--text); }
.seg-glider { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .4s var(--spring), background .3s; }
.seg-2 .seg-glider { width: calc((100% - 8px) / 2); } .seg-3 .seg-glider { width: calc((100% - 8px) / 3); } .seg-4 .seg-glider { width: calc((100% - 8px) / 4); }
.segmented .seg-expense.active { color: var(--danger); }
.segmented .seg-income.active { color: var(--success); } .segmented .seg-transfer.active { color: var(--info); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-style: normal; font-size: 11.5px; font-weight: 700; }

/* ---------- Badges / icons / avatars ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.4; }
.badge-success { background: var(--success-soft); color: var(--success-ink); } .badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); } .badge-info { background: var(--info-soft); color: var(--info-ink); }
.badge-violet { background: var(--violet-soft); color: var(--violet-ink); } .badge-primary { background: var(--primary-soft); color: var(--primary-ink); }
[data-theme="light"] .badge-primary { color: var(--primary); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-ink); }
.cat-ic { --c: var(--primary); display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.cat-ic .ic { width: 55%; height: 55%; max-width: 20px; max-height: 20px; }
.tone-bg-success { --c: var(--success); } .tone-bg-danger { --c: var(--danger); } .tone-bg-info { --c: var(--info); } .tone-bg-violet { --c: var(--violet); } .tone-bg-warning { --c: var(--warning); } .tone-bg-neutral { --c: var(--muted); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; font-weight: 700; flex: none; background: var(--primary-soft); color: var(--primary); overflow: hidden; }
[data-theme="dark"] span.avatar { filter: saturate(.9) brightness(.9); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); transition: background .3s, border-color .3s, transform .25s var(--ease), box-shadow .25s; }
.panel { padding: 20px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h3 { display: flex; align-items: center; gap: 9px; font-size: 15.5px; font-weight: 700; }
.panel-head h3 .ic { width: 18px; height: 18px; color: var(--primary); }
.panel-head .muted { font-size: 12.5px; }
.panel-link { font-size: 13px; font-weight: 600; }
.section-title { margin: 26px 0 12px; font-size: 15px; color: var(--muted); }
.empty { text-align: center; padding: 26px 16px; display: grid; justify-items: center; gap: 6px; }
.empty-ic { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 6px; animation: float 4s ease-in-out infinite; }
.empty-ic .ic { width: 26px; height: 26px; }
.empty h3 { font-size: 15.5px; } .empty p { color: var(--muted); font-size: 13.5px; max-width: 340px; }
.empty .btn { margin-top: 10px; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 0, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 800px 100%; animation: shimmer 1.3s infinite linear; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.auth-grid { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; min-height: 100dvh; }
.auth-art { position: relative; overflow: hidden; background: var(--hero); color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.auth-art::before, .auth-art::after { content: ""; position: absolute; border-radius: 50%; filter: blur(10px); }
.auth-art::before { width: 420px; height: 420px; background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%); top: -120px; right: -120px; animation: glow 9s ease-in-out infinite; }
.auth-art::after { width: 320px; height: 320px; background: radial-gradient(circle, rgba(236, 72, 153, .35), transparent 70%); bottom: -100px; left: -80px; animation: glow 11s ease-in-out infinite reverse; }
.art-card { position: relative; z-index: 1; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-radius: 20px; padding: 18px 20px; box-shadow: 0 20px 40px -18px rgba(0, 0, 0, .4); animation: fadeUp .8s var(--ease) both; }
.art-card small { opacity: .8; font-size: 12.5px; display: block; } .art-card b { font-size: 26px; letter-spacing: -.02em; }
.art-card.c1 { max-width: 360px; animation-delay: .1s; }
.art-bars { display: flex; align-items: flex-end; gap: 9px; height: 70px; margin-top: 12px; }
.art-bars i { flex: 1; background: rgba(255, 255, 255, .85); border-radius: 6px 6px 3px 3px; transform-origin: bottom; animation: grow .9s var(--spring) both; }
.art-bars i:nth-child(2) { animation-delay: .1s; } .art-bars i:nth-child(3) { animation-delay: .2s; } .art-bars i:nth-child(4) { animation-delay: .3s; } .art-bars i:nth-child(5) { animation-delay: .4s; } .art-bars i:nth-child(6) { animation-delay: .5s; }
.art-bars i { animation-name: barUp; } @keyframes barUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.art-card.c2, .art-card.c3 { display: flex; align-items: center; gap: 12px; max-width: 260px; padding: 13px 16px; }
.art-card.c2 { margin-left: 120px; animation-delay: .25s; } .art-card.c3 { animation-delay: .4s; margin-left: 40px; }
.art-card.c2 .ic, .art-card.c3 .ic { width: 38px; height: 38px; padding: 9px; border-radius: 12px; background: rgba(255, 255, 255, .2); }
.art-card.c2 b, .art-card.c3 b { font-size: 17px; }
.art-points { position: relative; z-index: 1; list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; animation: fadeUp .8s .55s var(--ease) both; }
.art-points li { display: flex; gap: 10px; align-items: center; font-weight: 500; opacity: .95; }
.art-points .ic { width: 18px; height: 18px; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 440px; animation: fadeUp .6s var(--ease) both; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-brand h1 { font-size: 22px; } .auth-brand p { color: var(--muted); font-size: 13.5px; }
.auth-card > h2 { font-size: 24px; margin-bottom: 4px; } .auth-card > p.muted { margin-bottom: 20px; }
.auth-note { display: flex; gap: 9px; align-items: flex-start; margin-top: 22px; font-size: 12.5px; color: var(--muted); line-height: 1.5; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.auth-note .ic { width: 16px; height: 16px; margin-top: 1px; color: var(--warning); }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--faint); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.chip-check { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check label { cursor: pointer; } .chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 11px; border: 1.5px solid var(--border); font-size: 13.5px; font-weight: 600; color: var(--muted); transition: all .2s; }
.chip-check span .ic { width: 16px; height: 16px; }
.chip-check input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chip-check input:focus-visible + span { outline: 2px solid var(--primary); }
.profile-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-bottom: 20px; }
.profile-opt { display: grid; justify-items: center; gap: 4px; padding: 14px 8px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface); transition: all .2s var(--ease); }
.profile-opt:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.profile-opt.active { border-color: var(--primary); background: var(--primary-soft); }
.profile-opt b { font-size: 13.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .profile-opt small { color: var(--muted); font-size: 11.5px; }
.demo-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; background: var(--warning-soft); color: var(--warning-ink); font-size: 12.5px; font-weight: 700; margin-bottom: 12px; }
.demo-pill .ic { width: 15px; height: 15px; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }
.sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; transition: width .35s var(--ease), transform .35s var(--ease), background .3s; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 18px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); min-width: 0; }
.brand img { flex: none; filter: drop-shadow(0 6px 12px rgba(79, 70, 229, .3)); }
.brand-text { display: grid; line-height: 1.15; white-space: nowrap; transition: opacity .2s; }
.brand-text strong { font-size: 15.5px; } .brand-text small { color: var(--muted); font-size: 12px; }
.collapse-btn { width: 34px; height: 34px; border: 0; background: transparent; }
.side-nav { display: grid; align-content: start; gap: 3px; overflow-y: auto; overflow-x: hidden; flex: 1; scrollbar-width: none; }
.side-nav a { position: relative; display: flex; align-items: center; gap: 13px; height: 46px; padding: 0 14px; border-radius: 13px; color: var(--muted); font-weight: 600; font-size: 14.5px; white-space: nowrap; transition: background .2s, color .2s; }
.side-nav a .ic { width: 21px; height: 21px; transition: transform .3s var(--spring); }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a:hover .ic { transform: scale(1.12); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .side-nav a.active { color: var(--primary-ink); }
.side-nav a.active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primary); animation: fadeIn .3s; }
.sidebar-foot { padding-top: 12px; }
.local-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; overflow: hidden; }
.local-note .ic { width: 18px; height: 18px; color: var(--success); margin-top: 1px; }
.local-note b { display: block; font-size: 13px; } .local-note small { color: var(--muted); }
.sidebar-scrim { display: none; }
body.sb-collapsed .sidebar { width: var(--sidebar-wc); }
body.sb-collapsed .brand-text, body.sb-collapsed .side-nav a span, body.sb-collapsed .local-note span { opacity: 0; pointer-events: none; width: 0; overflow: hidden; }
body.sb-collapsed .sidebar-head { flex-direction: column; gap: 12px; }
body.sb-collapsed .side-nav a { justify-content: center; padding: 0; }
body.sb-collapsed .side-nav a:hover::after { content: attr(data-tip); position: fixed; left: calc(var(--sidebar-wc) + 6px); padding: 6px 10px; border-radius: 8px; background: var(--tooltip); color: #fff; font-size: 12.5px; animation: fadeIn .15s; pointer-events: none; }
body.sb-collapsed .local-note { justify-content: center; }

.main { margin-left: var(--sidebar-w); min-width: 0; transition: margin .35s var(--ease); }
body.sb-collapsed .main { margin-left: var(--sidebar-wc); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: var(--topbar-h); padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid transparent; transition: border-color .3s; }
.menu-btn { display: none; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 21px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.storage-chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: all .2s; }
.storage-chip .ic { width: 15px; height: 15px; }
.storage-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); color: var(--success); animation: pulse 2.2s infinite; }
.storage-chip.tone-warn .dot { background: var(--warning); color: var(--warning); } .storage-chip.tone-bad .dot { background: var(--danger); color: var(--danger); }
.storage-chip.tone-bad { background: var(--danger-soft); color: var(--danger-ink); border-color: transparent; }
.user-menu { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: 8px; height: 42px; padding: 3px 10px 3px 4px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; transition: background .2s; }
.avatar-btn:hover { background: var(--surface-2); } .avatar-btn .ic { width: 16px; height: 16px; color: var(--muted); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: dropIn .22s var(--ease); z-index: 60; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.dd-head { display: flex; gap: 11px; align-items: center; padding: 8px 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-head b { display: block; font-size: 14px; } .dd-head small { color: var(--muted); font-size: 12px; }
.dropdown button { display: flex; align-items: center; gap: 11px; width: 100%; height: 40px; padding: 0 10px; border: 0; background: none; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--text-2); text-align: left; }
.dropdown button .ic { width: 18px; height: 18px; color: var(--muted); }
.dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown button.danger, .dropdown button.danger .ic { color: var(--danger); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

.view { padding: 8px 28px 48px; max-width: 1480px; margin: 0 auto; outline: none; }
.view.enter > * { animation: fadeUp .5s var(--ease) both; }
.view.enter > *:nth-child(2) { animation-delay: .04s; } .view.enter > *:nth-child(3) { animation-delay: .08s; } .view.enter > *:nth-child(4) { animation-delay: .12s; } .view.enter > *:nth-child(5) { animation-delay: .16s; } .view.enter > *:nth-child(6) { animation-delay: .2s; } .view.enter > *:nth-child(n+7) { animation-delay: .24s; }
.view > * + * { margin-top: 18px; }

/* Banners */
#banners { padding: 0 28px; max-width: 1480px; margin: 0 auto; display: grid; gap: 10px; }
#banners:not(:empty) { padding-top: 6px; padding-bottom: 6px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; animation: fadeUp .4s var(--ease); }
.banner > .ic { width: 20px; height: 20px; }
.banner span { flex: 1; }
.banner-demo { background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff; }
.banner-danger { background: var(--danger-soft); color: var(--danger-ink); } .banner-warn { background: var(--warning-soft); color: var(--text-2); } .banner-warn .ic { color: var(--warning); }
.banner-info { background: var(--info-soft); color: var(--text-2); } .banner-info > .ic { color: var(--info); }
.banner .icon-btn { border: 0; background: transparent; }

/* Bottom nav + FAB (mobile) */
.bottom-nav, .fab { display: none; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px; flex-wrap: wrap; }
.toolbar > div:first-child:not(.segmented):not(.search):not(.month-nav) { flex: 1; padding-left: 6px; }
.toolbar .segmented { margin: 0; flex: 1; max-width: 520px; }
.search { position: relative; flex: 1; min-width: 200px; }
.search > span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); display: flex; }
.search > span .ic { width: 18px; height: 18px; }
.search .input { padding-left: 40px; background: var(--surface-2); border-color: transparent; }
.search .input:focus { background: var(--surface); }
.sort-select { width: auto; min-width: 150px; }
.tb-actions { display: flex; gap: 8px; margin-left: auto; }
.filters { display: grid; grid-template-rows: 0fr; padding: 0 16px; transition: grid-template-rows .4s var(--ease), padding .4s var(--ease), opacity .3s, margin .4s; opacity: 0; overflow: hidden; border-width: 0; margin-top: 0 !important; }
.filters > * { min-height: 0; }
.filters.open { grid-template-rows: 1fr; padding: 16px; opacity: 1; border-width: 1px; margin-top: 12px !important; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; min-height: 0; overflow: hidden; }
.filters .btn { margin-top: 12px; justify-self: start; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: grid; gap: 2px; min-width: 0; }
.mini small { color: var(--muted); font-size: 12px; font-weight: 600; } .mini b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Transaction rows ---------- */
.day-group { padding: 6px; animation: fadeUp .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.day-group + .day-group { margin-top: 12px; }
.day-group header { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px 8px; }
.day-group header small { color: var(--muted); font-size: 12.5px; flex: 1; } .day-group header span { font-weight: 700; font-size: 13.5px; }
.tx-row { display: flex; align-items: center; gap: 13px; width: 100%; padding: 11px 12px; border: 0; background: none; border-radius: 14px; text-align: left; transition: background .2s, transform .2s var(--ease); }
.tx-row:hover { background: var(--surface-2); }
.tx-row:active { transform: scale(.99); }
.tx-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.tx-main b { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.tx-main small span { overflow: hidden; text-overflow: ellipsis; }
.tx-side { display: grid; justify-items: end; gap: 2px; flex: none; }
.tx-side .amt { font-size: 15px; } .tx-side small { color: var(--faint); font-size: 12px; }
.tx-list { display: grid; gap: 2px; margin: 0 -8px; }
.load-more { margin-top: 12px; }

/* ---------- Modal / sheet ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 28, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity .3s; }
.modal { position: relative; width: 100%; max-width: 560px; max-height: min(92vh, 860px); display: flex; flex-direction: column; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); opacity: 0; transform: translateY(18px) scale(.97); transition: transform .4s var(--spring), opacity .25s; }
.modal-sm { max-width: 440px; } .modal-lg { max-width: 760px; }
.modal-wrap.show .modal-backdrop { opacity: 1; } .modal-wrap.show .modal { opacity: 1; transform: none; }
.modal-wrap.hide .modal-backdrop { opacity: 0; } .modal-wrap.hide .modal { opacity: 0; transform: translateY(14px) scale(.98); transition-duration: .22s; }
.modal.shake { animation: shake .45s; }
.sheet-handle { display: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.modal-head > div { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-head h2 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; flex: none; background: var(--primary-soft); color: var(--primary); }
.modal-ic.tone-success { background: var(--success-soft); color: var(--success); } .modal-ic.tone-danger { background: var(--danger-soft); color: var(--danger); }
.modal-ic.tone-info { background: var(--info-soft); color: var(--info); } .modal-ic.tone-violet { background: var(--violet-soft); color: var(--violet); } .modal-ic.tone-warning { background: var(--warning-soft); color: var(--warning); } .modal-ic.tone-neutral { background: var(--neutral-soft); color: var(--muted); }
.modal-close { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 11px; }
.modal-body { padding: 14px 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.confirm-msg { color: var(--text-2); margin-bottom: 14px; line-height: 1.6; }
.action-list { display: grid; gap: 6px; }
.action-item { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 15px; border: 1px solid var(--border); background: var(--surface); text-align: left; transition: all .2s var(--ease); animation: fadeUp .35s var(--ease) both; }
.action-item:nth-child(2) { animation-delay: .04s; } .action-item:nth-child(3) { animation-delay: .08s; } .action-item:nth-child(4) { animation-delay: .12s; }
.action-item:hover { border-color: var(--primary); transform: translateX(3px); }
.action-item > span:nth-child(2) { flex: 1; display: grid; } .action-item b { font-size: 15px; } .action-item small { color: var(--muted); font-size: 12.5px; }
.action-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.action-ic.tone-danger { background: var(--danger-soft); color: var(--danger); } .action-ic.tone-success { background: var(--success-soft); color: var(--success); } .action-ic.tone-info { background: var(--info-soft); color: var(--info); } .action-ic.tone-violet { background: var(--violet-soft); color: var(--violet); }
.chev { color: var(--faint); width: 18px; height: 18px; }
.detail-hero { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface-2); margin-bottom: 14px; }
.detail-hero h3 { font-size: 16px; margin-bottom: 2px; } .detail-hero .amt { font-size: 24px; }
.detail-list { margin: 0; display: grid; }
.detail-list > div { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed var(--border); align-items: center; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 13px; } .detail-list dd { margin: 0; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; z-index: 120; right: 22px; bottom: 22px; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 12px 16px; border-radius: 14px; background: var(--tooltip); color: #fff; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(16px) scale(.96); transition: all .35s var(--spring); pointer-events: auto; }
.toast.show { opacity: 1; transform: none; }
.toast .ic { width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: var(--success); color: #fff; }
.toast-error .ic { background: var(--danger); } .toast-warning .ic { background: var(--warning); } .toast-info .ic { background: var(--info); }

/* ---------- Dashboard ---------- */
.dash-greet h2 { font-size: 24px; font-weight: 750; }
.dash-greet p { display: flex; align-items: center; gap: 6px; font-size: 13.5px; margin-top: 2px; } .dash-greet p .ic { width: 15px; height: 15px; }
.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; padding: 28px; background: var(--hero); color: #fff; border: 0; box-shadow: 0 24px 50px -20px rgba(79, 70, 229, .55); }
.hero-glow { position: absolute; width: 380px; height: 380px; right: -80px; top: -160px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 65%); animation: glow 10s ease-in-out infinite; pointer-events: none; }
.hero-main { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hero-main > small { font-size: 13.5px; opacity: .85; font-weight: 500; }
.hero-val { font-size: clamp(30px, 4.4vw, 46px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.hero-sub { opacity: .8; font-size: 13px; }
.hero-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.hero-btn { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 15px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; font-size: 13.5px; backdrop-filter: blur(6px); transition: all .2s var(--ease); }
.hero-btn:hover { background: rgba(255, 255, 255, .26); transform: translateY(-2px); }
.hero-btn .ic { width: 17px; height: 17px; }
.hero-accounts { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: center; }
.hero-acc { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); color: #fff; min-width: 0; transition: background .2s, transform .2s var(--ease); }
.hero-acc:hover { background: rgba(255, 255, 255, .22); transform: translateY(-2px); }
.hero-acc > span:last-child { display: grid; min-width: 0; } .hero-acc small { opacity: .8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .hero-acc b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ha-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .18); flex: none; } .ha-ic .ic { width: 17px; height: 17px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { --tone: var(--primary); --soft: var(--primary-soft); position: relative; overflow: hidden; padding: 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; animation: fadeUp .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms + .05s); }
.kpi[data-href] { cursor: pointer; }
.kpi:hover { transform: translateY(-3px); box-shadow: 0 18px 34px -16px rgba(15, 23, 42, .22); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: var(--soft); opacity: .7; transition: transform .5s var(--ease); }
.kpi:hover::after { transform: scale(1.3); }
.kpi.tone-success { --tone: var(--success); --soft: var(--success-soft); } .kpi.tone-danger { --tone: var(--danger); --soft: var(--danger-soft); } .kpi.tone-info { --tone: var(--info); --soft: var(--info-soft); }
.kpi.tone-violet { --tone: var(--violet); --soft: var(--violet-soft); } .kpi.tone-warning { --tone: var(--warning); --soft: var(--warning-soft); }
.kpi-top { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.kpi-top small { color: var(--muted); font-weight: 600; font-size: 13px; line-height: 1.3; }
.kpi-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--soft); color: var(--tone); flex: none; }
.kpi-ic .ic { width: 19px; height: 19px; }
.kpi-val { position: relative; z-index: 1; font-size: clamp(19px, 1.9vw, 25px); font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.kpi-sub { position: relative; z-index: 1; color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.trend .ic { width: 13px; height: 13px; }
.trend.up { color: var(--success-ink); background: var(--success-soft); } .trend.down { color: var(--danger-ink); background: var(--danger-soft); }
[data-theme="light"] .trend.up { color: var(--success-ink); }
.alert-strip { display: grid; gap: 8px; }
.budget-alert { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; color: var(--text-2); }
.budget-alert.warn { background: var(--warning-soft); } .budget-alert.warn .ic { color: var(--warning); }
.budget-alert.over { background: var(--danger-soft); } .budget-alert.over .ic { color: var(--danger); animation: pulse 2s infinite; border-radius: 50%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.today-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.today-stats > div { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); display: grid; min-width: 0; }
.today-stats small { color: var(--muted); font-size: 12px; } .today-stats b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-box { position: relative; height: 240px; } .chart-box.tall { height: 290px; }
.donut-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: center; }
.donut-box { position: relative; height: 200px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center small { color: var(--muted); font-size: 12px; } .donut-center b { font-size: 20px; font-weight: 800; }
.legend-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
.legend-list li { display: grid; grid-template-columns: 10px 1fr auto 40px; gap: 9px; align-items: center; font-size: 13.5px; }
.legend-list .dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-list .ll-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list small { color: var(--muted); text-align: right; }
.onboard { padding: 22px; background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%); }
.onboard-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.onboard-head > .ic { width: 42px; height: 42px; padding: 10px; border-radius: 13px; background: var(--primary); color: #fff; }
.onboard-head h3 { font-size: 17px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps li { counter-increment: s; position: relative; display: grid; gap: 6px; align-content: start; justify-items: start; padding: 16px 16px 16px 54px; border-radius: 15px; background: var(--surface); border: 1px solid var(--border); }
.steps li::before { content: counter(s); position: absolute; left: 16px; top: 16px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; }
.steps span { color: var(--muted); font-size: 13px; }
.budget-mini { display: grid; gap: 14px; }
.bm-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 14px; font-weight: 600; }
.bm-top > span { display: flex; align-items: center; gap: 9px; min-width: 0; } .bm-top small { color: var(--muted); font-weight: 500; white-space: nowrap; }
.bm-top .cat-ic { border-radius: 8px; }
.loan-mini { display: grid; gap: 4px; margin: 0 -8px; }
.lm { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 13px; color: var(--text); transition: background .2s; }
.lm:hover { background: var(--surface-2); }
.lm-main { flex: 1; display: grid; min-width: 0; } .lm-main b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .lm-main small { color: var(--muted); font-size: 12.5px; }
.lm-side { display: grid; justify-items: end; gap: 3px; }

/* Progress */
.progress { position: relative; height: 9px; border-radius: 99px; background: var(--surface-3); overflow: visible; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary-2), var(--primary)); transform-origin: left; animation: grow 1s var(--ease) both; max-width: 100%; }
.progress.ok > span, .progress.done > span { background: linear-gradient(90deg, #34d399, var(--success)); }
.progress.warn > span { background: linear-gradient(90deg, #fbbf24, var(--warning)); }
.progress.over > span { background: linear-gradient(90deg, #fb7185, var(--danger)); }
.progress .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--border-strong); border-radius: 2px; }

/* ---------- Accounts ---------- */
.acc-summary { display: flex; align-items: center; gap: 22px; padding: 20px 22px; flex-wrap: wrap; }
.acc-summary > div:first-child { display: grid; } .acc-summary > div:first-child small { color: var(--muted); font-weight: 600; font-size: 13px; } .acc-summary > div:first-child b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.acc-types { display: flex; flex-wrap: wrap; gap: 8px 16px; flex: 1; font-size: 13px; color: var(--muted); }
.acc-types span { display: inline-flex; align-items: center; gap: 6px; } .acc-types i { width: 9px; height: 9px; border-radius: 3px; } .acc-types b { color: var(--text); }
.acc-actions { display: flex; gap: 8px; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.acc-card { --c: var(--primary); position: relative; overflow: hidden; padding: 20px; display: flex; flex-direction: column; gap: 4px; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.acc-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.acc-card:hover { transform: translateY(-3px); }
.acc-card.archived { opacity: .65; }
.acc-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.acc-top > div:nth-child(2) { flex: 1; display: grid; min-width: 0; } .acc-top b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .acc-top small { color: var(--muted); font-size: 12.5px; }
.acc-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.acc-bal { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.acc-flow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.acc-flow > span { display: grid; grid-template-columns: auto 1fr; column-gap: 7px; padding: 9px 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.acc-flow .ic { grid-row: span 2; width: 16px; height: 16px; color: var(--muted); align-self: center; }
.acc-flow small { color: var(--muted); font-size: 11.5px; } .acc-flow b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; } .acc-foot small { color: var(--muted); }
.row-actions { display: inline-flex; gap: 6px; }

/* ---------- Loans ---------- */
.kpi-grid.kpi-4 .kpi-val { font-size: clamp(19px, 1.8vw, 24px); }
.loan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.loan-card { padding: 18px; display: grid; gap: 14px; cursor: pointer; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.loan-card:hover { transform: translateY(-3px); }
.loan-card.status-overdue { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.loan-card.status-paid { opacity: .8; }
.loan-top { display: flex; align-items: center; gap: 12px; }
.loan-top > div { flex: 1; display: grid; min-width: 0; } .loan-top b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .loan-top small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loan-amounts, .repay-summary, .bc-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.loan-amounts > div, .repay-summary > div, .bc-nums > div { padding: 9px 11px; border-radius: 12px; background: var(--surface-2); display: grid; min-width: 0; }
.loan-amounts small, .repay-summary small, .bc-nums small { color: var(--muted); font-size: 11.5px; }
.loan-amounts b, .repay-summary b, .bc-nums b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loan-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.loan-foot small { font-size: 12.5px; }
.loan-card .btn { justify-self: start; }
.repay-summary { margin-bottom: 16px; }
.loan-detail-top { display: grid; gap: 12px; margin-bottom: 10px; justify-items: start; } .loan-detail-top .repay-summary { width: 100%; margin: 0; } .loan-detail-top .progress { width: 100%; }
.sub-title { font-size: 14px; margin: 18px 0 10px; }
.repay-list { display: grid; gap: 8px; }
.repay-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 13px; background: var(--surface-2); }
.repay-item > span:first-child { color: var(--success); display: flex; }
.repay-item > div { flex: 1; display: grid; min-width: 0; } .repay-item small { color: var(--muted); font-size: 12.5px; }

/* ---------- Budgets ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-label { position: relative; min-width: 160px; text-align: center; font-size: 16px; cursor: pointer; }
.month-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.month-nav .input { width: auto; min-width: 150px; }
.budget-overview { display: flex; align-items: center; gap: 28px; padding: 22px; flex-wrap: wrap; }
.ring { --p: 0; --tone: var(--success); width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--tone) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; flex: none; animation: pop .7s var(--spring) both; }
.ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.ring > div { position: relative; display: grid; text-align: center; } .ring b { font-size: 26px; font-weight: 800; } .ring small { color: var(--muted); font-size: 12px; margin-top: -4px; }
.budget-overview.warn .ring { --tone: var(--warning); } .budget-overview.over .ring { --tone: var(--danger); }
.bo-stats { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.bo-stats > div { display: grid; } .bo-stats small { color: var(--muted); font-size: 12.5px; } .bo-stats b { font-size: 20px; font-weight: 750; }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.budget-card { padding: 18px; display: grid; gap: 14px; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.budget-card.over { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); } .budget-card.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
.bc-top { display: flex; align-items: center; gap: 12px; }
.bc-top > div { flex: 1; display: grid; min-width: 0; } .bc-top b { font-size: 15px; } .bc-top small { color: var(--muted); font-size: 12.5px; }
.bc-top small span { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; } .bc-top small .ic { width: 14px; height: 14px; }
.bc-foot { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.unbudgeted { display: grid; gap: 8px; }
.ub { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 13px; background: var(--surface-2); }
.ub span { flex: 1; font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Reports ---------- */
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px; flex-wrap: wrap; }
.report-head small { color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; }
.report-head h2 { font-size: 24px; margin: 2px 0; }
.report-kpis { display: grid; grid-template-columns: repeat(4, auto); gap: 10px 26px; }
.report-kpis > div { display: grid; } .report-kpis small { color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 600; } .report-kpis b { font-size: 19px; font-weight: 800; }
.report > * + * { margin-top: 18px; }
.statement { width: 100%; border-collapse: collapse; font-size: 14px; }
.statement td { padding: 10px 4px; border-bottom: 1px dashed var(--border); vertical-align: top; }
.statement td:first-child { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.statement td:first-child .ic { width: 17px; height: 17px; color: var(--muted); margin-top: 1px; }
.statement td small { flex-basis: 100%; padding-left: 27px; color: var(--muted); font-size: 12px; margin-top: -4px; }
.statement td:last-child { text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.statement tr.pos td:last-child { color: var(--success); } .statement tr.neg td:last-child { color: var(--danger); } .statement tr.muted td:last-child { color: var(--muted); }
.statement tr.strong td { font-weight: 700; } .statement tr.total td { border-bottom: 0; border-top: 2px solid var(--border-strong); font-size: 15.5px; padding-top: 12px; }
.statement + .hint { margin-top: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th:last-child, .data-table td:last-child { text-align: right; white-space: nowrap; }
.data-table td:first-child { display: flex; align-items: center; gap: 9px; }
.data-table td small { display: block; color: var(--muted); font-size: 11.5px; }
.data-table tr.total td { font-weight: 700; border-bottom: 0; }
.data-table .cat-ic { border-radius: 8px; }
.tx-table td:first-child { display: table-cell; white-space: nowrap; }
.table-scroll { overflow-x: auto; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
#rCats:not(:empty) { margin-bottom: 14px; }

/* ---------- Members ---------- */
.notice { display: flex; gap: 14px; padding: 16px 18px; align-items: flex-start; background: linear-gradient(135deg, var(--info-soft), var(--surface) 80%); }
.notice > .ic { width: 22px; height: 22px; color: var(--info); flex: none; margin-top: 2px; }
.notice p { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.member-card { position: relative; overflow: hidden; padding: 0 18px 18px; display: grid; justify-items: center; text-align: center; gap: 6px; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.member-card:hover { transform: translateY(-3px); }
.member-card.inactive { opacity: .6; }
.mc-cover { height: 64px; width: calc(100% + 36px); background: var(--hero); opacity: .9; margin-bottom: -36px; }
.member-card .avatar { border: 4px solid var(--surface); box-shadow: var(--shadow); }
.member-card h3 { font-size: 16px; margin-top: 4px; }
.you { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); vertical-align: middle; }
.mc-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 4px 0; }
.mc-stats { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; gap: 6px; margin: 6px 0; }
.mc-stats > div { display: grid; padding: 8px 4px; border-radius: 12px; background: var(--surface-2); } .mc-stats b { font-size: 15px; } .mc-stats small { color: var(--muted); font-size: 11px; }
.mc-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.avatar-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-edit > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .avatar-edit small { flex-basis: 100%; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.span-2 { grid-column: 1 / -1; }
.action-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { display: grid; justify-items: start; gap: 4px; padding: 16px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface-2); text-align: left; color: var(--text); cursor: pointer; transition: all .25s var(--ease); }
.tile > .ic { width: 38px; height: 38px; padding: 9px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); margin-bottom: 6px; transition: transform .35s var(--spring); }
.tile:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow); }
.tile:hover > .ic { transform: rotate(-8deg) scale(1.08); }
.tile b { font-size: 14.5px; } .tile small { color: var(--muted); font-size: 12.5px; }
.tile.disabled { opacity: .5; pointer-events: none; }
.howto { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); font-size: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone h3 .ic { color: var(--danger) !important; } .danger-zone p { margin-bottom: 14px; }
.settings-grid .panel > p.muted { margin-bottom: 14px; font-size: 14px; }
.settings-grid .field + .field { margin-top: 14px; } .settings-grid .segmented { margin-bottom: 0; }
.settings-grid .hint { margin-top: 14px; }
.app-foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 30px !important; }
.storage-info { display: grid; gap: 10px; }
.si-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.si-row > span { color: var(--muted); }
.storage-info .hint { margin-top: 6px; }
.storage-info .btn { justify-self: start; }
.restore-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 12px; }
.restore-meta > div { display: flex; gap: 10px; align-items: center; min-width: 0; } .restore-meta > div > span { display: grid; min-width: 0; } .restore-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .restore-meta small { color: var(--muted); font-size: 12.5px; }
.restore-meta .hint, .modal-body > .hint { margin-bottom: 12px; }
.restore-table td, .restore-table th { text-align: center !important; } .restore-table td:first-child, .restore-table th:first-child { text-align: left !important; }
.restore-options { display: grid; gap: 10px; margin-top: 16px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 15px; border: 1.5px solid var(--border); cursor: pointer; transition: border-color .2s, background .2s; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card.danger:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }
.radio-card > span { display: grid; gap: 3px; } .radio-card b { display: flex; align-items: center; gap: 7px; font-size: 14.5px; } .radio-card b .ic { width: 16px; height: 16px; } .radio-card small { color: var(--muted); font-size: 13px; }
.radio-card input { margin-top: 2px; }
.cat-add { display: flex; gap: 8px; margin-bottom: 14px; }
.cat-list { display: grid; gap: 6px; }
.cat-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 13px; border: 1px solid var(--border); }
.cat-item > span:nth-child(2) { flex: 1; display: grid; min-width: 0; } .cat-item b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .cat-item small { color: var(--muted); font-size: 12px; }
.cat-item .cat-ic { width: 36px; height: 36px; border-radius: 11px; }
.lock { color: var(--faint); display: flex; } .lock .ic { width: 16px; height: 16px; }
.icon-pick, .color-pick { display: flex; flex-wrap: wrap; gap: 7px; }
.icon-pick input, .color-pick input { position: absolute; opacity: 0; }
.icon-pick span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; border: 1.5px solid var(--border); color: var(--muted); cursor: pointer; transition: all .2s; }
.icon-pick input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.color-pick span { display: block; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--border); transition: transform .2s var(--spring); }
.color-pick input:checked + span { box-shadow: 0 0 0 2.5px var(--text); transform: scale(1.12); }

/* Viewer role: hide editing controls */
body.role-viewer .needs-edit, body.role-viewer #fab, body.role-viewer #quickAddTop, body.role-viewer .hero-actions { display: none !important; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid.kpi-4 { grid-template-columns: repeat(4, 1fr); }
  .report-kpis { grid-template-columns: repeat(2, auto); }
}
@media (min-width: 1281px) and (max-width: 1440px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }

@media (max-width: 1100px) {
  :root { --sidebar-w: 84px; }
  .sidebar { width: var(--sidebar-wc); }
  .brand-text, .side-nav a span, .local-note span { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }
  .sidebar-head { flex-direction: column; gap: 12px; }
  .collapse-btn { display: none; }
  .side-nav a { justify-content: center; padding: 0; }
  .main, body.sb-collapsed .main { margin-left: var(--sidebar-wc); }
  .hero { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-grid.kpi-4 { grid-template-columns: repeat(2, 1fr); }
  .auth-art { padding: 40px; }
}

/* Tablet / phone: off-canvas drawer + bottom navigation */
@media (max-width: 900px) {
  :root { --topbar-h: 62px; }
  .sidebar { z-index: 55; width: 286px !important; transform: translateX(-105%); box-shadow: var(--shadow-lg); padding-bottom: calc(18px + var(--safe-b)); }
  .brand-text, .side-nav a span, .local-note span { opacity: 1 !important; width: auto !important; pointer-events: auto !important; }
  .side-nav a { justify-content: flex-start !important; padding: 0 14px !important; }
  .sidebar-head { flex-direction: row !important; }
  body.drawer-open .sidebar { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 28, .45); opacity: 0; pointer-events: none; transition: opacity .3s; backdrop-filter: blur(2px); }
  body.drawer-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  .main, body.sb-collapsed .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar-title h1 { font-size: 18px; } .topbar-title p { display: none; }
  .hide-mobile { display: none !important; }
  .storage-chip .chip-text { display: none; }
  .storage-chip { width: 42px; height: 42px; padding: 0; justify-content: center; position: relative; }
  .storage-chip .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; }
  .storage-chip .ic { width: 18px; height: 18px; }
  .avatar-btn { padding: 3px; border: 0; background: none; }
  .view { padding: 6px 16px calc(110px + var(--safe-b)); }
  #banners { padding: 0 16px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; padding: 6px 8px calc(6px + var(--safe-b)); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--border); }
  .bn-item { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--faint); font-size: 11px; font-weight: 600; border-radius: 12px; transition: color .2s; }
  .bn-item .ic { width: 22px; height: 22px; transition: transform .3s var(--spring); }
  .bn-item.active { color: var(--primary); } .bn-item.active .ic { transform: translateY(-2px) scale(1.08); }
  .bn-item.active::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); margin-top: 1px; animation: pop .3s var(--spring); }
  .bn-item:not(.active)::after { content: ""; height: 6px; }
  .fab { display: grid; place-items: center; position: fixed; z-index: 46; left: 50%; bottom: calc(18px + var(--safe-b)); width: 60px; height: 60px; margin-left: -30px; border-radius: 20px; border: 4px solid var(--bg); background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; box-shadow: 0 12px 26px -8px rgba(79, 70, 229, .7); transition: transform .3s var(--spring); }
  [data-theme="dark"] .fab { color: #0b1020; }
  .fab .ic { width: 26px; height: 26px; transition: transform .35s var(--spring); }
  .fab:active { transform: scale(.9); } .fab:hover .ic { transform: rotate(90deg); }
  body.modal-open .fab .ic { transform: rotate(45deg); }
  #toast-root { left: 16px; right: 16px; bottom: calc(96px + var(--safe-b)); justify-items: center; }
  .toast { max-width: 100%; }
  .auth-grid { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { padding: 28px 18px calc(28px + var(--safe-b)); align-items: start; }
  .settings-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .dropdown { position: fixed; right: 12px; top: calc(var(--topbar-h) - 4px); }
}

/* Phones: bottom sheets, compact cards */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .view > * + * { margin-top: 14px; }
  .panel { padding: 16px; }
  .card { border-radius: 16px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 12px 10px; }
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal { max-width: none !important; max-height: 92vh; max-height: 92dvh; border-radius: 24px 24px 0 0; border-bottom: 0; transform: translateY(100%); opacity: 1; transition: transform .45s var(--ease); }
  .modal-wrap.show .modal { transform: none; } .modal-wrap.hide .modal { transform: translateY(100%); opacity: 1; }
  .sheet-handle { display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 9px auto 0; flex: none; }
  .modal-head { padding: 10px 16px 4px; } .modal-head h2 { font-size: 17px; }
  .modal-body { padding: 12px 16px 16px; }
  .modal-foot { padding: 12px 16px calc(12px + var(--safe-b)); }
  .modal-foot .btn { flex: 1; }
  .detail-list > div { grid-template-columns: 110px 1fr; }
  .dash-greet h2 { font-size: 20px; }
  .hero { padding: 20px; gap: 16px; border-radius: 22px; }
  .hero-accounts { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hero-acc { padding: 9px 10px; } .ha-ic { width: 30px; height: 30px; }
  .hero-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); } .hero-btn { justify-content: center; padding: 0 6px; min-width: 0; }
  .kpi-grid, .kpi-grid.kpi-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; gap: 4px; }
  .kpi-ic { width: 32px; height: 32px; border-radius: 10px; } .kpi-ic .ic { width: 16px; height: 16px; }
  .kpi-top { flex-direction: column; align-items: flex-start; gap: 8px; } .kpi-top small { font-size: 12px; }
  .kpi-val, .kpi-grid.kpi-4 .kpi-val { font-size: 18px; }
  .kpi-sub { font-size: 11.5px; } .kpi::after { width: 70px; height: 70px; }
  .today-stats { grid-template-columns: 1fr 1fr; }
  .chart-box { height: 210px; } .chart-box.tall { height: 240px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-box { width: 190px; height: 190px; } .legend-list { width: 100%; }
  .toolbar { padding: 8px; gap: 8px; }
  .toolbar .btn span, .toolbar .btn .hide-xs { display: none; }
  .toolbar .btn { padding: 0 12px; }
  .search { flex-basis: 100%; order: -1; }
  .sort-select { flex: 1; min-width: 0; }
  .toolbar .segmented { flex-basis: 100%; max-width: none; }
  .tb-actions { margin-left: 0; flex: 1; justify-content: flex-end; }
  .report-bar .month-nav { flex: 1; } .report-bar .month-nav .input { flex: 1; min-width: 0; }
  .report-bar .tb-actions { flex: none; }
  .month-bar .month-nav { flex: 1; justify-content: space-between; }
  .hide-xs { display: none !important; }
  .tx-row { padding: 10px 8px; gap: 11px; } .tx-row .cat-ic { width: 38px; height: 38px; border-radius: 12px; }
  .tx-main b { font-size: 14px; } .tx-main small .badge { display: none; }
  .day-group { padding: 4px; } .day-group header { padding: 9px 9px 6px; }
  .mini { padding: 10px 12px; } .mini b { font-size: 15px; }
  .acc-summary { padding: 18px; gap: 14px; } .acc-summary > div:first-child { flex-basis: 100%; }
  .acc-actions { width: 100%; } .acc-actions .btn { flex: 1; }
  .acc-grid, .loan-grid, .budget-grid, .member-grid { grid-template-columns: 1fr; gap: 12px; }
  .budget-overview { gap: 18px; padding: 18px; } .ring { width: 108px; height: 108px; } .ring b { font-size: 22px; }
  .bo-stats { grid-template-columns: 1fr 1fr; } .bo-stats b { font-size: 16px; }
  .report-head { padding: 18px; } .report-head h2 { font-size: 20px; }
  .report-kpis { grid-template-columns: 1fr 1fr; width: 100%; } .report-kpis b { font-size: 16px; }
  .data-table { font-size: 13px; } .data-table th, .data-table td { padding: 8px 5px; }
  .action-tiles { grid-template-columns: 1fr 1fr; gap: 10px; } .tile { padding: 13px; } .tile b { font-size: 13.5px; } .tile small { font-size: 12px; }
  .amount-input .input { font-size: 24px; height: 54px; }
  .segmented button { font-size: 12.5px; padding: 0 4px; } .segmented button .ic { display: none; }
  .profile-pick { grid-template-columns: repeat(3, 1fr); }
  .restore-meta { flex-wrap: wrap; }
  .banner { flex-wrap: wrap; font-size: 13px; }
}
@media (max-width: 380px) {
  .view { padding-left: 12px; padding-right: 12px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-actions { gap: 6px; }
  .icon-btn, .storage-chip { width: 38px; height: 38px; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-val, .kpi-grid.kpi-4 .kpi-val { font-size: 16px; }
  .hero-val { font-size: 28px; }
  .hero-accounts { grid-template-columns: 1fr; }
  .action-tiles { grid-template-columns: 1fr; }
  .loan-amounts b, .repay-summary b, .bc-nums b { font-size: 12.5px; }
  .today-stats b { font-size: 13px; }
  .profile-pick { grid-template-columns: repeat(2, 1fr); }
  .hero-btn { font-size: 12.5px; gap: 4px; } .hero-btn .ic { width: 15px; height: 15px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* =========================================================================
   Print (browser → Save as PDF)
   ========================================================================= */
@media print {
  :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f6f7fb; --surface-3: #eef1f6; --border: #dde2ec; --border-strong: #c9d0dd; --text: #0f172a; --text-2: #334155; --muted: #5b6577; color-scheme: light; }
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .bottom-nav, .fab, #banners, #toast-root, .no-print, .modal-wrap, .sidebar-scrim { display: none !important; }
  .main { margin: 0 !important; }
  .view { padding: 0 !important; max-width: none; }
  .view.enter > * { animation: none !important; }
  .card { box-shadow: none !important; border: 1px solid #dde2ec; break-inside: avoid; }
  .grid-2 { grid-template-columns: 1fr 1fr !important; }
  .print-only { display: block; } .print-meta { font-size: 11px; color: #5b6577; flex-basis: 100%; }
  .print-break { break-before: page; }
  .chart-box { height: 220px !important; }
  .table-scroll { overflow: visible; }
  .progress > span, .art-bars i { animation: none !important; }
  a { color: inherit; }
}

/* =========================================================================
   v2 — cloud login, account logos, avatar fixes
   ========================================================================= */
.acc-logo { --bg: var(--primary); --fg: #fff; display: inline-grid; place-items: center; flex: none; border-radius: 30%; background: var(--bg); color: var(--fg); font-weight: 800; letter-spacing: -.02em; line-height: 1; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 2px 6px -2px color-mix(in srgb, var(--bg) 60%, transparent); overflow: hidden; vertical-align: middle; }
.acc-logo .ic { width: 52%; height: 52%; }
.acc-logo.img { object-fit: contain; background: #fff; padding: 8%; box-shadow: inset 0 0 0 1px var(--border); }
.tx-main small .acc-logo { margin-right: -2px; border-radius: 5px; box-shadow: none; }
.tx-main small .acc-logo.text { font-size: 7px !important; }
.detail-list dd .acc-logo, .data-table .acc-logo { border-radius: 7px; }
.hero-acc .acc-logo { box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.acc-top .acc-logo { border-radius: 15px; }
.acc-card::before { background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 40%, transparent)); }
.chip-check span .acc-logo { border-radius: 6px; box-shadow: none; }
.chip-check span .acc-logo.text { font-size: 9px !important; }
.logo-edit { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.logo-edit > div { display: grid; gap: 4px; min-width: 0; } .logo-edit small { font-size: 12.5px; }
.logo-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
#logoPrev .acc-logo { animation: pop .45s var(--spring); }

/* Member cards: avatar always above the cover */
.member-card { padding-top: 0; }
.mc-cover { position: relative; z-index: 0; height: 76px; margin-bottom: 0; }
.mc-avatar { position: relative; z-index: 2; margin-top: -46px; border-radius: 50%; padding: 4px; background: var(--surface); box-shadow: 0 10px 24px -10px rgba(15, 23, 42, .45); transition: transform .35s var(--spring); }
.member-card:hover .mc-avatar { transform: scale(1.05); }
.mc-avatar .avatar { display: block; border: 0 !important; box-shadow: none !important; }
.member-card .avatar { border: 0; }
.mc-email { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-email .ic { width: 14px; height: 14px; flex: none; }
img.avatar { display: inline-block; }

/* Profile photo editor */
.avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0 4px; }
.av-pick { position: relative; cursor: pointer; border-radius: 50%; display: block; }
.av-pick #avPrev { display: block; border-radius: 50%; padding: 4px; background: linear-gradient(135deg, var(--primary-2), #db2777); }
.av-pick #avPrev .avatar { display: block; border: 3px solid var(--surface); }
.av-cam { position: absolute; right: 2px; bottom: 4px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; border: 3px solid var(--surface); transition: transform .25s var(--spring); }
.av-cam .ic { width: 16px; height: 16px; }
.av-pick:hover .av-cam { transform: scale(1.12) rotate(-8deg); }
.av-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pop-in { animation: pop .45s var(--spring); }

/* Auth v2 */
.auth-tabs { margin: 16px 0 18px; }
.auth-card > h2 { margin-top: 4px; }
.input-ic { position: relative; }
.input-ic > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.input-ic .input { padding-left: 40px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.link { border: 0; background: none; color: var(--primary); font-weight: 700; padding: 0; }
.link:hover { text-decoration: underline; }
.mb-2 { margin-bottom: 12px; }
.art-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-size: 20px; animation: fadeUp .6s var(--ease) both; }
.art-brand img { filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .25)); }
.art-title { position: relative; z-index: 1; font-size: clamp(28px, 3vw, 40px); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; animation: fadeUp .6s .05s var(--ease) both; }
.art-card.c2 .acc-logo, .art-card.c3 .acc-logo { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.setup-steps { margin: 14px 0; padding-left: 22px; display: grid; gap: 10px; color: var(--text-2); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--primary-ink); }
[data-theme="light"] code { color: var(--primary); }

/* Cloud status */
.storage-chip.tone-busy .dot { background: var(--warning); color: var(--warning); animation: pulse 1s infinite; }
.storage-chip.tone-warn { background: var(--warning-soft); border-color: transparent; color: var(--warning-ink); }
.cloud-card { background: linear-gradient(135deg, var(--primary-soft), var(--surface) 65%); }
.cloud-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cloud-hero > div { flex: 1; min-width: 200px; }
.cloud-hero small { color: var(--primary); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.cloud-hero h3 { font-size: 20px; margin: 2px 0; }
.cloud-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--hero); color: #fff; box-shadow: 0 10px 22px -10px rgba(79, 70, 229, .7); }
.cloud-ic .ic { width: 26px; height: 26px; }
.fam-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 16px; max-width: 520px; }
.fam-form .field { flex: 1; }
@media (max-width: 640px) {
  .logo-edit { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .logo-btns { justify-content: center; }
  .fam-form .btn span { display: inline; }
  .cloud-hero .btn span { display: none; }
}
