/* Casa Milagro — identidad: cercanía, tradición, innovación, confianza. */
:root {
  --crema: #fdf6ec;
  --masa: #f7e8d3;
  --corteza: #b4632c;
  --corteza-osc: #8a4a1e;
  --miga: #4a2f1b;
  --tinta: #2e2014;
  --verde: #2e7d4f;
  --rojo: #c0392b;
  --dorado: #e8a13c;
  --blanco: #fffdf9;
  --sombra: 0 4px 18px rgba(74, 47, 27, .10);
  --radio: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--crema);
  color: var(--tinta);
  line-height: 1.55;
}
main { max-width: 1080px; margin: 0 auto; padding: 1.2rem; min-height: 70vh; }
a { color: var(--corteza); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--miga); line-height: 1.2; }
h2 { margin: 1.2rem 0 .6rem; font-size: 1.15rem; }
code { background: var(--masa); padding: .1rem .4rem; border-radius: 6px; }

/* ── Barra superior ── */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.2rem; background: var(--blanco);
  border-bottom: 3px solid var(--dorado); position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 800; font-size: 1.25rem; color: var(--miga); }
.logo span { color: var(--corteza); }
.logo small { color: var(--dorado); font-size: .7em; vertical-align: super; }
.topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { padding: .35rem .7rem; border-radius: 8px; color: var(--miga); font-weight: 500; }
.topbar nav a:hover { background: var(--masa); text-decoration: none; }
.topbar nav a.activo { background: var(--masa); color: var(--corteza-osc); font-weight: 700; }
.topbar-der { display: flex; align-items: center; gap: .5rem; }
.tema-admin .topbar { border-bottom-color: var(--miga); }

/* ── Botones ── */
.btn {
  display: inline-block; background: var(--corteza); color: #fff; border: none;
  padding: .6rem 1.3rem; border-radius: 10px; font-weight: 700; font-size: .95rem;
  cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--corteza-osc); text-decoration: none; }
.btn:disabled { background: #c9b8a8; cursor: not-allowed; }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-lg { padding: .8rem 1.8rem; font-size: 1.05rem; }
.btn-claro { background: var(--masa); color: var(--corteza-osc); }
.btn-claro:hover { background: #efd9bb; }
.btn-peligro { background: var(--rojo); }
.btn-peligro:hover { background: #96281b; }
.btn-ghost { background: none; border: none; color: var(--miga); cursor: pointer; font-size: .95rem; padding: .35rem .6rem; }
.btn-ghost:hover { color: var(--corteza); }
.inline { display: inline; }

/* ── Hero ── */
.hero {
  display: flex; align-items: center; gap: 2rem; padding: 2.5rem 2rem;
  background: linear-gradient(120deg, var(--masa), var(--crema));
  border-radius: var(--radio); margin-top: 1rem;
}
.hero h1 { font-size: 2.3rem; margin: 0 0 .8rem; }
.hero em { color: var(--corteza); font-style: normal; }
.hero-acciones { display: flex; gap: .8rem; margin: 1.2rem 0; flex-wrap: wrap; }
.hero-puntos { background: var(--blanco); border-radius: 10px; padding: .6rem 1rem; display: inline-block; box-shadow: var(--sombra); }
.hero-emoji { font-size: 7rem; filter: drop-shadow(0 8px 12px rgba(74,47,27,.25)); }

/* ── Productos ── */
.seccion { margin: 2rem 0; }
.titulo-pagina { margin: 1.2rem 0; display: flex; align-items: baseline; gap: .5rem .8rem; flex-wrap: wrap; }
.campo .nota { margin: .1rem 0 0; }
.grilla-productos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.producto { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; display: flex; flex-direction: column; }
.producto-img { font-size: 3.2rem; text-align: center; padding: 1.1rem 0 .4rem; background: var(--masa); }
.producto-info { padding: .8rem 1rem 1rem; display: flex; flex-direction: column; flex: 1; }
.producto-info h3 { margin: 0 0 .2rem; font-size: 1rem; }
.producto-info p { margin: 0; font-size: .85rem; color: #6b5742; flex: 1; }
.producto-pie { display: flex; justify-content: space-between; align-items: center; margin-top: .8rem; }
.tres-pilares { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.pilar { background: var(--blanco); border-radius: var(--radio); padding: 1.2rem; box-shadow: var(--sombra); text-align: center; }
.pilar span { font-size: 2rem; }
.pilar h3 { margin: .5rem 0 .3rem; }
.pilar p { margin: 0; font-size: .9rem; color: #6b5742; }

/* ── Tarjetas y paneles ── */
.tarjeta { background: var(--blanco); border-radius: var(--radio); padding: 1.2rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.tarjeta h2:first-child { margin-top: 0; }
.grilla-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 1rem; }
.grilla-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .grilla-2col { grid-template-columns: 1fr; } }
.tarjeta-nivel { background: linear-gradient(120deg, var(--miga), var(--corteza-osc)); color: var(--crema); }
.tarjeta-nivel .nota, .tarjeta-nivel h2 { color: #ecd9c2; }
.nivel-cabecera { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.nivel-nombre { font-size: 1.3rem; font-weight: 800; }
.puntos-grandes { font-size: 1.6rem; font-weight: 800; color: var(--dorado); }
.puntos-grandes small { font-size: .6em; color: #ecd9c2; }
.barra { background: rgba(255,255,255,.25); height: 10px; border-radius: 5px; margin: .8rem 0 .4rem; }
.barra-relleno { background: var(--dorado); height: 100%; border-radius: 5px; }
.codigo-referido {
  font-size: 1.4rem; font-weight: 800; letter-spacing: .12em; text-align: center;
  border: 2px dashed var(--corteza); border-radius: 10px; padding: .7rem; margin: .6rem 0; color: var(--corteza-osc);
}
.lista-canjes { list-style: none; padding: 0; margin: 0; }
.lista-canjes li { display: flex; justify-content: space-between; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--masa); }
.cupon-fila { padding: .4rem 0; border-bottom: 1px solid var(--masa); }

/* ── Formularios ── */
.tarjeta-auth { max-width: 420px; margin: 2.5rem auto; background: var(--blanco); border-radius: var(--radio); padding: 1.8rem; box-shadow: var(--sombra); }
.tarjeta-auth.ancha { max-width: 660px; }
.tarjeta-auth h1 { margin-top: 0; font-size: 1.5rem; }
.campo { margin-bottom: .8rem; display: flex; flex-direction: column; gap: .25rem; }
.campo label { font-size: .85rem; font-weight: 600; color: var(--miga); }
input, select, textarea {
  padding: .55rem .7rem; border: 1.5px solid #ddc9b0; border-radius: 9px;
  font-size: .95rem; background: var(--blanco); color: var(--tinta); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--dorado); border-color: var(--dorado); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .9rem; align-items: end; }
.form-grid .doble { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.nivel-fila { border-bottom: 1px solid var(--masa); padding-bottom: .5rem; margin-bottom: .5rem; }

/* ── Tablas ── */
.tabla { width: 100%; border-collapse: collapse; background: var(--blanco); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); }
.tabla th { text-align: left; background: var(--masa); padding: .6rem .7rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--miga); }
.tabla td { padding: .55rem .7rem; border-top: 1px solid #f1e4d2; vertical-align: top; font-size: .92rem; }
.tabla.compacta { box-shadow: none; }
.tabla.compacta td { padding: .35rem .4rem; }
.fila-apagada { opacity: .5; }
.pos { color: var(--verde); font-weight: 700; }
.neg { color: var(--rojo); font-weight: 700; }

/* ── KPIs y CRM ── */
.grilla-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.kpi { background: var(--blanco); border-radius: var(--radio); padding: .9rem 1rem; box-shadow: var(--sombra); display: flex; flex-direction: column; }
.kpi-valor { font-size: 1.45rem; font-weight: 800; color: var(--corteza-osc); }
.kpi-etiqueta { font-size: .8rem; color: #6b5742; font-weight: 600; }
.kpi-detalle { font-size: .78rem; color: #9b8367; }
.filtros { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; background: var(--blanco); box-shadow: var(--sombra); font-size: .85rem; color: var(--miga); }
.chip:hover { text-decoration: none; background: var(--masa); }
.chip-activo { background: var(--corteza); color: #fff; font-weight: 700; }
.busqueda input { min-width: 230px; }
.lista-alertas { padding-left: 1.1rem; margin: .3rem 0 .8rem; }
.seg { padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.seg-vip { background: #fbe7c2; color: #8a5a00; }
.seg-frecuente { background: #d9efe2; color: #1d5c38; }
.seg-activo { background: #ddebf7; color: #1f4e79; }
.seg-recuperable { background: #fde3cf; color: #9c4a00; }
.seg-inactivo { background: #eee3e1; color: #7b3b32; }
.seg-nuevo { background: #ece7f5; color: #4a3a78; }
.seg-pos { background: #fbe7c2; color: #8a5a00; }
.seg-online { background: #ddebf7; color: #1f4e79; }
.estado { padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.estado-pendiente { background: #fbe7c2; color: #8a5a00; }
.estado-confirmado { background: #ddebf7; color: #1f4e79; }
.estado-entregado { background: #d9efe2; color: #1d5c38; }
.estado-cancelado { background: #eee3e1; color: #7b3b32; }
.pedido-cabecera { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }

/* ── Carrito y checkout ── */
.carrito-link { font-size: 1.05rem; }
.badge-n { background: var(--corteza); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .8rem; font-weight: 700; }
.checkout-caja { background: var(--blanco); border-radius: var(--radio); padding: 1.2rem; box-shadow: var(--sombra); margin-top: 1rem; max-width: 480px; }
.fila-cupon { display: flex; gap: .5rem; }
.fila-cupon input { flex: 1; }
.totales { margin: 1rem 0; }
.totales > div { display: flex; justify-content: space-between; padding: .25rem 0; }
.total-final { font-size: 1.2rem; font-weight: 800; border-top: 2px solid var(--masa); margin-top: .3rem; padding-top: .5rem !important; }
.cantidad-control { display: flex; align-items: center; gap: .4rem; }
.cantidad-control button { width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--masa); cursor: pointer; font-weight: 700; }

/* ── POS / Caja de mostrador ── */
.pos-grid { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .pos-grid { grid-template-columns: 1fr; } }
.grilla-pos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.pos-prod {
  background: var(--blanco); border: 1.5px solid #ddc9b0; border-radius: var(--radio);
  padding: .7rem .5rem; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: .2rem; font-family: inherit; font-size: .85rem; color: var(--tinta);
}
.pos-prod:hover { border-color: var(--dorado); background: var(--masa); }
.pos-emoji { font-size: 1.8rem; }
.pos-ticket { position: sticky; top: 70px; }
.pos-ticket .campo { margin-top: .8rem; }

/* ── Encuestas ── */
.encuesta { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; margin-top: .5rem; background: var(--crema); padding: .6rem; border-radius: 10px; }
.estrella input { display: none; }
.estrella span { font-size: 1.4rem; color: #d8c5ab; cursor: pointer; }
.estrella input:checked + span, .estrella:has(~ .estrella input:checked) span { color: var(--dorado); }
.encuesta input[name="comentario"] { flex: 1; min-width: 160px; }

/* ── Mensajes ── */
.alerta { background: #fbe3e0; color: var(--rojo); border-radius: 10px; padding: .6rem .9rem; margin-bottom: .8rem; }
.exito { background: #d9efe2; color: var(--verde); border-radius: 10px; padding: .6rem .9rem; margin-bottom: .8rem; }
.flash { background: var(--dorado); color: var(--miga); text-align: center; padding: .5rem; font-weight: 600; }
.nota { font-size: .85rem; color: #8d7456; }
.centro { text-align: center; }
.vacio { text-align: center; padding: 2.5rem; background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); font-size: 1.05rem; }
.oculto { display: none; }
.pie { text-align: center; padding: 1.6rem; color: #9b8367; font-size: .85rem; }

@media (max-width: 700px) {
  .hero { flex-direction: column; text-align: center; padding: 1.6rem 1rem; }
  .hero h1 { font-size: 1.7rem; }
  .hero-emoji { font-size: 4.5rem; }
  .hero-acciones { justify-content: center; }
  main { padding: .8rem; }
  .tabla { display: block; overflow-x: auto; }
}
