:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #1e293b;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --gold: #f59e0b;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--primary);
    margin-bottom: 3rem;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    margin-bottom: 8px;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.nav-item.active {
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2.5rem;
    max-width: calc(100vw - 260px);
}

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

.header-info h1 {
    font-size: 1.75rem;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 0.25rem;
}

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

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

.btn-icon-only {
    background: var(--secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-only i, .btn-icon-only svg {
    width: 20px !important;
    height: 20px !important;
}

.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

/* Tabs */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

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

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

.month-navigator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 5px;
}

.btn-icon {
    background: var(--secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#sidebar-nav {
    flex: 1;
}
.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

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

.btn-secondary {
    background: var(--secondary);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-edit-small {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: auto;
    transition: var(--transition);
}

.btn-edit-small:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.balance-stat.negative h3 {
    color: var(--danger);
}

.balance-stat.positive h3 {
    color: var(--success);
}

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

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card.gold .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--gold);
}

.stat-details .label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-details h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 4px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem;
    align-items: start;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.chart-container {
    height: 480px;
}

.chart-wrapper {
    flex: 1;
    min-height: 300px;
    position: relative;
}

.chart-container canvas {
    max-height: 280px !important;
    width: 100% !important;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    font-weight: 600;
}

.btn-delete {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: var(--transition);
}

.btn-delete:hover {
    opacity: 1;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    margin: 10% auto;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover {
    background: var(--secondary);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.btn-move:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-delete:hover {
    color: var(--danger);
    border-color: var(--danger);
}

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

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--secondary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.w-100 { width: 100%; }

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

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-header i {
    color: var(--text-muted);
}

/* Table */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

.empty-state {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted);
    font-style: italic;
}

.amount-positive { color: var(--success); }
.amount-negative { color: var(--text-main); }

/* Category Selects */
.category-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    max-width: 160px;
    appearance: none;
}

.category-select:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.category-select:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.category-select option {
    background: #1a1b2e;
    color: var(--text-main);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

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

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

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Transform Sidebar into Bottom Navigation */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        flex-direction: row;
        padding: 0.5rem 1rem;
        border-right: none;
        border-top: 1px solid var(--glass-border);
        justify-content: space-between;
        align-items: center;
        background: rgba(15, 23, 42, 0.95);
        padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    }
    
    .logo {
        display: none;
    }

    #sidebar-nav {
        display: flex;
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        gap: 0.5rem;
    }

    .nav-item {
        margin-bottom: 0;
        padding: 0.5rem;
        flex-direction: column;
        flex: 1;
        font-size: 0.7rem;
        gap: 4px;
        text-align: center;
    }

    .nav-item i {
        margin: 0;
    }

    .sidebar-footer {
        margin-top: 0;
        padding: 0;
        border-top: none;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 0.5rem;
    }
    
    /* Transform Save button into a round Floating Action Button in the bottom nav */
    .sidebar-footer .btn {
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        font-size: 0; /* Hide text */
    }
    
    .sidebar-footer .btn i {
        margin: 0;
        width: 20px;
        height: 20px;
    }

    /* Adjust Main Content to make space for bottom space */
    .main-content {
        margin-left: 0;
        padding: 1.5rem 1rem 6rem 1rem; 
        max-width: 100vw;
    }

    /* Header Adjustments */
    header {
        flex-direction: column;
        gap: 1.5rem;
        align-items: stretch;
    }

    .header-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }

    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .header-actions .btn {
        padding: 10px;
        font-size: 0.85rem;
        justify-content: center;
    }
    
    .header-actions .btn-icon-only {
        width: 100%;
        border-radius: 10px;
    }

    /* Modal Mobile Adjustments */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin: 10% auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    /* Typography adjustments for smaller screens */
    .stat-details h3 {
        font-size: 1.25rem;
    }
    
    /* Table Responsive fix */
    th, td {
        white-space: nowrap;
    }
}
