:root {
  --bg: #0a0f1e;
  --bg-2: #0d1428;
  --panel: rgba(18, 27, 51, 0.72);
  --panel-solid: #111b33;
  --line: rgba(94, 234, 255, 0.14);
  --ink: #e6f0ff;
  --muted: #8aa0c6;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --violet: #7c3aed;
  --violet-2: #a78bfa;
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --glow: 0 0 18px rgba(34, 211, 238, 0.35);
  --radius: 14px;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(34, 211, 238, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--cyan);
}

/* ---- Header ---------------------------------------------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(10, 15, 30, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #0b1220;
  box-shadow: var(--glow);
}

.brand-title {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 17px;
  line-height: 1;
  white-space: nowrap;
}

.brand-title .accent {
  color: var(--cyan);
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

header .spacer {
  flex: 1;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0891b2);
  border-color: transparent;
  color: #06202a;
  box-shadow: var(--glow);
}

.btn-premium {
  background: linear-gradient(135deg, var(--violet), #6d28d9);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 18px rgba(124, 58, 237, 0.4);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ---- Toolbar --------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 4px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.segmented button.active {
  background: rgba(34, 211, 238, 0.16);
  color: var(--cyan);
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
}

.stat-pill b {
  color: var(--ink);
  font-size: 14px;
}

.updated {
  font-size: 12px;
  color: var(--muted);
}

/* ---- Layout ---------------------------------------------------------------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 12px 16px 24px;
}

@media (min-width: 900px) {
  main {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
    align-items: start;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(8px);
}

#map {
  width: 100%;
  height: 58vh;
  min-height: 340px;
  background: #0b1220;
}

@media (min-width: 900px) {
  #map {
    height: calc(100dvh - 190px);
  }
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.list-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
}

.list {
  max-height: 60vh;
  overflow: auto;
}

@media (min-width: 900px) {
  .list {
    max-height: calc(100dvh - 250px);
  }
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  cursor: pointer;
  transition: background 0.12s ease;
}

.row:hover {
  background: rgba(34, 211, 238, 0.06);
}

.row .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  flex: none;
}

.row .grow {
  min-width: 0;
  flex: 1;
}

.row .name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.14);
  color: var(--cyan);
  flex: none;
}

.badge.state {
  background: rgba(124, 58, 237, 0.16);
  color: var(--violet-2);
}

/* ---- Premium lock ---------------------------------------------------------- */
.lock {
  margin: 6px 14px 14px;
  padding: 14px;
  border: 1px dashed rgba(124, 58, 237, 0.4);
  border-radius: 12px;
  background: rgba(124, 58, 237, 0.08);
}

.lock h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--violet-2);
}

.lock p {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.lock ul {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.7;
}

/* ---- Products in premium popup/list --------------------------------------- */
.products {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
}

.chip b {
  color: var(--cyan);
}

/* ---- Leaflet popup theming ------------------------------------------------- */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel-solid);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-size: 13px;
}

.leaflet-popup-content .pop-title {
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 2px;
}

.leaflet-popup-content .pop-sub {
  color: var(--muted);
  font-size: 12px;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--muted);
}

/* ---- Footer ---------------------------------------------------------------- */
footer {
  padding: 14px 16px 26px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden {
  display: none !important;
}

.skeleton {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
