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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

h1 {
    font-size: 1.8rem;
    color: #f8fafc;
}

.time-filter {
    display: flex;
    gap: 10px;
}

select, button {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

select:hover, button:hover {
    border-color: #3b82f6;
    background: #293548;
}

button {
    background: #3b82f6;
    border-color: #3b82f6;
}

button:hover {
    background: #2563eb;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #334155;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #f8fafc;
}

.stat-value.error {
    color: #ef4444;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #334155;
}

.chart-card h3 {
    font-size: 1rem;
    color: #f8fafc;
    margin-bottom: 16px;
    font-weight: 600;
}

.chart-card canvas {
    max-height: 300px;
}

.table-section {
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #334155;
    margin-bottom: 30px;
}

.table-section h3 {
    font-size: 1rem;
    color: #f8fafc;
    margin-bottom: 16px;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #334155;
}

th {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.875rem;
}

td {
    color: #e2e8f0;
    font-size: 0.875rem;
}

tr:hover td {
    background: #293548;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #334155;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 16px;
    color: #94a3b8;
}

/* Header controls */
.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.settings-btn {
    background: #334155;
    border-color: #475569;
}

.settings-btn:hover {
    background: #475569;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #1e293b;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #334155;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #334155;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: #f8fafc;
}

.close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: #f8fafc;
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 0.75rem;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    flex: 1;
    padding: 12px 20px;
    background: #3b82f6;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    padding: 12px 20px;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #475569;
}

/* Setup prompt */
.setup-prompt {
    text-align: center;
    padding: 60px 20px;
}

.setup-prompt h2 {
    color: #f8fafc;
    margin-bottom: 12px;
}

.setup-prompt p {
    color: #94a3b8;
    margin-bottom: 24px;
}

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

    header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}