:root {
  --ink: #edf5ff;
  --muted: #93a5b9;
  --panel: rgba(9, 20, 34, .9);
  --line: rgba(163, 190, 219, .16);
  --accent: #62e8bb;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  color: var(--ink);
  background: #07111d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.topbar {
  height: 82px;
  position: relative;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 29, .94);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px; border: 1px solid rgba(98,232,187,.38); border-radius: 13px;
  display: grid; place-items: center; background: rgba(98,232,187,.08); transform: rotate(45deg);
}
.brand-mark span { width: 14px; height: 14px; border: 2px solid var(--accent); border-radius: 50%; box-shadow: 0 0 16px var(--accent); }
.eyebrow { margin: 0 0 2px; color: var(--accent); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; }
h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }

.header-actions { display: flex; gap: 10px; }
.search {
  width: min(310px, 31vw); height: 42px; display: flex; align-items: center; gap: 9px;
  padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035);
}
.search span { color: var(--muted); font-size: 22px; }
.search input { width: 100%; color: var(--ink); border: 0; outline: 0; background: transparent; }
.search input::placeholder { color: #718398; }
.reset-btn {
  color: #0b1b20; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 750;
  background: var(--accent); cursor: pointer; box-shadow: 0 8px 24px rgba(98,232,187,.18);
}
.reset-btn:hover { filter: brightness(1.08); }

main { height: calc(100% - 82px); }
.map-shell { height: calc(100% - 42px); position: relative; }
#map { width: 100%; height: 100%; background: #091827; }
.leaflet-control-zoom a { color: var(--ink) !important; background: #0c1d30 !important; border-color: var(--line) !important; }
.leaflet-control-attribution { color: #718398; background: rgba(7,17,29,.72) !important; }
.leaflet-control-attribution a { color: #a9bdd2; }
.leaflet-tile { filter: saturate(.42) brightness(.58) contrast(1.1) hue-rotate(165deg); }

.guide-card, .legend {
  position: absolute; z-index: 700; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); box-shadow: 0 18px 50px rgba(0,0,0,.28); backdrop-filter: blur(14px);
}
.guide-card { top: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 11px; align-items: center; padding: 12px 17px; pointer-events: none; }
.guide-card strong { font-size: 13px; }
.guide-card p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.guide-icon { color: var(--accent); font-size: 21px; }

.legend { left: 20px; bottom: 20px; padding: 14px 16px; min-width: 128px; }
.legend p { margin: 0 0 10px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.legend div { display: flex; align-items: center; gap: 9px; margin-top: 8px; font-size: 12px; }
.legend i { width: 22px; height: 3px; border-radius: 3px; background: var(--c); box-shadow: 0 0 8px var(--c); }

.station-icon { background: transparent; border: 0; }
.station-pin { position: relative; width: 24px; height: 24px; display: grid; place-items: center; }
.station-pin::before { content: ""; position: absolute; inset: 2px; border: 1px solid rgba(255,255,255,.7); border-radius: 50%; background: #0b2033; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.station-pin::after { content: ""; position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--pin); box-shadow: 0 0 10px var(--pin); }
.station-pin.selected::before { animation: stationPulse 1.25s ease-out infinite; border-color: var(--accent); }
.station-pin.connected::before { border-color: var(--pin); box-shadow: 0 0 16px var(--pin); }
@keyframes stationPulse { 0% { box-shadow: 0 0 0 0 rgba(98,232,187,.55); } 100% { box-shadow: 0 0 0 14px rgba(98,232,187,0); } }

.station-label {
  color: #e6f0fb; border: 1px solid rgba(180,205,232,.16); border-radius: 7px; background: rgba(7,17,29,.82);
  box-shadow: 0 4px 14px rgba(0,0,0,.18); font-size: 10px; font-weight: 650; padding: 4px 6px;
}
.station-label::before { display: none; }
.flow-line { stroke-linecap: round; animation: flow 1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -26; } }
.draw-head, .energy-pulse {
  filter: drop-shadow(0 0 4px currentColor) drop-shadow(0 0 10px currentColor);
}
.energy-pulse { animation: energyGlow .75s ease-in-out infinite alternate; }
@keyframes energyGlow { from { stroke-width: 1.5; } to { stroke-width: 4; } }

footer {
  height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 22px;
  color: var(--muted); border-top: 1px solid var(--line); background: #07111d; font-size: 10px; letter-spacing: .02em;
}
footer b { color: var(--ink); }
.status { color: #b8c8d7; }
.status i { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

@media (max-width: 720px) {
  .topbar { height: 118px; padding: 13px 14px; align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .search { width: 100%; }
  .reset-btn { white-space: nowrap; }
  main { height: calc(100% - 118px); }
  .map-shell { height: calc(100% - 34px); }
  .guide-card { display: none; }
  .legend { left: 10px; bottom: 10px; }
  footer { height: 34px; padding: 0 10px; }
  footer span:last-child { display: none; }
}
