:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #1f2a37;
  --ink-2: #51607a;
  --muted: #8a97ab;
  --line: #e3e8ef;
  --line-2: #d3dae4;

  --brand: #2b6cb0;
  --brand-2: #1e4e79;
  --brand-grad-1: #3b73a8;
  --brand-grad-2: #2c5a86;

  --green: #2faa57;
  --yellow: #f2c200;
  --orange: #f08000;
  --red: #e23b3b;

  --row-none: #f4f6f9;
  --radius: 12px;
  --shadow: 0 6px 22px rgba(31, 42, 55, .10);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  display: flex; flex-direction: column; min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.bolt { font-size: 24px; filter: drop-shadow(0 1px 2px rgba(43,108,176,.4)); }
.brand-text h1 { margin: 0; font-size: 17px; letter-spacing: .2px; color: var(--brand-2); }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.status { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.badge {
  font-size: 11px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.badge-live { background: #e6f6ec; color: #1c7a3f; border-color: #b6e4c6; }
.badge-partial { background: #fff5d6; color: #8a6d00; border-color: #f3e0a0; }
.badge-stale { background: #ffedd8; color: #9a5800; border-color: #f6cf9f; }
.badge-unavailable { background: #fde3e3; color: #b32626; border-color: #f4b6b6; }
.badge-demo { background: #e2eefb; color: #1f5b9c; border-color: #b9d6f2; }
.badge-unknown { background: #eef1f5; color: var(--muted); border-color: var(--line); }
.updated { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.clock { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; gap: 10px; }
.auto { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.auto input { accent-color: var(--brand); }
.btn {
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  border-radius: 9px; padding: 8px 13px; font-size: 13px; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-2); }
.btn:active { transform: translateY(1px); }
.btn.spin { opacity: .6; pointer-events: none; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--line-2); }
.btn.ghost:hover { background: #f0f5fb; border-color: var(--brand); }

/* alertă cod roșu pe badge-ul de roșu */
.sh-badge.l3.alarm { animation: redpulse 1s ease-in-out infinite; }
@keyframes redpulse {
  0%, 100% { background: rgba(255,255,255,.16); box-shadow: 0 0 0 0 rgba(226,59,59,.0); }
  50% { background: rgba(226,59,59,.55); box-shadow: 0 0 0 4px rgba(226,59,59,.35); }
}

/* ---------- Banner ---------- */
.banner { margin: 10px 20px 0; padding: 11px 15px; border-radius: 10px; font-size: 13px; line-height: 1.5; border: 1px solid; }
.banner.warn { background: #fff8e1; border-color: #f3e0a0; color: #7a5d00; }
.banner.err  { background: #fdecec; border-color: #f4b6b6; color: #9c2020; }
.banner.info { background: #e9f2fc; border-color: #c2dbf5; color: #1c4f80; }
.banner code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 5px; }

/* ---------- Layout ---------- */
.layout {
  flex: 1; display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px; padding: 16px 20px 18px; align-items: stretch;
  min-height: 0;
}

/* ---------- Map ---------- */
.map-panel {
  position: relative; background: #e9edf2;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  min-height: 480px;
}
.map { position: absolute; inset: 0; width: 100%; height: 100%; background: #e9edf2; z-index: 1; }
.leaflet-container { font: inherit; background: #e9edf2; }

/* controale radar (suprapuse pe hartă) */
.map-ctrl {
  position: absolute; top: 12px; right: 12px; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.94); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px; box-shadow: var(--shadow);
}
.rc-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.rc-toggle input { accent-color: var(--brand); }
.map-ctrl input[type=range] { width: 70px; accent-color: var(--brand); cursor: pointer; }
.rc-btn { background: var(--brand); color: #fff; border: none; border-radius: 7px; width: 26px; height: 26px; cursor: pointer; font-size: 12px; }
.rc-btn:disabled { background: #b9c3d3; cursor: default; }
.rc-time { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 36px; }

.county { fill: #dfe5ee; stroke: #b9c3d3; stroke-width: .8; cursor: pointer;
  transition: fill .2s, stroke .12s, opacity .2s; }
.county:hover { stroke: var(--brand); stroke-width: 1.6; }
.county.selected { stroke: var(--brand-2); stroke-width: 2.2; }
.county.dim { opacity: .3; }
.county.flash { stroke: #11324f; stroke-width: 1.8; }

.county-label {
  font-size: 12.5px; fill: #2b3850; pointer-events: none; text-anchor: middle; font-weight: 600;
  paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 2.6px;
}

.map-legend {
  position: absolute; left: 14px; bottom: 12px; z-index: 1000;
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 11px; display: flex; gap: 13px; flex-wrap: wrap;
  box-shadow: var(--shadow); font-size: 12px;
}
.map-legend .li { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.map-legend .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.12); }

.tooltip {
  position: fixed; z-index: 1200; pointer-events: none; background: #fff;
  border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 10px;
  font-size: 12px; box-shadow: var(--shadow); max-width: 240px;
}
.tooltip h4 { margin: 0 0 2px; font-size: 13px; color: var(--ink); }
.tooltip .lvl { font-weight: 700; }
.tooltip .tt-types { margin-top: 3px; font-size: 14px; }

/* ---------- Side panel ---------- */
.side {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}

.side-header {
  background: linear-gradient(120deg, var(--brand-grad-1), var(--brand-grad-2));
  color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.sh-title h2 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.sh-scope { font-size: 12px; opacity: .85; }
.sh-counts { display: flex; gap: 7px; }
.sh-badge {
  display: inline-flex; align-items: baseline; gap: 5px; min-width: 34px; justify-content: center;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px; padding: 5px 9px; font-size: 12px;
}
.sh-badge b { font-size: 15px; }
.sh-badge.l1 b { color: var(--yellow); } .sh-badge.l2 b { color: #ffd9ad; } .sh-badge.l3 b { color: #ffc9c9; }

.tabs { display: flex; border-bottom: 1px solid var(--line); background: #f7f9fc; }
.tab {
  flex: 1; background: none; border: none; padding: 11px 8px; font-size: 13px; cursor: pointer;
  color: var(--ink-2); border-bottom: 3px solid transparent; font-weight: 600;
}
.tab:hover { color: var(--brand-2); }
.tab.active { color: var(--brand-2); border-bottom-color: var(--brand); background: #fff; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 14px 6px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.field select {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 9px; font-size: 13px;
  color: var(--ink); background: #fff; cursor: pointer;
}
.field select:focus { outline: none; border-color: var(--brand); }

.search-row { position: relative; padding: 6px 14px 10px; }
.search-ico { position: absolute; left: 24px; top: 50%; transform: translateY(-30%); font-size: 13px; opacity: .5; }
#search {
  width: 100%; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 9px 12px 9px 32px; font-size: 13px; color: var(--ink);
}
#search:focus { outline: none; border-color: var(--brand); }

/* ---------- County list ---------- */
.county-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.county-list::-webkit-scrollbar { width: 9px; }
.county-list::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 8px; }

.crow { border-bottom: 1px solid var(--line); }
.crow-head {
  display: flex; align-items: center; gap: 10px; padding: 11px 8px; cursor: pointer;
  border-left: 4px solid transparent; transition: background .12s;
}
.crow-head:hover { background: #f5f8fc; }
.crow.l1 .crow-head { border-left-color: var(--yellow); }
.crow.l2 .crow-head { border-left-color: var(--orange); }
.crow.l3 .crow-head { border-left-color: var(--red); }
.crow.none .crow-head { cursor: default; }
.crow.none .cname { color: var(--muted); }
.crow.selected .crow-head { background: #eaf2fb; }

.cname { font-size: 14px; font-weight: 600; }
.cregion { font-size: 11px; color: var(--muted); margin-left: 2px; }
.cright { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ccount { font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; }
.cnone { font-size: 12px; color: var(--muted); }
.cchips { display: flex; gap: 4px; }
.chip-ico {
  width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; line-height: 1;
}
.chip-ico.l1 { background: var(--yellow); } .chip-ico.l2 { background: var(--orange); } .chip-ico.l3 { background: var(--red); }
.caret { color: var(--muted); font-size: 16px; transition: transform .15s; }
.crow.open .caret { transform: rotate(90deg); }

.cdetail { padding: 4px 12px 14px; background: #fafbfd; border-left: 4px solid var(--line-2); }
.wmini { border: 1px solid var(--line); border-left-width: 4px; border-radius: 9px; padding: 9px 11px; margin-top: 9px; background: #fff; }
.wmini.l1 { border-left-color: var(--yellow); } .wmini.l2 { border-left-color: var(--orange); } .wmini.l3 { border-left-color: var(--red); }
.wmini-top { display: flex; align-items: center; gap: 8px; }
.wtag { font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: #3a2c00; }
.wtag.l1 { background: var(--yellow); } .wtag.l2 { background: var(--orange); color: #fff; } .wtag.l3 { background: var(--red); color: #fff; }
.wkind { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-left: auto; }
.wmini h4 { margin: 7px 0 3px; font-size: 13px; line-height: 1.35; }
.wmini .wmeta { font-size: 11.5px; color: var(--ink-2); }
.wmini p { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.45; }

.cd-obs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.cd-metric { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; text-align: center; }
.cd-metric .k { font-size: 10px; color: var(--muted); }
.cd-metric .v { font-size: 15px; font-weight: 700; margin-top: 2px; }
.cd-metric .v small { font-size: 10px; font-weight: 500; color: var(--muted); }
.cd-station { font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.cd-empty { font-size: 12px; color: var(--muted); margin-top: 8px; }

.fc { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-2); }
.fc-head { font-size: 12px; font-weight: 700; color: var(--brand-2); display: flex; align-items: center; gap: 6px; }
.fc-head .fc-ico { font-size: 16px; }
.fc-obs { grid-template-columns: repeat(3, 1fr); }

.empty-state { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* legendă fenomene */
.side-foot { border-top: 1px solid var(--line); background: #f7f9fc; }
.legend-toggle {
  width: 100%; background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.legend-toggle:hover { color: var(--brand-2); }
.legend-toggle .lt-caret { transition: transform .15s; }
.legend-toggle.open .lt-caret { transform: rotate(180deg); }
.hazard-legend {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  padding: 4px 16px 14px;
}
.hazard-legend .hz { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.hazard-legend .hz-ico { font-size: 15px; width: 18px; text-align: center; }

.notif { border-top: 1px solid var(--line); padding: 9px 16px 12px; }
.notif-status { display: block; font-size: 11.5px; color: var(--ink-2); margin-bottom: 7px; }
.notif-status b { color: var(--ink); }
.notif-test { display: flex; gap: 7px; }
.notif-test input {
  flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 9px; font-size: 12.5px; color: var(--ink);
}
.notif-test input:focus { outline: none; border-color: var(--brand); }
.notif-test .btn { white-space: nowrap; }

/* ---------- Footer ---------- */
.foot {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between;
  padding: 9px 20px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); background: var(--surface);
}

.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .side { max-height: none; }
  .map-panel { min-height: 60vh; }
  .county-list { max-height: 460px; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 9px; }
  .brand-text p { display: none; }
  .controls { margin-left: auto; }
  .layout { padding: 12px; }
}
