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

:root {
    --bg: #f0f2f5;
    --text: #1a1a2e;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --card-bg: white;
    --card-shadow: rgba(0,0,0,0.08);
    --gauge-bg: #e5e7eb;
    --gauge-label: #1a1a2e;
    --border: #d1d5db;
    --input-bg: white;
    --query-row-bg: #f9fafb;
    --btn-secondary-bg: #e5e7eb;
    --btn-secondary-text: #374151;
    --btn-secondary-hover: #d1d5db;
    --weekday-bg: white;
    --weekday-hover: #f3f4f6;
    --chart-grid: rgba(0,0,0,0.1);
    --chart-text: #666;
}

[data-theme="dark"] {
    --bg: #111827;
    --text: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --text-faint: #6b7280;
    --card-bg: #1f2937;
    --card-shadow: rgba(0,0,0,0.3);
    --gauge-bg: #374151;
    --gauge-label: #f3f4f6;
    --border: #4b5563;
    --input-bg: #374151;
    --query-row-bg: #111827;
    --btn-secondary-bg: #374151;
    --btn-secondary-text: #d1d5db;
    --btn-secondary-hover: #4b5563;
    --weekday-bg: #374151;
    --weekday-hover: #4b5563;
    --chart-grid: rgba(255,255,255,0.1);
    --chart-text: #9ca3af;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

header {
    background: linear-gradient(135deg, #4f46e5, #0891b2);
    color: white;
    padding: 1.5rem 2rem 1rem;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.subtitle {
    opacity: 0.85;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.location-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: background 0.2s;
    color: white;
    line-height: 1;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.25);
}

.tab {
    padding: 0.5rem 1.5rem;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 2rem;
    background: transparent;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    background: rgba(255,255,255,0.15);
}

.tab.active {
    background: white;
    color: #4f46e5;
    border-color: white;
    font-weight: 600;
}

main {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    transition: background 0.3s, box-shadow 0.3s;
}

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

.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Current status */
.status-display {
    text-align: center;
}

.gauge-container {
    position: relative;
    height: 40px;
    background: var(--gauge-bg);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    transition: background 0.3s;
}

.gauge-bar {
    height: 100%;
    border-radius: 20px;
    transition: width 0.6s ease, background-color 0.6s ease;
    width: 0%;
}

.gauge-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gauge-label);
    text-shadow: 0 0 4px rgba(255,255,255,0.8);
}

[data-theme="dark"] .gauge-label {
    text-shadow: 0 0 4px rgba(0,0,0,0.6);
}

.trend-info {
    font-size: 1.2rem;
    margin: 0.5rem 0 0.25rem;
}

.trend-arrow {
    font-size: 1.4rem;
}

.trend-text {
    color: var(--text-muted);
}

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

/* Weekday selector */
.weekday-selector {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.weekday-selector button {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--weekday-bg);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
}

.weekday-selector button:hover {
    background: var(--weekday-hover);
}

.weekday-selector button.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

/* Custom comparison */
.custom-controls {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.btn {
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover { background: #4338ca; }

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
}

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

.btn-danger {
    background: none;
    color: var(--text-faint);
    padding: 0.25rem 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
}

.btn-danger:hover { color: #ef4444; }

.query-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem;
    background: var(--query-row-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: background 0.3s, border-color 0.3s;
}

.query-row label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.query-row input,
.query-row select {
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    background: var(--input-bg);
    color: var(--text);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}

.query-row input[type="text"] {
    width: 120px;
}

.query-row input[type="date"] {
    width: 130px;
}

.query-color {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

@media (max-width: 600px) {
    header { padding: 1rem; }
    header h1 { font-size: 1.4rem; }
    main { margin: 1rem auto; }
    .card { padding: 1rem; }
    .chart-container { height: 220px; }
    .theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        top: 0.75rem;
        right: 0.75rem;
    }
}
