/* css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Default (Dark Theme) */
:root,
[data-theme="dark"] {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --input-bg: #0f172a;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Light Theme */
[data-theme="light"] {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.auth-body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-card {
    background-color: var(--card-bg);
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .auth-card {
        padding: 30px 20px;
        border-radius: 12px;
    }
    .auth-header h2 {
        font-size: 22px;
    }
    .auth-logo {
        font-size: 40px;
    }
    .input-group input {
        font-size: 16px; /* iOS par zoom rokne ke liye */
        padding: 12px 15px 12px 45px;
    }
    .btn-primary {
        padding: 12px;
        font-size: 15px;
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 10px;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

/* Name field - grid rows trick se exact height tak smooth animation */
#name-group {
    display: grid;
    grid-template-rows: 0fr;
    margin-bottom: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                margin-bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#name-group input {
    min-height: 0;
}

#name-group.show {
    grid-template-rows: 1fr;
    margin-bottom: 20px;
    opacity: 1;
    pointer-events: auto;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.input-group input {
    width: 100%;
    padding: 14px 15px 14px 45px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Password Toggle Eye Icon */
.toggle-password {
    position: absolute;
    right: 15px;
    left: auto !important; /* Left position override */
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 2;
}

.toggle-password:hover {
    color: var(--primary);
}

/* Input mein right padding badhao taaki text eye icon ke neeche na aaye */
.input-group input[type="password"],
.input-group input[type="text"] {
    padding-right: 45px;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow);
    z-index: 100;
}

.theme-toggle:hover {
    color: var(--primary);
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Mobile */
@media (max-width: 480px) {
    .theme-toggle {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* ============================================
   DASHBOARD / APP LAYOUT
   ============================================ */

.app-body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.icon-btn, .theme-toggle-inline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.icon-btn:hover, .theme-toggle-inline:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.app-main { padding: 20px; max-width: 700px; margin: 0 auto; }

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 64px; margin-bottom: 16px; color: var(--border-color); }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: var(--text-main); }
.empty-state p { font-size: 14px; }

/* ============================================
   FLOATING ACTION BUTTON
   ============================================ */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s ease, background-color 0.2s ease;
    z-index: 60;
}

.fab:hover { transform: scale(1.08); background-color: var(--primary-hover); }
.fab:active { transform: scale(0.95); }

/* ============================================
   BOTTOM SHEET
   ============================================ */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 90;
}

.sheet-overlay.active { opacity: 1; pointer-events: auto; }

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border-radius: 24px 24px 0 0;
    padding: 12px 20px 24px;
    max-height: 92vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
    /* Scrollbar hide karo */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.bottom-sheet::-webkit-scrollbar {
    display: none;
}

.bottom-sheet.active { transform: translateY(0); }



.sheet-handle {
    width: 40px;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 16px;
}

/* Type Toggle */
.type-toggle {
    display: flex;
    background-color: var(--input-bg);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}

.type-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-btn.active {
    background-color: var(--primary);
    color: white;
}

/* Amount Row */
.amount-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px 16px;
    background-color: var(--input-bg);
    border-radius: 14px;
    border: 1px solid var(--border-color);
}

.currency-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-muted);
}

.amount-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 32px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    width: 100%;
}

.amount-input::placeholder { color: var(--border-color); }

/* Quick Amounts */
.quick-amounts {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.quick-amounts::-webkit-scrollbar { display: none; }

/* Quick Amount Chips - Ghost/outlined (secondary action) */
.chip {
    padding: 8px 14px;
    min-height: 40px;
    border-radius: 20px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: rgba(99, 102, 241, 0.08);
}

.chip:active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Field Row */
.field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: var(--input-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    transition: border-color 0.2s ease;
}

.field-row:focus-within { border-color: var(--primary); }

.field-row i { color: var(--text-muted); font-size: 18px; }

.field-row input,
.field-row select {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    width: 100%;
}

.field-row input::placeholder { color: var(--text-muted); }
/* Payment Method Segmented Toggle */
.payment-row {
    padding: 6px 12px !important;
}

.payment-toggle {
    display: flex;
    flex: 1;
    gap: 4px;
}

.payment-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.payment-btn:hover {
    color: var(--text-main);
}

.payment-btn.active {
    background-color: var(--primary);
    color: white;
}

/* Category Chips */
.category-section {
    margin-bottom: 12px;
}

.section-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-label small { font-weight: 400; text-transform: none; letter-spacing: 0; }

.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Category Chips - Muted default, Glow on select */
.cat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-chip i { font-size: 16px; }

.cat-chip:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.cat-chip.selected {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* Date Chip - Text action style (tertiary) */
.date-row { margin-bottom: 12px; }

.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 12px;
    background-color: transparent;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-chip:hover {
    background-color: var(--input-bg);
}

.date-chip i { font-size: 18px; }

.hidden-date {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* Payment & Notes section - always visible */
.more-options {
    display: block;
}

/* Save Button */
.save-btn {
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.save-btn:hover { background-color: var(--primary-hover); }
.save-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* Cancel Button */
.cancel-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 4px;
    font-family: 'Inter', sans-serif;
}

.cancel-btn:hover { color: var(--text-main); }

/* ============================================
   SUCCESS POPUP ANIMATION
   ============================================ */
.success-popup {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 200;
}

.success-popup.active { opacity: 1; pointer-events: auto; }

.success-card {
    background-color: var(--card-bg);
    padding: 32px 40px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.7);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-popup.active .success-card { transform: scale(1); }

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: #10b981;
    color: white;
    font-size: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 16px;
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.success-card h3 { font-size: 20px; margin-bottom: 6px; color: var(--text-main); }
.success-card p { font-size: 14px; color: var(--text-muted); }

/* ============================================
   MOBILE OPTIMIZATION
   ============================================ */
@media (max-width: 480px) {
    .app-header { padding: 12px 16px; }
    .app-main { padding: 16px; }
    .bottom-sheet { padding: 12px 16px 20px; }
    .amount-input { font-size: 28px; }
    .fab {
        bottom: calc(80px + env(safe-area-inset-bottom));
        left: calc(50% - 28px);
        right: auto;
        width: 56px;
        height: 56px;
        font-size: 26px;
    }
}

/* Prevent iOS zoom on input focus */
@media (max-width: 480px) {
    input, select, textarea { font-size: 16px !important; }
    .amount-input { font-size: 28px !important; }
}

/* ============================================
   NAVIGATION & LAYOUT
   ============================================ */

.app-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============ DESKTOP SIDEBAR ============ */
.sidebar {
    display: none;
    flex-direction: column;
    width: 240px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px 12px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.sidebar-brand i {
    color: var(--primary);
    font-size: 24px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    min-height: 44px;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: var(--input-bg);
}

.nav-item.active {
    color: var(--primary);
    background-color: rgba(99, 102, 241, 0.1);
}

/* ============ MOBILE BOTTOM NAV ============ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    z-index: 80;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border-radius: 10px;
    transition: color 0.2s ease;
    min-height: 48px;
    flex: 1;
    max-width: 100px;
}

.bottom-nav-item i {
    font-size: 22px;
}

.bottom-nav-item.active {
    color: var(--primary);
}

/* ============ MAIN CONTENT AREA ============ */
.app-main {
    flex: 1;
    width: 100%;
    padding: 20px;
    padding-bottom: 100px; /* FAB + bottom nav space */
    max-width: 900px;
    margin: 0 auto;
}

/* Tab panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeInUp 0.25s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ BALANCE CARD ============ */
.balance-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 24px 22px;
    border-radius: 20px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.balance-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    opacity: 0.85;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.balance-amount {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    color: white;
}

.balance-sub {
    display: block;
    font-size: 12px;
    opacity: 0.75;
}

/* ============ SUMMARY GRID ============ */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.summary-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.3s ease;
}

.summary-card.income .summary-icon {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.summary-card.expense .summary-icon {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.summary-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 4px;
}

.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.summary-amount {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
}

/* ============ SECTION HEADER ============ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.section-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.link-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.link-btn:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

/* ============ FILTER BAR ============ */
.filter-bar {
    margin-bottom: 16px;
}

.filter-chips {
    display: flex;
    gap: 8px;
}

.filter-chip {
    padding: 9px 18px;
    border-radius: 20px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
}

.filter-chip:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.filter-chip.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ============ TRANSACTIONS LIST ============ */
.txn-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.txn-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.txn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.txn-group-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0 4px;
    margin-bottom: 2px;
}

.txn-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.txn-item:hover {
    border-color: var(--primary);
}

.txn-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.txn-item.income .txn-icon {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.txn-item.expense .txn-icon {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.txn-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.txn-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txn-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
}

.txn-meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.txn-amount {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.txn-item.income .txn-amount {
    color: #10b981;
}

.txn-item.expense .txn-amount {
    color: #ef4444;
}

/* ============ DESKTOP BREAKPOINT ============ */
@media (min-width: 768px) {
    .app-body {
        flex-direction: row;
    }

    .sidebar {
        display: flex;
    }

    .app-header {
        display: none;
    }

    .bottom-nav {
        display: none;
    }

    .app-main {
        margin-left: 240px;
        max-width: 800px;
        margin-right: auto;
        padding: 32px 32px 80px;
    }

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    }

    .balance-amount {
        font-size: 40px;
    }

    /* Desktop: Modal ke andar spacing compact karo - scroll hatane ke liye */
    .bottom-sheet .type-toggle {
        margin-bottom: 12px;
    }

    .bottom-sheet .amount-row {
        margin-bottom: 8px;
    }

    .bottom-sheet .quick-amounts {
        margin-bottom: 10px;
    }

    .bottom-sheet .field-row {
        margin-bottom: 8px;
    }

    .bottom-sheet .category-section {
        margin-bottom: 8px;
    }

    .bottom-sheet .date-row {
        margin-bottom: 8px;
    }

    .bottom-sheet .save-btn {
        margin-top: 10px;
        padding: 14px;
    }

    /* Desktop: Bottom sheet ko centered modal banao */
    .bottom-sheet {
        bottom: auto;
        top: 50%;
        left: 50%;
        right: auto;
        max-width: 480px;
        width: calc(100% - 40px);
        max-height: calc(100vh - 16px);
        padding: 28px 24px 20px;
        border-radius: 20px;
        overflow-y: hidden;
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        pointer-events: none;
        border: 1px solid var(--border-color);
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    }

    .bottom-sheet.active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        pointer-events: auto;
    }

    .sheet-handle {
        display: none;
    }
}


/* Prevent iOS zoom on input focus */
@media (max-width: 480px) {
    input, select, textarea { font-size: 16px !important; }
    .amount-input { font-size: 28px !important; }
    .app-main { padding: 16px 16px 100px; }
    .balance-amount { font-size: 30px; }
    .summary-amount { font-size: 16px; }
}

/* FAB above bottom nav - Tablets */
@media (min-width: 481px) and (max-width: 767px) {
    .fab {
        bottom: calc(84px + env(safe-area-inset-bottom));
        left: calc(50% - 30px);
        right: auto;
    }
}

/* ============================================
   MODE-AWARE COLOR CODING (Expense vs Income)
   ============================================ */

/* Expense mode (default) - RED accents */
.type-toggle .type-btn.active {
    background-color: #ef4444;
    color: white;
}

.amount-row:focus-within {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.save-btn {
    background-color: #ef4444;
}

.save-btn:hover:not(:disabled) {
    background-color: #dc2626;
}

/* Income mode - GREEN accents */
.bottom-sheet.income-mode .type-btn.active {
    background-color: #10b981;
}

.bottom-sheet.income-mode .amount-row:focus-within {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.bottom-sheet.income-mode .save-btn {
    background-color: #10b981;
}

.bottom-sheet.income-mode .save-btn:hover:not(:disabled) {
    background-color: #059669;
}

/* ============================================
   STICKY HERO (Home) & STICKY FILTERS (Transactions)
   ============================================ */



/* Transactions: filter chips ko lock karo */
#tab-transactions .filter-bar {
    position: sticky;
    top: 64px;
    z-index: 10;
    background-color: var(--bg-color);
    padding: 16px 0 12px;
    margin-bottom: 8px;
    transition: background-color 0.3s ease;
}

/* Tablet: header is 72px tall */
@media (min-width: 481px) and (max-width: 767px) {
    .home-hero,
    #tab-transactions .filter-bar {
        top: 72px;
    }
}

/* Desktop: no mobile header, stick to viewport top */
@media (min-width: 768px) {
    .home-hero,
    #tab-transactions .filter-bar {
        top: 0;
    }
}

/* ============================================
   DATE FILTER (Transactions)
   ============================================ */

/* Filter chips ko wrap karne do */
.filter-chips {
    flex-wrap: wrap;
    align-items: center;
}

.date-filter-wrap {
    position: relative;
    margin-left: auto;
}

.date-filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 20px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
    white-space: nowrap;
}

.date-filter-btn:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.date-filter-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.1);
}

.date-filter-btn i:first-child {
    font-size: 16px;
}

.date-filter-btn i:last-child {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.date-filter-btn.open i:last-child {
    transform: rotate(180deg);
}

.date-filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    min-width: 180px;
    box-shadow: var(--shadow);
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease,
                background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Mobile/Tablet: dropdown full-width, JS se positioned below button */
@media (max-width: 767px) {
    .date-filter-menu {
        position: fixed;
        top: 0; /* JS will override */
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
        max-height: 70vh;
        overflow-y: auto;
        z-index: 200;
        transform: translateY(-6px);
    }

    .date-filter-menu.open {
        transform: translateY(0);
    }
}

.date-filter-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.date-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease;
}

.date-filter-option:hover {
    background-color: var(--input-bg);
}

.date-filter-option.active {
    color: var(--primary);
    background-color: rgba(99, 102, 241, 0.1);
}

.date-filter-option i {
    font-size: 16px;
    margin-right: 4px;
}

/* Mobile: date button ko poori width do taaki wrap ho kar neeche aaye */
@media (max-width: 480px) {
    .date-filter-wrap {
        margin-left: 0;
    }
}

/* ============================================
   CUSTOM RANGE FORM
   ============================================ */

.custom-range-form {
    display: none;
    padding: 10px 8px 6px;
    margin-top: 4px;
    border-top: 1px solid var(--border-color);
}

.custom-range-form.show {
    display: block;
}

.custom-range-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.custom-range-input {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    margin-bottom: 10px;
    transition: border-color 0.2s ease;
    color-scheme: dark;
}

[data-theme="light"] .custom-range-input {
    color-scheme: light;
}

.custom-range-input:focus {
    border-color: var(--primary);
}

.custom-range-apply {
    width: 100%;
    padding: 10px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.custom-range-apply:hover {
    background-color: var(--primary-hover);
}

/* ============================================
   STATS TAB
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 2px;
}

.stat-icon.today {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.stat-icon.month {
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.stat-icon.avg {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.stat-icon.top {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-amount {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
    line-height: 1.2;
    word-break: break-word;
}

/* Chart Card */
.chart-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    padding: 0 2px;
}

.chart-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.chart-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.chart-wrap {
    position: relative;
    height: 200px;
    width: 100%;
}

.doughnut-wrap {
    height: 260px;
}

/* Top Expenses */
.top-expenses-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.top-expense-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background-color: var(--input-bg);
    border-radius: 12px;
    transition: background-color 0.3s ease;
}

.top-expense-item .txn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 16px;
    flex-shrink: 0;
}

.top-expense-item .txn-info {
    flex: 1;
    min-width: 0;
}

.top-expense-item .txn-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-expense-item .txn-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-expense-item .txn-amount {
    color: #ef4444;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .chart-wrap {
        height: 240px;
    }
    .doughnut-wrap {
        height: 300px;
    }
}

/* ============================================
   LEDGER / KHATA
   ============================================ */

.ledger-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.ledger-summary-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    transition: all 0.3s ease;
}

.ledger-summary-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ledger-summary-card.they-owe .ledger-summary-icon {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.ledger-summary-card.i-owe .ledger-summary-icon {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.ledger-summary-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ledger-summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.ledger-summary-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ledger List */
.ledger-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.person-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.person-card:hover {
    border-color: var(--primary);
}

.person-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    letter-spacing: -0.3px;
}

.person-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.person-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.person-balance {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.person-balance.positive { color: #10b981; }
.person-balance.negative { color: #ef4444; }
.person-balance.zero { color: var(--text-muted); }

/* Person Detail */
.ledger-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 16px;
    transition: background-color 0.2s ease;
}

.ledger-back:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

.person-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 20px 20px;
    gap: 10px;
    margin-bottom: 16px;
}

.person-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.person-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    text-align: center;
}

.person-balance-lg {
    font-size: 15px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

.person-balance-lg.positive {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.person-balance-lg.negative {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.person-balance-lg.zero {
    color: var(--text-muted);
}

.person-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.person-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    background-color: var(--primary);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.person-action-btn:hover {
    background-color: var(--primary-hover);
}

.person-action-btn.danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.45);
}

.person-action-btn.danger:hover {
    background-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.6);
}

.person-action-btn.danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.person-entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.person-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.person-entry-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.person-entry-icon.positive {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.person-entry-icon.negative {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.person-entry-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.person-entry-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-entry-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.person-entry-amount {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.person-entry-amount.positive { color: #10b981; }
.person-entry-amount.negative { color: #ef4444; }

/* Ledger Sheet */
.ledger-sheet-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    padding: 0 4px;
}

.entry-type-toggle {
    margin-top: 4px;
}

.entry-type-toggle .type-btn.active {
    background-color: var(--primary);
    color: white;
}

/* Autocomplete */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 4px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-shadow: var(--shadow);
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-main);
    transition: background-color 0.15s ease;
    font-family: 'Inter', sans-serif;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: var(--input-bg);
    color: var(--primary);
}

/* Ledger sheet inherits mode colors — but we don't need red/green here */
.ledger-sheet .save-btn {
    background-color: var(--primary);
}

.ledger-sheet .save-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.ledger-sheet.income-mode .save-btn {
    background-color: var(--primary);
}

.ledger-sheet.income-mode .amount-row:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ledger-sheet .amount-row:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Mobile: full-width bottom sheet for ledger too */
@media (max-width: 767px) {
    .ledger-sheet {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ============================================
   LEDGER — Direction toggle colors + Preview
   ============================================ */

/* Direction toggle: They Owe Me (Green) — HIGH PRIORITY */
.ledger-sheet .direction-toggle .dir-btn-they-owe.active {
    background-color: #10b981 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.ledger-sheet .direction-toggle .dir-btn-i-owe.active {
    background-color: #ef4444 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

/* Non-active direction buttons should stay muted, not red */
.ledger-sheet .direction-toggle .type-btn:not(.active) {
    background-color: transparent !important;
    color: var(--text-muted) !important;
}

/* Entry type toggle: primary purple, NOT red */
.ledger-sheet .entry-type-toggle .type-btn.active {
    background-color: var(--primary) !important;
    color: white !important;
}

.ledger-sheet .direction-toggle .type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ledger-sheet .direction-toggle .type-btn i {
    font-size: 16px;
}

/* Entry type toggle: neutral primary color */
.ledger-sheet .entry-type-toggle .type-btn.active {
    background-color: var(--primary);
    color: white;
}

/* Preview line */
.ledger-preview {
    padding: 10px 14px;
    margin-bottom: 12px;
    background-color: var(--input-bg);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    transition: all 0.25s ease;
}

.ledger-preview.positive {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.4);
    background-color: rgba(16, 185, 129, 0.06);
}

.ledger-preview.negative {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
    background-color: rgba(239, 68, 68, 0.06);
}

/* Name field row needs relative for autocomplete */
.name-field-row {
    position: relative;
}

/* Autocomplete inside field-row */
.name-field-row .autocomplete-list {
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
}

/* ============================================
   SETTLEMENT CELEBRATION
   ============================================ */

.settle-popup {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 250;
    backdrop-filter: blur(4px);
}

.settle-popup.active {
    opacity: 1;
    pointer-events: auto;
}

.settle-card {
    background-color: var(--card-bg);
    padding: 40px 32px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    transform: scale(0.6);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 320px;
}

.settle-popup.active .settle-card {
    transform: scale(1);
}

.settle-icon-wrap {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settle-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #10b981;
    opacity: 0;
}

.settle-popup.active .settle-ring {
    animation: settleRing 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes settleRing {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

.settle-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.settle-popup.active .settle-icon {
    animation: settleIconPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes settleIconPop {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.15) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

.settle-card h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.settle-card p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ============================================
   APP DIALOG (In-app Alert/Confirm)
   ============================================ */

.app-dialog {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 250;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.app-dialog.active {
    opacity: 1;
    pointer-events: auto;
}

.app-dialog-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px 24px 20px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    transform: scale(0.85);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-dialog.active .app-dialog-card {
    transform: scale(1);
}

.app-dialog-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

/* Icon variants */
.app-dialog-icon.info {
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.app-dialog-icon.success {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.app-dialog-icon.warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.app-dialog-icon.error {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.app-dialog-card h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.app-dialog-card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 22px;
}

.app-dialog-actions {
    display: flex;
    gap: 10px;
}

.app-dialog-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.app-dialog-btn.primary {
    background-color: var(--primary);
    color: white;
}

.app-dialog-btn.primary:hover {
    background-color: var(--primary-hover);
}

.app-dialog-btn.secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.app-dialog-btn.secondary:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* Hide cancel in alert mode */
.app-dialog.alert-mode .app-dialog-btn.secondary {
    display: none;
}

/* ============================================
   LEDGER V2 — Badges, Tabs, Due Date
   ============================================ */

/* --- Filter Tabs --- */
.ledger-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    flex-wrap: wrap;
}

.ledger-filter-tabs::-webkit-scrollbar { display: none; }

.ledger-filter-tab {
    padding: 8px 14px;
    min-height: 38px;
    border-radius: 20px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.ledger-filter-tab:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.ledger-filter-tab.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* --- Person Card Badge --- */
.person-card {
    position: relative;
}

.person-balance-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.2px;
    transition: all 0.2s ease;
}

.person-balance-badge.positive {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.person-balance-badge.negative {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.person-balance-badge.zero {
    background-color: rgba(148, 163, 184, 0.12);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* Remove old .person-balance styling conflict */
.person-balance { display: none; }

/* --- Last Activity Text --- */
.person-last-activity {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Person Entry Balance Info --- */
.person-entry {
    position: relative;
}

.person-entry-balance {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    font-style: italic;
    letter-spacing: 0.2px;
}

/* --- Due Date Field --- */
.due-date-chip {
    color: var(--text-muted);
}

.due-date-chip.active {
    color: var(--primary);
    background-color: var(--input-bg);
}

.due-clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.due-clear-btn:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

/* --- Locked Name Field --- */
.name-field-row.locked {
    background-color: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
    opacity: 0.9;
}

.name-field-row.locked input {
    cursor: not-allowed;
    color: var(--text-muted);
}

.name-field-row .lock-icon {
    color: var(--primary);
    font-size: 14px;
    margin-left: auto;
    opacity: 0.6;
}

/* Balance preview line in Add Entry */
.ledger-preview .preview-balance {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    opacity: 0.85;
}

/* --- Payment (settling) distinct style --- */
.person-entry-icon.settling {
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.person-entry-amount.settling {
    color: var(--primary);
}

.person-entry.payment {
    border-style: dashed;
    opacity: 0.95;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   TRANSACTION SELECT MODE
   ============================================ */



/* Selection mode state */
.txn-list.selecting .txn-item {
    padding-left: 48px;
    position: relative;
}

.txn-list.selecting .txn-item::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    background-color: transparent;
    transition: all 0.15s ease;
    pointer-events: none;
}

.txn-list.selecting .txn-item.selected::before {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
    background-size: 14px;
    background-repeat: no-repeat;
    background-position: center;
}

.txn-list.selecting .txn-item.selected {
    background-color: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Bulk Bar */
.bulk-bar {
    position: fixed;
    bottom: 78px;
    left: 16px;
    right: 16px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(calc(100% + 120px));
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0.3s;
    z-index: 85;
}

.selecting-mode #tab-transactions.active .bulk-bar.active {
    transform: translateY(0);
    visibility: visible;
    transition-delay: 0s;
}

.bulk-info {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.bulk-cancel {
    padding: 8px 12px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    min-height: 38px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.bulk-cancel:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.bulk-delete {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    background-color: #ef4444;
    border: none;
    color: white;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    min-height: 40px;
    transition: all 0.2s ease;
}

.bulk-delete:hover:not(:disabled) {
    background-color: #dc2626;
}

.bulk-delete:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@media (min-width: 768px) {
    .bulk-bar {
        bottom: 32px;
        left: auto;
        right: 32px;
        max-width: 400px;
    }

    .txn-list.selecting .txn-item::before {
        position: static;
        grid-column: 1;
        transform: none;
    }
}

/* ============================================
   LEDGER MENU BUTTONS
   ============================================ */

.ledger-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 2px;
}

.ledger-top-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.ledger-menu-btn,
.person-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ledger-menu-btn:hover,
.person-menu-btn:hover {
    color: var(--text-main);
    border-color: var(--primary);
    background-color: var(--input-bg);
}

.person-header {
    position: relative;
}

.person-menu-btn {
    position: absolute;
    top: 0;
    right: 0;
}

/* Person entry menu (edit/delete) */
.person-entry {
    position: relative;
    cursor: pointer;
}

.person-entry-menu {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.person-entry-menu:hover {
    color: var(--text-main);
    background-color: var(--input-bg);
}

/* Hide FAB during select mode */
body.selecting-mode .fab {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

/* ============================================
   COMPACT ACTION MENU (replaces ugly bottom sheet)
   ============================================ */

.action-menu {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 230;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.action-menu.active {
    opacity: 1;
    pointer-events: auto;
}

.action-menu-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 6px;
    width: 100%;
    max-width: 300px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.action-menu.active .action-menu-card {
    transform: scale(1);
}

.action-menu-card h3 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 10px 14px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-menu-options {
    display: flex;
    flex-direction: column;
}

.action-menu-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease;
    min-height: 44px;
    width: 100%;
}

.action-menu-option:hover {
    background-color: var(--input-bg);
}

.action-menu-option.danger {
    color: #ef4444;
}

.action-menu-option.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.action-menu-option i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.action-menu-cancel {
    width: 100%;
    padding: 12px;
    margin-top: 4px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    min-height: 44px;
    border-radius: 0 0 10px 10px;
    transition: color 0.15s ease;
}

.action-menu-cancel:hover {
    color: var(--text-main);
}

/* Bulk info — compact, single line */
.bulk-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

#bulk-count {
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.bulk-select-all-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 6px;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.bulk-select-all-btn:hover {
    background-color: rgba(99, 102, 241, 0.1);
}



/* Multi-line dialog message support */
.app-dialog-card p {
    white-space: pre-line;
}

/* ============================================
   ADMIN PANEL
   ============================================ */
.admin-header {
    margin-bottom: 20px;
}
.admin-header h2 {
    font-size: 20px;
    color: var(--text-main);
    margin-bottom: 4px;
}
.admin-header p {
    font-size: 14px;
    color: var(--text-muted);
}
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.admin-user-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}
.admin-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-user-name {
    font-weight: 600;
    color: var(--text-main);
}
.admin-user-date {
    font-size: 12px;
    color: var(--text-muted);
}
.admin-user-actions {
    display: flex;
    gap: 8px;
}
.admin-btn {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}
.admin-btn.approve {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}
.admin-btn.approve:hover {
    background-color: rgba(16, 185, 129, 0.2);
}
.admin-btn.reject {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
.admin-btn.reject:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

/* ============================================
   DESKTOP LAYOUT OVERHAUL
   ============================================ */

/* --- Sidebar Upgrades --- */
.sidebar {
    width: 280px !important;
    padding: 24px 16px !important;
}

.sidebar-brand {
    padding: 8px 16px !important;
    margin-bottom: 32px !important;
    font-size: 20px !important;
}

.sidebar-brand i {
    font-size: 28px !important;
}

.nav-item {
    min-height: 48px !important;
    font-size: 15px !important;
    padding: 12px 16px !important;
}

/* Sidebar User Profile */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin-bottom: 12px;
    background-color: var(--input-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Main Content Layout --- */
@media (min-width: 768px) {
    .app-main {
        margin-left: 280px !important;
        width: calc(100% - 280px) !important;
        max-width: none !important;
        padding: 32px 40px !important;
        display: block !important;
    }

    .content-container {
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
    }

    /* Page Header (Desktop Add Button) */
    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
    }

    .page-title {
        font-size: 24px;
        font-weight: 700;
        color: var(--text-main);
    }

    .btn-add-transaction {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 20px;
        background-color: var(--primary);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        font-family: 'Inter', sans-serif;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    }

    .btn-add-transaction:hover {
        background-color: var(--primary-hover);
        transform: translateY(-2px);
    }

    /* Hide FAB on Desktop */
    .fab {
        display: none !important;
    }

    /* Two-Column Home Layout */
    .home-layout {
        display: grid;
        grid-template-columns: 1fr 1.2fr;
        gap: 32px;
        align-items: start;
    }

    .home-col-left {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    .summary-grid {
        margin-bottom: 0 !important;
        gap: 20px !important;
    }

    /* Transactions Layout */
    .txn-list {
        gap: 8px !important;
    }

    .txn-group {
        gap: 8px !important;
    }

    .txn-group-label {
        margin-top: 16px;
        margin-bottom: 4px;
    }

    .txn-group:first-child .txn-group-label {
        margin-top: 0;
    }

    .txn-item {
        display: grid !important;
        grid-template-columns: 44px 1fr auto auto;
        align-items: center;
        gap: 16px;
        padding: 16px 20px !important;
    }

    .txn-date {
        display: block !important;
        font-size: 13px;
        color: var(--text-muted);
        white-space: nowrap;
    }

    /* Hide date in meta for desktop */
    .txn-meta .txn-meta-date {
        display: none;
    }
}

/* Hide Desktop Elements on Mobile */
@media (max-width: 767px) {
    .page-header {
        display: none;
    }
    .txn-date {
        display: none;
    }
    .sidebar-user {
        display: none;
    }
}

/* ============================================
   NEW PROFESSIONAL DASHBOARD LAYOUT
   ============================================ */

/* Mobile-First Base (Stacked) */
.dashboard-top-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.dashboard-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.home-chart-wrap {
    position: relative;
    height: 250px;
    width: 100%;
    margin-top: 10px;
}

/* Desktop Overrides */
@media (min-width: 768px) {
    /* Top Row: 3 Cards */
    .dashboard-top-grid {
        grid-template-columns: 2fr 1fr 1fr;
        gap: 24px;
        align-items: stretch;
    }

    .dashboard-top-grid > .balance-card {
        margin-bottom: 0 !important;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* Bottom Row: 2 Columns (5fr for chart, 7fr for list) */
    .dashboard-bottom-grid {
        grid-template-columns: 5fr 7fr;
        gap: 24px;
        align-items: stretch;
    }

    /* Fix Transaction Rows (Grid alignment) */
    .txn-item {
        display: grid !important;
        grid-template-columns: 44px 1fr 80px 120px;
        align-items: center;
        gap: 16px;
        padding: 16px !important;
    }

    .txn-date {
        display: block !important;
        font-size: 13px;
        color: var(--text-muted);
        text-align: right;
        white-space: nowrap;
    }

    .txn-amount {
        text-align: right;
        width: 100%;
    }
}

/* Hide Date Column on Mobile */
@media (max-width: 767px) {
    .txn-date {
        display: none !important;
    }
}

/* ============================================
   HIDE CHART ON MOBILE/TABLET
   ============================================ */
#home-chart-card {
    display: none !important;
}

/* Desktop (1024px and above): Show chart and use 2-column layout */
@media (min-width: 1024px) {
    #home-chart-card {
        display: flex !important;
    }
    .dashboard-bottom-grid {
        grid-template-columns: 5fr 7fr !important;
    }
}

/* Tablet (768px to 1023px): Force single column for transactions so it doesn't stretch */
@media (min-width: 768px) and (max-width: 1023px) {
    .dashboard-bottom-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile: Remove container background for Recent Transactions */
@media (max-width: 1023px) {
    #home-recent-card {
        background-color: transparent !important;
        border: none !important;
        padding: 0 !important;
    }
}

/* ============================================
   FIX TOP EXPENSES TEXT ON DESKTOP
   ============================================ */
@media (min-width: 768px) {
    /* Reserve a real grid column for the selection checkbox on desktop. */
    .txn-list.selecting .txn-item {
        grid-template-columns: 20px 44px 1fr 80px 120px;
    }

    .top-expense-item {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 16px !important;
        padding: 16px !important;
    }
    .top-expense-item .txn-info {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0 !important;
        width: auto !important;
        min-width: 0 !important;
        text-align: left !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    .top-expense-item .txn-name {
        display: block !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        color: var(--text-main) !important;
        margin-bottom: 2px !important;
    }
    .top-expense-item .txn-meta {
        display: block !important;
        font-size: 12px !important;
        color: var(--text-muted) !important;
    }
    .top-expense-item .txn-amount {
        width: auto !important;
        flex-shrink: 0;
    }
}

.network-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Mobile header mein thoda compact */
@media (max-width: 767px) {
    .network-indicator {
        margin-right: 8px;
    }
    .network-indicator .text {
        display: none; /* Mobile par sirf dot dikhega, text nahi (jagah bachane ke liye) */
    }
}

.network-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981; /* Green */
}
.network-indicator.offline .dot {
    background-color: #f59e0b; /* Orange */
}
.network-indicator.offline .text {
    color: #f59e0b;
}
.network-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981; /* Green */
}
.network-indicator.offline .dot {
    background-color: #f59e0b; /* Orange */
}
.network-indicator.offline .text {
    color: #f59e0b;
}

/* ============================================
   1. NETWORK INDICATOR FIX & PULSE ANIMATION
   ============================================ */
.network-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 16px; /* Spacing fix */
}

.desktop-only-indicator {
    margin: 8px 0 16px 0;
}

.network-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    transition: background-color 0.3s ease;
}

/* Pulse Animation jab Online ho */
.network-indicator:not(.offline) .dot {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Offline State (Calm, No Pulse) */
.network-indicator.offline .dot {
    background-color: #ef4444; /* Red dot for offline */
}
.network-indicator.offline .text {
    color: #ef4444;
}

/* Double lines remove karne ke liye */
.sidebar-footer {
    border-top: none !important; /* Agar purana border aa raha hai toh */
    padding-top: 16px;
    border-top: 1px solid var(--border-color) !important; /* Sirf ek clean line */
}

/* ============================================
   2. iPHONE SE & SMALL SCREENS OPTIMIZATION (< 380px)
   ============================================ */
@media (max-width: 380px) {
    /* Header spacing */
    .app-header { padding: 10px 12px !important; }
    .header-left span { font-size: 16px !important; }
    .header-left i { font-size: 20px !important; }
    
    /* Main padding */
    .app-main { padding: 12px 12px 90px !important; }
    
    /* Balance Card Font Size */
    .balance-amount { font-size: 26px !important; }
    .balance-card { padding: 16px !important; }
    
    /* Summary Cards */
    .summary-card { padding: 12px !important; gap: 4px !important; }
    .summary-amount { font-size: 15px !important; }
    .summary-icon { width: 28px; height: 28px; font-size: 14px; }
    
    /* Transaction Items (Tight squeeze fix) */
    .txn-item { padding: 10px !important; gap: 8px !important; }
    .txn-icon { width: 36px; height: 36px; font-size: 16px; }
    .txn-name { font-size: 13px !important; }
    .txn-amount { font-size: 14px !important; }
    .txn-meta { font-size: 11px !important; }
    
    /* Floating Action Button (FAB) */
    .fab {
        width: 52px !important;
        height: 52px !important;
        left: calc(50% - 26px) !important;
        bottom: calc(70px + env(safe-area-inset-bottom)) !important;
        font-size: 22px !important;
    }
    
    /* Page Header (Desktop Add Button) */
    .btn-add-transaction {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
}

/* ============================================
   MOBILE SUMMARY CARDS LAYOUT (UI Balance Fix)
   ============================================ */
@media (max-width: 767px) {
    /* Mobile par grid ko 2 columns mein divide karo */
    .dashboard-top-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Balance card ko poori width do (2 columns span kare) */
    .dashboard-top-grid > .balance-card {
        grid-column: 1 / -1; /* Full width */
        margin-bottom: 0 !important;
    }

    /* Income aur Expense cards ki styling thodi compact karo */
    .summary-card {
        padding: 14px 12px !important;
        gap: 8px !important;
    }

    .summary-label {
        font-size: 11px !important;
    }

    .summary-amount {
        font-size: 15px !important;
    }
}

/* iPhone SE ke liye extra chhota text agar zaroorat ho */
@media (max-width: 375px) {
    .summary-amount {
        font-size: 13px !important;
    }
}

/* ============================================
   FIX GAPS & SPACING (Recent Transactions & Home)
   ============================================ */

/* 1. Fix Transaction Gaps (Uniform 10px) */
.txn-list {
    display: flex;
    flex-direction: column;
    gap: 10px !important; /* Force exactly 10px between groups */
}

.txn-group {
    display: flex;
    flex-direction: column;
    gap: 10px !important; /* Force exactly 10px inside groups */
    margin: 0 !important; /* Remove any default margins */
    padding: 0 !important;
}

/* 2. Fix Home Screen Vertical Spacing (Exactly 16px) */
.dashboard-top-grid {
    gap: 16px !important; /* Between Balance and Income/Expense */
    margin-bottom: 16px !important; /* Between Income/Expense and Recent Transactions */
}

/* Mobile Specific Overrides */
@media (max-width: 767px) {
    .dashboard-bottom-grid {
        margin-top: 0 !important;
        gap: 0 !important; /* Chart is hidden, so no gap needed here */
    }

    #home-recent-card {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .section-header {
        margin-top: 0 !important;
        margin-bottom: 12px !important; /* Space between heading and list */
    }
}

/* ============================================
   ADMIN PANEL MOBILE OPTIMIZATION
   ============================================ */
@media (max-width: 600px) {
    .admin-user-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .admin-user-info {
        width: 100%;
    }

    /* Lambi email ko screen se bahar jane se roko */
    .admin-user-email {
        word-break: break-all; 
    }

    .admin-user-actions {
        width: 100%;
        display: flex;
        gap: 10px;
    }

    /* Buttons ko barabar width do taaki dono screen par fit ho jayein */
    .admin-btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
    }
}

/* ============================================
   MOBILE TAB SCROLLING ADJUSTMENTS
   ============================================ */
@media (max-width: 767px) {
    /* Give the Home dashboard a little more breathing room below the header. */
    #tab-home {
        padding-top: 8px;
    }

    /* Let transaction rows scroll normally instead of underneath the filters. */
    #tab-transactions .filter-bar {
        position: static;
    }

    /* Keep the Ledger overview controls still; only the people list scrolls. */
    #tab-ledger.active #ledger-main {
        height: calc(100vh - 189px);
        height: calc(100dvh - 189px);
    }

    #tab-ledger.active #ledger-main {
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .ledger-fixed-header {
        flex: 0 0 auto;
    }

    #ledger-main > .ledger-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
}

@media (max-width: 380px) {
    #tab-ledger.active #ledger-main {
        height: calc(100vh - 163px);
        height: calc(100dvh - 163px);
    }
}
