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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: #0f1218; /* dark */
    color: #e6e8ec; /* light text */
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #151a23;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

header h1 {
    color: #ffda79;
    font-size: 2rem;
    font-weight: 600;
}

.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    min-height: 70vh;
}

.sidebar {
    background: #151a23;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.upload-section {
    margin-bottom: 2rem;
}

.upload-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #e6e8ec;
}

.file-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #3a3f4b;
    border-radius: 8px;
    background: #0f1218;
    color: #9aa3b2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-input:hover {
    border-color: #6ea8fe;
    background: #111624;
}

.file-status {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #9aa3b2;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: #e6e8ec;
}

.control-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #2a2f3a;
    border-radius: 6px;
    background: #0f1218;
    color: #e6e8ec;
    font-size: 0.9rem;
}

.control-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.main-content {
    background: #151a23;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    padding: 2rem;
}

/* Top toolbar for dataset selection */
.toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar-label {
    color: #e6e8ec;
    font-weight: 500;
}
.toolbar-select {
    min-width: 280px;
    max-width: 50%;
    padding: 0.5rem;
    border: 1px solid #2a2f3a;
    border-radius: 6px;
    background: #0f1218;
    color: #e6e8ec;
}

.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff4b4b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: #3a0d0d;
    border: 1px solid #a23232;
    color: #ffb3b3;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.info-message {
    text-align: center;
    padding: 3rem;
    color: #9aa3b2;
    font-size: 1.1rem;
}

.content-area {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.chart-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid #2a2f3a;
    border-radius: 8px;
    background: #0f1218;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e6e8ec;
}

.download-btn {
    background: #6ea8fe;
    color: #0b1020;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.download-btn:hover {
    background: #8ab6ff;
}

/* Bottom download area */
.downloads-section {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #2a2f3a;
}

.chart-container {
    position: relative;
    height: 460px;
    margin-bottom: 1rem;
}

/* Hover tooltip for chart bars */
.chart-tooltip {
    position: absolute;
    display: none;
    min-width: 220px;
    max-width: 320px;
    background: #1b202b;
    border: 1px solid #2a2f3a;
    color: #e6e8ec;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    border-radius: 8px;
    padding: 8px 10px;
    pointer-events: none;
    z-index: 5;
    font-size: 12px;
    line-height: 1.4;
}
.chart-tooltip .row { display: flex; gap: 8px; }
.chart-tooltip .key { color: #9aa3b2; min-width: 86px; }
.chart-tooltip .val { color: #e6e8ec; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #2a2f3a;
}

.data-table th {
    background: #111624;
    color: #e6e8ec;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.data-table tbody tr:hover {
    background: #111624;
}

.data-table .number-cell {
    text-align: right;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Responsive design */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sidebar {
        position: static;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* File upload drag and drop styling */
.file-input.dragover {
    border-color: #8ab6ff;
    background: #111624;
    transform: scale(1.02);
}

/* Success message */
.success-message {
    background: #0f2b14;
    border: 1px solid #2b8a3e;
    color: #a8e6b3;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
