:root {
  --fosc: #1b3a2f;
  --clar: #f4f1ea;
  --accent: #d97706;
  --text: #22201c;
  --gris: #6b6560;
  --vora: #ddd8ce;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

#mapa { position: absolute; inset: 0; z-index: 1; }

/* ---- Barra superior ---- */
#barra-sup {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; gap: 8px; padding: 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0,0,0,.45), transparent);
  pointer-events: none;
}
#barra-sup select {
  pointer-events: auto;
  flex: 1; min-width: 0; height: 44px;
  padding: 0 12px; border: none; border-radius: 10px;
  background: #fff; color: var(--text);
  font-size: 15px; font-weight: 500;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 32px;
}

/* ---- Boto d'ubicacio ---- */
#btn-ubicacio {
  position: absolute; right: 12px; bottom: 96px; z-index: 500;
  width: 48px; height: 48px; border: none; border-radius: 50%;
  background: #fff; color: var(--fosc);
  font-size: 22px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
#btn-ubicacio:active { background: #eee; }

/* ---- Llegenda ---- */
#llegenda {
  position: absolute; left: 12px; bottom: 24px; z-index: 500;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  font-size: 11px; color: var(--gris);
}
#llegenda .barra {
  width: 90px; height: 8px; border-radius: 4px;
  background: linear-gradient(to right,
    rgba(217,119,6,.15), rgba(217,119,6,.5), rgba(180,60,10,.95));
}

/* ---- Panell inferior ---- */
#panell {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 600;
  max-height: 72vh;
  background: var(--clar);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.28);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
#panell.tancat { transform: translateY(102%); }

#nansa {
  flex: none; width: 40px; height: 4px; border-radius: 2px;
  background: var(--vora); margin: 10px auto 4px;
}

#panell-cos { overflow-y: auto; padding: 6px 18px 22px; }

#p-titol { margin: 4px 0 2px; font-size: 17px; font-weight: 600; }
#p-subtitol { margin: 0 0 14px; font-size: 13px; color: var(--gris); }

.seccio { margin-bottom: 18px; }
.seccio h3 {
  margin: 0 0 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--gris);
}

.graella-dades {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.dada {
  background: #fff; border: 1px solid var(--vora);
  border-radius: 10px; padding: 8px 10px;
}
.dada .et { display: block; font-size: 11px; color: var(--gris); }
.dada .val { display: block; font-size: 16px; font-weight: 600; margin-top: 2px; }

/* ---- Files d'especie ---- */
.esp {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--vora);
}
.esp:last-child { border-bottom: none; }
.esp .punt { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.esp .info { flex: 1; min-width: 0; }
.esp .nom { font-size: 14px; font-weight: 500; }
.esp .lim { font-size: 11px; color: var(--gris); margin-top: 1px; }
.esp .pct { flex: none; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.esp.apagada { opacity: .45; }

@media (min-width: 720px) {
  #panell { left: auto; right: 16px; bottom: 16px; width: 380px;
            max-height: calc(100vh - 120px); border-radius: 14px; }
  #panell.tancat { transform: translateY(calc(100% + 24px)); }
  #barra-sup { max-width: 460px; }
}
