:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e3e3e6;
  --accent: #0071e3;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.10);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); }

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

header.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  z-index: 1000;
}
header.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
header.topbar .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
header.topbar .brand { flex: 1; }
header.topbar .nav a {
  font-size: 13px; text-decoration: none; color: var(--accent);
  padding: 7px 14px; border-radius: 980px; border: 1px solid var(--line);
  background: #fff; transition: background .15s;
}
header.topbar .nav a:hover { background: #f0f0f2; }
header.topbar .nav a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.main { flex: 1; display: flex; min-height: 0; }

/* Sidebar */
.sidebar {
  width: 320px; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 16px; flex-shrink: 0;
}
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0 10px; }

#map { flex: 1; min-height: 0; }

/* Filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 13px; padding: 7px 12px; border-radius: 980px;
  border: 1.5px solid var(--line); background: #fff; user-select: none;
  transition: all .12s;
}
.chip .dot { width: 11px; height: 11px; border-radius: 50%; }
.chip.active { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; font-weight: 600; }
.chip.off { opacity: .45; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

button.btn {
  font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  padding: 10px 16px; border-radius: 980px; border: none;
  background: var(--accent); color: #fff; transition: filter .15s;
}
button.btn:hover { filter: brightness(1.05); }
button.btn.secondary { background: #e8e8ed; color: var(--text); }
button.btn.danger { background: #fdecec; color: #e5484d; }
button.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.count-badge {
  display: inline-block; background: #f0f0f2; color: var(--muted);
  font-size: 12px; padding: 2px 9px; border-radius: 980px; margin-left: 6px;
}

/* Points list (admin) */
.point-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  margin-bottom: 8px; font-size: 13px; cursor: pointer; background: #fff;
}
.point-item:hover { border-color: var(--accent); }
.point-item .pi-top { display: flex; align-items: center; gap: 7px; }
.point-item .pi-tag { font-size: 11px; padding: 1px 7px; border-radius: 980px; color: #fff; }
.point-item .pi-title { font-weight: 600; margin: 4px 0 2px; }
.point-item .pi-team { color: var(--muted); font-size: 12px; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.hint.callout { background: #eef6ff; border: 1px solid #cfe6ff; border-radius: 10px; padding: 10px 12px; }

/* Marcadores */
.sign-glyph {
  width: 34px; height: 34px;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  background: var(--pin);
}
.sign-glyph span { font-size: 15px; line-height: 1; }

/* Gota (pin) */
.shape-pin { border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.shape-pin span { transform: rotate(45deg); }

/* Aro (I Pledge) */
.shape-ring { border-radius: 50%; background: #fff; border: 4px solid var(--pin); }

/* Estrella (Map) */
.shape-star {
  border: none; box-shadow: none; background: transparent;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.5));
}
.shape-star::before {
  content: ''; position: absolute; inset: 0; background: var(--pin);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.shape-star span { position: relative; font-size: 12px; }

/* Colocado: check verde */
.sign-glyph.placed::after {
  content: '✓'; position: absolute; top: -8px; right: -8px;
  width: 16px; height: 16px; background: #30a46c; color: #fff;
  border-radius: 50%; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; transform: rotate(0deg);
}
.shape-pin.placed::after { transform: rotate(45deg); }
.sign-glyph.placed { opacity: .55; }

.sign-glyph.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 2px 6px rgba(0,0,0,.4); }
  50% { box-shadow: 0 0 0 8px rgba(0,113,227,.3), 0 2px 6px rgba(0,0,0,.4); }
}

/* Insignia de zona (1–9) */
.zone-badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.62); color: #fff; border: 2px solid rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

/* Estado en popup */
.popup-status.done {
  display: inline-block; background: #e6f6ee; color: #218358;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 8px; margin-bottom: 8px;
}
.popup-btn { font-size: 13px; padding: 9px 14px; }

/* Barra de progreso */
.progress-wrap { margin: 4px 0 2px; }
.progress-track { height: 8px; background: #e8e8ed; border-radius: 980px; overflow: hidden; }
.progress-fill { height: 100%; background: #30a46c; width: 0; transition: width .3s; }
.progress-text { font-size: 12px; color: var(--muted); margin-top: 6px; }
.backend-note { font-size: 11.5px; color: #b25000; margin-top: 6px; display: none; }

/* Item colocado en la lista */
.point-item.done { opacity: .7; }
.point-item .pi-check { margin-left: auto; }

/* Popup */
.popup { width: 230px; }
.popup-tag { display: inline-block; color: #fff; font-size: 11px; padding: 3px 9px; border-radius: 980px; }
.popup h3 { margin: 8px 0 4px; font-size: 15px; }
.popup-team { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.popup-photo { width: 100%; border-radius: 10px; display: block; margin-bottom: 8px; max-height: 150px; object-fit: cover; }
.popup-photo.placeholder {
  background: #f0f0f2; color: var(--muted); font-size: 12px;
  padding: 22px 0; text-align: center; border: 1px dashed var(--line);
}
.popup-place { font-size: 12.5px; line-height: 1.5; margin: 0; }
.leaflet-popup-content { margin: 12px 14px; }

/* Mobile */
.mobile-toggle { display: none; }
@media (max-width: 720px) {
  .main { flex-direction: column; }
  .sidebar {
    width: 100%; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--line);
  }
  .sidebar.collapsed { display: none; }
  .mobile-toggle {
    display: inline-block; font-size: 13px; padding: 7px 14px;
    border-radius: 980px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  }
}
