:root {
  --verde: #0B6B45;
  --verde-osc: #084F33;
  --azul: #1D4E9E;
  --tinta: #1B1F1C;
  --gris: #5A615C;
  --arena: #F7F5EF;
  --linea: #E2DED3;
  --linea-suave: #ECE8DE;
  --naranja: #9A4A00;
  --rojo: #9B1C1C;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--arena);
  color: var(--tinta);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--verde); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 20px calc(110px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.loading, .empty { text-align: center; color: var(--gris); padding: 48px 12px; }

/* Encabezado */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 0 10px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--tinta); font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.logo img { width: 34px; height: 34px; border-radius: 10px; }
.zona-pick { height: 44px; max-width: 180px; padding: 0 12px; border: 1px solid var(--linea); background: #fff; border-radius: 22px; font-size: 14px; font-weight: 600; }

h1 { margin: 8px 0 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.6px; }
h2 { margin: 0; font-size: 19px; font-weight: 800; }
.sub { margin: 8px 0 0; color: var(--gris); }

.search { display: flex; align-items: center; gap: 10px; height: 50px; margin-top: 16px; padding: 0 16px; background: #fff; border: 1px solid var(--linea); border-radius: 14px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; }

.promo { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 16px; border-radius: 18px; background: var(--tinta); color: #fff; text-decoration: none; }
.promo small { display: block; font-size: 12px; font-weight: 700; color: #9FE0BF; letter-spacing: 0.4px; }
.promo strong { display: block; margin-top: 4px; font-size: 17px; font-weight: 800; line-height: 1.25; }
.promo .cam { flex-shrink: 0; width: 56px; height: 56px; border-radius: 28px; background: var(--verde); display: flex; align-items: center; justify-content: center; }
.promo > div { flex: 1; }

.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 16px; padding: 4px; background: var(--linea-suave); border-radius: 14px; }
.tabs button { height: 40px; border: 0; border-radius: 11px; background: transparent; color: var(--gris); font-size: 14px; font-weight: 700; }
.tabs button.on { background: #fff; color: var(--tinta); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

.chips { display: flex; gap: 8px; margin: 12px -20px 0; padding: 0 20px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
.chip { flex-shrink: 0; height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--linea); background: #fff; font-size: 14px; font-weight: 600; }
.chip.on { background: var(--tinta); color: #fff; border-color: var(--tinta); }

.sec { display: flex; align-items: baseline; justify-content: space-between; padding: 20px 0 10px; }
.sec + .hint { margin: -4px 0 12px; font-size: 13px; color: var(--gris); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--linea-suave); border-radius: 16px; overflow: hidden; text-decoration: none; color: var(--tinta); }
.card .ph { position: relative; height: 130px; display: flex; align-items: center; justify-content: center; color: var(--gris); font-size: 12px; font-weight: 600; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.tag { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; color: #fff; background: var(--verde); padding: 3px 8px; border-radius: 8px; }
.card .cb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card strong { font-size: 14px; font-weight: 700; line-height: 1.25; }
.card small { font-size: 12px; color: var(--gris); }

.needs { display: flex; flex-direction: column; gap: 10px; }
.need { display: flex; align-items: center; gap: 12px; padding: 14px; background: #fff; border: 1px solid #DCE5F3; border-radius: 16px; }
.need .ic { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; background: #E4ECF7; display: flex; align-items: center; justify-content: center; }
.need .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--tinta); }
.need .tx b { font-size: 11px; font-weight: 700; color: var(--azul); letter-spacing: 0.4px; }
.need .tx strong { font-size: 14px; font-weight: 700; line-height: 1.25; }
.need .tx small { font-size: 12px; color: var(--gris); }
.btn-azul { flex-shrink: 0; display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--azul); background: #fff; color: var(--azul); font-size: 13px; font-weight: 700; text-decoration: none; }

.aviso { display: flex; gap: 12px; align-items: center; margin-top: 20px; padding: 12px 14px; border-radius: 14px; background: #FFF4E0; color: #6B3600; font-size: 13px; }
.aviso.rojo { background: #FDECEC; color: #7A1616; }
.aviso.azul { background: #E4ECF7; color: #183F80; }
.aviso p { margin: 0; }
.aviso svg { flex-shrink: 0; }

/* Navegación inferior */
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; align-items: flex-start; height: calc(84px + env(safe-area-inset-bottom)); padding-top: 8px; background: #fff; border-top: 1px solid var(--linea); }
#nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 72px; min-height: 44px; text-decoration: none; color: var(--gris); font-size: 11px; font-weight: 600; }
#nav a.on { color: var(--verde); font-weight: 700; }
#nav a.fab { margin-top: -22px; color: var(--tinta); font-weight: 700; }
#nav a.fab span { width: 58px; height: 58px; border-radius: 29px; background: var(--verde); border: 4px solid #fff; box-shadow: 0 4px 14px rgba(11,107,69,0.3); display: flex; align-items: center; justify-content: center; }

/* Detalle */
.back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 12px 0 8px -10px; border-radius: 22px; color: var(--tinta); }
.fotos { display: flex; gap: 8px; margin: 0 -20px; padding: 0 20px; overflow-x: auto; scroll-snap-type: x mandatory; }
.fotos > * { flex: 0 0 100%; height: 300px; border-radius: 16px; scroll-snap-align: center; object-fit: cover; background: #E3EFE8; }
.fotos .nofoto { display: flex; align-items: center; justify-content: center; color: var(--gris); font-weight: 600; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; background: var(--verde); padding: 3px 9px; border-radius: 8px; }
.badge.azul { background: #E4ECF7; color: var(--azul); }
.badge.gris { background: var(--linea-suave); color: var(--gris); }
.det h1 { font-size: 24px; margin-top: 8px; }
.det .meta { color: var(--gris); font-size: 14px; }
.owner { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 14px; background: #fff; border: 1px solid var(--linea-suave); border-radius: 16px; }
.owner .av { width: 44px; height: 44px; border-radius: 22px; background: #FDEBD6; color: var(--naranja); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.owner strong { display: block; font-size: 15px; }
.owner small { color: var(--gris); font-size: 12px; }
.det .desc { margin: 18px 0 0; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.facts { display: flex; gap: 8px; margin-top: 12px; }
.facts div { flex: 1; padding: 12px; background: #fff; border: 1px solid var(--linea-suave); border-radius: 12px; }
.facts small { display: block; font-size: 12px; color: var(--gris); }
.facts strong { font-size: 14px; }

/* Botones y formularios */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; padding: 0 20px; border: 0; border-radius: 16px; background: var(--verde); color: #fff; font-size: 17px; font-weight: 800; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.sec2 { background: #fff; color: var(--tinta); border: 1px solid var(--linea); font-size: 15px; font-weight: 700; }
.btn.peligro { background: #fff; color: var(--rojo); border: 1px solid #E8C4C4; font-size: 15px; font-weight: 700; }
.btn.mini { width: auto; min-height: 40px; padding: 0 14px; border-radius: 20px; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > span.lb { font-size: 15px; font-weight: 700; }
.field em { font-style: normal; font-weight: 500; color: var(--gris); }
.field input[type=text], .field input[type=tel], .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid var(--linea); border-radius: 14px; background: #fff; font-size: 16px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--verde); outline-offset: 1px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.tel { display: flex; gap: 8px; }
.tel select { flex: 0 0 112px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; accent-color: var(--verde); }
.err { color: var(--rojo); font-size: 14px; font-weight: 600; margin: 0; }
.nota { color: var(--gris); font-size: 12px; text-align: center; margin: 0; }

.pics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pics > * { height: 104px; border-radius: 14px; }
.pics .add { border: 2px dashed #9FB8A9; background: #fff; color: var(--verde); font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.pics .pic { position: relative; background: var(--linea-suave); overflow: hidden; }
.pics .pic img { width: 100%; height: 100%; object-fit: cover; }
.pics .pic button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 16px; background: rgba(27,31,28,0.75); color: #fff; font-size: 18px; line-height: 1; }

.mine { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--linea-suave); border-radius: 14px; }
.mine a { flex: 1; min-width: 0; text-decoration: none; color: var(--tinta); font-weight: 700; font-size: 14px; }
.mine a small { display: block; font-weight: 500; color: var(--gris); font-size: 12px; }
.list { display: flex; flex-direction: column; gap: 10px; }

/* Hoja (inicio de sesión / registro) */
#sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(27,31,28,0.55); }
#sheet .box { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--arena); border-radius: 22px 22px 0 0; }
#sheet h2 { font-size: 22px; }
#sheet .x { float: right; width: 44px; height: 44px; margin: -10px -10px 0 0; border: 0; background: transparent; font-size: 26px; color: var(--gris); }
.gbtn { background: #fff; color: var(--tinta); border: 1px solid var(--linea); font-size: 16px; font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; max-width: 88vw; padding: 12px 18px; border-radius: 14px; background: var(--tinta); color: #fff; font-size: 14px; font-weight: 600; text-align: center; }
