/* ============================================================
   ALAR DESIGN SYSTEM — DEEP COSMOS PALETTE
   ① #4f46e5  Deep Indigo  — primary CTA, nav, logo
   ② #818cf8  Soft Indigo  — gradient end, hover
   ③ #22d3ee  Cyan         — accent spark, beam
   ④ #10b981  Emerald      — income, success
   ⑤ #f59e0b  Amber        — budgets, warnings
   Font: Satoshi (headings), Switzer (UI), DM Mono (numbers)
   ============================================================ */

/* ── DARK (default) ── */
:root,
:root[data-theme="dark"] {
    --bg-primary: #08080f;
    --bg-secondary: #0f0f1a;
    --bg-card: #0f0f1a;
    --bg-card-hover: #16162a;
    --bg-elevated: #16162a;
    --border: #252540;
    --border-subtle: #1a1a30;
    --logo-border: #3d3d62;

    --text-primary: #f0f0ff;
    --text-secondary: #9898c0;
    --text-muted: #6060a0;

    /* ① Primary */
    --accent-blue: #4f46e5;
    --accent-blue-glow: rgba(79, 70, 229, 0.28);
    --accent-blue-soft: rgba(79, 70, 229, 0.13);
    /* ② Secondary */
    --accent-soft: #818cf8;
    --accent-soft-glow: rgba(129, 140, 248, 0.20);
    /* ③ Cyan spark */
    --accent-cyan: #22d3ee;
    --accent-cyan-glow: rgba(34, 211, 238, 0.22);
    /* ④ Emerald */
    --accent-emerald: #4ade80;
    --accent-emerald-soft: rgba(74, 222, 128, 0.14);
    /* ⑤ Amber */
    --accent-amber: #f59e0b;
    --accent-amber-soft: rgba(245, 158, 11, 0.12);

    /* Gradient: Deep Indigo → Soft Indigo (cyan appears in beam/hover) */
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
    /* Sparkle gradient — for beams, ripples */
    --spark-gradient: linear-gradient(135deg, #4f46e5 0%, #818cf8 50%, #22d3ee 100%);

    /* Semantic (maps to palette) */
    --accent-violet: var(--accent-cyan);
    --accent-violet-glow: var(--accent-cyan-glow);
    --success: var(--accent-emerald);
    --success-soft: var(--accent-emerald-soft);
    --warning: var(--accent-amber);
    --warning-soft: var(--accent-amber-soft);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);

    /* Logo */
    --logo-dot: rgba(255, 255, 255, 0.85);
    /* Header / Nav */
    --header-bg: rgba(8, 8, 15, 0.88);
    --header-border: rgba(37, 37, 64, 0.8);
    --nav-bg: rgba(15, 15, 26, 0.94);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── LIGHT ── */
:root[data-theme="light"] {
    --bg-primary: #f2f2fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #ebebf8;
    --bg-elevated: #e8e8f5;
    --border: #d8d8ee;
    --border-subtle: #e4e4f4;
    --logo-border: #d8d8ee;

    --text-primary: #0a0a18;
    --text-secondary: #44446a;
    --text-muted: #8888aa;

    /* ① Primary — slightly deeper for light bg contrast */
    --accent-blue: #4338ca;
    --accent-blue-glow: rgba(67, 56, 202, 0.18);
    --accent-blue-soft: rgba(67, 56, 202, 0.09);
    /* ② Secondary */
    --accent-soft: #6366f1;
    --accent-soft-glow: rgba(99, 102, 241, 0.15);
    /* ③ Cyan spark */
    --accent-cyan: #0891b2;
    --accent-cyan-glow: rgba(8, 145, 178, 0.15);
    /* ④ Emerald */
    --accent-emerald: #16a34a;
    --accent-emerald-soft: rgba(22, 163, 74, 0.10);
    /* ⑤ Amber */
    --accent-amber: #d97706;
    --accent-amber-soft: rgba(217, 119, 6, 0.09);

    --accent-gradient: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
    --spark-gradient: linear-gradient(135deg, #4338ca 0%, #6366f1 50%, #0891b2 100%);

    --accent-violet: var(--accent-cyan);
    --accent-violet-glow: var(--accent-cyan-glow);
    --success: var(--accent-emerald);
    --success-soft: var(--accent-emerald-soft);
    --warning: var(--accent-amber);
    --warning-soft: var(--accent-amber-soft);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);

    --logo-dot: #4338ca;
    --header-bg: rgba(242, 242, 250, 0.90);
    --header-border: rgba(216, 216, 238, 0.95);
    --nav-bg: rgba(255, 255, 255, 0.96);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Switzer', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   APP SHELL
   ============================================ */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    overflow: hidden;
}



/* ── Theme icon inner wrapper ── */
.theme-icon-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    position: relative;
}

/* Spin only the inner icon, not the container pill */
@keyframes themeSpin {
    0%   { transform: rotate(0deg)   scale(1);    opacity: 1; }
    38%  { transform: rotate(158deg) scale(0.45); opacity: 0; }
    50%  { transform: rotate(180deg) scale(0.3);  opacity: 0; } /* icon switches here */
    62%  { transform: rotate(202deg) scale(0.45); opacity: 0.4; }
    78%  { transform: rotate(375deg) scale(1.18); opacity: 1; } /* spring */
    100% { transform: rotate(360deg) scale(1);    opacity: 1; }
}
.theme-icon-inner.spinning {
    animation: themeSpin 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: none;
}

/* show/hide moon/sun per theme — opacity for smooth transition */
.icon-moon, .icon-sun { transition: opacity 0.25s ease; position: absolute; }
:root[data-theme="dark"]  .icon-sun  { opacity: 0; pointer-events: none; }
:root[data-theme="dark"]  .icon-moon { opacity: 1; }
:root[data-theme="light"] .icon-moon { opacity: 0; pointer-events: none; }
:root[data-theme="light"] .icon-sun  { opacity: 1; }

/* ── Settings icon variants ── */
.si-emerald { background: rgba(74,222,128,0.13);  color: var(--accent-emerald); }
.si-indigo  { background: rgba(79,70,229,0.13);   color: var(--accent-blue); }
.si-soft    { background: rgba(129,140,248,0.13);  color: var(--accent-soft); }
.si-cyan    { background: rgba(34,211,238,0.13);   color: var(--accent-cyan); }
.si-amber   { background: rgba(245,158,11,0.13);   color: var(--accent-amber); }
.si-red     { background: rgba(248,113,113,0.13);  color: var(--danger); }
.settings-icon svg { width: 18px; height: 18px; display: block; }

/* --- App content --- */
.app-content {
    flex: 1;
    min-height: 0;    /* critical: allows flex child to shrink + overflow */
    overflow: hidden;
    position: relative;
}

/* ── Pager track — all screens side by side ── */
#screenTrack {
    display: flex;
    width: 400%;        /* 4 tabs × 100% */
    height: 100%;
    will-change: transform;
    transform: translateX(0);
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: calc(12px + var(--safe-bottom));
    left: 16px;
    right: 16px;
    background: var(--nav-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 28px;
    display: flex;
    align-items: center;
    padding: 8px 4px;
    z-index: 100;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.25),
                0 1px 4px rgba(0,0,0,0.15);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: 'Switzer', sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    /* Alar spring release */
    transition: color 0.2s ease,
                transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:active {
    transform: scale(0.88);
    transition-duration: 0.07s;
    transition-timing-function: ease-in;
}

.nav-item.active {
    color: var(--accent-blue);
}

/* Active indicator pill under icon */
.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    animation: navPillIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes navPillIn {
    from { width: 0; opacity: 0; }
    to   { width: 20px; opacity: 1; }
}

.nav-item svg {
    width: 22px;
    height: 22px;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item.active svg {
    transform: scale(1.12);
}

/* ── FAB slot (placeholder in nav flex layout) ── */
.nav-fab-slot {
    width: 64px;
    flex-shrink: 0;
    pointer-events: none;
}

/* ── FAB — центральная кнопка добавления (fixed, always on top) ── */
.nav-fab {
    position: fixed;
    bottom: calc(34px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 250;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: 4px solid var(--bg-primary);
    box-shadow: 0 6px 24px rgba(79,70,229,0.55),
                0 2px 8px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease,
                background 0.3s ease,
                opacity 0.18s ease;
    will-change: transform;
}
.nav-fab.fab-hidden {
    opacity: 0;
    pointer-events: none;
}
.nav-fab:active {
    transform: translateX(-50%) scale(0.87);
    box-shadow: 0 3px 10px rgba(79,70,229,0.3);
    transition-duration: 0.06s;
    transition-timing-function: ease-in;
}

/* FAB icon: plus and close (×) */
.fab-icon-plus,
.fab-icon-close {
    position: absolute;
    width: 26px;
    height: 26px;
    stroke: white;
    stroke-width: 2.5;
    stroke-linecap: round;
    fill: none;
    transition: opacity 0.28s ease,
                transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab-icon-plus  { opacity: 1; transform: rotate(0deg) scale(1); }
.fab-icon-close { opacity: 0; transform: rotate(-45deg) scale(0.4); }

/* When action sheet is open: FAB shows white × */
.nav-fab.is-open {
    background: #ffffff;
    box-shadow: 0 6px 28px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
    border-color: transparent;
}
.nav-fab.is-open .fab-icon-plus  { opacity: 0; transform: rotate(45deg) scale(0.4); }
.nav-fab.is-open .fab-icon-close { opacity: 1; transform: rotate(0deg)  scale(1); stroke: #09090b; }

/* ============================================
   SCREENS & ALAR TAB TRANSITIONS
   Metaphor: light sweeps through the prism
   ============================================ */

.screen {
    width: 25%;          /* 100vw (1/4 of the 400% track) */
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(96px + var(--safe-bottom));
    box-sizing: border-box;
    height: 100%;
}
/* .active kept for JS compat — visibility now controlled by track position */
.screen.active {}

/* Directional entrance animations — 0.5s so user can see the wave */
.screen.alar-enter-right {
    animation: alarEnterRight 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.screen.alar-enter-left {
    animation: alarEnterLeft 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
/* First load: gentle rise */
.screen.alar-enter-up {
    animation: alarEnterUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes alarEnterRight {
    from { opacity: 0; transform: translateX(36px) scale(0.97); }
    60%  { opacity: 1; }
    to   { opacity: 1; transform: translateX(0)    scale(1); }
}

@keyframes alarEnterLeft {
    from { opacity: 0; transform: translateX(-36px) scale(0.97); }
    60%  { opacity: 1; }
    to   { opacity: 1; transform: translateX(0)     scale(1); }
}

@keyframes alarEnterUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Alar Beam Overlay — Deep Cosmos: Indigo → Soft Indigo → Cyan ── */
.alar-beam-overlay {
    position: fixed;
    top: 0; bottom: 0;
    width: 100px;
    pointer-events: none;
    z-index: 9999;
    /* Deep Indigo core fading to cyan edge — the prism refraction */
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(79, 70, 229, 0.10) 15%,
        rgba(129, 140, 248, 0.22) 35%,
        rgba(34, 211, 238, 0.30) 50%,
        rgba(129, 140, 248, 0.22) 65%,
        rgba(79, 70, 229, 0.10) 85%,
        transparent 100%);
}
.alar-beam-overlay.to-right {
    left: -90px;
    animation: alarBeamRight 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.alar-beam-overlay.to-left {
    right: -90px;
    animation: alarBeamLeft 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes alarBeamRight {
    from { transform: translateX(0);              opacity: 0; }
    8%   { opacity: 1; }
    85%  { opacity: 1; }
    to   { transform: translateX(calc(100vw + 180px)); opacity: 0; }
}
@keyframes alarBeamLeft {
    from { transform: translateX(0);               opacity: 0; }
    8%   { opacity: 1; }
    85%  { opacity: 1; }
    to   { transform: translateX(calc(-100vw - 180px)); opacity: 0; }
}

/* ── Alar Ripple — Deep Indigo core → Cyan edge ── */
.alar-ripple {
    position: fixed;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: radial-gradient(circle,
        rgba(79, 70, 229, 0.35) 0%,
        rgba(129, 140, 248, 0.22) 40%,
        rgba(34, 211, 238, 0.10) 70%,
        transparent 100%);
    pointer-events: none;
    z-index: 9998;
    animation: alarRippleOut 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes alarRippleOut {
    from { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    to   { transform: translate(-50%, -50%) scale(7); opacity: 0; }
}

/* ── Alar Delete — shake then slide-dissolve ── */
.alar-shake {
    animation: alarShake 0.28s ease forwards;
}
@keyframes alarShake {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-7px); }
    45%  { transform: translateX(5px); }
    65%  { transform: translateX(-4px); }
    85%  { transform: translateX(2px); }
    100% { transform: translateX(0); }
}
.alar-deleting {
    animation: alarDeleteOut 0.35s ease forwards;
    overflow: hidden;
}
@keyframes alarDeleteOut {
    0%   { opacity: 1; transform: translateX(0); max-height: 80px; padding: 14px; margin-bottom: 2px; }
    40%  { opacity: 0.4; transform: translateX(-20px); }
    100% { opacity: 0; transform: translateX(-40px); max-height: 0; padding: 0; margin-bottom: 0; }
}

/* ── Input glow: только при наборе, не при фокусе ── */
.desc-input:focus,
.amount-display:focus {
    outline: none;
    box-shadow: none;   /* нет обводки при пустом поле */
}
.amount-display:focus:not(:placeholder-shown) {
    box-shadow: 0 0 0 3px var(--accent-blue-glow);  /* появляется при вводе */
    caret-color: var(--accent-soft);
}
.amount-display {
    caret-color: transparent;  /* курсор невидим пока поле пустое */
}

/* ============================================
   ALAR INTERACTION LANGUAGE
   Prism-inspired spring & glow feedback
   ============================================ */

/* --- Universal Alar spring press --- */
/* Press: fast compress  | Release: spring overshoot bounce */
.alar-press {
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
    cursor: pointer;
}
.alar-press:active {
    transform: scale(0.93);
    transition-duration: 0.06s;
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}

/* --- Gradient pulse on release (Alar signature) --- */
/* Applied via JS class .alar-pulsed, auto-removed */
@keyframes alarGradientPulse {
    0%   { box-shadow: 0 0 0 0    rgba(79, 70, 229, 0); }
    25%  { box-shadow: 0 0 0 5px  rgba(79, 70, 229, 0.28); }
    55%  { box-shadow: 0 0 0 10px rgba(129, 140, 248, 0.14); }
    80%  { box-shadow: 0 0 0 14px rgba(34, 211, 238, 0.06); }
    100% { box-shadow: 0 0 0 18px rgba(79, 70, 229, 0); }
}

.alar-pulsed {
    animation: alarGradientPulse 0.55s ease-out forwards;
}

/* --- Category button bounce on select --- */
@keyframes alarCatSelect {
    0%   { transform: scale(1); }
    35%  { transform: scale(0.9); }
    65%  { transform: scale(1.07); }
    100% { transform: scale(1); }
}

.category-btn.alar-cat-bounce {
    animation: alarCatSelect 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Count-up number animation --- */
.count-up {
    display: inline-block;
    animation: alarCountUp 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes alarCountUp {
    from { opacity: 0.3; transform: translateY(8px) scale(0.94); }
    to   { opacity: 1;   transform: translateY(0)   scale(1); }
}

/* ============================================
   ACCOUNTS CAROUSEL
   ============================================ */

.accounts-carousel-wrapper {
    position: relative;
    overflow: hidden;
    margin-bottom: 4px;
    border-radius: var(--radius-xl);
    transition: height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

body.is-pro #subBanner { display: none !important; margin: 0; }

.accounts-carousel-track {
    display: flex;
    align-items: flex-start;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.accounts-carousel-track .balance-card {
    flex: 0 0 100%;
    margin-bottom: 0;
    border-radius: var(--radius-xl);
    /* color accent bar at top */
    border-top: 3px solid var(--account-color, var(--accent-blue));
}

/* Account name chip inside balance-card */
.account-name-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.account-name-chip svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    display: block;
    stroke: var(--text-muted);
}

/* Dots indicator */
.account-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 8px;
}

.account-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--border);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

.account-dot.active {
    width: 18px;
    background: var(--accent-gradient);
}

/* Crypto card variant */
.crypto-balance-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.crypto-balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 8px 12px;
}

.crypto-symbol {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.crypto-amount {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.crypto-usd {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--warning);
}

.crypto-sync-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.crypto-sync-btn:active { transform: scale(0.94); transition-duration: 0.06s; }

/* ── Portfolio 24h performance ── */
.portfolio-perf {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
}
.portfolio-perf.pos { color: var(--accent-emerald); }
.portfolio-perf.neg { color: var(--danger); }

/* ── Stacked allocation bar ── */
.alloc-stacked-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    gap: 2px;
    margin: 14px 0 8px;
}
.alloc-seg { height: 100%; border-radius: 2px; }
.alloc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 4px;
}
.alloc-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    color: var(--text-secondary);
}
.alloc-legend-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Per-coin 24h change ── */
.coin-perf {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 600;
}
.coin-perf.pos { color: var(--accent-emerald); }
.coin-perf.neg { color: var(--danger); }

/* ============================================
   ACTION SHEET (+ button)
   ============================================ */

.action-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.action-sheet-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.action-sheet-menu {
    width: calc(100% - 32px);
    margin: 0 16px calc(88px + var(--safe-bottom));
    background: var(--bg-card);
    border-radius: 24px;        /* all four corners rounded — floating card */
    padding: 8px 16px 28px;
    transform: translateY(calc(100% + 120px));
    transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;           /* clips the notch-hole circle */
}

.action-sheet-overlay.show .action-sheet-menu {
    transform: translateY(0);
}

/* Notch hole — sector ~26% of circle (gentle scoop, not 50%) */
.action-sheet-notch-hole {
    position: absolute;
    bottom: -56px;              /* visible arc = 76-56 = 20px ≈ 26% sector */
    left: 50%;
    transform: translateX(-50%);
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: rgba(0,0,0,0.82);  /* approximate overlay color behind the sheet */
    pointer-events: none;
    z-index: 1;
}
:root[data-theme="light"] .action-sheet-notch-hole {
    background: rgba(0,0,0,0.38);
}

.action-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    margin: 8px auto 16px;
}

.action-sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background 0.15s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

.action-sheet-item:active { transform: scale(0.96); transition-duration: 0.06s; }
.action-sheet-item:hover, .action-sheet-item:active { background: var(--bg-elevated); }

.action-sheet-item-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.action-sheet-item-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    display: block;
}

.action-sheet-item:first-of-type .action-sheet-item-icon {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}
.action-sheet-item:nth-of-type(2) .action-sheet-item-icon {
    background: rgba(139, 92, 246, 0.12);
    color: #8b5cf6;
}

/* Cancel removed – FAB × closes the sheet */

/* ============================================
   NEW ACCOUNT MODAL
   ============================================ */

.account-templates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.account-template-card {
    position: relative;
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    background: var(--bg-elevated);
    cursor: pointer;
    text-align: left;
    aspect-ratio: 1.15;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.account-template-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--card-gradient, transparent);
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.account-template-card > * { position: relative; z-index: 1; }

.account-template-card.selected {
    border-color: var(--text-primary);
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(15, 15, 35, 0.12);
}
.account-template-card.selected::before { opacity: 0.9; }

.account-template-card:active { transform: scale(0.97); transition-duration: 0.06s; }

.account-template-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-primary);
    backdrop-filter: blur(4px);
}
[data-theme="dark"] .account-template-icon { background: rgba(255, 255, 255, 0.12); color: #fff; }
.account-template-icon i { pointer-events: none; }

.account-template-card[data-template="personal"]       { --card-gradient: linear-gradient(135deg, #ede9fe, #c4b5fd); }
.account-template-card[data-template="business"]       { --card-gradient: linear-gradient(135deg, #e0e7ff, #93c5fd); }
.account-template-card[data-template="family_shared"]  { --card-gradient: linear-gradient(135deg, #d1fae5, #6ee7b7); }
.account-template-card[data-template="crypto"]         { --card-gradient: linear-gradient(135deg, #fef3c7, #fcd34d); }
.account-template-card[data-template="bank"]           { --card-gradient: linear-gradient(135deg, #e0f2fe, #7dd3fc); }

[data-theme="dark"] .account-template-card[data-template="personal"]       { --card-gradient: linear-gradient(135deg, #312e81, #4338ca); }
[data-theme="dark"] .account-template-card[data-template="business"]       { --card-gradient: linear-gradient(135deg, #1e3a8a, #3730a3); }
[data-theme="dark"] .account-template-card[data-template="family_shared"]  { --card-gradient: linear-gradient(135deg, #064e3b, #047857); }
[data-theme="dark"] .account-template-card[data-template="crypto"]         { --card-gradient: linear-gradient(135deg, #78350f, #b45309); }
[data-theme="dark"] .account-template-card[data-template="bank"]           { --card-gradient: linear-gradient(135deg, #164e63, #0e7490); }

.account-template-label {
    font-family: 'Satoshi', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.account-template-desc {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    font-weight: 500;
}

.account-color-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.account-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid transparent;
}

.account-color-swatch:active { transform: scale(0.86); transition-duration: 0.06s; }
.account-color-swatch.selected { border-color: var(--text-primary); transform: scale(1.15); }

/* Crypto API fields */
.crypto-fields {
    display: none;
}
.crypto-fields.visible {
    display: block;
}

/* ── Input fields for modals (account creation etc.) ── */
.input-field {
    width: 100%;
    height: 48px;
    background:
        linear-gradient(var(--bg-elevated), var(--bg-elevated)) padding-box,
        linear-gradient(135deg, #4f46e5, #818cf8, #4f46e5) border-box;
    background-size: 100% 100%, 200% 200%;
    background-position: 0 0, 0% 50%;
    border: 1.5px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: 'Switzer', sans-serif;
    font-size: 15px;
    font-weight: 400;
    padding: 0 14px;
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.08);
    animation: inputShimmer 6s ease-in-out infinite, inputFloat 4s ease-in-out infinite;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}
.input-field:hover {
    box-shadow: 0 4px 18px rgba(79, 70, 229, 0.18);
    transform: translateY(-1px);
}
.input-field:focus {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18), 0 8px 24px rgba(79, 70, 229, 0.22);
    outline: none;
    animation-play-state: paused;
    transform: translateY(-1px);
}

@keyframes inputShimmer {
    0%, 100% { background-position: 0 0, 0% 50%; }
    50%      { background-position: 0 0, 100% 50%; }
}
@keyframes inputFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-1.5px); }
}
.input-field::placeholder { color: var(--text-muted); }

/* Select — custom arrow */
select.input-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23818cf8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}
select.input-field option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ============================================
   DASHBOARD SCREEN
   ============================================ */

/* ── Dashboard logo bar (replaces greeting) ── */
.dash-logo-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-top: max(4px, env(safe-area-inset-top, 4px));
}

.dash-logo-pill {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 14px var(--accent-blue-glow);
}

.dash-logo-pill svg {
    width: 32px;
    height: 32px;
}

/* Wordmark — used in Settings screen heading */
.dash-wordmark {
    font-family: 'Switzer', sans-serif;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 3px;
    color: var(--text-muted);
}

/* Header left group: avatar + greeting on one row */
.dash-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

/* Avatar button (left of dashboard header — opens Settings) */
.dash-header-avatar {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-blue, #4f46e5);
    background-image: var(--accent-gradient, linear-gradient(135deg, #4f46e5, #818cf8));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.28);
    transition: transform 0.12s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.dash-header-avatar:hover {
    box-shadow: 0 4px 18px rgba(79, 70, 229, 0.4);
}

.dash-header-avatar:active {
    transform: scale(0.94);
}

.dash-header-avatar__initial {
    color: #fff;
    font-family: 'Satoshi', system-ui, sans-serif;
    font-weight: 700;
    font-size: 22px;
    line-height: 1;
    text-transform: uppercase;
}

/* Greeting next to avatar (Hi, {name}!) */
.dash-greeting__title {
    margin: 0;
    font-family: 'Satoshi', system-ui, sans-serif;
    font-weight: 700;
    font-size: 22px;
    line-height: 1.15;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 380px) {
    .dash-greeting__title { font-size: 19px; }
    .dash-header-left { gap: 10px; }
}

/* Balance Card */
.balance-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--accent-blue-glow) 0%, transparent 70%);
    pointer-events: none;
}

.balance-card::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -20%;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, var(--accent-violet-glow) 0%, transparent 70%);
    pointer-events: none;
}

.balance-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.balance-amount {
    font-family: 'DM Mono', monospace;
    font-size: 36px;
    font-weight: 500;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

.balance-amount.positive { color: var(--success); }
.balance-amount.negative { color: var(--danger); }

.balance-row {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

.balance-stat {
    flex: 1;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 12px;
}

.balance-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.balance-stat-value {
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    font-weight: 500;
}

.balance-stat-value.income { color: var(--success); }
.balance-stat-value.expense { color: var(--danger); }

.balance-progress {
    margin-top: 16px;
    position: relative;
    z-index: 1;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Quick Add Button — Alar spring + gradient pulse */
/* quick-add row: add + mic side by side */
.quick-add-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 12px;
}
.quick-add-row .quick-add-btn {
    flex: 1;
    margin-bottom: 0;
}

.quick-add-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-family: 'Switzer', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    -webkit-tap-highlight-color: transparent;
    /* Alar spring release */
    transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.4s ease;
    box-shadow: 0 4px 20px var(--accent-blue-glow);
    will-change: transform;
}

/* mic button — square, same height as quick-add */
.quick-mic-btn {
    flex-shrink: 0;
    width: 52px;
    padding: 0;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.quick-mic-btn:active {
    transform: scale(0.92);
    transition-duration: 0.06s;
    transition-timing-function: ease-in;
}
.quick-mic-btn svg { width: 22px; height: 22px; }

.quick-add-btn:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px var(--accent-blue-glow);
    transition-duration: 0.06s;
    transition-timing-function: ease-in;
}

.quick-add-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quick-add-btn:active svg {
    transform: rotate(45deg) scale(0.9);
    transition-duration: 0.06s;
}

/* Undo Button */
.undo-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-family: 'Switzer', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.15s ease;
}

.undo-btn:active {
    transform: scale(0.94);
    background: var(--bg-card-hover);
    transition-duration: 0.06s;
    transition-timing-function: ease-in;
}

.undo-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Subscription trial banner ── */
.sub-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s;
}
.sub-banner:active { opacity: 0.7; }
.sub-banner-icon {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sub-banner-icon svg { width: 16px; height: 16px; color: #fff; }
.sub-banner-text { flex: 1; min-width: 0; }
.sub-banner-title {
    font-family: 'Switzer', sans-serif;
    font-size: 13px; font-weight: 600;
    color: var(--text-primary); line-height: 1.3;
}
.sub-banner-desc {
    font-family: 'Switzer', sans-serif;
    font-size: 11px; color: var(--text-muted);
    margin-top: 1px;
}
.sub-banner-cta {
    font-family: 'Switzer', sans-serif;
    font-size: 12px; font-weight: 700;
    color: var(--accent-amber);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Paywall modal ── */
.paywall-overlay {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.28s ease;
    display: flex; align-items: flex-end;
}
.paywall-overlay.show {
    opacity: 1; pointer-events: all;
}
.paywall-card {
    width: 100%;
    background: var(--bg-card);
    border-radius: 24px 24px 0 0;
    padding: 0 0 calc(28px + var(--safe-bottom));
    transform: translateY(100%);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}
.paywall-overlay.show .paywall-card {
    transform: translateY(0);
}
.paywall-header {
    padding: 20px 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.paywall-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.paywall-close svg { width: 16px; height: 16px; }
.paywall-crown {
    width: 52px; height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(245,158,11,0.4);
}
.paywall-crown svg { width: 26px; height: 26px; color: #fff; }
.paywall-body { padding: 16px 20px 0; }
.paywall-title {
    font-family: 'Satoshi', sans-serif;
    font-size: 22px; font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.paywall-subtitle {
    font-family: 'Switzer', sans-serif;
    font-size: 14px; color: var(--text-secondary);
    margin-bottom: 20px;
}
.paywall-features { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.paywall-feature {
    display: flex; align-items: center; gap: 12px;
}
.paywall-feature-check {
    width: 24px; height: 24px; border-radius: 8px;
    background: rgba(79,70,229,0.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.paywall-feature-check svg { width: 13px; height: 13px; color: var(--accent-blue); }
.paywall-feature-name {
    font-family: 'Switzer', sans-serif;
    font-size: 14px; font-weight: 500;
    color: var(--text-primary);
}
.paywall-cta {
    width: 100%;
    padding: 16px;
    background: var(--accent-gradient);
    border: none; border-radius: var(--radius-lg);
    color: #fff;
    font-family: 'Switzer', sans-serif;
    font-size: 16px; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--accent-blue-glow);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.paywall-cta:active { transform: scale(0.96); transition-duration: 0.06s; }
.paywall-fine {
    text-align: center;
    font-family: 'Switzer', sans-serif;
    font-size: 12px; color: var(--text-muted);
    margin-top: 10px;
}

/* ── Settings Pro card ── */
.settings-pro-card {
    margin-bottom: 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(79,70,229,0.18) 0%, rgba(129,140,248,0.12) 100%);
    border: 1px solid rgba(79,70,229,0.25);
    padding: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s;
}
.settings-pro-card:active { opacity: 0.8; }
.settings-pro-card-row {
    display: flex; align-items: center; gap: 12px;
}
.settings-pro-icon {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}
.settings-pro-icon svg { width: 20px; height: 20px; color: #fff; }
.settings-pro-text { flex: 1; }
.settings-pro-title {
    font-family: 'Satoshi', sans-serif;
    font-size: 15px; font-weight: 700;
    color: var(--text-primary);
}
.settings-pro-desc {
    font-family: 'Switzer', sans-serif;
    font-size: 12px; color: var(--text-muted);
    margin-top: 2px;
}
.settings-pro-badge {
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase;
    background: var(--accent-gradient);
    color: #fff; padding: 3px 8px; border-radius: 6px;
}
.settings-pro-active-badge {
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase;
    background: rgba(74,222,128,0.15);
    color: var(--accent-emerald); padding: 3px 8px; border-radius: 6px;
    border: 1px solid rgba(74,222,128,0.3);
}

/* Recent Transactions */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-title {
    font-family: 'Satoshi', 'Switzer', sans-serif;
    font-size: 16px;
    font-weight: 500;
}

.section-link {
    font-size: 13px;
    color: var(--accent-blue);
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    font-family: 'Switzer', sans-serif;
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
    cursor: pointer;
}

.transaction-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
}

.transaction-item:last-child {
    border-radius: var(--radius-md) var(--radius-md) var(--radius-lg) var(--radius-lg);
}

.transaction-item:only-child {
    border-radius: var(--radius-lg);
}

.transaction-item:active {
    background: var(--bg-card-hover);
}

.transaction-delete {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: var(--radius-full);
    background: var(--danger-soft);
    border: none;
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    margin-left: 8px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.transaction-delete:active {
    opacity: 1;
    transform: scale(0.9);
}

.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.transaction-info {
    flex: 1;
    min-width: 0;
}

.transaction-category {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-desc {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-right {
    text-align: right;
    flex-shrink: 0;
}

.transaction-amount {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    font-weight: 500;
}

.transaction-amount.expense { color: var(--danger); }
.transaction-amount.income { color: var(--success); }

.transaction-date {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============================================
   ADD EXPENSE SCREEN (MODAL)
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: flex-end;
    animation: overlayIn 0.2s ease;
}

/* Custom picker always renders on top of any open modal */
#customPickerModal { z-index: 400; }

.modal-overlay.show {
    display: flex;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-sheet {
    width: 100%;
    max-height: 92vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 12px 16px calc(16px + var(--safe-bottom));
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    margin: 0 auto 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-family: 'Satoshi', 'Switzer', sans-serif;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

/* Type Toggle */
.type-toggle {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
}

.type-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Switzer', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-muted);
}

.type-btn.active-expense {
    background: var(--danger-soft);
    color: var(--danger);
}

.type-btn.active-income {
    background: var(--success-soft);
    color: var(--success);
}

/* Amount Input */
.amount-input-wrap {
    text-align: center;
    margin-bottom: 24px;
}

.amount-display {
    font-family: 'DM Mono', monospace;
    font-size: 48px;
    font-weight: 500;
    color: var(--text-primary);
    border: none;
    background: none;
    text-align: center;
    width: 100%;
    outline: none;
    caret-color: transparent;
}

.amount-display::placeholder {
    color: var(--text-muted);
}

.amount-currency {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}
/* Voice input button below amount */
.voice-input-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    margin-top: 2px;
    border-radius: var(--radius-md);
    border: 1.5px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.voice-input-btn:hover, .voice-input-btn:active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(79,70,229,0.06);
}
.voice-input-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Voice Recording Modal */
.voice-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 60px 24px 40px;
}
.voice-modal.show { display: flex; }
.voice-modal-top { text-align: center; }
.voice-modal-title { font-size: 22px; font-weight: 700; font-family: 'Satoshi',sans-serif; color: var(--text-primary); margin-bottom: 8px; }
.voice-modal-subtitle { font-size: 14px; color: var(--text-secondary); }
.voice-modal-center { display: flex; flex-direction: column; align-items: center; gap: 32px; }
.voice-mic-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.voice-mic-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(79,70,229,0.12);
    animation: voicePulse 1.8s ease-in-out infinite;
}
.voice-mic-ring:nth-child(2) { animation-delay: 0.6s; }
.voice-mic-ring:nth-child(3) { animation-delay: 1.2s; }
@keyframes voicePulse {
    0% { transform: scale(0.85); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 0.2; }
    100% { transform: scale(0.85); opacity: 0; }
}
.voice-mic-btn {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-soft));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(79,70,229,0.45);
    transition: transform 0.1s;
    z-index: 1;
}
.voice-mic-btn:active { transform: scale(0.94); }
.voice-mic-btn svg { width: 32px; height: 32px; }
.voice-waveform {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 40px;
}
.voice-wave-bar {
    width: 4px;
    border-radius: 2px;
    background: var(--accent-blue);
    opacity: 0.7;
    animation: voiceWave 1.2s ease-in-out infinite;
}
.voice-wave-bar:nth-child(1) { height: 12px; animation-delay: 0s; }
.voice-wave-bar:nth-child(2) { height: 24px; animation-delay: 0.1s; }
.voice-wave-bar:nth-child(3) { height: 36px; animation-delay: 0.2s; }
.voice-wave-bar:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.voice-wave-bar:nth-child(5) { height: 32px; animation-delay: 0.4s; }
.voice-wave-bar:nth-child(6) { height: 16px; animation-delay: 0.5s; }
.voice-wave-bar:nth-child(7) { height: 28px; animation-delay: 0.6s; }
.voice-wave-bar:nth-child(8) { height: 10px; animation-delay: 0.7s; }
.voice-wave-bar:nth-child(9) { height: 22px; animation-delay: 0.8s; }
@keyframes voiceWave {
    0%, 100% { transform: scaleY(0.4); opacity: 0.4; }
    50% { transform: scaleY(1.0); opacity: 1; }
}
.voice-hint { font-size: 12px; color: var(--text-muted); text-align: center; }
.voice-modal-bottom { width: 100%; display: flex; flex-direction: column; gap: 10px; }

/* Bank Connect Modal */
.bank-modal-search {
    position: relative;
    margin-bottom: 12px;
}
.bank-modal-search input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px 11px 40px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.bank-modal-search input:focus { border-color: var(--accent-blue); }
.bank-modal-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); }
.bank-list { display: flex; flex-direction: column; gap: 2px; }
.bank-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.bank-item:hover, .bank-item:active { background: var(--bg-elevated); }
.bank-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
    border: 1.5px solid var(--logo-border);
    overflow: hidden;
}
.bank-logo.own-frame { border: none; }
.bank-logo img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 4px; box-sizing: border-box; }
.bank-logo.own-frame img { padding: 0; object-fit: cover; }
.bank-item-text { flex: 1; }
.bank-item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.bank-item-country { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.bank-item-chevron { color: var(--text-muted); font-size: 18px; }
/* Bank confirm screen */
.bank-confirm { display: none; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 16px; }
.bank-confirm.show { display: flex; }
.bank-list-wrap { display: block; }
.bank-list-wrap.hidden { display: none; }
.bank-confirm-logo { width: 72px; height: 72px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 900; margin: 0 auto 16px; border: 2px solid var(--logo-border); overflow: hidden; }
.bank-confirm-logo.own-frame { border: none; }
.bank-confirm-logo img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 8px; box-sizing: border-box; }
.bank-confirm-logo.own-frame img { padding: 0; object-fit: cover; }
.bank-confirm-name { font-size: 20px; font-weight: 700; font-family: 'Satoshi',sans-serif; color: var(--text-primary); margin-bottom: 6px; }
.bank-confirm-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; max-width: 280px; margin-bottom: 24px; }
.bank-confirm-perms { width: 100%; text-align: left; background: var(--bg-secondary); border-radius: 10px; padding: 12px 14px; margin-bottom: 20px; }
.bank-confirm-perm { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); padding: 4px 0; }
.bank-confirm-perm svg { width: 16px; height: 16px; color: var(--accent-emerald); flex-shrink: 0; }

/* Coming soon card */
.coming-soon-card {
    opacity: 0.75;
    position: relative;
}
.coming-soon-card:hover { opacity: 0.9; }
.coming-soon-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 100px;
    line-height: 1.4;
}

/* Category Grid */
.category-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 10px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 4px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: 'Switzer', sans-serif;
    -webkit-tap-highlight-color: transparent;
    /* Alar spring */
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.15s ease,
                background 0.15s ease;
    will-change: transform;
}

.category-btn:active {
    transform: scale(0.88);
    transition-duration: 0.07s;
    transition-timing-function: ease-in;
}

.category-btn.selected {
    border-color: var(--accent-blue);
    background: var(--accent-blue-soft);
}

.category-emoji {
    font-size: 24px;
    line-height: 1;
}

.category-name {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.category-btn.selected .category-name {
    color: var(--accent-blue);
}

/* Description Input */
.desc-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Switzer', sans-serif;
    font-size: 14px;
    outline: none;
    margin-bottom: 20px;
    transition: border-color 0.2s ease;
}

.desc-input:focus {
    border-color: var(--accent-blue);
}

.desc-input::placeholder {
    color: var(--text-muted);
}

/* Submit Button — Alar spring */
.receipt-source-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: 'Switzer', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.receipt-source-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--text-muted);
}
.receipt-source-btn:active { transform: scale(0.96); }

.submit-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius-lg);
    font-family: 'Switzer', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
    will-change: transform;
}

.submit-btn.expense-mode {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 16px var(--danger-soft);
}

.submit-btn.income-mode {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 16px var(--success-soft);
}
/* Default submit (no mode) = primary accent gradient */
.submit-btn:not(.expense-mode):not(.income-mode) {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px var(--accent-blue-glow);
}

.submit-btn:active {
    transform: scale(0.93);
    transition-duration: 0.06s;
    transition-timing-function: ease-in;
}

.submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    transition: none;
}

/* ============================================
   STATS SCREEN
   ============================================ */

.stats-header {
    margin-bottom: 20px;
    padding-top: max(0px, env(safe-area-inset-top, 0px));
}

.stats-title {
    font-family: 'Satoshi', 'Switzer', sans-serif;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stats-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    justify-content: center;
}

.month-nav {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

.month-nav:active {
    background: var(--bg-card-hover);
}

.month-current {
    font-size: 15px;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

/* Donut Chart */
.chart-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    position: relative;
}

.donut-chart {
    width: 200px;
    height: 200px;
}

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.chart-center-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-center-value {
    font-family: 'DM Mono', monospace;
    font-size: 20px;
    font-weight: 500;
}

/* Category Breakdown */
.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.breakdown-color {
    width: 4px;
    height: 32px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.breakdown-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.breakdown-info {
    flex: 1;
    min-width: 0;
}

.breakdown-category {
    font-size: 14px;
    font-weight: 500;
}

.breakdown-bar {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    margin-top: 6px;
    overflow: hidden;
}

.breakdown-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.breakdown-right {
    text-align: right;
    flex-shrink: 0;
}

.breakdown-amount {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    font-weight: 500;
}

.breakdown-percent {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============================================
   HISTORY SCREEN
   ============================================ */

.history-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.history-filters::-webkit-scrollbar { display: none; }

.filter-chip {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-family: 'Switzer', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.filter-chip.active {
    background: var(--accent-blue-soft);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.filter-chip:active {
    transform: scale(0.95);
}

.day-group {
    margin-bottom: 16px;
}

.day-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding-left: 4px;
}

/* ============================================
   SETTINGS SCREEN
   ============================================ */

.settings-group {
    margin-bottom: 24px;
}

.settings-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding-left: 4px;
}

.settings-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Transaction Details modal */
.txd-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.txd-meta-row:last-child { border-bottom: none; }
.txd-meta-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.txd-meta-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.txd-desc-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap;
}
.txd-desc-text.txd-collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
#txdReceiptBtn { display: none; }
#txdReceiptBtn[data-show="1"] { display: flex !important; }

/* Receipts Vault list */
.receipt-vault-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.receipt-vault-item:hover { background: var(--bg-elevated); }
.receipt-vault-item:active { transform: scale(0.98); }
.receipt-vault-icon {
    width: 38px; height: 38px;
    background: rgba(245, 158, 11, 0.14);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.receipt-vault-text {
    flex: 1;
    min-width: 0;
}
.receipt-vault-merchant {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}
.receipt-vault-meta {
    font-size: 11px;
    color: var(--text-muted);
}
.receipt-vault-total {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--danger);
    white-space: nowrap;
    flex-shrink: 0;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:active {
    background: var(--bg-card-hover);
}

.settings-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.settings-text {
    flex: 1;
}

.settings-label {
    font-size: 14px;
    font-weight: 500;
}

.settings-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Toggle switch ── */
.toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--bg-elevated);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    align-self: center;
    transition: background 0.2s;
    border: 1px solid var(--border);
}
.toggle.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}
.toggle-knob {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 1px;
    left: 1px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.active .toggle-knob {
    transform: translateX(20px);
}

.settings-chevron {
    color: var(--text-muted);
    font-size: 14px;
}

.powered-by {
    text-align: center;
    padding: 24px 0 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.powered-by span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* ── Family active card ── */
.family-active-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
}

/* ── Input groups & labels ── */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-label {
    font-family: 'Switzer', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-left: 2px;
}

/* Currency picker modal */
.currency-picker {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 300;
    display: none;
    align-items: flex-end;
}

.currency-picker.show {
    display: flex;
}

.currency-sheet {
    width: 100%;
    max-height: 70vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 12px 16px calc(16px + var(--safe-bottom));
    animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.currency-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 12px;
}

.currency-item {
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.currency-item:active {
    background: var(--bg-card-hover);
}

.currency-item.selected {
    background: var(--accent-blue-soft);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
    background: linear-gradient(90deg,
        var(--bg-card) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   SUCCESS ANIMATION
   ============================================ */

.success-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: linear-gradient(135deg,
        rgba(79,70,229,0.18) 0%,
        rgba(129,140,248,0.12) 100%);
    border: 1px solid rgba(129,140,248,0.35);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 300;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(79,70,229,0.25),
                0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

@keyframes toastWave {
    0%   { box-shadow: 0 8px 32px rgba(79,70,229,0.25), 0 0 0 0   rgba(129,140,248,0.35); }
    45%  { box-shadow: 0 8px 32px rgba(79,70,229,0.15), 0 0 0 10px rgba(129,140,248,0.08); }
    100% { box-shadow: 0 8px 32px rgba(79,70,229,0.25), 0 0 0 18px rgba(129,140,248,0); }
}

.success-toast.show {
    transform: translateX(-50%) translateY(0);
    animation: toastWave 0.7s ease-out 0.35s both;
}

.success-toast.error {
    background: linear-gradient(135deg, rgba(248,113,113,0.20) 0%, rgba(248,113,113,0.12) 100%);
    border-color: rgba(248,113,113,0.40);
    box-shadow: 0 8px 32px rgba(248,113,113,0.22), 0 2px 8px rgba(0,0,0,0.3);
}

.success-toast-icon {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    background: rgba(79,70,229,0.18);
    border: 1px solid rgba(129,140,248,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-soft);
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================
   CATEGORY COLORS — Deep Cosmos Palette
   ① #4f46e5 Deep Indigo  ② #818cf8 Soft Indigo
   ③ #22d3ee Cyan         ④ #10b981 Emerald
   ⑤ #f59e0b Amber
   ============================================ */

/* Groceries — Emerald (fresh, organic) */
.cat-groceries { background: rgba(16, 185, 129, 0.13); }
/* Restaurants / Dining — Amber (warmth, food) */
.cat-dining    { background: rgba(245, 158, 11, 0.13); }
/* Transport — Deep Indigo (movement, reliable) */
.cat-transport { background: rgba(79, 70, 229, 0.13); }
/* Apartment / Housing — Soft Indigo (stable, home) */
.cat-house     { background: rgba(129, 140, 248, 0.13); }
/* Subscriptions / Regular — Cyan (digital, tech) */
.cat-regular   { background: rgba(34, 211, 238, 0.13); }
/* Shopping — Deep Indigo (premium, desire) */
.cat-shopping  { background: rgba(79, 70, 229, 0.13); }
/* Beauty / Health — Amber (warmth, care) */
.cat-beauty    { background: rgba(245, 158, 11, 0.13); }
/* Sports — Emerald (energy, health) */
.cat-sport     { background: rgba(16, 185, 129, 0.13); }
/* Travel — Cyan (sky, horizon) */
.cat-travel    { background: rgba(34, 211, 238, 0.13); }
/* Home decor / Garden — Soft Indigo */
.cat-home      { background: rgba(129, 140, 248, 0.13); }
/* Trading / Crypto — Amber (value, gold) */
.cat-trading   { background: rgba(245, 158, 11, 0.13); }
/* Other / Unknown — neutral */
.cat-other     { background: rgba(148, 163, 184, 0.10); }

/* Income categories */
.cat-salary    { background: rgba(16, 185, 129, 0.14); }
.cat-freelance { background: rgba(79, 70, 229, 0.13); }
.cat-invest    { background: rgba(34, 211, 238, 0.13); }
.cat-gift      { background: rgba(245, 158, 11, 0.13); }
.cat-refund    { background: rgba(129, 140, 248, 0.13); }

/* ============================================
   CATEGORY MANAGER
   ============================================ */

.category-manager-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 2px;
}

.category-manager-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
}

.category-manager-item:last-child {
    border-radius: var(--radius-md) var(--radius-md) var(--radius-lg) var(--radius-lg);
}

.category-manager-item:only-child {
    border-radius: var(--radius-lg);
}

.category-manager-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    font-size: 20px;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-elevated);
}

/* Icon Picker */
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    padding: 2px;
    margin-bottom: 16px;
}
.icon-picker-item {
    aspect-ratio: 1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    background: var(--bg-elevated);
}
.icon-picker-item i { font-size: 18px; color: var(--text-secondary); pointer-events: none; }
.icon-picker-item.selected { background: var(--accent-blue-soft); border-color: var(--accent-blue); }
.icon-picker-item.selected i { color: var(--accent-blue); }
.icon-picker-item:hover:not(.selected) { border-color: var(--border); }

.cat-inline-icon-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: -4px 0 8px;
    max-height: 200px;
    overflow-y: auto;
}
.category-manager-icon.editing {
    cursor: pointer;
    position: relative;
    outline: 2px solid var(--accent-blue);
    outline-offset: 1px;
}

.category-manager-info {
    flex: 1;
    min-width: 0;
}

.category-manager-name {
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-manager-name input {
    background: var(--bg-elevated);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Switzer', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 4px 8px;
    outline: none;
    flex: 1;
}

.category-manager-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 6px;
}
.category-badge svg {
    width: 11px;
    height: 11px;
    display: block;
    stroke: currentColor;
}

.category-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.category-action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s ease;
}
.category-action-btn svg {
    width: 15px;
    height: 15px;
    display: block;
    stroke: currentColor;
}
.category-action-btn.edit  { background: var(--accent-blue-soft); color: var(--accent-blue); }
.category-action-btn.delete { background: var(--danger-soft); color: var(--danger); }

.category-action-btn.edit {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

.category-action-btn.delete {
    background: var(--danger-soft);
    color: var(--danger);
}

.category-action-btn.save {
    background: var(--success-soft);
    color: var(--success);
}

.category-action-btn.cancel {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.category-action-btn:active {
    transform: scale(0.9);
}

/* ============================================
   ACCOUNT CHIP FILTER (category manager)
   ============================================ */

.account-chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 12px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 4px;
}
.account-chip-row::-webkit-scrollbar { display: none; }

.account-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--border-subtle);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.account-chip svg {
    display: block;
    width: 14px !important;
    height: 14px !important;
    min-width: 14px;
    max-width: 14px;
    flex-shrink: 0;
}
.account-chip.active {
    border-color: var(--accent-blue);
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}
.account-chip:active { transform: scale(0.95); }

/* ============================================
   CUSTOM PICKER (bottom-sheet select replacement)
   ============================================ */

.picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--bg-card);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: border-color 0.15s, background 0.15s;
    text-align: left;
    font-family: inherit;
    color: var(--text-primary);
    box-sizing: border-box;
}
.picker-trigger:active { background: var(--bg-elevated); }

.picker-trigger-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.picker-trigger-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 17px;
}
.picker-trigger-icon svg { width: 17px; height: 17px; }
.picker-trigger-text {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.picker-trigger-chevron { color: var(--text-muted); flex-shrink: 0; }
.picker-trigger-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.1s;
    margin: 0 4px;
}
.picker-item:active { background: var(--bg-elevated); transform: scale(0.99); }
.picker-item.selected { background: var(--accent-blue-soft); }
.picker-item-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}
.picker-item-icon svg { width: 18px; height: 18px; }
.picker-trigger-icon svg { width: 18px; height: 18px; }
.picker-item-icon:has(img), .picker-trigger-icon:has(img) {
    border: 1.5px solid var(--logo-border);
    overflow: hidden;
}
.picker-item-icon img, .picker-trigger-icon img {
    width: 100%; height: 100%; object-fit: contain; display: block; padding: 4px; box-sizing: border-box;
}
.picker-item-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}
.picker-item-check { color: var(--accent-blue); flex-shrink: 0; }


/* ============================================
   ACCOUNT MANAGE LIST (settings)
   ============================================ */

.account-manage-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
}
.account-manage-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
}
.account-manage-item:last-child {
    border-radius: var(--radius-md) var(--radius-md) var(--radius-lg) var(--radius-lg);
    border-bottom: none;
}
.account-manage-item:only-child { border-radius: var(--radius-lg); }

.account-manage-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--bg-elevated);
}
.account-manage-icon svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: currentColor;
}
.account-manage-info { flex: 1; min-width: 0; }
.account-manage-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}
.account-manage-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================
   EXPORT TABLE
   ============================================ */

#exportTable tbody tr {
    border-bottom: 1px solid var(--border-subtle);
}

#exportTable tbody tr:last-child {
    border-bottom: none;
}

#exportTable tbody td {
    padding: 10px 8px;
    vertical-align: middle;
}

#exportTable .export-amount {
    font-family: 'DM Mono', monospace;
    font-weight: 500;
}

#exportTable .export-amount.income {
    color: var(--success);
}

#exportTable .export-amount.expense {
    color: var(--danger);
}

#exportTable .export-type {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#exportTable .export-type.income {
    background: var(--success-soft);
    color: var(--success);
}

#exportTable .export-type.expense {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ============================================
   AUTH SCREEN
   ============================================ */
#authScreen {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 1000;
    overflow-y: auto;
    padding: 0 0 env(safe-area-inset-bottom, 20px);
}
.auth-container {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    max-width: 400px;
    margin: 0 auto;
}
.auth-logo { margin-bottom: 24px; }
.auth-title {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #4f46e5, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
    text-align: center;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    margin-bottom: 32px;
}
.auth-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 24px;
    width: 100%;
    border: 1px solid var(--border);
}
.auth-tab {
    flex: 1;
    padding: 9px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    font-family: inherit;
}
.auth-tab.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.auth-form { width: 100%; }
.auth-field { margin-bottom: 14px; }
.auth-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}
.auth-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px 14px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.auth-input:focus { border-color: var(--accent-blue); }
.auth-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: opacity 0.2s, transform 0.1s;
}
.auth-btn:active { transform: scale(0.98); opacity: 0.85; }
.auth-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #818cf8);
    color: white;
}
.auth-btn-telegram {
    background: #2AABEE;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.auth-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: #f87171;
    margin-bottom: 14px;
    display: none;
}
.tg-widget-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 4px;
}
.tg-widget-wrap iframe {
    border-radius: 10px !important;
    overflow: hidden;
}
.social-login-btns {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}
.auth-btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: 10px;
    padding: 13px 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.auth-btn-social:active { transform: scale(0.98); opacity: 0.85; }
.auth-btn-social svg { flex-shrink: 0; }
.auth-btn-tg  { background: #2AABEE; color: #fff; }
.auth-btn-google { background: #fff; color: #3c4043; border: 1px solid #dadce0; }
.auth-btn-apple  { background: #000; color: #fff; }
.auth-btn-fb     { background: #1877F2; color: #fff; }

/* ── Global scrollbar ── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   DESKTOP LAYOUT  ≥ 768px
   ============================================================ */

/* Narrow icon sidebar — hidden on mobile */
.desktop-sidebar {
    display: none;
    width: 64px;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    padding: 20px 0 16px;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    z-index: 10;
}

/* Logo pill */
.ds-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 16px;
}

.ds-logo-pill {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px var(--accent-blue-glow);
    flex-shrink: 0;
}

.ds-logo-pill svg { width: 22px; height: 22px; }

/* "+" FAB in sidebar */
.ds-fab {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--accent-blue-glow);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
    margin-bottom: 14px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.ds-fab:hover { opacity: 0.85; transform: scale(1.08); }
.ds-fab:active { transform: scale(0.92); }
.ds-fab svg { width: 20px; height: 20px; }

/* Nav icons */
.ds-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    width: 100%;
}

.ds-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.ds-nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.ds-nav-item.active {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

/* Active left indicator bar */
.ds-nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    border-radius: 2px;
    background: var(--accent-gradient);
}

.ds-nav-item svg { width: 20px; height: 20px; }

/* Logout btn in sidebar */
.ds-logout-btn { color: var(--danger) !important; opacity: 0.55; }
.ds-logout-btn:hover { background: rgba(239,68,68,0.1) !important; color: var(--danger) !important; opacity: 1; }

/* Version */
.ds-version {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    opacity: 0.35;
    margin-top: 8px;
}

/* ── Desktop breakpoint ── */
@media (min-width: 768px) {
    body { background: var(--bg-primary); }

    .app {
        flex-direction: row;
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .desktop-sidebar { display: flex; }
    .bottom-nav { display: none !important; }
    .nav-fab    { display: none !important; }
    .dash-logo-bar { display: none; }

    /* screenTrack: single active screen, full-width */
    #screenTrack {
        width: 100% !important;
        display: block !important;
        transform: none;
        transition: none;
        height: 100%;
        overflow: hidden;
    }

    .screen {
        width: 100% !important;
        height: 100%;
        display: none;
        overflow-y: auto;
        padding-bottom: 24px;
        box-sizing: border-box;
    }

    .screen.active { display: flex; flex-direction: column; }

    /* Dashboard: hide mobile content, show desktop card grid */
    .mobile-dash-content { display: none; }

    /* Desktop 4-card grid — shown inside screenDashboard */
    .dsk-dash-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 14px;
        padding: 20px;
        flex: 1;
        min-height: 0;
        box-sizing: border-box;
    }
    /* Card glow by position */
    .dsk-card:nth-child(1) {
        border-color: rgba(99,102,241,0.25);
        box-shadow: 0 2px 16px rgba(0,0,0,0.07), 0 0 28px rgba(99,102,241,0.18);
    }
    .dsk-card:nth-child(1):hover {
        border-color: rgba(99,102,241,0.5);
        box-shadow: 0 4px 28px rgba(0,0,0,0.12), 0 0 48px rgba(99,102,241,0.32);
    }
    .dsk-card:nth-child(2) {
        border-color: rgba(16,185,129,0.22);
        box-shadow: 0 2px 16px rgba(0,0,0,0.07), 0 0 28px rgba(16,185,129,0.16);
    }
    .dsk-card:nth-child(2):hover {
        border-color: rgba(16,185,129,0.45);
        box-shadow: 0 4px 28px rgba(0,0,0,0.12), 0 0 48px rgba(16,185,129,0.28);
    }
    .dsk-card:nth-child(3) {
        border-color: rgba(245,158,11,0.22);
        box-shadow: 0 2px 16px rgba(0,0,0,0.07), 0 0 28px rgba(245,158,11,0.16);
    }
    .dsk-card:nth-child(3):hover {
        border-color: rgba(245,158,11,0.45);
        box-shadow: 0 4px 28px rgba(0,0,0,0.12), 0 0 48px rgba(245,158,11,0.28);
    }
    .dsk-card:nth-child(4) {
        border-color: rgba(236,72,153,0.2);
        box-shadow: 0 2px 16px rgba(0,0,0,0.07), 0 0 28px rgba(236,72,153,0.14);
    }
    .dsk-card:nth-child(4):hover {
        border-color: rgba(236,72,153,0.42);
        box-shadow: 0 4px 28px rgba(0,0,0,0.12), 0 0 48px rgba(236,72,153,0.26);
    }
}

/* Desktop dashboard header */
.dsk-dash-header { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 768px) {
    .dsk-dash-header {
        display: block;
        flex-shrink: 0;
        border-bottom: 1px solid var(--border-subtle);
    }
    /* History screen: sticky header+filters, scrollable list */
    #screenHistory { overflow: hidden !important; }
    #screenHistory .stats-header { flex-shrink: 0; padding: 20px 20px 0; margin-bottom: 10px; }
    #screenHistory .history-filters { flex-shrink: 0; padding: 0 20px 12px; }
    #screenHistory #historyList { flex: 1; overflow-y: auto; min-height: 0; padding: 0 8px; }
    #screenHistory #receiptsHistorySection { flex-shrink: 0; padding: 0 8px 16px; }
    /* Settings scrollable */
    #screenSettings { overflow-y: auto !important; }
    /* Add modal — centered dialog on desktop */
    #addModal { align-items: center; justify-content: center; }
    #addModal .modal-sheet {
        border-radius: var(--radius-xl);
        max-width: 480px;
        width: 90%;
        max-height: 82vh;
        animation: none;
    }
    #addModal .category-grid {
        max-height: 160px;
        overflow-y: auto;
    }
}

/* ── Force mobile layout — body.force-mobile (Capacitor default) ── */
body.force-mobile .desktop-sidebar { display: none !important; }
body.force-mobile .bottom-nav      { display: flex !important; }
body.force-mobile .nav-fab         { display: flex !important; }
body.force-mobile .dash-logo-bar   { display: flex !important; }
body.force-mobile .app             { flex-direction: column !important; }
body.force-mobile #screenTrack {
    width: 400% !important;
    display: flex !important;
    overflow: visible !important;
}
body.force-mobile .screen {
    width: 25% !important;
    display: block !important;
    overflow-y: auto !important;
    padding-bottom: calc(96px + var(--safe-bottom)) !important;
}
body.force-mobile .screen.active { display: block !important; }
body.force-mobile .mobile-dash-content { display: block !important; }
body.force-mobile .dsk-dash-grid   { display: none !important; }
body.force-mobile .dsk-dash-header { display: none !important; }
body.force-mobile #screenHistory   { overflow: auto !important; }
body.force-mobile #addModal        { align-items: flex-end !important; justify-content: center !important; }
body.force-mobile #addModal .modal-sheet {
    border-radius: 24px 24px 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh !important;
}
body.force-mobile #addModal .category-grid { max-height: none !important; overflow-y: visible !important; }

/* Card styles (apply always, responsive visibility) */
.dsk-dash-grid { display: none; }

.dsk-card {
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0,0,0,0.07);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.dsk-card-header {
    padding: 16px 18px 10px;
    font-family: 'Switzer', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.dsk-card-body {
    flex: 1;
    padding: 14px 18px;
    overflow-y: auto;
    min-height: 0;
}
    /* Hide old injected Electron logout button (replaced by settings button) */
    #_eLogout { display: none !important; }
    /* Always show logout button in settings */
    #logoutSection { display: block !important; }

/* ── Auth language switcher ── */
.auth-lang-row { display:flex; justify-content:center; gap:8px; margin-top:20px; padding-bottom:8px; }
.auth-lang-btn { background:none; border:1px solid var(--border); color:var(--text-muted); padding:4px 12px; border-radius:20px; font-size:12px; cursor:pointer; font-family:inherit; transition:all .15s; }
.auth-lang-btn.active, .auth-lang-btn:hover { border-color:var(--accent-blue); color:var(--accent-blue); }
