:root {
  --bg: #f5f6f8; --card: #ffffff; --ink: #14161a; --ink2: #5b6270; --ink3: #98a0ad;
  --line: #e8eaee; --soft: #f0f2f5; --accent: #0f766e; --accent-soft: #e0f2ef;
  --good: #0f9f6e; --good-bg: #e3f6ee; --warn: #c27803; --warn-bg: #fdf1d8; --bad: #d6403a; --bad-bg: #fde8e7;
  --blue: #3b6fe0; --blue-bg: #e7eefc;
  --shadow: 0 1px 2px rgba(20,22,26,.04), 0 4px 16px rgba(20,22,26,.04);
  --r: 16px; --nav-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
}
@media all {
  :root[data-theme="dark"] {
    --bg: #0e1013; --card: #171a1f; --ink: #eef0f3; --ink2: #a3aab6; --ink3: #6b7280;
    --line: #262a31; --soft: #1e2228; --accent: #2dd4bf; --accent-soft: #123430;
    --good: #34d399; --good-bg: #11322a; --warn: #fbbf24; --warn-bg: #36290c; --bad: #f87171; --bad-bg: #3a1a19;
    --blue: #7aa2ff; --blue-bg: #1a2640; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--ink2); } .faint { color: var(--ink3); }
.hide { display: none !important; }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.sidebar { display: none; }
.main { padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topbar h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--ink2); font-size: 13px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.bottom-nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink3); font-size: 10.5px; font-weight: 500; padding: 6px 0; }
.bottom-nav button svg { width: 22px; height: 22px; }
.bottom-nav button.on { color: var(--accent); }
.bottom-nav .fab { width: 50px; height: 50px; border-radius: 50%; background: var(--ink); color: var(--bg); margin: -22px auto 0; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); padding: 0; }
.bottom-nav .fab svg { width: 24px; height: 24px; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; padding: 24px 16px; border-right: 1px solid var(--line); background: var(--card); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; padding: 4px 10px 22px; }
  .brand i { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
  .brand i svg { width: 17px; height: 17px; }
  .side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: none; border: 0; color: var(--ink2); font-weight: 500; text-align: left; width: 100%; }
  .side-link svg { width: 19px; height: 19px; }
  .side-link:hover { background: var(--soft); }
  .side-link.on { background: var(--accent-soft); color: var(--accent); }
  .side-spacer { flex: 1; }
  .main { padding: 32px 36px 60px; width: 100%; }
  .bottom-nav { display: none; }
  .topbar h1 { font-size: 28px; }
}

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 .h3-extra { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12.5px; }
.grid { display: grid; gap: 14px; }
.grid.kpis { grid-template-columns: repeat(2, 1fr); }
.grid.two { grid-template-columns: 1fr; }
@media (max-width: 899px) { .grid.kpis > :last-child:nth-child(odd) { grid-column: span 2; } }
@media (max-width: 640px) { .hide-m { display: none; } }
.spin-icon { animation: sp .8s linear infinite; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.two.wide-left { grid-template-columns: 1.5fr 1fr; } .grid.kpis { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 900px) and (max-width: 1150px) { .grid.kpis { grid-template-columns: repeat(3, 1fr); } .grid.kpis > :last-child { grid-column: auto; } }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 14px; font-weight: 600; font-size: 14px; display: inline-flex; gap: 7px; align-items: center; justify-content: center; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn svg { width: 17px; height: 17px; }
.btn.icon { padding: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--ink2); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.blue { background: var(--blue-bg); color: var(--blue); }

.seg { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.kpi { padding: 14px; }
.kpi .l { font-size: 12px; color: var(--ink2); font-weight: 500; }
.kpi .v { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 11.5px; color: var(--ink3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero { background: var(--ink); color: var(--bg); border-color: var(--ink); grid-column: span 2; }
.kpi.hero .l, .kpi.hero .s { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.kpi.hero .v { font-size: 28px; }
@media (min-width: 900px) { .kpi.hero { grid-column: span 2; } }
.pos { color: var(--good); } .neg { color: var(--bad); }

.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar.good > i { background: var(--good); } .bar.warn > i { background: #e6a117; } .bar.bad > i { background: var(--bad); }
.bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .55; }

.rule { padding: 12px 0; border-top: 1px solid var(--line); } .rule:first-of-type { border-top: 0; padding-top: 0; }
.rule .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 500; }
.rule .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink2); margin-top: 6px; }

.list > .row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list > .row:first-child { border-top: 0; }
.ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--soft); color: var(--ink2); font-weight: 700; font-size: 13px; }
.ico svg { width: 18px; height: 18px; }
.ico.in { background: var(--good-bg); color: var(--good); } .ico.out { background: var(--bad-bg); color: var(--bad); } .ico.tr { background: var(--blue-bg); color: var(--blue); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .d { font-size: 12.5px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { text-align: right; font-weight: 700; white-space: nowrap; }
.row .amt small { display: block; font-weight: 500; color: var(--ink3); font-size: 12px; }
.row .thumb { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.row.click { cursor: pointer; }
.day { font-size: 12px; font-weight: 600; color: var(--ink3); text-transform: uppercase; letter-spacing: .05em; padding: 14px 0 2px; }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.r, td.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: var(--soft); } tfoot td:first-child { border-radius: 10px 0 0 10px; } tfoot td:last-child { border-radius: 0 10px 10px 0; }
td.dim { color: var(--ink3); }
.cat-cell { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.cat-cell .bar { height: 5px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .lbl { font-size: 12px; font-weight: 600; color: var(--ink2); }
.input, select.input, textarea.input { width: 100%; background: var(--soft); border: 1.5px solid transparent; border-radius: 12px; padding: 11px 13px; font-size: 16px; outline: none; transition: border-color .15s, background .15s; appearance: none; -webkit-appearance: none; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239aa1ad' stroke-width='2'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.input:focus { border-color: var(--accent); background: var(--card); }
.input.big { font-size: 30px; font-weight: 700; padding: 14px 16px; letter-spacing: -.02em; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2.amt-cur { grid-template-columns: 1fr 110px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--soft); border-radius: 12px; margin-bottom: 14px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--ink3); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::after { transform: translateX(18px); }
.cell-input { background: var(--soft); border: 1.5px solid transparent; border-radius: 9px; padding: 7px 9px; font-size: 14px; width: 100%; min-width: 80px; outline: none; }
.cell-input:focus { border-color: var(--accent); background: var(--card); }
.cell-input.num { text-align: right; }

.drop { border: 1.5px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; color: var(--ink2); background: var(--soft); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop svg { width: 28px; height: 28px; color: var(--accent); }
.receipt-prev { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }
.receipt-prev img { display: block; width: 100%; max-height: 260px; object-fit: contain; }
.receipt-prev .x { position: absolute; top: 8px; right: 8px; }
.scan-status { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- modal / sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,12,16,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.modal { background: var(--card); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 14px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2,.8,.2,1); }
.modal .grab { width: 38px; height: 4px; background: var(--line); border-radius: 99px; margin: 0 auto 14px; }
.modal h2 { margin: 0 0 16px; font-size: 20px; letter-spacing: -.02em; display: flex; justify-content: space-between; align-items: center; }
.modal .actions { display: flex; gap: 10px; margin-top: 8px; } .modal .actions .btn { flex: 1; padding: 13px; }
@media (min-width: 700px) { .overlay { align-items: center; } .modal { max-width: 520px; border-radius: 22px; padding: 22px; } .modal .grab { display: none; } }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(30px); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 500; font-size: 14px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .25s; max-width: 90vw; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- misc ---------- */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; } .legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend span.v { margin-left: auto; font-weight: 600; }
.empty { text-align: center; color: var(--ink3); padding: 28px 10px; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav .lab { min-width: 130px; text-align: center; font-weight: 600; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink2); white-space: nowrap; cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--ink2); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.goal-ring { width: 64px; height: 64px; flex: none; }
.note { font-size: 12.5px; color: var(--ink2); background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.sect-title { font-size: 17px; font-weight: 700; margin: 22px 0 10px; letter-spacing: -.01em; display: flex; justify-content: space-between; align-items: center; }
.coin { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--soft); font-size: 9px; font-weight: 700; margin-right: 6px; vertical-align: middle; color: var(--ink2); }
.more-menu button { display: flex; width: 100%; align-items: center; gap: 14px; padding: 14px 4px; background: none; border: 0; border-top: 1px solid var(--line); font-weight: 600; font-size: 16px; text-align: left; }
.more-menu button:first-child { border-top: 0; } .more-menu svg { width: 22px; height: 22px; color: var(--accent); }
.view { animation: fade .25s; }

/* ---------- Auth Screen ---------- */
.auth-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--bg); box-sizing: border-box; }
.auth-card { width: 100%; max-width: 400px; padding: 28px 20px; border-radius: 20px; box-shadow: var(--shadow); margin: auto; }
.auth-brand { text-align: center; margin-bottom: 8px; }
.auth-brand i { width: 44px; height: 44px; border-radius: 14px; background: var(--ink); color: var(--bg); display: inline-grid; place-items: center; margin-bottom: 12px; }
.auth-brand i svg { width: 24px; height: 24px; }
.auth-brand h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; font-weight: 700; }
.user-badge { margin-top: 8px; }

.grid > * { min-width: 0; margin-top: 0 !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
@media (max-width: 480px) {
  .kpi .v { font-size: 18px; }
  .kpi.hero .v { font-size: 26px; }
  .modal { padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
  .auth-card { padding: 22px 16px; }
}

/* =====================================================================
   LIQUID GLASS THEME  (overrides above; works on phone + desktop)
   ===================================================================== */
:root {
  --bg: #eaf0f7;
  --glass: rgba(255,255,255,.56); --glass-strong: rgba(255,255,255,.80); --glass-brd: rgba(255,255,255,.75);
  --glass-shadow: 0 10px 34px rgba(30,41,59,.10), 0 2px 6px rgba(30,41,59,.04);
  --glass-hi: inset 0 1px 0 rgba(255,255,255,.85), inset 0 -1px 0 rgba(255,255,255,.25);
  --soft: rgba(15,23,42,.055); --line: rgba(15,23,42,.09);
  --blur: blur(22px) saturate(180%);
  --grad-a: #5eead4; --grad-b: #93c5fd; --grad-c: #f0abfc;
  --hero-1: #0f766e; --hero-2: #2563eb;
}
@media all {
  :root[data-theme="dark"] {
    --bg: #0a0d12;
    --glass: rgba(30,38,50,.48); --glass-strong: rgba(26,32,43,.78); --glass-brd: rgba(255,255,255,.10);
    --glass-shadow: 0 12px 40px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
    --glass-hi: inset 0 1px 0 rgba(255,255,255,.12), inset 0 -1px 0 rgba(255,255,255,.03);
    --soft: rgba(255,255,255,.075); --line: rgba(255,255,255,.10);
    --grad-a: #0d9488; --grad-b: #1d4ed8; --grad-c: #7c3aed;
    --hero-1: #0d9488; --hero-2: #4f46e5;
  }
}
html { background: var(--bg); }
body { background: transparent; min-height: 100vh; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(48vmax 48vmax at 8% 6%, color-mix(in srgb, var(--grad-a) 55%, transparent), transparent 62%),
    radial-gradient(52vmax 52vmax at 96% 12%, color-mix(in srgb, var(--grad-b) 50%, transparent), transparent 60%),
    radial-gradient(56vmax 56vmax at 70% 104%, color-mix(in srgb, var(--grad-c) 42%, transparent), transparent 60%),
    var(--bg);
}

.card, .modal, .sidebar, .bottom-nav, .toast, .auth-card {
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.card { background: var(--glass); border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow), var(--glass-hi); border-radius: 22px; }
.sidebar { background: var(--glass) !important; border-right: 1px solid var(--glass-brd) !important; box-shadow: var(--glass-hi); }
.side-link.on { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); }
.side-link:hover { background: var(--soft); }
.brand i, .auth-brand i { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.28); }

/* floating glass tab bar on phones */
.bottom-nav {
  left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); height: var(--nav-h); padding-bottom: 0;
  border-radius: 28px; background: var(--glass); border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow), var(--glass-hi);
}
.bottom-nav button { border-radius: 20px; }
.bottom-nav .fab { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; box-shadow: 0 10px 24px rgba(37,99,235,.35), inset 0 1px 0 rgba(255,255,255,.4); }
.main { padding-bottom: calc(var(--nav-h) + 44px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); background: var(--glass-strong); color: var(--ink); border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow); }
@media (min-width: 900px) { .main { padding-bottom: 60px; } .toast { bottom: 28px; } }
@media (min-width: 1500px) { .main { max-width: 1320px; } }

/* controls */
.btn { background: var(--glass); border: 1px solid var(--glass-brd); box-shadow: var(--glass-hi); transition: transform .12s, background .15s, box-shadow .15s; }
.btn:hover { background: var(--glass-strong); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 86%, #fff), var(--ink)); color: var(--bg); border-color: transparent; }
.btn.accent { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); border-color: transparent; color: #fff; }
.seg { background: var(--soft); box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.seg button.on { background: var(--glass-strong); box-shadow: 0 2px 8px rgba(0,0,0,.12), var(--glass-hi); }
.input, select.input, textarea.input { background-color: rgba(255,255,255,.5); border: 1.5px solid var(--glass-brd); }
:root[data-theme="dark"] .input, :root[data-theme="dark"] select.input, :root[data-theme="dark"] textarea.input { background-color: rgba(255,255,255,.06); }
.input:focus { background-color: var(--glass-strong); border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.cell-input { background: var(--soft); }
.chip { background: var(--glass); border-color: var(--glass-brd); }
.chip.on { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border-color: transparent; }
.pill { backdrop-filter: blur(6px); }
.bar { background: var(--soft); }
.note { background: var(--soft); }
.drop { background: var(--soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.switch input:checked + span { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); }
tfoot td { background: var(--soft); }

/* modals */
.overlay { background: rgba(8,12,20,.38); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal { background: var(--glass-strong); border: 1px solid var(--glass-brd); box-shadow: 0 24px 80px rgba(0,0,0,.28), var(--glass-hi); max-height: 90vh; max-height: 90dvh; }
.modal .grab { background: var(--ink3); opacity: .5; }

/* KPI hero */
.kpi.hero {
  background: linear-gradient(135deg, color-mix(in srgb, var(--hero-1) 92%, transparent), color-mix(in srgb, var(--hero-2) 90%, transparent)) !important;
  color: #fff !important; border: 1px solid rgba(255,255,255,.28) !important;
  box-shadow: 0 16px 40px rgba(37,99,235,.28), inset 0 1px 0 rgba(255,255,255,.45) !important; position: relative; overflow: hidden;
}
.kpi.hero::after { content: ''; position: absolute; width: 260px; height: 260px; right: -70px; top: -110px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.35), transparent 70%); pointer-events: none; }
.kpi.hero .l, .kpi.hero .s { color: rgba(255,255,255,.78) !important; }
.kpi.hero .v { color: #fff; }

/* ---------- auth: phone + desktop ---------- */
.app.auth-mode { display: block; }
.auth-container { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: clamp(14px, 4vw, 48px) clamp(14px, 4vw, 48px) calc(clamp(14px, 4vw, 48px) + env(safe-area-inset-bottom)); background: none; }
.auth-shell { width: 100%; max-width: 440px; }
.auth-hero { display: none; }
.auth-card { width: 100%; max-width: none; margin: 0; padding: 28px 22px; }
.auth-seg { display: flex; width: 100%; margin: 18px 0 16px; }
.auth-seg button { flex: 1; padding: 10px; }
.auth-submit { width: 100%; margin-top: 10px; padding: 13px; font-size: 15px; }
.auth-demo { width: 100%; padding: 11px; font-size: 14px; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; }
.auth-or span { flex: 1; height: 1px; background: var(--line); }
.auth-or em { font-style: normal; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink3); }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; }
@media (min-width: 900px) {
  .auth-shell {
    max-width: 1020px; display: grid; grid-template-columns: 1.08fr 1fr; border-radius: 34px; overflow: hidden;
    border: 1px solid var(--glass-brd); box-shadow: 0 30px 80px rgba(30,41,59,.22), var(--glass-hi);
  }
  .auth-hero {
    display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 56px 52px; color: #fff; position: relative; overflow: hidden;
    background: linear-gradient(145deg, color-mix(in srgb, var(--hero-1) 94%, #000), color-mix(in srgb, var(--hero-2) 92%, #000));
  }
  .auth-hero::before { content: ''; position: absolute; width: 420px; height: 420px; right: -140px; top: -140px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.28), transparent 70%); }
  .auth-hero::after { content: ''; position: absolute; width: 360px; height: 360px; left: -120px; bottom: -150px; border-radius: 50%; background: radial-gradient(circle, rgba(240,171,252,.35), transparent 70%); }
  .auth-hero > * { position: relative; z-index: 1; }
  .auth-hero-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
  .auth-hero-brand i { width: 34px; height: 34px; border-radius: 11px; background: rgba(255,255,255,.2); display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); }
  .auth-hero-brand i svg { width: 19px; height: 19px; }
  .auth-hero h1 { font-size: 38px; line-height: 1.12; letter-spacing: -.03em; margin: 18px 0 0; font-weight: 700; }
  .auth-hero p { margin: 0; font-size: 16px; color: rgba(255,255,255,.82); max-width: 380px; }
  .auth-feats { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
  .auth-feat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .auth-feat i { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.22); display: grid; place-items: center; flex: none; }
  .auth-feat i svg { width: 17px; height: 17px; }
  .auth-feat b { display: block; font-size: 14px; }
  .auth-feat span { display: block; font-size: 12.5px; color: rgba(255,255,255,.78); }
  .auth-card { border-radius: 0; border: 0; box-shadow: none; padding: 52px 48px; background: var(--glass-strong); display: flex; flex-direction: column; justify-content: center; }
  .auth-brand i { display: none; }
  .auth-brand h2 { font-size: 26px; }
}

/* ---------- phone: settings tables become stacked cards ---------- */
@media (max-width: 700px) {
  .table-wrap:has(table.rt) { margin: 0; padding: 0; overflow: visible; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { padding: 10px 14px; margin-bottom: 10px; border: 1px solid var(--glass-brd); border-radius: 16px; background: var(--soft); }
  table.rt tr:last-child { margin-bottom: 0; }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border: 0; white-space: normal; min-width: 0 !important; text-align: right; }
  table.rt td::before { content: attr(data-label); flex: none; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink2); text-align: left; }
  table.rt td .cell-input { width: 62%; max-width: 62%; min-width: 0; background: var(--glass-strong); }
  table.rt td.r { text-align: right; }
  .card h3 { flex-wrap: wrap; }
  .card h3 .h3-extra { display: flex; flex-wrap: wrap; gap: 6px; }
  .topbar { flex-wrap: wrap; }
  .card { border-radius: 20px; padding: 14px; }
}
@media (max-width: 380px) { .kpi .v { font-size: 16px; } .row2 { grid-template-columns: 1fr; } .row2.amt-cur { grid-template-columns: 1fr 96px; } }
@keyframes flashfill { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); background-color: var(--good-bg); } 100% { box-shadow: 0 0 0 14px transparent; } }
.input.flash { animation: flashfill 1.1s ease-out 1; border-color: var(--good); }
@media (min-width: 900px) { .hide-d { display: none !important; } }
details.ai-opt { background: var(--soft); border-radius: 14px; padding: 10px 14px; } details.ai-opt summary { cursor: pointer; font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; justify-content: space-between; list-style: none; } details.ai-opt summary::-webkit-details-marker { display: none; }

/* ---------- theme toggle ---------- */
:root { color-scheme: light; } :root[data-theme="dark"] { color-scheme: dark; }
.theme-toggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: 99px; background: var(--glass); border: 1px solid var(--glass-brd); box-shadow: var(--glass-hi); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.theme-toggle button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink2); font-weight: 600; font-size: 12.5px; padding: 6px 12px; border-radius: 99px; }
.theme-toggle button svg { width: 15px; height: 15px; }
.theme-toggle button.on { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; box-shadow: 0 2px 10px rgba(37,99,235,.35); }
.appbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.auth-theme { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 40; }
@media (max-width: 420px) { .theme-toggle button span { display: none; } .theme-toggle button { padding: 7px 11px; } }
