:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --income: #10b981;
    --expense: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header & Summary Cards */
.header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

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

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

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    align-items: flex-end;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.card-balance {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
}

.card-balance .card-label { color: rgba(255,255,255,0.8); }
.card-balance .value-balance { color: white; }

/* Analytics Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Main Content Area */
.content-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Transaction List */
.transaction-list {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.transaction-item {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    display: flex;
    flex-direction: column;
}

.transaction-desc {
    font-weight: 600;
    font-size: 1rem;
}

.transaction-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.transaction-amount {
    font-weight: 700;
    font-size: 1.125rem;
}

.amount-income::before { content: '+'; }
.amount-expense::before { content: '-'; }

/* Floating Action Button for Mobile */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    border: none;
    z-index: 100;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 450px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
}

/* Management Modal styles */
.manage-list { margin-top: 1rem; border: 1px solid var(--border); border-radius: 12px; max-height: 300px; overflow-y: auto; }
.manage-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.manage-item:last-child { border-bottom: none; }
.manage-item:hover { background: #f8fafc; }

/* Tab buttons */
.tab-btn { padding: 0.5rem 1rem; border: 1px solid var(--border); background: #f1f5f9; cursor: pointer; border-radius: 8px; font-family: 'Itim', cursive; font-size: 1rem; }
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.modal-header {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

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

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

.btn {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

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

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

/* Print Styles for PDF Report */
@media print {
    body * { visibility: hidden; }
    #reportView, #reportView * { visibility: visible; }
    #reportView { 
        position: absolute; 
        left: 0; 
        top: 0; 
        width: 100%; 
        display: block !important; 
        padding: 0;
        margin: 0;
    }
    .no-print { display: none !important; }
    @page { margin: 1cm; }
}

#reportView { display: none; }

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

@media (max-width: 640px) {
    .container { padding: 1rem; }
    .header h1 { font-size: 1.5rem; }
    .card-value { font-size: 1.5rem; }
    .fab { bottom: 1.5rem; right: 1.5rem; }
    .filter-bar { flex-direction: column; align-items: stretch; }
}
