/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #0a0a1a;
    --bg-card: #16213e;
    --bg-card-hover: #1a2744;
    --bg-radar: #141428;
    --border: #2a3a5c;
    --border-light: #1e2d4a;
    --text-primary: #e0e0e0;
    --text-secondary: #8892a4;
    --text-muted: #5a6478;
    --green: #00d4aa;
    --green-bg: rgba(0,212,170,0.1);
    --red: #ff4757;
    --red-bg: rgba(255,71,87,0.1);
    --gold: #ffd700;
    --blue: #4a9eff;
    --orange: #ff9f43;
    --purple: #a855f7;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { scroll-behavior: smooth; }

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

/* ── Loading Overlay ── */
.loading-overlay {
    position: fixed; inset: 0;
    background: var(--bg-primary);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sticky Header ── */
.header-bar {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.header-top {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 10px 20px; flex-wrap: wrap; gap: 8px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-subtitle { font-size: 0.72rem; color: var(--text-muted); }
.last-update { font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.badge-paper {
    background: var(--orange); color: #000;
    padding: 2px 8px; border-radius: 3px;
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-live {
    background: rgba(0,212,170,0.15); color: var(--green);
    padding: 2px 8px; border-radius: 3px;
    font-size: 0.6rem; font-weight: 600;
    display: flex; align-items: center; gap: 5px;
}
.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green);
    animation: pulse-live 2s ease-in-out infinite;
}
@keyframes pulse-live { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Quick Stats ── */
.quick-stats {
    display: grid; grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--border-light);
    padding: 0;
}
.stat-item {
    padding: 8px 16px;
    border-right: 1px solid var(--border-light);
    text-align: center;
}
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ── Container ── */
.container { max-width: 1400px; margin: 0 auto; padding: 16px 20px; }

/* ── Section ── */
.section { margin-bottom: 24px; }
.section-title {
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.count-badge {
    background: var(--bg-card); color: var(--text-muted);
    padding: 1px 7px; border-radius: 10px;
    font-size: 0.7rem; font-weight: 600;
}

/* ── Radar Section ── */
.radar-section { background: var(--bg-radar); border-radius: 8px; padding: 16px; }
.radar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }

.radar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px; padding: 12px;
    transition: background 0.15s;
}
.radar-card:hover { background: var(--bg-card-hover); }
.radar-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.radar-symbol { font-weight: 700; font-size: 0.95rem; }
.radar-tf { font-size: 0.7rem; color: var(--text-muted); background: var(--bg-primary); padding: 1px 6px; border-radius: 3px; }
.radar-body { display: flex; flex-direction: column; gap: 4px; }
.radar-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; }
.radar-label { color: var(--text-muted); }
.radar-val { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Radar Status Badges */
.radar-status {
    padding: 2px 10px; border-radius: 3px;
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.status-entry {
    background: rgba(0,212,170,0.2); color: var(--green);
    animation: pulse-entry 1.5s ease-in-out infinite;
}
@keyframes pulse-entry { 0%,100% { box-shadow: 0 0 0 0 rgba(0,212,170,0.4); } 50% { box-shadow: 0 0 12px 4px rgba(0,212,170,0.15); } }
.status-guss-aktiv { background: rgba(255,159,67,0.2); color: var(--orange); }
.status-vorwarnung { background: rgba(255,215,0,0.15); color: var(--gold); }
.status-wartet { background: rgba(90,100,120,0.15); color: var(--text-muted); }

.badge-long { background: var(--green-bg); color: var(--green); padding: 1px 6px; border-radius: 3px; font-size: 0.7rem; font-weight: 600; }
.badge-short { background: var(--red-bg); color: var(--red); padding: 1px 6px; border-radius: 3px; font-size: 0.7rem; font-weight: 600; }
.badge-neutral { background: rgba(90,100,120,0.15); color: var(--text-muted); padding: 1px 6px; border-radius: 3px; font-size: 0.7rem; font-weight: 600; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: 6px; border: 1px solid var(--border-light); }
.data-table {
    width: 100%; border-collapse: collapse;
    font-size: 0.8rem; white-space: nowrap;
}
.data-table thead { background: #111128; }
.data-table th {
    padding: 8px 12px; text-align: left;
    font-size: 0.68rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table td {
    padding: 7px 12px;
    border-top: 1px solid rgba(42,58,92,0.4);
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.015); }
.empty-cell { text-align: center; color: var(--text-muted); padding: 24px 12px !important; font-style: italic; }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--text-muted); }

/* Grade Badges */
.grade { padding: 1px 8px; border-radius: 3px; font-size: 0.7rem; font-weight: 700; }
.grade-a-plus { background: rgba(255,215,0,0.15); color: var(--gold); }
.grade-a { background: var(--green-bg); color: var(--green); }
.grade-b { background: rgba(74,158,255,0.15); color: var(--blue); }
.grade-c { background: rgba(255,159,67,0.15); color: var(--orange); }
.grade-d { background: var(--red-bg); color: var(--red); }

/* Trade Status Badges */
.trade-status { padding: 1px 7px; border-radius: 3px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; }
.ts-open { background: rgba(74,158,255,0.15); color: var(--blue); }
.ts-tp1 { background: var(--green-bg); color: var(--green); }
.ts-tp2 { background: rgba(255,215,0,0.15); color: var(--gold); }
.ts-tp3 { background: rgba(168,85,247,0.15); color: var(--purple); }
.ts-sl { background: var(--red-bg); color: var(--red); }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-btn {
    background: var(--bg-card); border: 1px solid var(--border-light);
    color: var(--text-secondary); padding: 4px 14px;
    border-radius: 4px; font-size: 0.75rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
}
.filter-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.filter-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.page-btn {
    background: var(--bg-card); border: 1px solid var(--border-light);
    color: var(--text-secondary); padding: 4px 10px;
    border-radius: 3px; font-size: 0.75rem; cursor: pointer;
}
.page-btn:hover { background: var(--bg-card-hover); }
.page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Cards ── */
.cards-row {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 10px; margin-bottom: 16px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px; padding: 12px; text-align: center;
    transition: background 0.15s;
}
.card:hover { background: var(--bg-card-hover); }
.card-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { font-size: 1.1rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ── Charts ── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px; padding: 16px;
}
.chart-title { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Empty State ── */
.empty-state { text-align: center; color: var(--text-muted); padding: 24px; font-size: 0.85rem; }

/* ── Footer ── */
.footer {
    text-align: center; padding: 16px;
    color: var(--text-muted); font-size: 0.7rem;
    border-top: 1px solid var(--border-light);
    margin-top: 24px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .quick-stats { grid-template-columns: repeat(3, 1fr); }
    .cards-row { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .quick-stats { grid-template-columns: repeat(2, 1fr); }
    .header-top { padding: 8px 12px; }
    .header-left h1 { font-size: 0.9rem; }
    .container { padding: 10px 12px; }
    .radar-grid { grid-template-columns: 1fr; }
    .cards-row { grid-template-columns: repeat(2, 1fr); }
}
