/* ═══ DESIGN SYSTEM — Information-dense fintech ═══ */
:root {
    --bg-primary: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222636;
    --bg-sidebar: #0d0f15;
    --border: #2a2e3a;
    --text-primary: #e8eaed;
    --text-secondary: #8b8fa3;
    --text-muted: #5f6378;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --income: #22c55e;
    --income-bg: rgba(34,197,94,.12);
    --expense: #ef4444;
    --expense-bg: rgba(239,68,68,.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,.12);
    --neutral: #64748b;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,.25);
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
}
[data-bs-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fb;
    --bg-sidebar: #1a1d23;
    --border: #e2e5ea;
    --text-primary: #1a1d23;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body { background: var(--bg-primary); color: var(--text-primary); font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; font-size: .875rem; }

/* ═══ SIDEBAR (desktop) ═══ */
.sidebar {
    width: 210px; min-width: 210px;
    height: 100vh; max-height: 100vh;
    background: var(--bg-sidebar); color: #e8eaed;
    display: flex; flex-direction: column;
    position: sticky; top: 0; z-index: 1040;
    border-right: 1px solid rgba(255,255,255,.05);
    transition: width .2s, min-width .2s;
}
.sidebar.collapsed { width: 52px; min-width: 52px; }
.sidebar.collapsed .nav-text, .sidebar.collapsed .brand-text,
.sidebar.collapsed small.nav-text { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-link i { margin-right: 0; }
.sidebar.collapsed .sidebar-footer .dropdown-toggle span { display: none; }
.sidebar.collapsed .collapse, .sidebar.collapsed .sidebar-group-toggle .bi-chevron-down { display: none; }
.sidebar.collapsed .sidebar-footer-full { display: none !important; }
.sidebar.collapsed .sidebar-collapsed-toggle { display: block !important; }
.sidebar.collapsed .sidebar-footer { padding: 4px !important; }

.sidebar-header { flex-shrink: 0; }
.sidebar-scroll {
    flex: 1 1 0; overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch; min-height: 0;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 3px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
.sidebar-footer { flex-shrink: 0; overflow: visible; position: relative; z-index: 1050; }

.sidebar-brand { font-size: 1.1rem; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.sidebar .nav-link {
    color: #8b8fa3; border-radius: 8px; padding: .45rem .7rem;
    font-size: .8rem; display: flex; align-items: center; white-space: nowrap;
    transition: all .15s;
}
.sidebar .nav-link:hover { color: #e8eaed; background: rgba(255,255,255,.06); }
.sidebar .nav-link.active { color: #fff; background: var(--accent); }
.sidebar .nav-link i { width: 18px; text-align: center; margin-right: 8px; flex-shrink: 0; font-size: .85rem; }
.sidebar .nav-sub { padding-left: 2rem; font-size: .75rem; padding-top: .25rem; padding-bottom: .25rem; }
.sidebar .nav-sub::before { content:''; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: #5f6378; margin-right: 6px; vertical-align: middle; }
.sidebar .nav-sub.active::before { background: #fff; }
.sidebar-group-toggle .bi-chevron-down { transition: transform .2s; }
.sidebar-group-toggle.collapsed .bi-chevron-down { transform: rotate(-90deg); }

/* ═══ MAIN CONTENT ═══ */
.main-content { flex: 1; min-width: 0; overflow-y: auto; padding: 1rem; padding-bottom: 5rem; }

/* ═══ CARDS ═══ */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-clickable:hover { box-shadow: 0 4px 16px rgba(0,0,0,.2); cursor: pointer; }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .8rem; }

/* Stat cards */
.stat-card { border: none; }
.stat-card .stat-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 2px; }
.stat-card .stat-value { font-size: 1.2rem; font-weight: 700; font-family: var(--font-mono); }

/* ═══ MONEY FORMATTING ═══ */
.text-income { color: var(--income) !important; }
.text-expense { color: var(--expense) !important; }
.text-warning-custom { color: var(--warning) !important; }
.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ═══ LIST ITEMS ═══ */
.list-group-item {
    background: transparent; border-color: var(--border);
    transition: background .1s;
}
.list-group-item:hover, .list-group-item-action:hover { background: var(--bg-card-hover); }

/* ═══ TABLES ═══ */
.table { color: var(--text-primary); --bs-table-bg: transparent; }
.table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-color: var(--border); }
.table td { border-color: var(--border); vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--bg-card-hover); }

/* ═══ TRANSACTION ALTERNATING ROWS ═══ */
.tx-row-alt { background: rgba(59,130,246,.04) !important; }
.tx-date-header { background: rgba(0,0,0,.03); }
.tx-date-header.tx-row-alt { background: rgba(59,130,246,.08) !important; }
[data-bs-theme="dark"] .tx-row-alt { background: rgba(59,130,246,.06) !important; }
[data-bs-theme="dark"] .tx-date-header { background: rgba(255,255,255,.04); }
[data-bs-theme="dark"] .tx-date-header.tx-row-alt { background: rgba(59,130,246,.10) !important; }

/* ═══ LOADING SPINNER ═══ */
.modal-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; color: var(--text-muted);
}
.modal-loading .spinner-border { width: 2rem; height: 2rem; }

/* ═══ FORMS ═══ */
.form-control, .form-select, .ts-control {
    background: var(--bg-card); border-color: var(--border); color: var(--text-primary);
    border-radius: 8px; font-size: .85rem;
}
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.2); }
.form-control::placeholder { color: var(--text-muted); }

/* TomSelect — match form-control-sm */
.ts-wrapper { border-radius: 8px; flex-shrink: 0; width: 160px; }
/* In modal: auto-width to fill container */
.modal .ts-wrapper { width: 100%; flex-shrink: 1; }
.ts-wrapper .ts-control {
    border-radius: 8px; min-height: 31px; max-height: 31px;
    flex-wrap: nowrap; overflow: hidden; padding: 0 8px;
    display: flex; align-items: center;
}
.ts-wrapper .ts-control input { font-size: .8rem; line-height: 27px; padding: 0; }
.ts-wrapper .ts-control input::placeholder { color: var(--text-muted); opacity: 1; }
.ts-wrapper .ts-control > .item {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; line-height: 27px; padding: 0; margin: 0;
    font-size: .8rem;
}
.ts-wrapper.focus .ts-control { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.2); }
.ts-wrapper.focus .ts-control > .item { display: none; }
/* Dropdown */
.ts-dropdown { border-radius: 0 0 8px 8px; border-color: var(--border); min-width: 180px; }
.ts-dropdown .option { font-size: .8rem; padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-dropdown .active { background: var(--accent); color: #fff; }

/* ═══ BUTTONS ═══ */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn { border-radius: 8px; font-size: .8rem; transition: all .15s; }

/* ═══ BADGES ═══ */
.badge { font-weight: 500; font-size: .7rem; border-radius: 6px; }

/* ═══ PROGRESS BARS ═══ */
.budget-progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.budget-progress-bar { height: 100%; border-radius: 3px; transition: width .5s ease; }
/* Calendar heatmap */
.cal-cell { border-radius: 6px; padding: 4px 2px; min-height: 52px; text-align: center; border: 1px solid var(--border); transition: transform .15s; }
.cal-cell:hover { transform: scale(1.05); z-index: 1; }
.cal-today { border: 2px solid var(--accent) !important; font-weight: 700; }
.cal-weekend { background-color: rgba(128,128,128,.05); }
.cal-weekend .cal-day { color: var(--text-muted); }
.cal-empty { background: transparent; border-color: transparent; min-height: 52px; }
.cal-day { font-size: .75rem; font-weight: 600; color: var(--text-primary); }
.cal-amount { font-size: .6rem; font-weight: 500; color: var(--text-secondary); margin-top: 1px; }
.cal-legend { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 3px; }

/* Analytics: recurring action buttons */
.rec-actions .btn { min-width: 36px; min-height: 32px; font-size: .85rem; }

/* Analytics: accent card border */
.card-accent { border-left: 3px solid var(--accent); }

/* Analytics: comparison total row */
.comp-total { background: var(--bg-secondary); font-weight: 600; }

/* Analytics: responsive chart container */
.chart-container { position: relative; width: 100%; }
.chart-container canvas { width: 100% !important; }

/* Mobile: hide secondary columns in tables */
@media (max-width: 575px) {
    .hide-xs { display: none !important; }
    .cal-cell { min-height: 40px; padding: 2px 1px; }
    .cal-day { font-size: .65rem; }
    .rec-actions .btn { min-width: 32px; min-height: 28px; font-size: .75rem; }
}
.budget-ok { background: var(--income); }
.budget-warn { background: var(--warning); }
.budget-over { background: var(--expense); }

/* ═══ ANALYTICS ═══ */
/* Chart containers — aspect ratio controlled, no fixed height */
.chart-doughnut { position: relative; }
.chart-bar { position: relative; }
.chart-line { position: relative; }
.chart-mini { position: relative; height: 120px; }
/* Recurring action buttons — large enough for touch */
.btn-action { min-width: 36px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; }
/* Confidence indicator */
.confidence-bar { height: 3px; border-radius: 2px; }
/* Category accent border */
.card-accent-blue { border-left: 3px solid var(--accent); }
.card-accent-green { border-left: 3px solid var(--income); }
.card-accent-red { border-left: 3px solid var(--expense); }
/* Comparison total row */
.comp-total-row { background: var(--bg-card); font-weight: 600; border-top: 2px solid var(--border); }
/* Cashflow corridor labels */
.corridor-up { color: var(--income); }
.corridor-down { color: var(--expense); }

@media (max-width: 767px) {
    .cal-cell { min-height: 40px; padding: 2px 1px; }
    .cal-day { font-size: .65rem; }
    .hide-mobile { display: none !important; }
    .chart-doughnut, .chart-bar, .chart-line { min-height: 180px; }
}

/* ═══ FILTER BAR ═══ */
.filter-bar { margin-bottom: .5rem; }

/* ═══ MASS ACTION BAR ═══ */
.mass-bar {
    position: sticky; bottom: 0; z-index: 100; padding: .5rem;
    background: var(--bg-card); border-top: 2px solid var(--accent);
    box-shadow: 0 -2px 8px rgba(0,0,0,.2);
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

/* Merge bar: grid layout — inline on desktop, stacked on mobile */
.merge-bar-inner {
    display: grid;
    grid-template-columns: auto 1fr 180px auto;
    gap: .5rem;
    align-items: center;
    max-width: 100%;
}
.merge-bar-title { font-size: .85rem; white-space: nowrap; }
.merge-bar-input, .merge-bar-select { min-width: 0; }
.merge-bar-actions { display: flex; gap: .4rem; }
@media (max-width: 768px) {
    .mass-bar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        padding: .5rem .75rem;
        margin: 0;
    }
    .merge-bar-inner {
        display: flex;
        flex-direction: column;
        gap: .4rem;
        width: 100%;
    }
    .merge-bar-title {
        font-size: .8rem;
        text-align: center;
        padding: 2px 0;
    }
    .merge-bar-input, .merge-bar-select {
        width: 100%;
    }
    .merge-bar-actions {
        display: flex;
        gap: .4rem;
        width: 100%;
    }
    .merge-bar-actions .btn {
        flex: 1;
        font-size: .8rem;
        padding: .35rem .25rem;
    }
    /* Add bottom padding to body so content doesn't hide under fixed bar */
    body.merge-active {
        padding-bottom: 200px;
    }
}

/* ═══ QUICK-FAB ═══ */
.quick-fab {
    position: fixed; bottom: 20px; right: 20px; z-index: 1030;
    width: 52px; height: 52px; font-size: 1.3rem;
    box-shadow: 0 4px 16px rgba(59,130,246,.4);
    transition: transform .2s, box-shadow .2s;
}
.quick-fab:hover { transform: scale(1.1); box-shadow: 0 6px 24px rgba(59,130,246,.5); }

/* ═══ TOAST ═══ */
.toast { border-radius: var(--radius); }

/* ═══ SIDEBAR BACKDROP ═══ */
.sidebar-backdrop { display: none; }

/* ═══ LOGIN ═══ */
.login-container { max-width: 380px; margin: 1vh auto; }
.login-card { border: none; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,.15); }

/* ═══ AUTOCOMPLETE HINT ═══ */
.autocat-hint { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--income-bg); color: var(--income); }

/* ═══ PAYEE AUTOCOMPLETE DROPDOWN ═══ */
.payee-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 0 0 8px 8px; box-shadow: 0 4px 12px rgba(0,0,0,.3);
    max-height: 200px; overflow-y: auto;
}
.payee-item {
    padding: 6px 10px; font-size: .8rem; cursor: pointer;
    transition: background .1s;
}
.payee-item:hover { background: var(--bg-card-hover); }
.payee-item b { color: var(--accent); }
.ls-item { border-bottom: 1px solid var(--border); transition: background .15s; }
.ls-item:last-child { border-bottom: none; }
.ls-item:hover { background: var(--bg-card-hover); }

/* ═══ ANIMATIONS ═══ */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.fade-in { animation: fadeInUp .3s ease both; }
.skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--bg-card-hover) 50%, var(--border) 75%); background-size: 200%; animation: pulse 1.5s infinite; border-radius: 4px; }

/* Stagger children */
.stagger > *:nth-child(1) { animation-delay: 0s; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }

/* ═══ MOBILE BOTTOM TAB-BAR ═══ */
@media (max-width: 767px) {
    .sidebar { display: none !important; }
    .sidebar.show {
        display: flex !important;
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 1050;
        width: 240px; min-width: 240px;
        padding-top: env(safe-area-inset-top, 0px);
        box-shadow: 4px 0 24px rgba(0,0,0,.5);
    }
    .sidebar-toggle { display: none !important; }
    .sidebar-backdrop { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1045; background: rgba(0,0,0,.5); }
    .sidebar-backdrop.show { display: block !important; }

    .main-content { padding: calc(2rem + env(safe-area-inset-top, 0px)) .5rem 5rem .5rem !important; }

    .bottom-nav {
        position: fixed; bottom: 0; left: 0; right: 0; z-index: 1040;
        background: var(--bg-card); border-top: 1px solid var(--border);
        display: flex; justify-content: space-around; align-items: center;
        padding: .3rem 0 env(safe-area-inset-bottom, .3rem);
        box-shadow: 0 -2px 12px rgba(0,0,0,.15);
    }
    .bottom-nav a {
        display: flex; flex-direction: column; align-items: center;
        color: var(--text-muted); text-decoration: none;
        font-size: .55rem; padding: .25rem .25rem; border-radius: 8px;
        transition: color .15s; min-width: 0;
    }
    .bottom-nav a i { font-size: 1.1rem; margin-bottom: 1px; }
    .bottom-nav a.active { color: var(--accent); }
    .bottom-nav a:hover { color: var(--accent); }

    /* Quick-fab above tab bar */
    .quick-fab { bottom: 70px !important; right: 16px !important; width: 46px !important; height: 46px !important; }

    /* Hide non-essential on mobile */
    .d-mob-none { display: none !important; }
    .stat-card .stat-value { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* Card padding */
    .card-body { padding: .5rem; }

    /* Touch targets: minimum 36px */
    .btn-sm { min-height: 36px; }
    .form-select-sm, .form-control-sm { min-height: 36px; }

    /* Full-screen modal */
    .modal-dialog { margin: 0; max-width: 100%; min-height: 100vh; }
    .modal-content { border: none; border-radius: 0; min-height: 100vh; padding-top: 32px; }

    /* Mass action bar: wrap on mobile */
    .mass-bar { flex-wrap: wrap; gap: .25rem; }
    .mass-bar .form-select { max-width: 140px; }

    /* Collapsible filters */
    .filter-extra { display: none; }
    .filter-extra.show { display: contents; }

    /* Dashboard sections: collapsed by default on mobile */
    .dash-collapse-mob { display: none; }
    .dash-collapse-mob.show { display: block; }
}
@media (min-width: 768px) {
    .bottom-nav { display: none !important; }
    .sidebar-toggle { display: none !important; }
}

/* ═══ SCROLLBAR (webkit) ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══ CHECKLIST — per-owner cards ═══ */
.ck-type-row {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    font-size: .75rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}
.ck-acc-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 12px 3px 28px;
    font-size: .8rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: background .12s;
}
.ck-acc-row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ck-acc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 65%; }
.ck-acc-bal { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ═══ ACCOUNTS ═══ */
.acc-star, .acc-check {
    cursor: pointer;
    user-select: none;
    transition: all .15s;
    line-height: 1;
}
.acc-star { font-size: 1rem; color: var(--border); }
.acc-star:hover { color: #f59e0b; transform: scale(1.3); }
.acc-star.active { color: #f59e0b; }
.acc-check { font-size: .7rem; color: var(--border); font-weight: 700; }
.acc-check:hover { color: var(--accent); transform: scale(1.3); }
.acc-check.active { color: var(--accent); }

/* ═══ NOTIFICATION DROPDOWN ═══ */
.notif-dropdown {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color, rgba(0,0,0,.15));
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    font-size: .85rem;
}
.notif-dropdown .dropdown-item {
    color: var(--text-primary, #212529) !important;
    white-space: normal;
}
.notif-dropdown .dropdown-item:hover,
.notif-dropdown .dropdown-item:focus {
    background: var(--accent-bg, rgba(67,97,238,.1)) !important;
    color: var(--text-primary, #212529) !important;
}
[data-bs-theme="dark"] .notif-dropdown {
    background: #1e1e2e !important;
    border-color: rgba(255,255,255,.1);
}
[data-bs-theme="dark"] .notif-dropdown .dropdown-item {
    color: #e8eaed !important;
}
[data-bs-theme="dark"] .notif-dropdown .dropdown-item:hover {
    background: rgba(255,255,255,.08) !important;
}

/* ═══ Empty States ═══════════════════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted, #6c757d);
}
.empty-state i {
    font-size: 3rem;
    opacity: .4;
    margin-bottom: .5rem;
    display: block;
}
.empty-state p {
    margin: .5rem 0;
    font-size: .95rem;
}
.empty-state .btn { margin-top: .5rem; }

/* ═══ FAB Template Menu ═══ */
.fab-tpl-menu {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 260px;
    max-width: calc(100vw - 48px);
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #dee2e6);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    z-index: 1029;
    animation: fabMenuIn .15s ease-out;
}
@keyframes fabMenuIn {
    from { opacity: 0; transform: translateY(8px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.fab-tpl-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #dee2e6);
    font-size: .85rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.fab-tpl-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    text-align: left;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border, #dee2e6);
    color: var(--text-primary);
    cursor: pointer;
    font-size: .85rem;
    transition: background-color .1s;
}
.fab-tpl-item:last-child { border-bottom: none; }
.fab-tpl-item:hover, .fab-tpl-item:focus {
    background: var(--bg-hover, rgba(0,0,0,.05));
    outline: none;
}
.fab-tpl-item .tpl-name { font-weight: 500; display: block; }
.fab-tpl-item .tpl-meta {
    font-size: .72rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

/* ═══ Pull-to-refresh ═══ */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    z-index: 9996;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card, #fff);
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease-out, opacity .15s;
    opacity: 0;
    pointer-events: none;
}
.ptr-indicator.ptr-pulling {
    transition: none;
}
.ptr-indicator.ptr-refreshing {
    transform: translateX(-50%) translateY(16px) !important;
    opacity: 1 !important;
}
.ptr-arrow {
    width: 18px; height: 18px;
    color: var(--text-primary, #1f2937);
    transition: transform .2s;
}
.ptr-indicator.ptr-ready .ptr-arrow {
    transform: rotate(180deg);
}
.ptr-indicator.ptr-refreshing .ptr-arrow {
    display: none;
}
.ptr-spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--accent, #3b82f6);
    border-top-color: transparent;
    border-radius: 50%;
    animation: syncSpin .8s linear infinite;
    display: none;
}
.ptr-indicator.ptr-refreshing .ptr-spinner { display: block; }

/* ═══ Offline Indicator ═══ */
.offline-indicator {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9997;
    display: flex;
    align-items: center;
    padding: 4px 10px;
    background: #f59e0b;
    color: #fff;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(245,158,11,.4);
    animation: offlinePulse 2s ease-in-out infinite;
}
@keyframes offlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* ═══ Sync Indicator (top pill during async operations) ═══ */
.sync-indicator {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-card, #1f2937);
    color: var(--text-primary, #e4e6ea);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    font-size: .8rem;
    border: 1px solid var(--border, #374151);
    animation: syncSlideDown .2s ease-out;
}
@keyframes syncSlideDown {
    from { opacity: 0; transform: translate(-50%, -12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
.sync-spinner {
    width: 12px; height: 12px;
    border: 2px solid var(--accent, #3b82f6);
    border-top-color: transparent;
    border-radius: 50%;
    animation: syncSpin .8s linear infinite;
}
@keyframes syncSpin {
    to { transform: rotate(360deg); }
}
.sync-indicator.sync-success {
    border-color: #22c55e;
}
.sync-indicator.sync-success .sync-spinner {
    border-color: #22c55e;
    border-top-color: #22c55e;
    animation: none;
}
.sync-indicator.sync-error {
    border-color: #ef4444;
}
.sync-indicator.sync-error .sync-spinner {
    border-color: #ef4444;
    border-top-color: #ef4444;
    animation: none;
}

/* ═══ Sync Indicator ═══ */
.sync-indicator {
    position: fixed;
    top: 12px; right: 12px;
    z-index: 1040;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #dee2e6);
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    font-size: .75rem;
    color: var(--text-muted, #6c757d);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity .2s;
    animation: syncSlideIn .3s ease-out;
    cursor: pointer;
}
.sync-indicator.sync-ok { border-color: #22c55e; color: #16a34a; }
.sync-indicator.sync-error { border-color: #ef4444; color: #dc2626; }
.sync-indicator.sync-processing { border-color: #3b82f6; color: #2563eb; }
.sync-indicator.sync-pending { border-color: #f59e0b; color: #d97706; }
.sync-spin {
    display: inline-block;
    animation: syncSpin 1s linear infinite;
    font-size: .85rem;
}
.sync-indicator:not(.sync-processing) .sync-spin { animation: none; }
@keyframes syncSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes syncSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) {
    .sync-indicator { top: 8px; right: 8px; font-size: .7rem; padding: 3px 8px; }
}

/* ═══ Period Chips (dashboard quick filters) ═══ */
.period-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    background: var(--bg-secondary, #f1f3f5);
    color: var(--text-primary, #212529);
    text-decoration: none;
    font-size: .8rem;
    border: 1px solid var(--border, #dee2e6);
    transition: background-color .15s, color .15s, transform .08s;
    white-space: nowrap;
}
.period-chip:hover {
    background: var(--accent, #0d6efd);
    color: #fff;
    border-color: var(--accent, #0d6efd);
    text-decoration: none;
}
.period-chip:active { transform: scale(.96); }

/* ═══ Transaction Context Menu ═══ */
.tx-ctx-menu {
    position: fixed;
    z-index: 10000;
    min-width: 180px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #dee2e6);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: 4px;
    animation: ctxFadeIn .08s ease-out;
}
@keyframes ctxFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.tx-ctx-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary, #212529);
    font-size: .85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color .1s;
}
.tx-ctx-item:hover, .tx-ctx-item:focus {
    background: var(--bg-hover, rgba(0,0,0,.05));
    outline: none;
}
.tx-ctx-item.tx-ctx-danger { color: #dc3545; }
.tx-ctx-item.tx-ctx-danger:hover { background: rgba(220,53,69,.1); }
.tx-ctx-divider {
    height: 1px;
    background: var(--border, #dee2e6);
    margin: 4px 0;
}

/* ═══ Loading Pulse ═════════════════════════════════════════════════════════ */
.loading-pulse {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
.skeleton-block {
    background: var(--border, #dee2e6);
    border-radius: .375rem;
    height: 1.2rem;
    margin-bottom: .5rem;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-block.wide { width: 80%; }
.skeleton-block.medium { width: 50%; }
.skeleton-block.narrow { width: 30%; }

/* ═══ Mobile-Responsive Tables ══════════════════════════════════════════════ */
@media (max-width: 576px) {
    /* Card-based layout for transaction tables on mobile */
    .table-mobile-cards thead {
        display: none;
    }
    .table-mobile-cards tbody tr {
        display: block;
        margin-bottom: .5rem;
        border: 1px solid var(--border, #dee2e6);
        border-radius: .5rem;
        padding: .5rem .75rem;
        background: var(--bg-card, #fff);
    }
    .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: .15rem 0;
        border: none;
        font-size: .85rem;
    }
    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: .75rem;
        color: var(--text-muted, #6c757d);
        flex-shrink: 0;
        margin-right: .5rem;
    }
    .table-mobile-cards tbody td:empty { display: none; }
    /* Hide less important columns */
    .table-mobile-cards .d-mob-none { display: none !important; }
    /* Compact buttons */
    .table-mobile-cards .btn-sm { padding: .15rem .4rem; font-size: .7rem; }
    /* Wider dropdowns */
    .dropdown-menu { min-width: auto; }
}

/* ═══ Compact Cards on Mobile ═══════════════════════════════════════════════ */
@media (max-width: 576px) {
    .card-body { padding: .5rem .75rem; }
    .modal-body { padding: .75rem; }
    h4, h5 { font-size: 1.1rem; }
    .sidebar { width: 56px; }
    .sidebar.expanded { width: 240px; }
    /* Touch-friendly buttons */
    .btn-sm { min-height: 32px; }
    .btn.py-0 { min-height: 28px; padding-top: 2px !important; padding-bottom: 2px !important; }
    /* Mass bar compact */
    .mass-bar select { max-width: 140px !important; }
    .mass-bar .gap-2 { gap: .3rem !important; }
    /* Filter collapse toggle — show only on mobile */
    #filterExtra { margin-top: .25rem; }
}
