:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.92);
  --panel-solid: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --border: #334155;
}

* { box-sizing: border-box; }

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

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#head {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  pointer-events: none;
}

#head > * { pointer-events: auto; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}

.chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.chip .meta { color: var(--muted); font-size: 11px; }

.chip.off { opacity: 0.45; }

.hidden { display: none !important; }

/* ---- markers ---- */

.p4f-catpin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c, #64748b);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.p4f-catpin.big { font-size: 13px; }

.p4f-catpin.p4f-p {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.p4f-catpin.p4f-pss {
  font-size: 12px;
}

.p4f-catpin.p4f-pss .p4f-p {
  font-size: 10px;
  font-weight: 800;
  font-style: normal;
  margin-left: 2px;
  line-height: 1;
}

.p4f-catpin.p4f-spray {
  flex-direction: column;
  gap: 0;
  font-size: 13px;
}

.p4f-catpin.p4f-spray .p4f-jet {
  font-size: 8px;
  line-height: 1;
  margin-top: -1px;
  color: #7dd3fc;
  filter: drop-shadow(0 0 2px rgba(125, 211, 252, 0.8));
}

.p4f-marker {
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.p4f-cluster {
  min-width: 34px;
  height: 34px;
  background: #0f172a;
  border: 2px solid #fff;
  color: #fff;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
}

.p4f-cluster.cat {
  flex-direction: row;
  gap: 3px;
  font-size: 14px;
  background: var(--c, #0f172a);
}

.p4f-cluster.cat .num {
  font-size: 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 1px 6px;
}

.p4f-gridpin {
  min-width: 34px;
  height: 34px;
  background: #0f172a;
  border: 2px solid #fff;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* ---- panell de filtres ---- */

.filters-modal .card { display: flex; flex-direction: column; max-height: 82vh; }

.filters-modal .card .section { overflow-y: auto; }

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sheet-foot { justify-content: flex-end; margin-top: 8px; }

.chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.servicerow {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  padding-bottom: 4px;
}

.servicerow .chip {
  justify-content: flex-start;
  text-align: left;
  border-radius: 10px;
  font-size: 11.5px;
  padding: 8px 10px;
  white-space: normal;
}

/* ---- cercador ---- */

.searchbox {
  position: relative;
  width: 320px;
  max-width: 78vw;
}

.searchbox input {
  width: 100%;
  background: var(--panel);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
}

.searchbox input:focus { border-color: var(--accent); }

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 380px;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  z-index: 1100;
}

.sr {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.sr:last-child { border-bottom: none; }
.sr:hover { background: rgba(255, 255, 255, 0.06); }

.sr-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sr-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sr-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-meta { font-size: 11px; color: var(--muted); }

.sr-empty { padding: 14px; font-size: 12px; color: var(--muted); }

.sr-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 12px 4px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.chip-cat .emoji {
  font-size: 13px;
 }

/* ---- filtres de tipus agrupats ---- */

#catfilters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.flt-group {
  position: relative;
}

.flt-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
}

.flt-head:hover { border-color: var(--muted); }

.flt-head.alloff { opacity: 0.6; }

.flt-gdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.flt-glabel { white-space: nowrap; }

.flt-gstate {
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
}

.flt-gstate.off { color: var(--muted); }

.flt-chevr {
  color: var(--muted);
  font-size: 9px;
  transition: transform 0.15s;
}

.flt-group.open .flt-chevr { transform: rotate(180deg); }

.flt-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  padding: 4px;
  z-index: 1100;
}

.flt-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 12px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.flt-item:hover { background: rgba(255, 255, 255, 0.07); }

.flt-item.off { opacity: 0.5; }

.flt-item.flt-all {
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  border-radius: 7px 7px 0 0;
  margin-bottom: 4px;
}

.flt-box {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--muted);
  flex: 0 0 auto;
}

.flt-item.on .flt-box {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--panel-solid);
}

.flt-item.flt-all .flt-box {
  border-radius: 50%;
}

.flt-item.flt-all.on .flt-box {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--panel-solid);
}

/* ---- popup graella ---- */

.p4f-grid-popup .head {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}

.grid-sample {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 9px;
  margin-bottom: 6px;
  cursor: pointer;
}

.grid-sample:hover { background: rgba(255, 255, 255, 0.1); }

.grid-sample .emoji {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.grid-sample .main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.grid-sample .name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-sample .meta { font-size: 11px; color: var(--muted); }

.grid-zoom { margin-top: 4px; }

/* ---- popup ---- */

.leaflet-popup-content-wrapper {
  background: var(--panel-solid);
  color: var(--text);
  border-radius: 12px;
}

.leaflet-popup-content { margin: 12px; width: 340px !important; max-width: 78vw; }

.leaflet-popup-tip { background: var(--panel-solid); }

.p4f-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.p4f-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}

.p4f-close:hover { color: var(--text); }

.p4f-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.p4f-tab.active {
  color: var(--text);
}

.p4f-tab .cnt {
  background: var(--border);
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 6px;
}

.p4f-tab.active .cnt { background: rgba(255, 255, 255, 0.18); }

.p4f-panel { min-height: 120px; }

.p4f-pick-title { font-weight: 700; font-size: 13px; padding: 4px 2px; }

.p4f-pick-list { display: flex; flex-direction: column; gap: 6px; }

.p4f-pick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

.p4f-pick-item:hover { border-color: var(--accent, #38bdf8); }

.p4f-pick-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.p4f-pick-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.p4f-pick-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p4f-pick-sub { font-size: 11px; color: var(--muted); }

.p4f-pick-go { color: var(--muted); font-size: 18px; line-height: 1; }

.p4f-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; }

.p4f-stars { color: #fbbf24; font-size: 13px; letter-spacing: 1px; }
.p4f-stars .num { color: var(--muted); font-size: 11px; margin-left: 4px; }

.p4f-cat {
  display: inline-block;
  background: var(--border);
  border-radius: 6px;
  font-size: 11px;
  padding: 2px 8px;
  margin: 6px 0;
}

.p4f-subcat {
  display: inline-block;
  border: 1px solid;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  margin: 6px 0 6px 6px;
  background: #fff;
}

.p4f-services {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 8px;
}

.p4f-services span {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent);
  border-radius: 999px;
  font-size: 10px;
  padding: 2px 8px;
}

.p4f-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 0 6px;
}

.p4f-desc {
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.p4f-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.p4f-photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  background: var(--border);
}

.p4f-photos.many { grid-template-columns: repeat(3, 1fr); max-height: 260px; overflow-y: auto; }

.p4f-comments { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }

.p4f-comment {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.p4f-comment .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.p4f-comment .author { font-weight: 600; color: var(--text); }
.p4f-comment .text { font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

.p4f-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.p4f-actions .p4f-btn { cursor: pointer; }

.p4f-more {
  flex: 1;
  width: 100%;
  margin-top: 12px;
  text-align: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  color: var(--accent);
  background: none;
  cursor: pointer;
}

.p4f-more:hover { background: rgba(56, 189, 248, 0.08); }

.p4f-btn {
  flex: 1;
  text-align: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.p4f-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #082f49;
}

.p4f-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 0;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.p4f-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }

/* ---- botons i userbox ---- */

#userbox {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 6px;
  font-size: 12px;
}

#userbox #btn-user {
  background: none;
  border: none;
  font-size: 18px;
  padding: 2px 8px;
}

#userinfo { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#usermenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  min-width: 210px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

#usermenu #userinfo { display: block; padding: 2px 6px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

#usermenu .btn {
  text-align: left;
  justify-content: flex-start;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  width: 100%;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}

.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:disabled { opacity: 0.5; cursor: wait; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #082f49; }
.btn-primary:hover { background: #7dd3fc; }

.btn-ghost { background: none; padding: 5px 8px; font-size: 13px; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

.btn-danger { color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.15); }

.btn-block { width: 100%; padding: 10px; font-size: 14px; }

/* ---- overlay / modals ---- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1e293b, #0b1120 70%);
  padding: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.6);
  padding: 16px;
}

.card {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.card h2 { margin: 0; font-size: 20px; }
.card h3 { margin: 0; font-size: 16px; }
.card h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.card-wide { max-width: 640px; }

.card .muted { color: var(--muted); font-size: 12px; margin: -8px 0 0; }

.card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.card input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 11px;
  outline: none;
}

.card input:focus { border-color: var(--accent); }

.error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fca5a5;
  border-radius: 8px;
  font-size: 12px;
  padding: 8px 10px;
}

/* ---- fitxa de punt a pantalla completa ---- */

.detail-modal {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(2, 6, 23, 0.7);
  z-index: 1600;
}

.detail-card {
  width: 100%;
  max-width: none;
  max-height: 100vh;
  border-radius: 0;
  border: none;
  gap: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.detail-card .sheet-head,
.detail-card .sheet-head h3 { display: none; }

.detail-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  flex: 1;
  min-height: 0;
}

@media (min-width: 700px) {
  .detail-card {
    max-width: 720px;
    margin: 24px auto;
    border-radius: 16px;
    border: 1px solid var(--border);
    max-height: calc(100vh - 48px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  }
  .detail-modal {
    padding: 0;
    align-items: center;
    justify-content: center;
  }
}

.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 6px; }
.row input { flex: 1; }

.section { margin-bottom: 18px; }

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.user-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-main span:first-child { overflow: hidden; text-overflow: ellipsis; }

.role-badge {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-badge.admin { background: rgba(250, 204, 21, 0.15); color: #fde047; }

.user-actions { display: flex; gap: 6px; align-items: center; }

.reset-input {
  width: 130px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
}

.muted { color: var(--muted); }

/* ============================ mòbil ============================ */

@media (max-width: 720px) {
  #head {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 8px;
  }

  .searchbox {
    width: 100%;
    max-width: none;
  }

  #filters,
  #catfilters,
  #searchbox {
    width: 100%;
  }

  /* files de chips d'origen/categoria en scroll horitzontal */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .filters::-webkit-scrollbar { display: none; }
  .filters .chip { flex: 0 0 auto; white-space: nowrap; }

  /* els 3 grups de filtres en una sola fila */
  #catfilters {
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
  }
  #catfilters .flt-group {
    flex: 1;
    min-width: 0;
  }
  #catfilters .flt-head {
    width: 100%;
    justify-content: center;
  }
  #catfilters .flt-glabel {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #btn-filters { align-self: flex-start; }

  #userbox { margin-left: auto; }
  #usermenu { min-width: 180px; }

  /* popups a mida de pantalla */
  .leaflet-popup-content { width: 92vw !important; max-width: 92vw; }
  .leaflet-popup-content-wrapper { max-height: 78vh; overflow-y: auto; }

  /* panell de filtres: bottom sheet */
  .filters-modal {
    align-items: flex-end;
    padding: 0;
  }
  .filters-modal .card {
    max-width: none;
    width: 100%;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .filters-modal .card .section { max-height: 34vh; overflow-y: auto; }

  /* botons més tàctils */
  .chip { padding: 9px 13px; font-size: 12.5px; }
  .btn { padding: 9px 12px; font-size: 12.5px; min-height: 38px; }
  .btn-ghost { padding: 8px 10px; }
  .sr { padding: 12px; }
  .sr-name { font-size: 14px; }
  .sr-meta { font-size: 12px; }
  .p4f-title { font-size: 16px; }
  #search-results { max-height: 55vh; }
}

/* botó ubicació actual */
.p4f-locate {
  width: 34px;
  height: 34px;
  background: var(--panel-solid, #fff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.p4f-locate:hover { filter: brightness(0.94); }

/* marcador d'ubicació actual (mida fixa en píxels, no escala amb el zoom) */
.p4f-loc-wrap { background: transparent; border: none; }

.p4f-loc-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #1e3a8a;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* botó ubicació: mateix punt blau que al mapa */
.p4f-locate {
  display: flex;
  align-items: center;
  justify-content: center;
}

.p4f-loc-btn-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #1e3a8a;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* avís temporal de geolocalització */
#p4f-loc-toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(92vw, 460px);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 2000;
}

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

/* temps estimat de ruta a la fitxa */
.p4f-eta {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border, #334155);
  font-size: 12px;
  color: var(--muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.p4f-eta::before { content: '🚗'; filter: grayscale(0.2); }

/* visor de fotos (lightbox) */
#p4f-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.88);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#p4f-lightbox.open { opacity: 1; pointer-events: auto; }

#p4f-lightbox .p4f-lb-img {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(94vw, 1200px);
  max-height: 88vh;
}

#p4f-lightbox .p4f-lb-img img {
  display: block;
  max-width: 94vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s;
}

#p4f-lightbox .p4f-lb-img.loading img { opacity: 0.35; }

#p4f-lightbox .p4f-lb-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
}

#p4f-lightbox .p4f-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

#p4f-lightbox .p4f-lb-nav.prev { left: 14px; }
#p4f-lightbox .p4f-lb-nav.next { right: 14px; }

#p4f-lightbox .p4f-lb-nav:hover,
#p4f-lightbox .p4f-lb-close:hover { background: rgba(255, 255, 255, 0.22); }

#p4f-lightbox .p4f-lb-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #cbd5e1;
  font-size: 13px;
  background: rgba(2, 6, 23, 0.6);
  padding: 4px 12px;
  border-radius: 999px;
}

@media (max-width: 720px) {
  #p4f-lightbox .p4f-lb-nav { width: 40px; height: 40px; font-size: 22px; }
  #p4f-lightbox .p4f-lb-nav.prev { left: 6px; }
  #p4f-lightbox .p4f-lb-nav.next { right: 6px; }
}

/* pantalla de càrrega inicial */
#boot-splash { z-index: 2100; }

#boot-splash .card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 200px;
  padding: 26px 16px;
  text-align: center;
}
