:root {
    /* Color Palette - Elegant Dark Theme */
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --primary-color: #10b981;
    /* Emerald */
    --primary-hover: #059669;
    --secondary-color: #38bdf8;
    /* Sky */
    --accent-color: #f43f5e;
    /* Rose for expenses */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 20px 40px -10px rgba(0, 0, 0, 0.4);
    --primary-gradient: linear-gradient(135deg, #10b981, #059669);

    --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Light Mode ──────────────────────────────────────────── */
html.light-mode {
    --bg-color: #f0f4f8;
    --surface-color: #ffffff;
    --surface-hover: #e2e8f0;
    --primary-color: #059669;
    --primary-hover: #047857;
    --secondary-color: #0284c7;
    --accent-color: #e11d48;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    --shadow-strong: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    --primary-gradient: linear-gradient(135deg, #059669, #047857);
}

/* Smooth theme transition */
*,
*::before,
*::after {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}



* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
}

/* Base Layout */
.app-container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    height: 100vh;
    position: sticky;
    top: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    letter-spacing: -0.05em;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--surface-hover);
    color: var(--text-main);
}

.nav-item.active {
    color: var(--primary-color);
    background-color: rgba(16, 185, 129, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header-title p {
    color: var(--text-muted);
}

/* Dash Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--card-accent, var(--primary-color));
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-up {
    color: var(--primary-color);
}

.trend-down {
    color: var(--accent-color);
}

/* Input Section */
.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.form-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.btn-primary {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 1rem;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* History List */
.history-card {
    grid-column: span 1;
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.transaction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    animation: slideIn 0.4s ease forwards;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.item-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background-color: var(--surface-color);
}

.item-details h4 {
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.item-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-amount {
    font-weight: 700;
    font-size: 1rem;
}

.amount-expense {
    color: var(--accent-color);
}

.amount-income {
    color: var(--primary-color);
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive Adjustments & Mobile Navigation */
@media (max-width: 1024px) {
    .input-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        display: block;
    }

    .sidebar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 0;
        z-index: 1000;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: var(--surface-color);
        backdrop-filter: blur(20px);
    }

    .logo {
        display: none;
    }

    nav {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
    }

    nav::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .nav-links {
        display: flex;
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        align-items: flex-end;
        /* Bottom align for items */
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        box-sizing: border-box;
    }

    .nav-item {
        flex-direction: column;
        padding: 0.5rem;
        font-size: 0.65rem;
        gap: 4px;
        border-radius: 8px;
        text-align: center;
        min-width: 75px;
        /* Give items enough breathing room */
        flex-shrink: 0;
        /* Prevent squishing */
    }

    .nav-item span {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }

    .main-content {
        display: block;
        padding: 1rem;
        padding-bottom: 90px;
        /* Space for bottom nav */
        min-height: 100vh;
        width: 100%;
        overflow-y: visible;
        flex: none;
    }

    header {
        flex-direction: row;
        /* Keep header side-by-side if possible */
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }

    .header-title h1 {
        font-size: 1.4rem;
    }

    .header-title p {
        font-size: 0.8rem;
    }

    .user-info-text {
        display: none;
    }

    .card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .card-value {
        font-size: 1.5rem;
    }

    .form-card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .input-section {
        gap: 1.5rem;
        margin-bottom: 0;
    }

    .transaction-list {
        max-height: none;
        /* Let the whole page scroll on mobile */
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .calendar-card {
        padding: 1rem;
        overflow-x: auto;
    }

    .calendar-grid {
        min-width: 600px;
        /* Allow horizontal scroll for calendar grid on mobile */
    }

    .calendar-day {
        min-height: 80px;
        padding: 0.25rem;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .event-tag {
        font-size: 0.6rem;
    }
}