body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  overflow: hidden;
  display: flex;
  height: 100vh;
}

body.theme-dark {
  background: #050505;
  color: #f3f4f6;
}

body.theme-light {
  background: #f3f4f6;
  color: #111827;
}

#sidebar {
  width: 260px;
  flex-shrink: 0;
  height: 100%;
  padding: 16px;
  overflow-y: auto;

  background: rgba(20,20,20,0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border-right: 1px solid rgba(255,255,255,0.08);
  box-shadow: 4px 0 18px rgba(0,0,0,0.45);
}

body.theme-light #sidebar {
  background: rgba(255,255,255,0.55);
  border-right-color: rgba(0,0,0,0.08);
  box-shadow: 4px 0 18px rgba(0,0,0,0.15);
}

#map,
.leaflet-container {
  flex: 1;
  height: 100%;
}

body.theme-dark #map,
body.theme-dark .leaflet-container {
  background: #000 !important;
}

body.theme-light #map,
body.theme-light .leaflet-container {
  background: #e5e7eb !important;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sync-status {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
}

#sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 6px rgba(249,115,22,0.7);
}

#sync-dot.active {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.8);
}

.stats-row {
  display: flex;
  gap: 6px;
  margin: 14px 0;
}

.stat {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.08);

  display: flex;
  flex-direction: column;
}

body.theme-light .stat {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.15);
}

.stat .label {
  font-size: 9px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat .value {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}

/* === CONTROLS === */
.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

/* iOS-style toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  cursor: pointer;
}

.toggle input {
  appearance: none;
  width: 36px;
  height: 20px;
  background: #555;
  border-radius: 20px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle input:checked {
  background: #22c55e;
}

.toggle input::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.toggle input:checked::before {
  transform: translateX(16px);
}

#search-input,
#team-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.55);
  color: #f3f4f6;
  font-size: 12px;
}

body.theme-light #search-input,
body.theme-light #team-filter {
  background: rgba(0,0,0,0.15);
  border-color: rgba(0,0,0,0.25);
  color: #111;
}

#team-filter option {
  background: #1a1a1a;
  color: #f3f4f6;
}

body.theme-light #team-filter option {
  background: #e5e5e5;
  color: #111;
}

.section-title {
  margin: 14px 0 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
}

#playerList {
  list-style: none;
  padding: 0;
  margin: 0;
}

.unit-row {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);

  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;

  min-height: 32px;
}

body.theme-light .unit-row {
  border-bottom: 1px solid rgba(0,0,0,0.15);
}

.unit-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: 70%;
}

.unit-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  max-width: 30%;
}

.unit-name {
  font-size: 12px;
  font-weight: 500;
  color: #f3f4f6;
}

body.theme-light .unit-name {
  color: #111;
}

.callsign-badge {
  margin-left: 4px;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  color: #f3f4f6;
}

body.theme-light .callsign-badge {
  background: rgba(0,0,0,0.15);
  color: #111;
}

.unit-team {
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 6px;
  width: fit-content;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.unit-team.pd { background: #2563eb; }
.unit-team.sheriff { background: #8b49c9; }
.unit-team.fd { background: #dc2626; }
.unit-team.dot { background: #f59e0b; }
.unit-team.civ { background: #8c8d8e; }

.permission-pill {
  background: #05872c !important;
  color: #fff !important;
}

.leaflet-popup-content-wrapper {
  background: rgba(20,20,20,0.85) !important;
  color: #fff !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
  max-width: 260px !important;
}

body.theme-light .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.9) !important;
  color: #111 !important;
  border: 1px solid rgba(0,0,0,0.15) !important;
}

.profile-popup {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 220px;
}

.profile-popup img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  object-fit: cover;
}

.profile-popup .info h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.profile-popup .info p {
  margin: 2px 0;
  font-size: 11px;
  color: #cbd5e1;
}

body.theme-light .profile-popup .info p {
  color: #333;
}

.profile-popup .badge-container {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
