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

:root {
  --bg:      #0c0c10;
  --bg2:     #12121a;
  --bg3:     #1a1a24;
  --bg4:     #22222e;
  --border:  #27273a;
  --text:    #f0f0f8;
  --text2:   #8080a0;
  --text3:   #4a4a65;
  --accent:  #e87c35;
  --accent2: #c45e1a;
  --blue:    #4488ff;
  --green:   #22d470;
  --orange:  #f97316;
  --red:     #ef4444;
  --yellow:  #eab308;
  --font:    'Inter', 'Segoe UI', system-ui, sans-serif;
  --r:       6px;
  --shadow:  0 4px 24px rgba(0,0,0,0.5);
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 13px; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 0 18px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  height: 50px; flex-shrink: 0;
}

.header-brand { display: flex; flex-direction: column; gap: 1px; }

.logo-sirocco {
  font-size: 16px; font-weight: 800; letter-spacing: 2.5px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.logo-s { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: 2.5px; }

.header-sub { font-size: 10px; color: var(--text3); letter-spacing: 0.2px; }

.badge {
  background: var(--bg4); color: var(--text3);
  font-size: 9px; font-weight: 600; letter-spacing: 0.5px;
  padding: 2px 5px; border-radius: 4px; border: 1px solid var(--border);
  vertical-align: middle; margin-left: 4px;
}

/* Live Pill */
.live-pill {
  display: flex; align-items: center; gap: 5px;
  background: rgba(34,212,112,0.1);
  border: 1px solid rgba(34,212,112,0.25);
  color: var(--green); font-size: 9px; font-weight: 700;
  padding: 4px 11px; border-radius: 20px; letter-spacing: 1.5px;
  flex-shrink: 0; transition: opacity 0.3s;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); animation: blink 2.5s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* ── Tabs ────────────────────────────────────────────────────────────── */
nav.tabs { display: flex; gap: 1px; margin-left: auto; }

.tab {
  background: transparent; border: none; color: var(--text2);
  font-size: 11px; font-weight: 500; font-family: var(--font);
  padding: 6px 14px; border-radius: var(--r);
  cursor: pointer; transition: all 0.15s; letter-spacing: 0.1px;
}
.tab:hover { background: var(--bg3); color: var(--text); }
.tab.active { background: var(--accent); color: #fff; font-weight: 700; }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; flex-shrink: 0;
}
.toolbar.hidden { display: none; }

.prod-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 11px; font-weight: 500;
  font-family: var(--font); padding: 4px 11px; border-radius: var(--r);
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.prod-btn:hover  { background: var(--bg4); color: var(--text); border-color: #333355; }
.prod-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

.toolbar-sep { flex: 1; }

.model-select {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 11px; font-weight: 500;
  font-family: var(--font); padding: 4px 8px; border-radius: var(--r);
  outline: none; cursor: pointer; transition: border-color 0.15s;
}
.model-select:focus { border-color: var(--accent); }

/* Opacity slider */
.opacity-wrap {
  display: flex; align-items: center; gap: 5px;
  color: var(--text3); padding: 0 4px;
}
.opacity-slider {
  -webkit-appearance: none; appearance: none;
  width: 68px; height: 3px; border-radius: 2px;
  background: var(--border); outline: none; cursor: pointer;
}
.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg2); box-shadow: 0 0 0 1px var(--accent);
}
.opacity-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg2);
}

.ctrl-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 11px; font-weight: 500;
  font-family: var(--font); padding: 4px 10px; border-radius: var(--r);
  cursor: pointer; transition: all 0.12s;
}
.ctrl-btn:hover  { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctrl-btn.danger:hover { background: var(--red); border-color: var(--red); color: #fff; }

.refresh-countdown { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* Loading Bar */
.loading-bar { height: 2px; background: transparent; flex-shrink: 0; overflow: hidden; }
.loading-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.25s ease; }

/* ── Main Layout ─────────────────────────────────────────────────────── */
.main-layout {
  display: flex; flex: 1; overflow: hidden;
  height: calc(100vh - 50px - 39px - 2px);
}
.main-layout.hidden { display: none !important; }

#map-container { flex: 1; position: relative; cursor: crosshair; }
#map { width: 100%; height: 100%; background: #0d0e16; }

/* ── Schwebende Karten-Elemente ──────────────────────────────────────── */

/* Legende */
.map-legend {
  position: absolute; bottom: 32px; left: 14px; z-index: 900;
  background: rgba(12,12,18,0.88); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 10px 10px 8px;
  backdrop-filter: blur(8px); min-width: 40px;
  box-shadow: var(--shadow);
}
.legend-title {
  font-size: 9px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 6px; text-align: center;
}
.legend-body { display: flex; gap: 5px; align-items: stretch; }
.legend-bar {
  width: 14px; height: 130px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.08);
}
.legend-ticks {
  position: relative;
  width: 28px;
  height: 130px;
  flex-shrink: 0;
}
.legend-tick {
  position: absolute; right: 0;
  font-size: 8.5px; color: var(--text3); white-space: nowrap;
  font-variant-numeric: tabular-nums; line-height: 1;
  transform: translateY(50%);
}

/* Valid-Time Badge */
.map-time-badge {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 900; background: rgba(12,12,18,0.88);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 20px;
  padding: 3px 12px; font-size: 10px; font-weight: 600;
  color: var(--text2); letter-spacing: 0.3px;
  backdrop-filter: blur(8px); pointer-events: none;
  display: none;
}

/* Hover Tooltip */
.map-tooltip {
  position: absolute; z-index: 1100;
  background: rgba(12,12,18,0.92); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 4px 10px;
  font-size: 13px; font-weight: 700; color: var(--text);
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(4px); box-shadow: var(--shadow);
  transform: translate(12px, -50%);
}
.map-tooltip.hidden { display: none; }
.tooltip-unit { font-size: 10px; font-weight: 400; color: var(--text2); margin-left: 3px; }

/* Map hint */
.map-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.65); color: var(--text3);
  font-size: 10px; padding: 3px 12px; border-radius: 20px;
  pointer-events: none; z-index: 900; white-space: nowrap;
}

/* ── Side Panel ──────────────────────────────────────────────────────── */
.side-panel {
  width: 262px; min-width: 262px; background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
}
.side-panel::-webkit-scrollbar { width: 3px; }
.side-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.panel-card { padding: 12px 14px; border-bottom: 1px solid var(--border); }

.card-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 9px;
}
.card-loc {
  margin-left: auto; font-size: 10px; color: var(--text3);
  font-weight: 400; text-transform: none; letter-spacing: 0;
}
.live-tag {
  margin-left: auto; font-size: 8px; font-weight: 800;
  color: var(--green); letter-spacing: 1.2px;
  border: 1px solid rgba(34,212,112,0.3); padding: 1px 5px; border-radius: 4px;
}

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-red    { background: var(--red); }
.pulse { animation: blink 2.5s ease-in-out infinite; }

/* ── Station Grid ────────────────────────────────────────────────────── */
.station-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.sval {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r); padding: 6px 8px; transition: border-color 0.2s;
}
.sval.highlight { border-color: #2a2a40; }
.sval-label { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }
.sval-value { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.2; }
.sval-value.rain { color: #5599ff; }

.station-updated { font-size: 9px; color: var(--text3); margin-top: 7px; text-align: right; }

/* ── Indizes ─────────────────────────────────────────────────────────── */
.idx-table { display: flex; flex-direction: column; gap: 2px; }
.idx-loading { color: var(--text2); font-size: 11px; padding: 4px 0; }

.idx-row {
  display: flex; align-items: center;
  padding: 5px 7px; border-radius: 5px;
  border-left: 3px solid transparent;
  background: var(--bg3); gap: 7px; transition: background 0.1s;
}
.idx-row:hover { background: var(--bg4); }
.idx-info { flex: 1; min-width: 0; }
.idx-name { font-size: 10px; color: var(--text2); font-weight: 500; white-space: nowrap; }
.idx-bar  { height: 2px; border-radius: 2px; margin-top: 4px; background: var(--bg); }
.idx-bar-fill { height: 100%; border-radius: 2px; transition: width 0.7s cubic-bezier(.4,0,.2,1); }
.idx-val  { font-size: 12px; font-weight: 700; min-width: 54px; text-align: right;
            font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }

.level-0 { border-left-color: #28283a; } .level-0 .idx-val { color: var(--text3); }
.level-1 { border-left-color: var(--green); }  .level-1 .idx-val { color: var(--green); }
.level-2 { border-left-color: var(--yellow); } .level-2 .idx-val { color: var(--yellow); }
.level-3 { border-left-color: var(--orange); } .level-3 .idx-val { color: var(--orange); }
.level-4 { border-left-color: var(--red); }    .level-4 .idx-val { color: var(--red); }

/* ── Sturmbewegung ───────────────────────────────────────────────────── */
.storm-info { display: flex; gap: 5px; }
.storm-val {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r); padding: 7px 9px;
}
.storm-label { display: block; font-size: 9px; color: var(--text3);
               text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.storm-val span:last-child { font-size: 15px; font-weight: 700; color: var(--orange); }

/* ── Log Panel ───────────────────────────────────────────────────────── */
.log-panel {
  display: flex; flex-direction: column;
  height: calc(100vh - 50px - 2px); overflow: hidden;
}
.log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.log-header h2 { font-size: 14px; font-weight: 700; color: var(--accent); }
.log-actions { display: flex; gap: 6px; }
.log-table-wrap { flex: 1; overflow: auto; }
.log-table-wrap::-webkit-scrollbar { width: 4px; height: 4px; }
.log-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.log-table th {
  position: sticky; top: 0; background: var(--bg2); color: var(--text3);
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.log-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.log-table tr:hover td { background: var(--bg2); }
.log-time  { color: var(--text3); font-size: 10px; }
.log-coord { color: var(--blue); font-size: 10px; }
.log-model { color: var(--orange); font-size: 10px; font-weight: 600; }
.log-source { font-size: 9px; color: var(--text3); border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; }
.val-high { color: var(--red); font-weight: 700; }
.val-mid  { color: var(--orange); font-weight: 700; }
.val-low  { color: var(--yellow); }
.val-none { color: var(--text3); }

/* ── Station / Info Panel ────────────────────────────────────────────── */
.station-panel, .info-panel {
  padding: 24px 30px; overflow-y: auto;
  height: calc(100vh - 50px - 2px);
}
.station-panel h2, .info-panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.station-detail { margin-top: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 13px;
}
.detail-label { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.detail-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1; }
.detail-unit  { font-size: 11px; color: var(--text3); font-weight: 400; }

.info-panel h3 { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase;
                 letter-spacing: 0.6px; margin: 18px 0 7px; }
.info-panel p, .info-panel li { color: var(--text2); line-height: 1.75; font-size: 12px; }
.info-panel ul { padding-left: 16px; }

.hidden { display: none !important; }

/* ── Leaflet Styling ─────────────────────────────────────────────────── */
.leaflet-container { background: #0d0e16 !important; font-family: var(--font); }
.leaflet-control-zoom a {
  background: var(--bg2) !important; color: var(--text) !important;
  border-color: var(--border) !important; font-family: var(--font) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg3) !important; color: var(--accent) !important; }
.leaflet-control-attribution {
  background: rgba(12,12,18,0.82) !important; color: var(--text3) !important;
  font-size: 9px !important; font-family: var(--font) !important;
}
.leaflet-control-attribution a { color: var(--blue) !important; }

/* Popup */
.leaflet-popup-content-wrapper {
  background: var(--bg2) !important; border: 1px solid var(--border) !important;
  border-radius: 8px !important; box-shadow: 0 8px 32px rgba(0,0,0,0.7) !important;
}
.leaflet-popup-tip { background: var(--bg2) !important; }
.leaflet-popup-content {
  color: var(--text) !important; font-family: var(--font) !important;
  font-size: 12px !important; margin: 11px 15px !important;
}
.popup-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--accent); }
.popup-row { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 4px; }
.popup-label { color: var(--text3); }
.popup-value { font-weight: 600; }

.analysis-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.analysis-row:last-child { border-bottom: none; }
.analysis-name { color: var(--text2); font-size: 11px; }
.analysis-val  { font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .side-panel { display: none; }
  .main-layout { height: calc(100vh - 50px - 39px - 2px); }
}
