:root {
  --paprika: #B4432B;
  --paprika-oscuro: #8f3320;
  --fondo: #f4f1ee;
  --tarjeta: #ffffff;
  --texto: #2b2b2b;
  --suave: #6b6b6b;
  --linea: #e6e0da;
  --ok: #2f7d4f;
  --ok-fondo: #e8f4ec;
  --pago: #8a5a00;
  --pago-fondo: #fff4dc;
  --alerta: #a3281a;
  --alerta-fondo: #fdeceb;
  --proceso-fondo: #eef1f6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Montserrat, Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--texto);
  background: var(--fondo);
  padding-bottom: 96px;
}

.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--paprika); color: #fff;
  padding: 12px 16px;
}
.marca { font-size: 18px; letter-spacing: .2px; }
.enlace-claro { background: none; border: 0; color: #fff; font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; margin: 8px 0 6px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
p { margin: 0 0 12px; }
.suave { color: var(--suave); font-size: 14px; }

.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 10px;
  padding: 16px; margin-bottom: 12px;
}

label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input[type=text], input[type=tel], input[type=search], textarea {
  width: 100%; font: inherit; font-size: 17px;
  padding: 12px 14px; border: 1px solid #cfc6bd; border-radius: 8px; background: #fff; color: var(--texto);
}
input:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(180,67,43,.35); outline-offset: 1px; border-color: var(--paprika); }
textarea { min-height: 70px; resize: vertical; font-size: 16px; }
.rut { font-size: 22px; letter-spacing: 1px; text-align: center; }
.codigo { font-size: 28px; letter-spacing: 10px; text-align: center; }

.boton {
  display: block; width: 100%; min-height: 50px;
  font: inherit; font-weight: 700; font-size: 17px;
  color: #fff; background: var(--paprika); border: 0; border-radius: 10px;
  padding: 12px 16px; cursor: pointer; margin-top: 16px;
}
.boton:hover { background: var(--paprika-oscuro); }
.boton[disabled] { background: #cdbfb6; cursor: not-allowed; }
.boton.secundario { background: #fff; color: var(--paprika); border: 2px solid var(--paprika); }
.enlace { background: none; border: 0; color: var(--paprika); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 8px 0; }

.error { background: var(--alerta-fondo); color: var(--alerta); border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: 15px; }
.aviso { background: var(--pago-fondo); color: var(--pago); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 12px 0; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--linea); font-weight: 500; margin: 0; }
.check:last-of-type { border-bottom: 0; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--paprika); margin-top: 1px; }
.check small { display: block; color: var(--suave); font-weight: 400; }

.opcion {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--texto);
  background: #fff; border: 1px solid var(--linea); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.opcion:hover { border-color: var(--paprika); }
.opcion b { display: block; }
.opcion .fila { display: flex; justify-content: space-between; gap: 10px; }
.opcion.nuevo { background: var(--paprika); color: #fff; border-color: var(--paprika); text-align: center; font-weight: 700; }

.linea { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 0; border-bottom: 1px solid var(--linea); }
.linea:last-child { border-bottom: 0; }
.linea .nombre { font-weight: 600; }
.linea .meta { color: var(--suave); font-size: 13px; grid-column: 1 / -1; }
.linea .nota { color: var(--pago); font-size: 13px; font-weight: 600; grid-column: 1 / -1; }
.linea .monto { text-align: right; font-weight: 600; white-space: nowrap; }

.cantidad { display: flex; align-items: center; gap: 0; border: 1px solid #cfc6bd; border-radius: 8px; overflow: hidden; width: max-content; }
.cantidad button { width: 44px; height: 44px; border: 0; background: #f1ebe6; color: var(--paprika); font-size: 22px; font-weight: 700; cursor: pointer; }
.cantidad input { width: 64px; height: 44px; border: 0; border-left: 1px solid #cfc6bd; border-right: 1px solid #cfc6bd; border-radius: 0; text-align: center; font-size: 17px; padding: 0; }
.quitar { background: none; border: 0; color: var(--suave); font-size: 14px; text-decoration: underline; cursor: pointer; }

.producto { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--linea); }
.producto .info { min-width: 0; }
.producto .info b { display: block; }
.producto .agregar { flex: none; min-width: 92px; min-height: 44px; border-radius: 8px; border: 2px solid var(--paprika); background: #fff; color: var(--paprika); font: inherit; font-weight: 700; cursor: pointer; }
.producto .agregar[disabled] { border-color: #cdbfb6; color: #9a8f86; cursor: not-allowed; }
.etiqueta { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 4px; padding: 1px 6px; }
.agotado { background: #ece6e1; color: #6b5f56; }
.vencida { background: var(--alerta-fondo); color: var(--alerta); }

.resultado { border-radius: 10px; padding: 16px; margin-bottom: 14px; border: 1px solid transparent; }
.resultado h1 { margin-top: 0; }
.resultado.ok { background: var(--ok-fondo); border-color: #b9dcc6; }
.resultado.pago { background: var(--pago-fondo); border-color: #f1d79f; }
.resultado.alerta { background: var(--alerta-fondo); border-color: #f2c0bb; }
.resultado.proceso { background: var(--proceso-fondo); border-color: #cfd7e6; }

.totales { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 10px; }
.totales .fuerte { font-weight: 700; font-size: 18px; }

.pie {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-top: 1px solid var(--linea);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.pie-montos { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pie-montos span { font-size: 13px; color: var(--suave); }
.pie-montos strong { font-size: 19px; }
.pie .boton { width: auto; margin: 0; min-width: 150px; }

.cargando { text-align: center; color: var(--suave); padding: 32px 0; }
.vacio { text-align: center; color: var(--suave); padding: 20px 0; }

@media (max-width: 380px) {
  .pie .boton { min-width: 0; padding: 12px; font-size: 15px; }
  .codigo { letter-spacing: 6px; }
}
