:root {
  --azul: #0d5a7a;
  --azul-hondo: #08405a;
  --azul-claro: #e6f1f6;
  --acento: #ff7a59;
  --acento-suave: #fff1ec;
  --tinta: #14242c;
  --gris: #5f7178;
  --gris-claro: #8b9aa1;
  --linea: #e6ebee;
  --ok: #158a52;
  --ok-bg: #e3f5ea;
  --off: #93a1a8;
  --warn: #9a5b00;
  --warn-bg: #fff6e2;
  --bg: #f4f7f8;
  --radio: 16px;
  --radio-sm: 12px;
  --sombra: 0 1px 2px rgba(16,35,43,.06), 0 6px 20px rgba(16,35,43,.06);
  --sombra-fuerte: 0 -2px 16px rgba(16,35,43,.08);
  --tap: 48px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--tinta);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--linea);
}
.brand { font-weight: 800; font-size: 1.08rem; color: var(--azul); text-decoration: none; letter-spacing: -.01em; display: flex; align-items: center; gap: 6px; }
.sail { font-size: 1.3rem; }
.cart-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--azul); color: #fff; text-decoration: none;
  padding: 9px 15px; border-radius: 999px; font-weight: 700; font-size: .9rem;
  min-height: 40px;
}

/* ---- Layout ---- */
.wrap { max-width: 540px; margin: 0 auto; padding: 20px 16px 48px; }
.wrap.has-stickybar { padding-bottom: 108px; }
h1 { font-size: 1.55rem; margin: .2em 0 .35em; letter-spacing: -.02em; line-height: 1.2; }
h2.sec { font-size: 1.02rem; margin: 1.7em 0 .7em; letter-spacing: -.01em; }
.muted { color: var(--gris); }
.small { font-size: .85rem; }
.back {
  display: inline-flex; align-items: center; gap: 4px; color: var(--azul);
  text-decoration: none; font-size: .92rem; font-weight: 600;
  margin-bottom: 12px; min-height: 32px;
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-hondo) 100%);
  color: #fff; border-radius: var(--radio); padding: 26px 22px;
  margin-bottom: 8px; box-shadow: var(--sombra);
}
.hero h1 { font-size: 1.7rem; margin: 0 0 .35em; color: #fff; }
.hero .lead { color: rgba(255,255,255,.9); font-size: 1.02rem; margin: 0; }

/* ---- Grid de cards ---- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.card {
  background: #fff; border: 1px solid var(--linea); border-radius: var(--radio);
  text-decoration: none; color: inherit; overflow: hidden; box-shadow: var(--sombra);
  display: flex; flex-direction: column; transition: transform .12s ease;
}
.card:active { transform: scale(.98); }
.card.edificio { grid-column: 1 / -1; }
.card-body { padding: 13px 15px; }
.card-body h3 { margin: 0 0 4px; font-size: 1rem; line-height: 1.25; }
.card-links {
  margin-top: auto; padding: 11px 15px; border-top: 1px solid var(--linea);
  color: var(--azul); font-size: .88rem; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
}

/* Foto placeholder por categoría (gradiente + emoji) */
.card.prod .foto {
  font-size: 3rem; text-align: center; padding: 26px 0 22px;
  position: relative;
}
.foto.g0 { background: linear-gradient(135deg, #ffe3d4, #ffcdb6); }
.foto.g1 { background: linear-gradient(135deg, #d9ecf6, #b9dcee); }
.foto.g2 { background: linear-gradient(135deg, #e2f0e0, #c6e4c1); }
.foto.g3 { background: linear-gradient(135deg, #ede1f5, #d8c2ec); }
.foto.g4 { background: linear-gradient(135deg, #fdeecb, #f8dfa0); }
.foto.g5 { background: linear-gradient(135deg, #d7edea, #b4ddd6); }
.price { font-weight: 800; font-size: 1.05rem; margin-top: 6px; color: var(--tinta); }
.price.big { font-size: 1.8rem; color: var(--azul); margin: 6px 0; }

/* ---- Pills / badges ---- */
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .01em; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: #eef1f2; color: var(--off); }
.pill.svc { background: var(--acento-suave); color: var(--acento); }
.pill.doc { background: var(--azul-claro); color: var(--azul); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Sello de confianza (comité verificado) */
.verificado {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ok-bg); color: var(--ok);
  padding: 8px 13px; border-radius: 999px; font-size: .82rem; font-weight: 700;
}
.verificado .ic { font-size: 1rem; }

/* Badge de documento que recibe el comprador */
.doc-badge {
  display: flex; align-items: center; gap: 10px;
  background: var(--azul-claro); border-radius: var(--radio-sm);
  padding: 11px 13px; margin-top: 12px;
}
.doc-badge .ic { font-size: 1.35rem; }
.doc-badge .txt { display: flex; flex-direction: column; }
.doc-badge .txt strong { font-size: .9rem; color: var(--azul); }
.doc-badge .txt span { font-size: .78rem; color: var(--gris); }

/* ---- Detalle producto ---- */
.detail { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); }
.detail .foto-hero { font-size: 4.6rem; text-align: center; padding: 40px 0 34px; }
.detail .detail-body { padding: 20px; }
.detail h1 { margin: 0 0 4px; }
.detail .seller { margin: 4px 0 0; }
.detail .desc { margin: 14px 0; color: var(--tinta); }
.detail .stock-line { color: var(--gris); font-size: .88rem; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 12px 18px; border-radius: 12px;
  font-weight: 700; text-decoration: none; text-align: center;
  border: none; cursor: pointer; font-size: 1rem; line-height: 1.1;
}
.btn.primary { background: var(--azul); color: #fff; }
.btn.primary:active { background: var(--azul-hondo); }
.btn.ghost { background: #fff; color: var(--azul); border: 1.5px solid var(--linea); }
.btn.danger { background: #fbe9e7; color: #c0392b; }
.btn.full { display: flex; width: 100%; margin-top: 14px; }
.btn:disabled { background: var(--off); color: #fff; cursor: not-allowed; }
.quick-links { display: flex; gap: 8px; margin-top: 12px; }
.quick-links .btn { flex: 1; min-height: 42px; padding: 9px; font-size: .92rem; }

/* Barra fija inferior (CTA al pulgar) */
.stickybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--linea); box-shadow: var(--sombra-fuerte);
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.stickybar .inner { max-width: 540px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.stickybar .precio-cta { display: flex; flex-direction: column; line-height: 1.15; }
.stickybar .precio-cta .l { font-size: .72rem; color: var(--gris); }
.stickybar .precio-cta .v { font-size: 1.25rem; font-weight: 800; color: var(--azul); }
.stickybar .btn { flex: 1; }
.stickybar form { flex: 1; display: flex; }

/* ---- Listas / filas ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border: 1px solid var(--linea); border-radius: var(--radio-sm); padding: 12px 14px;
  text-decoration: none; color: inherit;
}
.row .emoji { font-size: 1.7rem; flex-shrink: 0; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-main strong { line-height: 1.2; }
.row-price { font-weight: 800; white-space: nowrap; }
.link-del { background: none; border: none; color: #c0392b; font-size: .82rem; font-weight: 600; cursor: pointer; min-height: 40px; padding: 0 4px; }

/* ---- Totales / split de pago ---- */
.totals { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); padding: 16px 16px 6px; margin: 16px 0; box-shadow: var(--sombra); }
.totals .titulo { font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.t-row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px dashed var(--linea); }
.t-row:last-child { border-bottom: none; }
.t-row.total { padding-top: 11px; font-size: 1.05rem; }
.t-row.total strong { font-size: 1.15rem; color: var(--azul); }
.t-row.neto { color: var(--ok); font-weight: 700; }
.t-row .lbl { color: var(--gris); font-size: .9rem; }
.t-row .lbl small { display: block; color: var(--gris-claro); font-size: .76rem; }

/* ---- Formularios ---- */
.pay-form, .form { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.form label, .pay-form label { font-weight: 700; font-size: .88rem; margin-top: 10px; }
input, select, textarea {
  padding: 13px; border: 1.5px solid var(--linea); border-radius: 11px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--tinta);
  width: 100%; min-height: var(--tap);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px var(--azul-claro); }
textarea { min-height: 88px; resize: vertical; }
.two { display: flex; gap: 12px; }
.two > div { flex: 1; }
.check-label { display: flex; align-items: center; gap: 10px; font-weight: 500; margin-top: 12px; }
.check-label input { width: auto; min-height: auto; }
.sim-badge { background: var(--warn-bg); color: var(--warn); padding: 10px 13px; border-radius: 10px; font-size: .84rem; text-align: center; margin: 14px 0 4px; font-weight: 600; }

/* ---- Confirmación ---- */
.ok-hero { text-align: center; padding: 18px 0 8px; }
.check { width: 66px; height: 66px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2.2rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; box-shadow: 0 6px 18px rgba(21,138,82,.3); }
.receipt { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); padding: 18px; margin-bottom: 14px; box-shadow: var(--sombra); }
.r-head { display: flex; align-items: center; gap: 12px; }
.r-head .emoji { font-size: 2.1rem; }
.r-split { display: flex; justify-content: space-between; margin: 16px 0; padding: 14px 0; border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea); text-align: center; }
.r-split > div { flex: 1; }
.r-split .rs-l { display: block; color: var(--gris); font-size: .74rem; margin-bottom: 3px; }
.r-split .rs-v { font-weight: 800; font-size: .98rem; }
.r-split .rs-v.neto { color: var(--ok); }
.r-doc { margin-top: 10px; }
.r-doc p { margin: 8px 0 0; }

/* ---- Alertas / estados vacíos ---- */
.alert { background: var(--azul-claro); color: var(--azul); padding: 13px 15px; border-radius: 11px; margin: 14px 0; font-size: .92rem; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.empty {
  background: #fff; border: 1.5px dashed var(--linea); border-radius: var(--radio);
  padding: 30px 22px; text-align: center; color: var(--gris); margin-top: 14px;
}
.empty .ic { font-size: 2.4rem; display: block; margin-bottom: 10px; }
.empty strong { display: block; color: var(--tinta); font-size: 1.02rem; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; display: inline-flex; }
.demo-note { background: #fff; border: 1.5px dashed var(--linea); border-radius: var(--radio); padding: 16px; color: var(--gris); margin-top: 16px; font-size: .9rem; }
code { background: #eef1f2; padding: 2px 6px; border-radius: 5px; font-size: .85em; }

/* Aviso de problemas del carro */
.problemas { background: var(--warn-bg); border: 1px solid #f0d089; border-radius: var(--radio-sm); color: var(--warn); padding: 13px 15px; margin: 12px 0; font-size: .9rem; }
.problemas div { padding: 2px 0; }

/* ---- Comité / stats ---- */
.activar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); padding: 16px; margin: 14px 0 10px; box-shadow: var(--sombra); }
.activar .btn { min-height: 42px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
.stat { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio-sm); padding: 15px; text-align: center; box-shadow: var(--sombra); }
.stat .n { display: block; font-weight: 800; font-size: 1.2rem; color: var(--azul); letter-spacing: -.01em; }
.stat .l { font-size: .78rem; color: var(--gris); margin-top: 2px; }

/* ---- Habitualidad ---- */
.habitualidad { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio-sm); padding: 15px; margin: 14px 0; box-shadow: var(--sombra); }
.bar { height: 12px; background: #eef1f2; border-radius: 999px; overflow: hidden; margin: 9px 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--acento), #ff9575); border-radius: 999px; }

/* ---- Footer ---- */
.foot { text-align: center; padding: 26px 20px 34px; color: var(--gris-claro); font-size: .82rem; }
.foot .marca { font-weight: 700; color: var(--gris); }
.edif-head { margin-bottom: 8px; }
