/* ==========================================================================
   CSS VARIABLES & THEME SETUP
   ========================================================================== */
:root {
    /* Fonts */
    --font-primary: 'Outfit', 'Sarabun', sans-serif;

    /* Theme: Dark (Default) */
    --bg-primary: #0f172a;
    --bg-secondary: #0b0f19;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.95);
    --bg-input: #1e293b;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Accents */
    --accent-primary: #6366f1; /* Indigo */
    --accent-primary-hover: #4f46e5;
    --accent-secondary: #8b5cf6; /* Violet */
    --success: #10b981; /* Green */
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #ef4444; /* Red */
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b; /* Yellow */
    --warning-bg: rgba(245, 158, 11, 0.15);
    --info: #0ea5e9; /* Light blue */
    --info-bg: rgba(14, 165, 233, 0.15);

    /* Shadows & Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(16px);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-circle: 50%;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    /* Theme: Light */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --bg-input: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Shadows & Effects */
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-premium: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-primary);
}

body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styling (Desktop) */
.sidebar {
    width: 260px;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: background-color var(--transition-normal), border var(--transition-normal);
}

.sidebar-header {
    margin-bottom: 40px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    color: var(--accent-primary);
    width: 28px;
    height: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item i {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-fast);
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item:hover i {
    transform: translateX(2px);
}

.nav-item.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-left: 3px solid var(--accent-primary);
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px 40px;
    min-height: 100vh;
    padding-bottom: 80px; /* Space for mobile navigation */
}

/* Header Component */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.mobile-logo {
    display: none;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ==========================================================================
   BUTTONS & FORM CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background-color: var(--success);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-circle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    padding: 0;
}

.btn-text {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 500;
}
.btn-text:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.block {
    display: flex;
    width: 100%;
}
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Form Controls */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-row {
    display: flex;
    gap: 16px;
}

/* Segmented Control (Radio buttons styled like toggle) */
.segmented-control {
    display: flex;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 0;
    transition: all var(--transition-fast);
}

.segmented-control input[type="radio"]:checked + label {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

#txTypeExpense:checked + label {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}

#txTypeIncome:checked + label {
    color: var(--success);
    background-color: rgba(16, 185, 129, 0.1);
}

/* ==========================================================================
   TABS MANAGEMENT
   ========================================================================== */
.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

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

/* ==========================================================================
   DASHBOARD TAB STYLES
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-wrapper i {
    width: 24px;
    height: 24px;
}

.stat-info span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
}

/* Specific Stat Card Colors */
.stat-card.income .stat-icon-wrapper {
    background-color: var(--success-bg);
    color: var(--success);
}
.stat-card.income h3 {
    color: var(--success);
}

.stat-card.expense .stat-icon-wrapper {
    background-color: var(--danger-bg);
    color: var(--danger);
}
.stat-card.expense h3 {
    color: var(--danger);
}

.stat-card.balance .stat-icon-wrapper {
    background-color: var(--info-bg);
    color: var(--info);
}

.stat-card.projected .stat-icon-wrapper {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.projected-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-tooltip-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    cursor: help;
}

/* Charts Grid */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.chart-card h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

/* Insights Cards */
.insights-row {
    display: flex;
    gap: 24px;
}

@media (max-width: 768px) {
    .insights-row {
        flex-direction: column;
    }
}

.info-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.info-card-header i {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.info-card-header h4 {
    font-size: 16px;
    font-weight: 600;
}

.info-card-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.due-widget-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color);
}
.due-widget-item:last-child {
    border-bottom: none;
}

/* ==========================================================================
   LEDGER TAB STYLES
   ========================================================================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.search-filter-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper.search i {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.input-wrapper.search input {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px 8px 36px;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    width: 200px;
    transition: width var(--transition-normal);
}

.input-wrapper.search input:focus {
    width: 260px;
    border-color: var(--accent-primary);
}

select, input[type="month"] {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
}

select:focus, input[type="month"]:focus {
    border-color: var(--accent-primary);
}

/* Data Table */
.table-responsive {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 16px 20px;
    font-size: 14px;
}

.data-table th {
    background-color: rgba(0,0,0,0.1);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Category Badge styles */
.badge-category {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

/* Status styles */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pill.completed {
    background-color: var(--success-bg);
    color: var(--success);
}

.status-pill.pending {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.tx-amount {
    font-weight: 700;
}
.tx-amount.income {
    color: var(--success);
}
.tx-amount.expense {
    color: var(--danger);
}

.action-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ==========================================================================
   FIXED EXPENSES TAB STYLES
   ========================================================================== */
.section-intro {
    background-color: var(--bg-card);
    border-left: 4px solid var(--accent-primary);
    padding: 16px 20px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.fixed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.fixed-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.fixed-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium);
}

.fixed-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.fixed-card-title h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.fixed-card-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--danger);
}

.fixed-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fixed-card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.fixed-card.paid {
    border-color: rgba(16, 185, 129, 0.4);
}
.fixed-card.paid::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 32px 32px 0;
    border-color: transparent var(--success) transparent transparent;
    border-top-right-radius: var(--radius-lg);
}

.fixed-card.paid::after {
    content: '\2713';
    position: absolute;
    top: 4px;
    right: 6px;
    color: white;
    font-size: 11px;
    font-weight: 700;
}

/* ==========================================================================
   DEBTS & LOANS TAB STYLES
   ========================================================================== */
.stats-grid.compact {
    grid-template-columns: repeat(2, 1fr);
}

.debt-item-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-fast);
}

.debt-item-card.lent {
    border-left: 5px solid var(--success);
}
.debt-item-card.borrowed {
    border-left: 5px solid var(--danger);
}

.debt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.debt-title-area h4 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.debt-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
}
.debt-badge.lent {
    background-color: var(--success-bg);
    color: var(--success);
}
.debt-badge.borrowed {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.debt-amounts {
    text-align: right;
}

.debt-main-amount {
    font-size: 20px;
    font-weight: 700;
}
.debt-lent-color { color: var(--success); }
.debt-borrowed-color { color: var(--danger); }

.debt-original-amount {
    font-size: 11px;
    color: var(--text-muted);
}

.debt-progress-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.debt-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.debt-progress-bar-bg {
    height: 8px;
    background-color: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.debt-progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-normal);
}
.debt-item-card.lent .debt-progress-bar-fill {
    background: linear-gradient(90deg, var(--success) 0%, var(--accent-primary) 100%);
}
.debt-item-card.borrowed .debt-progress-bar-fill {
    background: linear-gradient(90deg, var(--danger) 0%, var(--accent-secondary) 100%);
}

.debt-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    font-size: 13px;
}

.debt-due {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.debt-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================================================
   CALENDAR TAB STYLES
   ========================================================================== */
.calendar-layout-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .calendar-layout-grid {
        grid-template-columns: 1fr;
    }
}

.calendar-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.calendar-header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.calendar-header-nav h3 {
    font-size: 18px;
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 10px 0;
}

.calendar-body-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    grid-column: span 7;
}

.calendar-day-cell {
    aspect-ratio: 1;
    background-color: rgba(255,255,255,0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: all var(--transition-fast);
}

.calendar-day-cell:hover {
    background-color: rgba(255,255,255,0.03);
}

.calendar-day-num {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.calendar-day-cell.today {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
}
.calendar-day-cell.today .calendar-day-num {
    color: var(--accent-primary);
    font-weight: 700;
}

.calendar-day-cell.other-month {
    opacity: 0.25;
}

.calendar-day-dots {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
    padding-bottom: 4px;
}

.calendar-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-circle);
}
.calendar-dot.paid { background-color: var(--success); }
.calendar-dot.unpaid { background-color: var(--danger); }
.calendar-dot.debt { background-color: var(--warning); }

/* Day Details Popover inside calendar */
.calendar-day-cell:active .calendar-tooltip,
.calendar-day-cell:hover .calendar-tooltip {
    visibility: visible;
    opacity: 1;
}

.calendar-tooltip {
    visibility: hidden;
    width: 200px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    text-align: left;
    border-radius: var(--radius-md);
    padding: 10px;
    position: absolute;
    z-index: 10;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
    font-size: 11px;
    line-height: 1.4;
    pointer-events: none;
}
.calendar-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--border-color) transparent transparent transparent;
}

.calendar-tooltip-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 4px;
}
.calendar-tooltip-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Reminders List sidebar */
.reminders-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 520px;
    overflow-y: auto;
}

.reminders-card .card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.reminders-card .card-header i {
    color: var(--accent-primary);
}

.reminders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reminder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    transition: background-color var(--transition-fast);
}

.reminder-item:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

.reminder-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reminder-title {
    font-weight: 600;
}

.reminder-due-tag {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
}
.reminder-due-tag.overdue {
    background-color: var(--danger-bg);
    color: var(--danger);
    animation: pulse 2s infinite;
}
.reminder-due-tag.soon {
    background-color: var(--warning-bg);
    color: var(--warning);
}
.reminder-due-tag.future {
    background-color: var(--info-bg);
    color: var(--info);
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.reminder-amount {
    font-weight: 700;
    font-size: 14px;
}

/* ==========================================================================
   NOTIFICATION POPUP DROPDOWN
   ========================================================================== */
.notification-bell-container {
    position: relative;
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-circle);
    background-color: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--bg-primary);
}

.noti-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 125%;
    width: 320px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn var(--transition-fast);
}

.noti-dropdown.open {
    display: block;
}

.noti-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.noti-list {
    max-height: 280px;
    overflow-y: auto;
}

.empty-noti {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.noti-item {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    transition: background-color var(--transition-fast);
}
.noti-item:last-child {
    border-bottom: none;
}
.noti-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.noti-title-row {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--text-primary);
}

.noti-body {
    color: var(--text-secondary);
}

.noti-time {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
}

/* In-App Alert Bar */
.alert-bar {
    background: linear-gradient(90deg, var(--danger-bg) 0%, rgba(239, 68, 68, 0.05) 100%);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-left: 5px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.alert-bar-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}
.alert-bar-content i {
    color: var(--danger);
    width: 18px;
    height: 18px;
}

.alert-bar-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 700;
}
.alert-bar-close:hover {
    color: var(--text-primary);
}

/* ==========================================================================
   MODALS LAYOUT
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: var(--glass-blur);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}
.close-btn:hover {
    color: var(--text-primary);
}

form {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    margin-top: 10px;
}

.info-bubble {
    background-color: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION BAR
   ========================================================================== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    height: 64px;
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    flex: 1;
    height: 100%;
    justify-content: center;
}

.mobile-nav-item i {
    width: 20px;
    height: 20px;
}

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

/* ==========================================================================
   RESPONSIVE OVERRIDES
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: 20px 16px 80px 16px;
    }
    .mobile-logo {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: 700;
        font-size: 18px;
        color: var(--accent-primary);
    }
    .mobile-logo i {
        width: 20px;
        height: 20px;
    }
    .page-title {
        display: none;
    }
    .mobile-nav {
        display: flex;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-filter-area {
        flex-direction: column;
        align-items: stretch;
    }
    .input-wrapper.search input {
        width: 100%;
    }
    .input-wrapper.search input:focus {
        width: 100%;
    }
    select, input[type="month"] {
        width: 100%;
    }
    .btn {
        width: 100%;
    }
    .action-cell {
        flex-direction: column;
        gap: 4px;
    }
}

/* ==========================================================================
   LOGIN & LOADING OVERLAYS
   ========================================================================== */
.login-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    transition: background-color var(--transition-normal);
}

.login-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    text-align: center;
}

.login-header {
    margin-bottom: 24px;
}

.login-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-top: 12px;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

.lock-icon {
    width: 44px;
    height: 44px;
    color: var(--accent-primary);
}

.login-error-msg {
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.spinner-container {
    text-align: center;
    color: var(--text-primary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px auto;
}

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

