:root {
  --bg: #0e1621;
  --panel: #16222f;
  --panel2: #1d2c3c;
  --text: #e8eef4;
  --muted: #93a5b5;
  --line: #2a3b4d;
  --accent: #38bdf8;
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---- top bar ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 1200;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.tagline { font-size: 11px; color: var(--muted); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.dirs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dirs button {
  background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--line);
  padding: 6px 9px; cursor: pointer; font-weight: 600; font-size: 12px;
}
.dirs button:last-child { border-right: 0; }
.dirs button:hover { color: var(--text); background: var(--panel2); }
.dirs button.active { background: var(--accent); color: #06212e; }
.searchwrap { position: relative; display: inline-block; }
#search {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 26px 6px 10px; font-size: 13px;
}
#search::-webkit-search-cancel-button { display: none; }
#searchClear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); font-size: 17px;
  line-height: 1; cursor: pointer; padding: 2px 5px;
}
#searchClear:hover { color: var(--text); }
.regdrop { position: relative; }
#regionBtn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
#regionBtn.active { border-color: var(--accent); color: var(--accent); }
#regionMenu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1300;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; min-width: 200px; max-height: 60vh; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#regionMenu label {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  font-size: 13px; color: var(--text); cursor: pointer; border-radius: 6px;
}
#regionMenu label:hover { background: var(--panel2); }
#regionMenu .rm-clear {
  display: block; width: 100%; margin-top: 6px; padding: 6px;
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; cursor: pointer;
}
#regionMenu .rm-clear:hover { color: var(--text); }
#search { width: 170px; }
.chk { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.best {
  background: var(--accent); color: #06212e; border: 0; border-radius: 8px;
  padding: 6px 12px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.best:hover { filter: brightness(1.1); }
.live-now { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.live-big { font-size: 22px; font-weight: 800; }
.live-corr { color: var(--good); }
.live-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
table.best-list { border-collapse: collapse; width: 100%; font-size: 13px; }
table.best-list th, table.best-list td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.best-list th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
table.best-list tr.row { cursor: pointer; }
table.best-list tr.row:hover td { background: var(--panel2); }

/* ---- map ---- */
#map { flex: 1; background: #0a121b; }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }

/* ---- status pill ---- */
#status {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 14px; font-size: 12px; color: var(--muted); z-index: 1100;
  pointer-events: none; white-space: nowrap;
}

/* ---- legend ---- */
#legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 1100;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; max-width: 220px;
}
.lg-title { font-weight: 700; margin-bottom: 6px; }
.lg-item { display: flex; align-items: center; gap: 7px; color: var(--muted); margin: 2px 0; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.credits { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.credits a { color: var(--accent); text-decoration: none; }

/* ---- spot panel ---- */
#panel {
  position: absolute; top: 58px; right: 0; bottom: 0; width: 380px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--line); z-index: 1150;
  overflow-y: auto; padding: 16px 18px 24px;
}
#panelClose {
  position: absolute; top: 8px; right: 10px; background: none; border: 0;
  color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1;
}
#panelClose:hover { color: var(--text); }
.sp-name { font-size: 20px; font-weight: 800; margin: 2px 24px 4px 0; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
}
.badge.hinne { color: var(--text); }
.sp-section { margin: 14px 0; }
.sp-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.rose-wrap { display: flex; align-items: center; gap: 14px; }
.rose-note { color: var(--muted); font-size: 12px; flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
table.korr { border-collapse: collapse; width: 100%; font-size: 13px; }
table.korr th, table.korr td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
table.korr th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.diff-pos { color: var(--good); font-weight: 700; }
.diff-neg { color: var(--warn); font-weight: 700; }
.diff-zero { color: var(--muted); font-weight: 700; }
.formula { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: italic; }
.sp-desc { font-size: 13px; color: var(--text); }
.sp-desc p { margin: 0 0 8px; }
.sp-desc a { color: var(--accent); word-break: break-all; }
.sp-links a {
  display: inline-block; margin: 4px 8px 0 0; color: var(--accent);
  text-decoration: none; font-size: 13px; font-weight: 600;
}
.note { font-size: 12px; color: var(--muted); }
.approx { color: var(--warn); }

/* ---- mõõtja tuulenool ---- */
.st-wind-icon { background: none; border: none; }
.st-wind { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.st-wind svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }
.st-wind span {
  font-size: 10px; font-weight: 700; color: #38bdf8;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8); margin-top: -3px;
}

/* ---- mobile ---- */
@media (max-width: 700px) {
  #search { width: 120px; }
  #panel { top: auto; left: 0; right: 0; width: auto; max-height: 60vh; border-left: 0; border-top: 1px solid var(--line); }
  #legend { display: none; }
  #status { top: auto; bottom: 10px; }
}
