:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-wrapper {
    display: flex;
    flex: 1;
}

.sidebar {
    width: 260px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: #4b5563; /* Gray-600 */
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    gap: 0.875rem;
}

.sidebar-nav li a i {
    color: #9ca3af; /* Gray-400 - Single color icons */
    transition: color 0.2s;
}

.sidebar-nav li a:hover, .sidebar-nav li a.active {
    color: var(--primary-color);
    background-color: #f5f3ff;
}

.sidebar-nav li a:hover i, .sidebar-nav li a.active i {
    color: var(--primary-color);
}

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

.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    height: 64px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem; /* Increased padding */
    }
}

.main-content {
    padding: 2rem 0;
    flex: 1;
}

@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 0;
    }
}

/* Old navbar classes to be removed or adapted */
.navbar { display: none; }

.card {
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.875rem;
}

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

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

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover {
    background-color: var(--bg-color);
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-span-2 { grid-column: span 2; }
.grid-span-3 { grid-column: span 3; }

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 1rem;
    display: block;
}

.card-auto {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
}

.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.color-income { color: var(--success-color); }
.color-expense { color: var(--danger-color); }
.color-balance { color: var(--primary-color); }

.table-container {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 0.75rem 1rem;
    background-color: var(--bg-color);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

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

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    padding: 1rem 0;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-height: 90vh;
    overflow-y: auto;
}

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

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

.close-modal:hover {
    color: var(--danger-color);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-selected {
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background-color: white;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 42px;
}

.multiselect-selected::after {
    content: '▼';
    font-size: 0.7rem;
    color: var(--text-muted);
}

.multiselect-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    padding: 0.5rem;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
    gap: 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.multiselect-option:hover {
    background-color: var(--bg-color);
}

#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease-out forwards;
    min-width: 250px;
}

.toast-success { border-left-color: var(--success-color); }
.toast-error { border-left-color: var(--danger-color); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0 1rem;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    gap: 0.25rem;
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.5rem 0;
}

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

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

.fab-container {
    flex: 1;
    display: flex;
    justify-content: center;
    position: relative;
    height: 100%;
}

.fab {
    position: absolute;
    top: -25px;
    width: 56px;
    height: 56px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.fab:active {
    transform: scale(0.9);
    background-color: var(--primary-hover);
}

.fab i {
    width: 28px;
    height: 28px;
}

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 150px);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* MEDIA QUERIES AT THE END */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .top-bar {
        display: flex;
        justify-content: space-between;
    }

    .bottom-nav {
        display: flex;
    }

    .container {
        padding: 0 1.25rem;
    }
    
    .main-content {
        padding: 1.5rem 0 90px 0 !important;
    }

    .card {
        margin-left: 0;
        margin-right: 0;
        padding: 1.25rem;
    }

    .page-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        margin-bottom: 2rem !important;
        padding: 0 !important;
        width: 100%;
        gap: 1.25rem !important;
    }

    .page-header .header-actions {
        display: flex !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }

    .page-header .header-actions .btn {
        flex: 1 !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
    }

    .page-header h1 {
        font-size: 1.5rem !important;
        text-align: left;
    }

    .grid-3, .grid-2 {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .grid-3 > div, .grid-2 > div {
        grid-column: span 1 !important;
    }
    
    .card {
        margin-bottom: 1.5rem !important;
        padding: 1.5rem !important;
    }

    .stat-card {
        margin-bottom: 0.75rem !important;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: white;
        padding: 1.5rem;
        box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
        border-top: 1px solid var(--border-color);
        gap: 1.25rem;
    }

    .nav-links.active {
        display: flex;
    }

    .mobile-menu-btn {
        display: block;
        padding: 0.5rem;
        margin-right: -0.5rem;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

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

    /* Accordion Styles */
    .date-group {
        margin-bottom: 1.25rem;
    }

    .date-group-header {
        background-color: white;
        padding: 1.25rem 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        font-weight: 600;
    }

    .date-group-content {
        display: none;
    }

    .date-group.active .date-group-content {
        display: block;
    }

    .date-group.active .date-group-header {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        background-color: #f8fafc;
    }

    .date-group-header::after {
        content: '▼';
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .date-group.active .date-group-header::after {
        transform: rotate(180deg);
    }

    .mobile-transaction-card {
        background: white;
        border: 1px solid var(--border-color);
        border-top: none;
        padding: 1.5rem;
    }

    .modal-content {
        padding: 1.25rem !important;
        width: 95% !important;
        max-height: 85vh !important;
    }

    .mobile-transaction-card:last-child {
        border-bottom-left-radius: 0.5rem;
        border-bottom-right-radius: 0.5rem;
    }

    .mobile-transaction-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.75rem;
        font-size: 0.875rem;
        gap: 1.5rem;
    }

    .mobile-transaction-label {
        color: var(--text-muted);
        font-weight: 500;
        white-space: nowrap;
    }

    .mobile-transaction-value {
        text-align: right;
        word-break: break-word;
    }

    .desktop-only-table {
        display: none;
    }

    /* General Table Mobile Optimization */
    .table-container table, 
    .table-container thead, 
    .table-container tbody, 
    .table-container th, 
    .table-container td, 
    .table-container tr { 
        display: block; 
    }

    .table-container thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-container tr { 
        border-bottom: 1px solid var(--border-color);
        padding: 1rem 0;
    }
    
    .table-container tr:last-child {
        border-bottom: none;
    }

    .table-container td { 
        border: none;
        position: relative;
        padding-left: 50% !important; 
        text-align: right;
        margin-bottom: 0.5rem;
    }

    .table-container td:before { 
        position: absolute;
        left: 0.5rem;
        width: 45%; 
        padding-right: 10px; 
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
        content: attr(data-label);
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none;
    }
}
