:root {
  --bg: #0b1220;
  --panel: #121c2e;
  --panel-2: #1a2740;
  --line: #24344f;
  --text: #e6edf7;
  --muted: #93a4bf;
  --brand: #22c1a4;
  --radar: #ef4444;
  --dome: #3b82f6;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Mapa (app.html) ---------- */
#map { position: absolute; inset: 0; z-index: 1; }

.topbar {
  position: absolute;
  z-index: 1000;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(11, 18, 32, .96), rgba(11, 18, 32, .78) 70%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: .3px;
  white-space: nowrap;
}
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 12px var(--brand); }
.brand small { color: var(--muted); font-weight: 600; }

.search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  box-shadow: var(--shadow);
}
.search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 15px;
}
.search input::placeholder { color: var(--muted); }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 18px;
}
.iconbtn:hover { background: var(--panel-2); }

/* Menu do usuario */
.menu { position: relative; }
.menu-pop {
  position: absolute;
  right: 0; top: 50px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 190px;
  padding: 6px;
  display: none;
}
.menu-pop.open { display: block; }
.menu-pop a, .menu-pop button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--panel-2); }
.menu-pop .who { color: var(--muted); font-size: 12px; padding: 8px 12px 4px; }

/* Filtros */
.filters {
  position: absolute;
  z-index: 1000;
  top: 66px; left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 24px);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  user-select: none;
}
.chip .swatch { width: 10px; height: 10px; border-radius: 50%; }
.chip.active { color: #fff; border-color: transparent; }
.chip.radar.active { background: var(--radar); }
.chip.dome.active { background: var(--dome); }
.chip.sent.active { background: var(--panel-2); color: #fff; border-color: var(--brand); }

/* Legenda + contagem */
.legend {
  position: absolute;
  z-index: 1000;
  left: 12px; bottom: 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.legend .row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.legend .swatch { width: 12px; height: 12px; border-radius: 50%; }
.legend .count { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* Rodape by Diniz */
.credit {
  position: absolute;
  z-index: 1000;
  right: 12px; bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(11, 18, 32, .72);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  backdrop-filter: blur(4px);
}
.credit b { color: var(--brand); }

/* Pins */
.pin {
  width: 26px; height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center;
}
.pin span { transform: rotate(45deg); font-size: 11px; font-weight: 800; color: #fff; }

/* Popup */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 14px; border: 1px solid var(--line); }
.leaflet-popup-tip { background: var(--panel); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.45; }
.pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pop-badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; }
.pop-title { font-weight: 800; font-size: 15px; }
.pop-vel { font-size: 22px; font-weight: 900; color: #fff; }
.pop-vel small { font-size: 12px; color: var(--muted); font-weight: 600; }
.pop-row { color: var(--muted); margin: 3px 0; }
.pop-row b { color: var(--text); font-weight: 600; }
.pop-sentido { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--brand); }
.pop-link { display: inline-block; margin-top: 8px; color: var(--brand); text-decoration: none; font-weight: 700; }

/* ---------- Auth (login/register) ---------- */
.auth-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(34, 193, 164, .15), transparent),
    var(--bg);
}
.card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 20px;
  box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.brand-lg { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 800; font-size: 18px; }
.brand-lg .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 14px var(--brand); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  outline: 0;
}
.field input:focus { border-color: var(--brand); }

.btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 0;
  background: var(--brand);
  color: #04231d;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: default; }

.msg { font-size: 13px; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; display: none; }
.msg.err { display: block; background: rgba(239, 68, 68, .12); color: #fca5a5; border: 1px solid rgba(239, 68, 68, .3); }
.msg.ok { display: block; background: rgba(34, 193, 164, .12); color: #7fe6d2; border: 1px solid rgba(34, 193, 164, .3); }

.foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--muted); }
.foot b { color: var(--brand); }
.foot a { color: var(--brand); text-decoration: none; }

/* ---------- Admin ---------- */
.admin-wrap { max-width: 820px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.admin-head a { color: var(--muted); text-decoration: none; font-size: 14px; }
.invite-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 20px; }
.invite-link { display: flex; gap: 8px; margin-top: 12px; }
.invite-link input { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 14px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list th, .list td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list th { color: var(--muted); font-weight: 600; background: var(--panel-2); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tag.livre { background: rgba(34, 193, 164, .15); color: #7fe6d2; }
.tag.usado { background: rgba(147, 164, 191, .15); color: var(--muted); }

@media (max-width: 560px) {
  .brand small { display: none; }
  .legend { bottom: 46px; }
}
