/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4F46E5;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --light-pink: #FCA5A5;
    --bg-color: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 24px;
    padding: 16px 0;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Card Component */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
}

/* Gauge Chart Specific */
.gauge-container {
    position: relative;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    aspect-ratio: 2 / 1;
}

.gauge-value {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.amount {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.gauge-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Chart Container */
.chart-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* Bar Chart specific height */
#barChart {
    max-height: 280px;
}

/* Donut Chart specific */
#donutChart {
    max-width: 240px;
    max-height: 240px;
    margin: 0 auto;
}

/* Legend */
.legend-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-color);
    border-radius: 8px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.legend-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 24px;
}

.footer p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive adjustments for smaller screens */
@media (max-width: 360px) {
    .container {
        padding: 12px;
    }

    .header h1 {
        font-size: 20px;
    }

    .card {
        padding: 16px;
    }

    .amount {
        font-size: 28px;
    }

    .card-title {
        font-size: 15px;
    }
}

/* Responsive adjustments for larger screens (iPad, etc) */
@media (min-width: 481px) {
    .container {
        padding: 24px;
    }

    .card {
        padding: 24px;
    }

    .header h1 {
        font-size: 28px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #111827;
        --card-bg: #1F2937;
        --text-primary: #F9FAFB;
        --text-secondary: #9CA3AF;
        --border-color: #374151;
    }
}

/* Prevent text selection on charts */
canvas {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
