/* CSS Variables for theming */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header Styles */
.header {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo-container {
    flex-shrink: 0;
}

.logo-placeholder {
    width: 180px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    overflow: hidden;
}

.logo-placeholder img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-xs);
}

.logo-image {
    width: 100%;
    height: auto;
    display: block;
}

.logo-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 3px;
}

.logo-subtitle {
    font-size: 0.625rem;
    font-weight: 500;
    opacity: 0.9;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.header-info h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.last-updated {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Section Styles */
section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    padding: 1.75rem;
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.card-icon {
    font-size: 2.5rem;
    line-height: 1;
    background: white;
    padding: 0.75rem;
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow);
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-content .amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.budget-card .amount {
    color: var(--info-color);
}

.spent-card .amount {
    color: var(--danger-color);
}

.remaining-card .amount {
    color: var(--success-color);
}

.forecast-card .amount {
    color: var(--warning-color);
}

/* Progress Section */
.progress-container {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    padding: 2rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.125rem;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, var(--warning-color) 60%, var(--danger-color) 100%);
    border-radius: 10px;
    transition: width 0.8s ease;
    width: 0%;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Chart Section */
.chart-container {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    padding: 2rem;
    position: relative;
    height: 400px;
}

/* Table Section */
.table-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input,
.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-size: 0.9375rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.table-container {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    overflow: hidden;
    overflow-x: auto;
}

.expenses-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9375rem;
}

.expenses-table thead {
    background: var(--primary-color);
    color: white;
}

.expenses-table th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.expenses-table th:first-child {
    border-radius: var(--radius-xs) 0 0 0;
}

.expenses-table th:last-child {
    border-radius: 0 var(--radius-xs) 0 0;
}

.expenses-table th.numeric {
    text-align: right;
}

.expenses-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.expenses-table tbody tr {
    transition: background-color 0.2s;
}

.expenses-table tbody tr:hover {
    background: white;
}

.expenses-table tbody tr:last-child td {
    border-bottom: none;
}

.expenses-table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 var(--radius-xs);
}

.expenses-table tbody tr:last-child td:last-child {
    border-radius: 0 0 var(--radius-xs) 0;
}

.expenses-table td.numeric {
    text-align: right;
    font-family: 'SF Mono', monospace;
    font-weight: 600;
    font-size: 1rem;
}

.expenses-table td:first-child {
    font-weight: 500;
    color: var(--text-primary);
}

/* Table Pagination */
.table-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-pagination {
    padding: 0.625rem 1.25rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#page-info {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Loading State */
.loading-row td {
    text-align: center;
    padding: 4rem 2rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-cell p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Error State */
.error-cell {
    text-align: center;
    padding: 3rem;
    color: var(--danger-color);
}

.error-cell p {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.btn-retry {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: white;
    opacity: 0.9;
}

.footer p {
    margin-bottom: 0.5rem;
}

.footer-note {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.75rem;
    }

    section {
        padding: 1.5rem;
        border-radius: var(--radius-sm);
    }

    .header {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .header-info h1 {
        font-size: 1.5rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1.5rem;
    }

    .card-content .amount {
        font-size: 1.625rem;
    }

    .section-title {
        font-size: 1.25rem;
    }

    .table-filters {
        flex-direction: column;
    }

    .search-input,
    .filter-select {
        width: 100%;
    }

    .expenses-table {
        font-size: 0.875rem;
    }

    .expenses-table th,
    .expenses-table td {
        padding: 1rem;
    }

    .expenses-table th:nth-child(3),
    .expenses-table td:nth-child(3) {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chart-container {
        height: 300px;
        padding: 1rem;
    }
}

/* Utility Classes */
.positive {
    color: var(--success-color);
}

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

.text-right {
    text-align: right;
}

.hidden {
    display: none !important;
}