:root {
  --bg: #07090e;
  --bg-2: #0b0e15;
  --panel: rgba(17, 22, 33, 0.72);
  --panel-solid: #11151f;
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #eef2f8;
  --text-2: #9aa6bd;
  --text-3: #5e6b85;
  --accent: #ff5a36;
  --accent-2: #ffb020;
  --cold: #38bdf8;
  --glow: 0 0 24px rgba(255, 90, 54, 0.35);
  --radius: 16px;
  --mono: "Space Grotesk", system-ui, sans-serif;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 78% -8%, rgba(255, 90, 54, 0.14), transparent 60%),
    radial-gradient(900px 600px at 8% 108%, rgba(56, 189, 248, 0.10), transparent 55%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Boot screen ---------- */
#boot {
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; background: var(--bg);
  transition: opacity .6s ease;
}
#boot.fade { opacity: 0; pointer-events: none; }
.boot-mark {
  font-family: var(--mono); font-weight: 700; font-size: 34px; letter-spacing: 6px;
  color: var(--text);
}
.boot-mark span { color: var(--accent); }
.boot-bar {
  width: 220px; height: 3px; border-radius: 3px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}
.boot-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  animation: load 1.8s cubic-bezier(.6, .1, .2, 1) forwards;
}
@keyframes load { to { width: 100%; } }
.boot-msg { font-family: var(--mono); font-size: 12px; letter-spacing: 2px; color: var(--text-3); text-transform: uppercase; }

/* ---------- App shell ---------- */
.app { height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 17, 25, 0.85), rgba(13, 17, 25, 0.35));
  backdrop-filter: blur(14px);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px rgba(255, 90, 54, 0.18), var(--glow);
  animation: beat 2.4s ease-in-out infinite;
}
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.brand-text { font-family: var(--mono); font-weight: 700; font-size: 19px; letter-spacing: 3px; }
.brand-text span { color: var(--accent); }
.brand-sub { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-3); padding-left: 6px; border-left: 1px solid var(--border); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { text-align: right; line-height: 1.05; }
.clock-time { font-family: var(--mono); font-weight: 600; font-size: 18px; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.clock-zone { font-size: 10px; letter-spacing: 2px; color: var(--text-3); }

.seg { display: flex; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--text-2); background: transparent; border: none; cursor: pointer;
  padding: 7px 13px; transition: .2s;
}
.seg button.active { background: var(--accent); color: #1a0c06; }

.refresh {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 1px;
  color: var(--text); background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-2); border-radius: 10px;
  padding: 7px 13px; cursor: pointer; transition: .2s;
}
.refresh:hover { border-color: var(--accent); color: var(--accent); }
.refresh.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 1fr 372px; min-height: 0; }

.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--bg-2); }
.leaflet-container { background: var(--bg-2); font-family: var(--sans); }
.leaflet-control-zoom { border: none !important; margin: 16px !important; }
.leaflet-control-zoom a {
  background: var(--panel) !important; color: var(--text) !important;
  border: 1px solid var(--border) !important; backdrop-filter: blur(10px);
  width: 32px !important; height: 32px !important; line-height: 30px !important;
}
.leaflet-control-zoom a:hover { background: var(--panel-solid) !important; color: var(--accent) !important; }
.leaflet-control-attribution { background: rgba(7, 9, 14, 0.7) !important; color: var(--text-3) !important; }
.leaflet-control-attribution a { color: var(--text-2) !important; }

/* ---------- Map markers ---------- */
.mk { position: relative; border-radius: 50%; cursor: pointer; transition: transform .18s ease; }
.mk:hover { transform: scale(1.35); z-index: 600; }
.mk-wave::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid currentColor; animation: wave 1.8s ease-out infinite;
}
@keyframes wave {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* ---------- Map overlays ---------- */
.map-overlay {
  position: absolute; z-index: 500;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; backdrop-filter: blur(16px);
}
.status {
  top: 16px; left: 16px; display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; font-family: var(--mono); font-size: 12px; letter-spacing: 1px;
}
.status-led { width: 8px; height: 8px; border-radius: 50%; background: #28d07a; box-shadow: 0 0 10px #28d07a; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

.legend { bottom: 16px; left: 16px; padding: 13px 15px; width: 210px; }
.legend-title { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-2); margin-bottom: 9px; }
.legend-ramp {
  height: 9px; border-radius: 5px;
  background: linear-gradient(90deg, #2b6cff, #38bdf8, #22c55e, #eab308, #f97316, #ef4444, #b91c5c);
}
.legend-scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--text-3); margin-top: 5px; }
.legend-flag { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 11px; color: var(--text-2); }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(255, 90, 54, .6); animation: pd 1.6s infinite; }
@keyframes pd { 0% { box-shadow: 0 0 0 0 rgba(255, 90, 54, .55); } 100% { box-shadow: 0 0 0 9px rgba(255, 90, 54, 0); } }

.readout {
  top: 16px; right: 16px; width: 218px; padding: 15px 16px; overflow: hidden;
}
.readout-city { font-family: var(--mono); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.readout-country { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.readout-temp { font-family: var(--mono); font-weight: 700; font-size: 44px; line-height: 1; margin: 10px 0 2px; font-variant-numeric: tabular-nums; }
.readout-feels { font-size: 12px; color: var(--text-2); }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.readout-cell { background: rgba(255, 255, 255, 0.04); border-radius: 9px; padding: 8px 10px; }
.readout-cell b { font-family: var(--mono); font-weight: 600; font-size: 16px; display: block; }
.readout-cell span { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }
.readout-wave { margin-top: 11px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-align: center; padding: 6px; border-radius: 8px; background: rgba(255, 90, 54, .14); color: #ff8a6a; text-transform: uppercase; }

/* ---------- Sidebar ---------- */
.sidebar {
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(11, 14, 21, 0.6), rgba(8, 10, 16, 0.9));
  backdrop-filter: blur(10px);
  padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 13px;
  padding: 13px 14px; position: relative; overflow: hidden;
}
.stat.alert { border-color: rgba(255, 90, 54, 0.32); }
.stat.alert::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); }
.stat-label { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3); }
.stat-value { font-family: var(--mono); font-weight: 700; font-size: 28px; line-height: 1.1; margin: 5px 0 3px; font-variant-numeric: tabular-nums; }
.stat.alert .stat-value { color: var(--accent); }
.stat-meta { font-size: 11px; color: var(--text-2); }

.control-row label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3); display: block; margin-bottom: 9px; }
.thr { display: flex; align-items: center; gap: 12px; }
.thr output { font-family: var(--mono); font-weight: 600; font-size: 14px; min-width: 48px; text-align: right; color: var(--accent); }
input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(255, 255, 255, 0.12));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; cursor: pointer; box-shadow: 0 0 0 4px rgba(255, 90, 54, 0.25);
}
input[type=range]::-moz-range-thumb { width: 17px; height: 17px; border: none; border-radius: 50%; background: #fff; cursor: pointer; box-shadow: 0 0 0 4px rgba(255, 90, 54, 0.25); }

.search { display: flex; align-items: center; gap: 9px; background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 0 12px; color: var(--text-3); }
.search input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: var(--sans); font-size: 13px; padding: 11px 0; }
.search input::placeholder { color: var(--text-3); }

.board-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3); }
.board-live { color: #28d07a; }
.board { display: flex; flex-direction: column; gap: 7px; }
.row {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  padding: 10px 12px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .2s, transform .2s;
}
.row:hover { border-color: var(--border-2); transform: translateX(-3px); }
.row.wave { border-color: rgba(255, 90, 54, 0.3); }
.row-bar { position: absolute; inset: 0; opacity: 0.1; }
.row-rank { font-family: var(--mono); font-size: 12px; color: var(--text-3); width: 18px; z-index: 1; }
.row-main { flex: 1; z-index: 1; min-width: 0; }
.row-city { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.row-city small { font-weight: 400; color: var(--text-3); font-size: 11px; }
.row-cond { font-size: 11px; color: var(--text-2); }
.row-temp { font-family: var(--mono); font-weight: 700; font-size: 18px; z-index: 1; font-variant-numeric: tabular-nums; }
.row-flag { position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); z-index: 1; }

.foot { font-size: 11px; color: var(--text-3); text-align: center; padding-top: 4px; }
.foot a { color: var(--text-2); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { border-left: none; border-top: 1px solid var(--border); max-height: 46vh; }
  .brand-sub { display: none; }
}
