/* ================================================================
   BESS Simulator — Design System
   Dark theme · Glassmorphism · Inter font
   ================================================================ */

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

:root {
    --bg-main: #0a0e1a;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-hover: rgba(30, 41, 59, 0.5);
    --border: rgba(99, 102, 241, 0.12);
    --border-glow: rgba(99, 102, 241, 0.3);
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #a855f7;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, system-ui, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ============ GLASS CARD ============ */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.glass-card:hover {
    border-color: var(--border-glow);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.06);
}

/* ============ HEADER ============ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ============ MAIN ============ */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 24px 80px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ============ CONFIG ============ */
.config-section {
    padding: 24px;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.config-group label {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 500;
}

.config-group input,
.config-group select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    transition: border-color 0.2s;
}

.config-group input:focus,
.config-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.config-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ============ UPLOAD SECTION ============ */
.upload-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .upload-section {
        grid-template-columns: 1fr;
    }
}

.upload-card {
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.upload-card p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.upload-card code {
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent);
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 4px;
}

.drop-zone {
    width: 100%;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 12px;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.06);
}

.drop-label {
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.file-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s;
}

.file-status.loaded {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    font-weight: 600;
}

/* ============ ACTION ============ */
.action-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.btn {
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.88rem;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 12px 28px;
    transition: all 0.25s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.45);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-large {
    padding: 16px 48px;
    font-size: 1rem;
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 8px 16px;
    font-size: 0.8rem;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text);
}

.progress-bar {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ============ RESULTS ============ */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.kpi-card {
    padding: 20px 16px;
    text-align: center;
}

.kpi-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Charts */
.chart-container {
    padding: 20px;
}

.chart-container h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-dim);
}

.chart-wrapper {
    height: 320px;
    position: relative;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* Table */
.table-container {
    padding: 20px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.table-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.table-scroll {
    overflow-x: auto;
    max-height: 480px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
    white-space: nowrap;
}

thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

th {
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.68rem;
    padding: 10px 10px;
    text-align: right;
    border-bottom: 2px solid var(--border);
}

th:first-child {
    text-align: left;
}

td {
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
}

td:first-child {
    text-align: left;
    color: var(--text);
    font-weight: 500;
}

tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

.td-c {
    color: var(--success) !important;
}

.td-d {
    color: var(--warning) !important;
}

/* ============ FOOTER ============ */
.footer {
    text-align: center;
    padding: 24px;
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}