:root {
  --rojo: #ce1126;
  --azul: #0a3161;
  --blanco: #ffffff;
  --fondo: #f4f6fa;
  --texto: #1c2430;
  --gris: #6b7686;
  --borde: #dbe2ec;
  --radio: 14px;
  --header-h: 76px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

/* Encabezado */
.app-header {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--header-h);
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--azul) 0%, #123f7d 60%, var(--rojo) 140%);
  color: var(--blanco);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.logo { width: 52px; height: 52px; border-radius: 14px; background: #fff; flex: none; }
.brand { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: .5px; }
.slogan { margin: 2px 0 0; font-size: .78rem; line-height: 1.25; opacity: .95; }
.slogan span { display: block; }

/* Botones */
.btn {
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 1rem; padding: 12px 16px; min-height: 48px;
  touch-action: manipulation;
}
.btn-primary { background: var(--rojo); color: #fff; font-weight: 700; }
.btn-primary:active { filter: brightness(.92); }
.btn-ghost { background: rgba(255,255,255,.16); color: #fff; }
main .btn-ghost { background: #e8edf5; color: var(--azul); }
.btn-danger { background: #fff; color: var(--rojo); border: 1px solid var(--rojo); }
.btn-block { width: 100%; margin-top: 10px; }

/* Vistas */
.view { padding: 14px 14px 90px; max-width: 720px; margin: 0 auto; }

/* Buscador y filtros */
.search-bar input {
  width: 100%; font-size: 1.05rem; padding: 13px 14px;
  border: 1px solid var(--borde); border-radius: var(--radio); background: #fff;
}
.filters { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.filters select {
  flex: 1; min-width: 140px; font-size: .95rem; padding: 12px 10px; min-height: 48px;
  border: 1px solid var(--borde); border-radius: var(--radio); background: #fff;
}

/* Pestañas */
.tabs { display: flex; gap: 8px; margin: 4px 0 12px; }
.tab {
  flex: 1; padding: 12px; min-height: 48px; font-size: 1rem; font-weight: 600;
  border: 1px solid var(--borde); border-radius: var(--radio); background: #fff; color: var(--gris);
}
.tab.active { background: var(--azul); color: #fff; border-color: var(--azul); }

/* Tarjetas */
.cards { display: grid; gap: 12px; }
.card {
  background: #fff; border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 14px; cursor: pointer;
}
.card h3 { margin: 0 0 4px; font-size: 1.08rem; color: var(--azul); }
.card .meta { font-size: .88rem; color: var(--gris); margin: 2px 0; }
.card .cat {
  display: inline-block; font-size: .75rem; font-weight: 700; color: var(--rojo);
  background: #fdeef0; border-radius: 999px; padding: 3px 10px; margin-bottom: 6px;
}
.card img.cover { width: 100%; height: 170px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.empty { text-align: center; color: var(--gris); padding: 40px 10px; }

/* Mapa */
#map { height: 62vh; min-height: 380px; border-radius: var(--radio); border: 1px solid var(--borde); background: #e5e9f0; z-index: 1; }
.map-error {
  text-align: center; color: var(--gris); background: #fff;
  border: 1px dashed var(--borde); border-radius: var(--radio); padding: 26px; margin-top: 10px;
}

/* Ficha */
.detail { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; }
.detail h2 { margin: 0 0 6px; color: var(--azul); }
.detail .meta { color: var(--gris); font-size: .92rem; margin: 3px 0; }
.detail .desc { margin: 12px 0; line-height: 1.5; white-space: pre-wrap; }
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.gallery img { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; }
.gallery img.portada { grid-column: 1 / -1; height: 220px; }
.owner-actions { display: flex; gap: 8px; margin-top: 14px; }
.owner-actions .btn { flex: 1; }
#detail-map { height: 240px; border-radius: var(--radio); border: 1px solid var(--borde); margin-top: 12px; z-index: 1; }
.contact-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.contact-row a.btn { text-decoration: none; display: inline-block; text-align: center; }

/* Formularios */
.form { display: grid; gap: 12px; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; }
.form label { display: grid; gap: 6px; font-size: .92rem; font-weight: 600; color: var(--azul); }
.form input, .form select, .form textarea {
  font-size: 1rem; padding: 12px; min-height: 48px;
  border: 1px solid var(--borde); border-radius: 10px; width: 100%; font-weight: 400; color: var(--texto);
  font-family: inherit;
}
.form textarea { min-height: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: var(--rojo); font-size: .9rem; margin: 0; }
h2 { color: var(--azul); }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: #222; color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: .95rem; z-index: 1000; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  max-width: 90vw; text-align: center;
}

@media (min-width: 720px) {
  .gallery { grid-template-columns: repeat(4, 1fr); }
  .brand h1 { font-size: 1.6rem; }
}
