/* ASM BOSQUE — pensado para leerse al sol y tocarse con guantes:
   contraste alto, tipografía grande, botones de 48 px para arriba. */

:root {
  --verde: #1d3a24;
  --verde-claro: #2f6b3c;
  --arena: #f4f1e8;
  --papel: #ffffff;
  --tinta: #16181a;
  --tinta-suave: #5b6167;
  --linea: #d8d3c6;
  --alerta: #d1450f;
  --aviso: #b26a00;
  --ok: #1f7a1f;
  --alto-barra: 56px;
  --alto-pie: 60px;
  --sombra: 0 2px 14px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; color: var(--tinta); background: var(--arena);
  overscroll-behavior: none;
}

.oculto { display: none !important; }
.tenue { color: var(--tinta-suave); }
.error { color: var(--alerta); font-weight: 600; margin: 0; }

/* ---------- pantallas de tapa ---------- */
.tapa {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: linear-gradient(165deg, #244a2c, #16281b 70%); color: #fff;
  padding: 24px; padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.marca { text-align: center; }
.marca-icono { font-size: 56px; line-height: 1; }
.marca h1 { margin: 10px 0 4px; font-size: 30px; letter-spacing: .14em; font-weight: 700; }
.marca-sub { margin: 0; opacity: .75; font-size: 14px; }
.tapa .tenue { color: rgba(255, 255, 255, .8); }

.tarjeta-ingreso {
  width: min(360px, 100%); background: var(--papel); border-radius: 16px;
  padding: 20px; display: grid; gap: 14px; color: var(--tinta); box-shadow: var(--sombra);
}
.tarjeta-ingreso label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.tarjeta-ingreso input {
  font-size: 18px; padding: 13px 12px; border: 2px solid var(--linea);
  border-radius: 10px; background: #fff; color: var(--tinta);
}
.tarjeta-ingreso input:focus { outline: none; border-color: var(--verde-claro); }

/* ---------- botones ---------- */
.boton {
  border: 0; border-radius: 12px; padding: 12px 16px; font-size: 16px; font-weight: 600;
  background: #e9e5d9; color: var(--tinta); cursor: pointer; min-height: 48px;
}
.boton.primario { background: var(--verde-claro); color: #fff; }
.boton.grande { font-size: 18px; min-height: 54px; }
.boton.alerta { background: #fde6de; color: var(--alerta); }
.boton:active { filter: brightness(.93); }
.boton[disabled] { opacity: .5; }

.icono {
  border: 0; background: transparent; color: inherit; font-size: 20px;
  width: 44px; height: 44px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; position: relative; flex: 0 0 auto;
}
.icono.chico { width: 34px; height: 34px; font-size: 15px; }
.icono.redondo {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .94);
  color: var(--tinta); box-shadow: var(--sombra); font-size: 21px; font-weight: 700;
}
.icono.redondo.activo { background: var(--verde-claro); color: #fff; }
.punto {
  position: absolute; top: 7px; right: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--alerta); border: 1.5px solid #fff;
}

/* ---------- barra superior ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

.barra-superior {
  height: calc(var(--alto-barra) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--verde); color: #fff;
  display: flex; align-items: center; gap: 6px; padding-inline: 6px; z-index: 20;
}
.buscador { flex: 1; position: relative; display: flex; align-items: center; }
.buscador input {
  width: 100%; height: 40px; border: 0; border-radius: 20px; padding: 0 40px 0 16px;
  font-size: 16px; background: rgba(255, 255, 255, .95); color: var(--tinta);
}
.buscador input:focus { outline: 2px solid #9fd4a8; }
#q-limpiar { position: absolute; right: 3px; color: var(--tinta-suave); }

.lista-flotante {
  position: absolute; top: calc(var(--alto-barra) + env(safe-area-inset-top)); left: 8px; right: 8px;
  max-height: 55vh; overflow-y: auto; background: var(--papel);
  border-radius: 0 0 14px 14px; box-shadow: var(--sombra); z-index: 19;
}

/* ---------- mapa ---------- */
.lienzo-caja { position: relative; flex: 1; overflow: hidden; }
#mapa { display: block; touch-action: none; cursor: grab; }
#mapa:active { cursor: grabbing; }

.controles-derecha {
  position: absolute; right: 10px; top: 12px; display: grid; gap: 10px; z-index: 10;
}
.escala {
  position: absolute; left: 10px; bottom: 10px; z-index: 10;
  background: rgba(255, 255, 255, .85); border-radius: 6px; padding: 3px 7px;
  font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 7px;
}
.escala span { display: block; height: 4px; background: var(--tinta); border-radius: 2px; }

.aviso-gps {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 11;
  background: rgba(22, 24, 26, .85); color: #fff; padding: 7px 13px;
  border-radius: 18px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.aviso-gps.bueno { background: rgba(31, 122, 31, .9); }
.aviso-gps.regular { background: rgba(178, 106, 0, .9); }
.aviso-gps.malo { background: rgba(209, 69, 15, .9); }

/* ---------- barra inferior ---------- */
.barra-inferior {
  height: calc(var(--alto-pie) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--papel); border-top: 1px solid var(--linea);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 20;
}
.pestana {
  border: 0; background: none; display: grid; place-items: center; gap: 1px;
  font-size: 11px; color: var(--tinta-suave); cursor: pointer; position: relative; padding: 0;
}
.pestana b { font-size: 20px; font-weight: 400; line-height: 1; }
.pestana.activo { color: var(--verde-claro); font-weight: 700; }

/* ---------- ficha del árbol ---------- */
.hoja {
  position: absolute; left: 0; right: 0; bottom: calc(var(--alto-pie) + env(safe-area-inset-bottom));
  max-height: 68vh; overflow-y: auto; z-index: 30;
  background: var(--papel); border-radius: 18px 18px 0 0; box-shadow: 0 -3px 20px rgba(0, 0, 0, .22);
  animation: subir .16s ease-out;
}
@keyframes subir { from { transform: translateY(30px); opacity: .4; } }

.ficha-cabeza {
  position: sticky; top: 0; background: var(--papel); z-index: 2;
  padding: 12px 14px 8px; border-bottom: 1px solid var(--linea);
  display: flex; align-items: flex-start; gap: 10px;
}
.ficha-chapa { font-size: 13px; color: var(--tinta-suave); font-weight: 600; letter-spacing: .04em; }
.ficha-especie { font-size: 22px; font-weight: 700; line-height: 1.15; margin: 1px 0 2px; }
.ficha-otros { font-size: 13px; color: var(--tinta-suave); font-style: italic; }
.sello-up { font-size: 12px; font-weight: 700; color: #fff; border-radius: 6px; padding: 3px 8px; }

.tira-avisos { display: grid; gap: 6px; padding: 10px 14px 0; }
.aviso {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px; font-weight: 600;
  background: #fff4e2; color: #7a4a00; border-left: 4px solid var(--aviso);
  border-radius: 6px; padding: 8px 10px; line-height: 1.35;
}
.aviso.grave { background: #fdeae2; color: #8c2f0d; border-left-color: var(--alerta); }

.distancia-caja {
  margin: 10px 14px 0; background: #eef4ef; border-radius: 12px; padding: 10px 12px;
  display: flex; align-items: center; gap: 12px;
}
.flecha-rumbo { width: 44px; height: 44px; flex: 0 0 auto; }
.distancia-caja b { font-size: 22px; }

.datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--linea); margin: 12px 0 0; }
.dato { background: var(--papel); padding: 9px 10px; }
.dato span { display: block; font-size: 11px; color: var(--tinta-suave); text-transform: uppercase; letter-spacing: .04em; }
.dato b { font-size: 17px; font-weight: 700; }
.dato small { font-size: 11px; color: var(--tinta-suave); font-weight: 600; }

.caida { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--linea); }
.caida-rosa { width: 62px; height: 62px; flex: 0 0 auto; }
.caida-texto b { font-size: 19px; }
.caida-texto div { font-size: 12px; color: var(--tinta-suave); }

.obs { padding: 10px 14px; border-top: 1px solid var(--linea); font-size: 14px; }
.obs span { font-size: 11px; color: var(--tinta-suave); text-transform: uppercase; display: block; margin-bottom: 2px; }

.acciones { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--linea); flex-wrap: wrap; }
.acciones .boton { flex: 1; min-width: 100px; }

/* ---------- paneles ---------- */
.fondo-panel { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 39; }
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 88vh;
  background: var(--arena); border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
  box-shadow: 0 -3px 24px rgba(0, 0, 0, .3); animation: subir .18s ease-out;
}
.panel-cabeza {
  display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 16px;
  border-bottom: 1px solid var(--linea); background: var(--papel); border-radius: 18px 18px 0 0;
}
.panel-cabeza h2 { margin: 0; font-size: 18px; flex: 1; }
.panel-cuerpo { overflow-y: auto; padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); }

/* ---------- listas ---------- */
.fila {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--papel); border-bottom: 1px solid var(--linea); cursor: pointer; width: 100%;
  border: 0; border-bottom: 1px solid var(--linea); text-align: left; font: inherit; color: inherit;
}
.fila:active { background: #f0ede4; }
.fila-marca { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.fila-cuerpo { flex: 1; min-width: 0; }
.fila-titulo { font-weight: 700; font-size: 15px; }
.fila-sub { font-size: 12.5px; color: var(--tinta-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-derecha { text-align: right; font-size: 13px; font-weight: 700; white-space: nowrap; }
.fila-derecha small { display: block; font-weight: 600; color: var(--tinta-suave); }

.bloque { background: var(--papel); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.bloque h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--tinta-suave); }

.fichas { display: flex; flex-wrap: wrap; gap: 8px; }
.pastilla {
  border: 2px solid var(--linea); background: var(--papel); border-radius: 20px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 42px;
}
.pastilla.activa { border-color: var(--verde-claro); background: #e6f2e8; color: var(--verde); }

.par { display: flex; gap: 10px; align-items: center; }
.par input[type=number] {
  width: 100%; font-size: 16px; padding: 10px; border: 2px solid var(--linea); border-radius: 10px;
}

.barra-progreso { height: 8px; background: var(--linea); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.barra-progreso i { display: block; height: 100%; background: var(--verde-claro); width: 0; transition: width .2s; }

.mensaje {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--alto-pie) + 22px + env(safe-area-inset-bottom)); z-index: 70;
  background: rgba(22, 24, 26, .92); color: #fff; padding: 11px 18px; border-radius: 22px;
  font-size: 14px; font-weight: 600; max-width: 90vw; text-align: center;
}

.vacio { text-align: center; color: var(--tinta-suave); padding: 30px 20px; font-size: 15px; }

/* Notas guardadas */
.nota { background: var(--papel); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.nota-cabeza { display: flex; justify-content: space-between; font-size: 12px; color: var(--tinta-suave); margin-bottom: 6px; }
.nota img { width: 100%; border-radius: 8px; margin-top: 8px; }
.nota audio { width: 100%; margin-top: 8px; }
.pendiente { color: var(--aviso); font-weight: 700; }
