:root {
    --bg-primary: #0b1320;
    --bg-surface: #141f32;
    --bg-surface-elevated: #1e2c45;
    --bg-surface-glass: rgba(20, 31, 50, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(56, 189, 248, 0.3);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #38bdf8;
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-glow: rgba(56, 189, 248, 0.25);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-subtle: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 24px 16px;
    line-height: 1.5;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
    flex-wrap: wrap;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4));
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.subtitle strong {
    color: var(--accent-blue);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.45);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.btn-loading .btn-icon {
    animation: spin 1s linear infinite;
}

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

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    font-size: 0.9rem;
    color: var(--text-primary);
    animation: slideIn 0.3s ease forwards;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-info { border-left: 4px solid var(--accent-blue); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 18px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-subtle);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.kpi-card.highlight {
    border-color: var(--border-highlight);
    background: linear-gradient(145deg, var(--bg-surface), var(--bg-surface-elevated));
}

.kpi-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.kpi-value.small {
    font-size: 1.25rem;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Controls */
.controls-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.control-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.segmented-control {
    display: inline-flex;
    background: var(--bg-primary);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.seg-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.seg-btn.active {
    background: var(--accent-blue);
    color: #0b1320;
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.4);
}

.form-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--accent-blue);
}

/* Chart */
.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
}

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

.chart-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-stats {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.chart-wrapper {
    position: relative;
    height: 420px;
    width: 100%;
}

/* Details Section & Table */
.details-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 20px;
}

details summary {
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    user-select: none;
}

details summary:hover {
    color: var(--accent-blue);
}

.table-container {
    margin-top: 16px;
    max-height: 350px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-surface-elevated);
    padding: 10px 14px;
    color: var(--text-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-interpolated { background: rgba(56, 189, 248, 0.15); color: var(--accent-blue); }
.badge-roth { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-wendelstein { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-schwabach { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* Footer */
.app-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 16px 0;
}

.app-footer strong {
    color: var(--text-secondary);
}

.app-footer code {
    background: var(--bg-surface-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-actions {
        width: 100%;
    }
    .btn {
        width: 100%;
        justify-content: center;
    }
    .chart-wrapper {
        height: 300px;
    }
}
