:root {
  --crema: #FAF5EE;
  --verde: #3c4a36;
  --hoja: #6b7d4e;
  --terra: #C0793F;
  --gris: #6b6459;
  --suave: #F1EADD;
  --borde: #E4D9C6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--crema);
  color: var(--verde);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}

body.centrado { display: flex; align-items: center; justify-content: center; }

.pantalla { width: 100%; max-width: 440px; margin: 0 auto; padding: 22px 18px 40px; }

.marca { display: block; width: 190px; margin: 0 auto 22px; }

.encabezado {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.chip {
  font-size: 11px; letter-spacing: 2px; font-weight: 700; color: #8a8578;
  background: var(--suave); border-radius: 30px; padding: 9px 16px;
}

.salir { font-size: 13px; color: var(--gris); text-decoration: none; }

.tarjeta {
  background: #fff; border-radius: 22px; padding: 24px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.05); margin-bottom: 16px;
}

.hola { text-align: center; font-size: 17px; color: var(--gris); margin-bottom: 4px; }

.conteo { text-align: center; line-height: 1; }
.conteo b { font-size: 52px; color: var(--verde); }
.conteo span { font-size: 26px; color: #9c9484; }

.sub { text-align: center; font-size: 15px; color: var(--gris); margin: 6px 0 20px; }

.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.tab {
  flex: 1; font-size: 12px; font-weight: 700; padding: 10px 6px; border: 0;
  border-radius: 20px; background: var(--suave); color: #8a8578; cursor: pointer;
}
.tab.on { background: var(--verde); color: #fff; }

.slots {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px; justify-items: center;
}
.slot {
  width: 100%; max-width: 60px; aspect-ratio: 1;
  border-radius: 50%; border: 2px dashed var(--borde); background: #FDFBF7;
  display: flex; align-items: center; justify-content: center;
}
.slot.full { border: 2px solid var(--terra); background: #FBF1E6; }
.slot img { width: 68%; }

.boton {
  display: block; width: 100%; background: var(--terra); color: #fff;
  border: 0; border-radius: 16px; padding: 18px; font-size: 18px;
  font-weight: 700; cursor: pointer; margin-bottom: 12px;
}
.boton:active { opacity: .85; }
.boton:disabled { opacity: .5; }
.boton.plano { background: transparent; color: var(--gris); font-size: 15px; padding: 12px; }

.etiqueta {
  font-size: 12px; letter-spacing: 1.5px; font-weight: 700;
  color: var(--terra); margin-bottom: 10px;
}

.campo {
  width: 100%; border: 1.5px solid #EFE4D2; background: #FDFBF7;
  border-radius: 12px; padding: 16px 14px; font-size: 17px;
  color: var(--verde); margin-bottom: 14px; outline: none;
}
.campo:focus { border-color: var(--terra); }
.campo.pin { letter-spacing: 10px; text-align: center; font-size: 24px; }

.ayuda { text-align: center; font-size: 14px; color: #7a7466; line-height: 1.5; }

.error {
  background: #FDECEA; color: #A03328; border-radius: 10px;
  padding: 11px 14px; font-size: 14px; margin-bottom: 14px;
}

.pie { text-align: center; font-size: 14px; color: #7a7466; line-height: 1.6; margin-top: 18px; }

.premio {
  background: #F1F4EA; border-radius: 18px; padding: 20px 16px;
  margin-top: 20px; text-align: center;
}
.premio .pt { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.premio .pd { font-size: 14px; color: var(--hoja); margin-bottom: 14px; }
.premio .pe { font-size: 12px; color: #8a8578; margin-top: 10px; }
.qrCanje { display: flex; justify-content: center; }
.qrCanje img, .qrCanje canvas { border-radius: 6px; }

.lector {
  background: #fff; border-radius: 22px; padding: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,.05); margin-bottom: 16px;
}
#qr { width: 100%; border-radius: 14px; overflow: hidden; }
.manual { margin-top: 18px; padding-top: 18px; border-top: 1px solid #F0EAE0; }

.aviso {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px;
  max-width: 400px; width: calc(100% - 36px); padding: 15px 18px;
  border-radius: 14px; font-size: 15px; font-weight: 600; text-align: center;
  color: #fff; z-index: 50;
}
.aviso.ok { background: #4a7a3d; }
.aviso.mal { background: #B4453A; }

.oculto { display: none !important; }

/* ---------- panel de vendedor ---------- */
.marcador { display: flex; gap: 12px; margin-top: 16px; }
.mitem {
  flex: 1; background: #F7F5EE; border-radius: 14px; padding: 16px 10px; text-align: center;
}
.mitem b { display: block; font-size: 32px; color: var(--verde); line-height: 1.1; }
.mitem span { font-size: 13px; color: var(--gris); }

.valido {
  text-align: center; font-size: 13px; font-weight: 700; letter-spacing: 1.5px;
  color: #4a7a3d; margin-bottom: 10px;
}
.entrega { text-align: center; font-size: 24px; margin-bottom: 6px; }
.detalle { text-align: center; font-size: 14px; color: var(--gris); margin-bottom: 20px; }

/* ---------- panel de administracion ---------- */
.pantalla.ancha { max-width: 900px; }

.kpis { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.kpi {
  flex: 1; min-width: 110px; background: #fff; border-radius: 16px;
  padding: 16px 10px; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.kpi b { display: block; font-size: 30px; color: var(--verde); line-height: 1.15; }
.kpi span { font-size: 12px; color: var(--gris); }

.formfila { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.formfila .campo { flex: 1; min-width: 130px; margin-bottom: 8px; }
.formfila .boton { width: auto; padding: 16px 22px; margin-bottom: 8px; }

.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th {
  text-align: left; font-size: 11px; letter-spacing: 1px; color: #8a8578;
  padding: 8px 6px; border-bottom: 2px solid #EFE9DE; text-transform: uppercase;
}
.tabla td { padding: 10px 6px; border-bottom: 1px solid #F3EEE4; }
.tabla td.vacio { text-align: center; color: #9c9484; padding: 18px; }

.estado {
  font-size: 11px; padding: 4px 9px; border-radius: 20px;
  background: #F1EADD; color: #7a7466;
}
.estado.impreso { background: #FBF1E6; color: var(--terra); }
.estado.circulacion { background: #F1F4EA; color: #4a7a3d; }

.mini { font-size: 13px; color: var(--terra); text-decoration: none; font-weight: 600; }

select.campo { appearance: none; background-image: none; }

/* ---------- graficas ---------- */
.cabtarjeta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.segmentos { display: flex; gap: 4px; }
.seg {
  font-size: 12px; font-weight: 700; padding: 7px 14px; border-radius: 20px;
  background: var(--suave); color: #8a8578; text-decoration: none;
}
.seg.on { background: var(--verde); color: #fff; }

.grafica {
  display: flex; align-items: flex-end; gap: 4px; height: 180px;
  padding: 10px 0 0; overflow-x: auto;
}
.grafica.chica { height: 110px; }
.barra {
  flex: 1; min-width: 22px; display: flex; flex-direction: column;
  align-items: center; height: 100%;
}
.barra .pila { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.barra .col {
  width: 100%; background: var(--terra); border-radius: 5px 5px 0 0;
  min-height: 2px; transition: opacity .15s;
}
.barra .col.hora { background: var(--hoja); }
.barra:hover .col { opacity: .75; }
.barra .valor { font-size: 10px; color: var(--gris); margin-bottom: 3px; }
.barra .eje { font-size: 9px; color: #9c9484; margin-top: 5px; white-space: nowrap; }

.leyenda { font-size: 12px; color: var(--gris); margin-top: 10px; }
.ll { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.ll.sellos { background: var(--terra); }
.ll.canjes { background: var(--hoja); }

.mt { margin-top: 16px; }
.columnas { display: flex; gap: 12px; flex-wrap: wrap; }
.columnas > .tarjeta { flex: 1; min-width: 260px; }
.scrollx { overflow-x: auto; }
.vacio { text-align: center; color: #9c9484; padding: 22px; font-size: 14px; }

.estado.abierta { background: #FBF1E6; color: var(--terra); }
.estado.completa { background: #F1F4EA; color: #4a7a3d; }
.estado.canjeada { background: #EDEFF3; color: #5a6472; }
.estado.vencida { background: #FDECEA; color: #A03328; }

/* ---------- historial ---------- */
.linea { margin-top: 6px; }
.mitem2 {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid #F3EEE4; align-items: baseline;
}
.mitem2:last-child { border-bottom: 0; }
.mfecha { font-size: 12px; color: #9c9484; min-width: 108px; }
.mtexto { font-size: 14px; color: var(--verde); }
.mitem2.canje .mtexto { color: #4a7a3d; }
.mpuesto {
  font-size: 11px; color: #8a8578; background: var(--suave);
  padding: 2px 8px; border-radius: 20px; margin-left: 6px;
}

.mov { font-size: 11px; padding: 3px 9px; border-radius: 20px;
       background: var(--suave); color: #7a7466; }
.mov.canje { background: #F1F4EA; color: #4a7a3d; }

.destacado { background: #F1F4EA; text-align: center; }
.ahorro { font-size: 26px; font-weight: 700; color: #4a7a3d; }
.ahorrosub { font-size: 14px; color: var(--gris); margin-top: 4px; }

.enlace-historial {
  display: block; text-align: center; font-size: 14px; color: var(--gris);
  text-decoration: none; padding: 12px; margin-bottom: 10px;
}

/* ---------- equipo ---------- */
.enlinea { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.campo.chico {
  padding: 7px 9px; font-size: 13px; margin: 0; min-width: 110px; width: auto;
}
.boton-mini {
  background: var(--suave); border: 0; border-radius: 8px; padding: 7px 11px;
  font-size: 12px; font-weight: 600; color: var(--verde); cursor: pointer;
}
.boton-mini:hover { background: #E8E0D0; }
.acciones { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
tr.apagado { opacity: .5; }
.exito {
  background: #F1F4EA; color: #3d6b32; border-radius: 10px;
  padding: 11px 14px; font-size: 14px; margin-bottom: 14px;
}
.enlaces-admin { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.enlaces-admin a {
  flex: 1; text-align: center; background: #fff; border-radius: 14px;
  padding: 14px 10px; text-decoration: none; color: var(--verde);
  font-size: 14px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

/* ---------- ajustes moviles del panel ---------- */
@media (max-width: 700px) {
  .pantalla.ancha { padding: 16px 12px 40px; }

  .scrollx {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
  }
  .scrollx .tabla { min-width: 620px; }
  .scrollx .tabla th, .scrollx .tabla td { white-space: nowrap; }

  .tarjeta { padding: 18px 16px; overflow: hidden; }
  .tabla { font-size: 13px; }
  .tabla th { font-size: 10px; }
  .tabla td, .tabla th { padding: 8px 5px; }

  .kpis { gap: 8px; }
  .kpi { min-width: calc(50% - 4px); padding: 14px 8px; }
  .kpi b { font-size: 24px; }

  .formfila { flex-direction: column; }
  .formfila .campo, .formfila .boton { width: 100%; min-width: 0; }

  .columnas { flex-direction: column; }
  .columnas > .tarjeta { min-width: 0; }

  .grafica { gap: 3px; }
  .barra { min-width: 18px; }
  .barra .valor { font-size: 9px; }

  .acciones { flex-direction: column; align-items: stretch; }
  .acciones .enlinea { width: 100%; }
  .campo.chico { min-width: 0; flex: 1; }
}

/* ---------- edicion de presentaciones ---------- */
.bloque-pres {
  border: 1px solid #EFE9DE; border-radius: 14px;
  padding: 16px; margin-bottom: 12px; background: #FDFBF7;
}
.fila-pres { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.campo-etq { display: flex; flex-direction: column; gap: 4px; }
.campo-etq.ancho { flex: 1; min-width: 200px; }
.campo-etq label {
  font-size: 10px; letter-spacing: .5px; color: #8a8578;
  text-transform: uppercase; font-weight: 700;
}
.campo-etq .campo.chico { margin: 0; }
.pie-pres {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid #F0EAE0;
}
.pie-pres .dato { font-size: 12px; color: #8a8578; }
.bloque-pres.apagado { opacity: .55; }

@media (max-width: 700px) {
  .campo-etq { flex: 1; min-width: calc(50% - 5px); }
  .campo-etq .campo.chico { width: 100%; }
}
