:root {
    --bg-color: #f7f7f7;
    --card-bg: #ffffff;
    --text-main: #0a0a0a;
    --text-muted: #666666;
    --border: #e0e0e0;
    --primary: #000000;
    --primary-hover: #333333;
    --transition: 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -0.03em;
}

.container {
    display: none;
    min-height: 100vh;
    opacity: 0;
    transition: opacity var(--transition);
    overflow-x: hidden;
    height: auto;
}

.container.active {
    display: block;
    opacity: 1;
}

#login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition);
    height: auto;
}

.card:hover {
    box-shadow: 0 15px 40px rgba(0,0,0,0.08);
}

.login-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
    margin: auto;
}

.login-box p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}
 
.quick-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.widget-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition);
}

.widget-btn:hover {
    transform: translateY(-5px);
    background: #000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.widget-btn:hover span {
    color: #fff;
}

.widget-btn span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    background: #fafafa;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
    background: #fff;
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: #000;
    color: #fff;
}

.hidden {
    display: none !important;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.summary-hero {
    width: 100%;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: #000;
    color: #fff;
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-bottom: 0.25rem;
}

#total-summary-balance {
    font-size: 2rem;
    font-weight: 700;
}

#total-receivable-balance {
    font-size: 2rem;
    font-weight: 700;
    color: #3b82f6;
}

.combined-summary {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1.5rem !important;
}

.summary-item {
    flex: 1;
    text-align: center;
}

.summary-divider {
    width: 1px;
    height: 50px;
    background: rgba(255,255,255,0.15);
    margin: 0 1.5rem;
}

@media (max-width: 768px) {
    .combined-summary {
        flex-direction: column;
        gap: 1.5rem;
    }
    .summary-divider {
        width: 80%;
        height: 1px;
        margin: 0 auto;
    }
}

.navbar .btn {
    width: auto;
    padding: 0.5rem 1.5rem;
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 0 auto 2rem;
    max-width: 1200px;
    padding: 0 2rem;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: #000;
    border-bottom: 2px solid #000;
}

.tabs-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    width: 100%;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

.section-card {
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .tabs-nav {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0 1rem;
        flex-wrap: wrap;
    }
    .tab-btn {
        flex: 1;
        min-width: 30%;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    .row {
        flex-direction: column;
    }
    .card {
        padding: 1rem;
        height: auto !important; /* Ensure card expands */
        overflow: visible;
    }
    .expense-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .expense-details {
        width: 100%;
        word-break: break-word; /* Prevent large descriptions from pushing off screen */
    }
    .expense-meta {
        margin-top: 0.25rem;
    }
    .expense-right {
        width: 100%;
        justify-content: space-between;
        align-items: center;
        flex-direction: row;
        border-top: 1px dotted var(--border);
        padding-top: 0.75rem;
    }
    .filters {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    .list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .stats {
        flex-direction: column;
        gap: 1rem;
        margin: 1rem 0;
    }
    .stat-value {
        font-size: 1.5rem;
    }
}

.row {
    display: flex;
    gap: 1rem;
}
.flex-1 {
    flex: 1;
}

.tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-selector label {
    cursor: pointer;
    margin: 0;
}

.tag-selector input {
    display: none;
}

.tag-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition);
    user-select: none;
}

.tag-badge:hover {
    transform: translateY(-2px);
    background: #000;
    color: #fff;
}

.tag-selector input:checked + .tag-badge {
    background: #000;
    color: #fff;
    border-color: #000;
}

#cancel-btn {
    margin-top: 1rem;
}

.stats {
    display: flex;
    gap: 2rem;
    margin: 1.5rem 0;
}
.stat {
    flex: 1;
}
.stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.list-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.filters {
    display: flex;
    gap: 1rem;
}
.filters select {
    width: auto;
    padding: 0.4rem 2rem 0.4rem 1rem;
}

.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.4s ease;
}

.expense-item:last-child {
    border-bottom: none;
}

.expense-details h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.expense-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.list-tag-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    background: #000;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.list-tag-badge.mandatory { background: #000; }
.list-tag-badge.unwanted { background: #ef4444; }
.list-tag-badge.occasional { background: #3b82f6; }
.list-tag-badge.emergency { background: #f59e0b; }
.list-tag-badge.payment-method { background: #eee; color: #333; border: 1px solid #ccc; }

.expense-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.expense-amount {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-main);
}

.expense-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: #000;
    text-decoration: underline;
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 0;
    font-size: 0.95rem;
}

/* New Analytics Layout */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.chart-container {
    background: #fafafa;
    padding: 1.25rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 380px; /* Fixed height for consistency */
    position: relative;
    overflow: hidden;
}

.chart-container h3 {
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 0; /* Important for flex child to shrink/grow correctly */
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .chart-container {
        height: 420px; /* Taller on mobile for legend at bottom */
    }
}

.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}
