* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.navbar {
    background: var(--bg-secondary);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 60px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--accent-primary);
}

.back-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px;
    border-radius: 5px;
    transition: background 0.3s;
}

.back-btn:hover {
    background: var(--bg-tertiary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.total-display {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 16px;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
}

.main-container {
    display: flex;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    position: fixed;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s;
    border-right: 3px solid transparent;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    border-right-color: var(--accent-primary);
}

.content {
    flex: 1;
    margin-left: 240px;
    padding: 30px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
}

.home-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}

.expense-form {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    height: fit-content;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.subcategory-group {
    margin-top: 10px;
    display: none;
}

.subcategory-group.show {
    display: block;
}

.btn {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
}

.expenses-section {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
}

.expenses-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filter-select {
    padding: 8px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.expense-list {
    max-height: 500px;
    overflow-y: auto;
}

.expense-item {
    background: var(--bg-primary);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s;
}

.expense-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.expense-info {
    flex-grow: 1;
}

.expense-category {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    color: var(--accent-primary);
}

.expense-subcategory {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.expense-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.expense-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e74c3c;
}

.delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 15px;
    font-size: 12px;
    transition: background 0.3s;
}

.delete-btn:hover {
    background: #c0392b;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.goal-section {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.goal-progress {
    width: 100%;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    margin: 15px 0;
    overflow: hidden;
}

.goal-progress-bar {
    height: 100%;
    background: var(--gradient);
    border-radius: 5px;
    transition: width 0.3s;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
        padding: 20px;
    }

    .home-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .navbar-right .total-display {
        font-size: 14px;
    }
}