/* Cambiagro CRECE · dirección visual "Bóveda verde" */
@font-face { font-family: "Jakarta"; src: url("plus-jakarta-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Jakarta"; src: url("plus-jakarta-sans-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("inter-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("inter-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("inter-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --verde: #1a5c2a;
  --acento: #00a651;
  --tinta: #10231a;
  --texto-2: #37423a;
  --apagado: #66726a;
  --fondo: #f5f7f5;
  --blanco: #ffffff;
  --linea: #e6ebe7;
  --menta: #e7f6ed;
  --claro: #d5e4d8;
  --error: #b42318;
  --error-suave: #fdecea;
  --aviso: #8a5a00;
  --aviso-suave: #fff4dc;
  --info: #1f5f8b;
  --info-suave: #e7f1f8;
  --display: "Jakarta", "Inter", system-ui, sans-serif;
  --texto: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --nav-alto: 76px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--tinta); font: 16px/1.45 var(--texto); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--display); line-height: 1.1; text-wrap: balance; }
.oculto { display: none !important; }
svg { width: 20px; height: 20px; flex: none; }
.pj { font-family: var(--display); }
.num { font-variant-numeric: tabular-nums; }

/* Decoración: píldoras escalonadas */
.pildoras { position: absolute; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.pildoras i { display: block; height: 26px; border-radius: 999px; background: rgba(0,166,81,.28); }
.pildoras i:nth-child(2) { background: rgba(0,166,81,.18); }
.pildoras i:nth-child(3) { background: rgba(0,166,81,.10); }

.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo b { font-family: var(--display); font-weight: 800; font-size: 19px; letter-spacing: -.3px; }
.logo span { font-family: var(--display); font-weight: 800; font-size: 11px; letter-spacing: 1.6px; padding: 4px 10px; border-radius: 999px; background: var(--acento); color: var(--tinta); }

/* ---------- Arranque e ingreso ---------- */
.arranque, .ingreso {
  min-height: 100vh; min-height: 100dvh; background: var(--verde); color: #fff; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  padding: calc(48px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.arranque { align-items: center; justify-content: center; gap: 24px; }
.cargando { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.ingreso-interno { width: 100%; max-width: 380px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; position: relative; }
.ingreso h1 { margin-top: 56px; font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; }
.ingreso p { margin: 10px 0 0; color: var(--claro); font-size: 15px; }
.campo-verde { margin-top: 26px; }
.campo-verde label { display: block; font-size: 13px; font-weight: 600; letter-spacing: .4px; color: var(--claro); margin-bottom: 6px; }
.entrada-verde { width: 100%; min-height: 52px; padding: 12px 18px; border-radius: 999px; border: 1.5px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); color: #fff; font-size: 16px; }
.entrada-verde::placeholder { color: rgba(255,255,255,.55); }
.entrada-verde:focus { outline: none; border-color: var(--acento); background: rgba(255,255,255,.12); }
.puntos { display: flex; gap: 16px; align-items: center; margin-top: 28px; min-height: 18px; }
.puntos i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); }
.puntos i.lleno { width: 18px; height: 18px; border: 0; background: var(--acento); }
.teclado { margin-top: auto; padding-top: 24px; display: grid; grid-template-columns: repeat(3, 1fr); row-gap: 12px; justify-items: center; }
.teclado button { width: 72px; height: 72px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #fff; font: 600 28px var(--display); cursor: pointer; }
.teclado button:active { background: rgba(255,255,255,.2); }
.teclado .sin-fondo { background: none; display: grid; place-items: center; }
.teclado svg { width: 26px; height: 26px; }
.nota-verde { margin-top: 14px; text-align: center; font-size: 14px; color: var(--claro); }

/* ---------- Encabezado verde (bóveda) ---------- */
.boveda {
  background: var(--verde); color: #fff; position: relative; overflow: hidden;
  padding: calc(18px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 64px max(20px, env(safe-area-inset-left));
}
.boveda .pildoras { bottom: 26px; right: -30px; flex-direction: row; }
.boveda .pildoras i { height: 22px; }
.boveda-interno { max-width: 1100px; margin: 0 auto; position: relative; }
.boveda-sup { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ojo { font-size: 12px; font-weight: 600; letter-spacing: 1.6px; color: var(--claro); text-transform: uppercase; }
.quien { font-family: var(--display); font-size: 19px; font-weight: 700; margin-top: 2px; }
.boton-redondo { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; cursor: pointer; }
.boton-redondo svg { width: 20px; height: 20px; }
.cifra-etiqueta { margin-top: 26px; font-size: 13px; color: var(--claro); }
.cifra { font-family: var(--display); font-weight: 800; font-size: 50px; letter-spacing: -2px; line-height: 1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.cifra small { font-size: 22px; letter-spacing: -.5px; font-weight: 700; }
.pastillas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pastilla { padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: 13px; }
.pastilla span { color: var(--claro); }
.pastilla strong { font-weight: 600; }
button.pastilla { border: 0; color: #fff; cursor: pointer; }
button.pastilla[aria-pressed="true"] { background: var(--acento); color: var(--tinta); }
.aviso-red { margin-top: 14px; padding: 10px 14px; border-radius: 14px; background: rgba(255,244,220,.15); color: #ffe6a8; font-size: 13px; }

/* ---------- Hoja de contenido ---------- */
main {
  position: relative; margin-top: -36px; background: var(--blanco); border-radius: 28px 28px 0 0;
  min-height: calc(100dvh - 160px);
  padding: 22px max(20px, env(safe-area-inset-right)) calc(var(--nav-alto) + 28px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.contenido { max-width: 1100px; margin: 0 auto; }
.angosto { max-width: 560px; margin: 0 auto; }
.titulo-seccion { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 22px 0 12px; }
.titulo-seccion:first-child { margin-top: 2px; }
.titulo-seccion h2 { font-size: 17px; font-weight: 700; }
.titulo-seccion a, .enlace { font-size: 14px; font-weight: 500; color: var(--verde); background: none; border: 0; cursor: pointer; padding: 0; }
.sub { color: var(--apagado); font-size: 14px; }
.lista { display: grid; gap: 10px; }
.rejilla { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.vacio { text-align: center; color: var(--apagado); padding: 28px 12px; background: var(--fondo); border-radius: 20px; }
.vacio strong { display: block; font-family: var(--display); color: var(--tinta); font-size: 17px; margin-bottom: 4px; }

/* ---------- Tarjetas de lista ---------- */
.fila {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border-radius: 18px;
  background: var(--fondo); border: 0; text-align: left; cursor: pointer; color: inherit;
}
.fila .icono { width: 42px; height: 42px; flex: none; border-radius: 14px; background: var(--verde); color: #fff; display: grid; place-items: center; }
.fila .icono.gris { background: var(--linea); color: var(--apagado); }
.fila .icono svg { width: 20px; height: 20px; }
.fila .centro { flex: 1; min-width: 0; }
.fila .titulo { font-family: var(--display); font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.fila .linea2 { font-size: 13px; color: var(--apagado); margin-top: 2px; overflow-wrap: anywhere; }
.fila .derecha { text-align: right; flex: none; }
.fila .monto { font-family: var(--display); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila.apagada .titulo, .fila.apagada .monto { color: var(--apagado); }
.estado { display: inline-block; margin-top: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.e-Emitido, .e-Activa, .e-En_Proceso { background: var(--menta); color: var(--verde); }
.e-Canjeado { background: var(--aviso-suave); color: var(--aviso); }
.e-Pagado, .e-Pagada { background: var(--verde); color: #fff; }
.e-Vencido, .e-Vencida, .e-Cerrada, .e-Borrador { background: var(--linea); color: var(--texto-2); }
.e-Anulado, .e-Cancelada { background: var(--error-suave); color: var(--error); }

.tarjeta { background: var(--fondo); border-radius: 22px; padding: 18px; min-width: 0; }
.tarjeta .cabeza { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.tarjeta h3 { font-size: 17px; font-weight: 800; }
.datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px 14px; margin-top: 14px; }
.dato .k { font-size: 12px; color: var(--apagado); }
.dato .v { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.avance { height: 8px; border-radius: 999px; background: var(--blanco); overflow: hidden; margin-top: 14px; }
.avance span { display: block; height: 100%; border-radius: 999px; background: var(--verde); }
.tarjeta .avance { background: var(--linea); }
.leyenda { display: flex; justify-content: space-between; font-size: 13px; color: var(--texto-2); margin-top: 6px; }

.alertas { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.alerta { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; cursor: pointer; padding: 14px; border-radius: 18px; background: var(--fondo); color: var(--texto-2); font-size: 14px; }
.alerta .icono { width: 40px; height: 40px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--menta); color: var(--verde); }
.alerta .icono svg { width: 20px; height: 20px; }
.alerta b { font-family: var(--display); font-size: 20px; color: var(--tinta); margin-right: 4px; }
.alerta.activa { background: var(--aviso-suave); color: var(--aviso); }
.alerta.activa .icono { background: #fde7b0; color: var(--aviso); }

.resumen { border-radius: 24px; background: var(--menta); padding: 20px; }
.resumen .arriba { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--texto-2); }
.resumen .grande { font-family: var(--display); font-weight: 800; font-size: 42px; letter-spacing: -1.5px; color: var(--verde); margin-top: 4px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.resumen .abajo { margin-top: 8px; font-size: 13px; color: var(--texto-2); }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 16px; }
.campo label, .etiqueta { display: block; font-size: 13px; font-weight: 600; color: var(--texto-2); margin-bottom: 8px; }
.ayuda { font-size: 13px; color: var(--apagado); margin-top: 6px; }
.entrada {
  width: 100%; min-height: 56px; padding: 14px 16px; border: 1.5px solid transparent; border-radius: 18px;
  background: var(--fondo); font-size: 16px; color: var(--tinta);
}
.entrada:focus { outline: none; border-color: var(--acento); background: #fff; }
select.entrada { appearance: none; padding-right: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2366726a' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
.entrada.codigo { font-family: var(--mono); text-transform: uppercase; letter-spacing: .5px; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.contador { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 18px; background: var(--fondo); }
.contador .mandos { display: flex; align-items: center; gap: 6px; }
.contador button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: var(--tinta); font-size: 22px; cursor: pointer; }
.contador button.mas { background: var(--verde); color: #fff; }
.contador input { width: 64px; text-align: center; border: 0; background: transparent; font: 800 22px var(--display); color: var(--tinta); }
.contador input:focus { outline: 2px solid var(--acento); border-radius: 10px; }
.campo-fijo { padding: 16px; border-radius: 18px; background: var(--fondo); }
.campo-fijo .v { font-weight: 600; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 22px; border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 16px; text-decoration: none; background: var(--verde); color: #fff;
}
.boton:active { transform: translateY(1px); }
.boton[disabled] { opacity: .5; cursor: not-allowed; }
.boton.ancho { width: 100%; }
.boton.acento { background: var(--acento); color: var(--tinta); }
.boton.suave { background: var(--fondo); color: var(--verde); }
.boton.peligro { background: var(--error-suave); color: var(--error); }
.boton.chico { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.boton svg { width: 20px; height: 20px; }
.boton-icono { width: 56px; height: 56px; flex: none; border-radius: 50%; border: 0; background: var(--fondo); color: var(--verde); display: grid; place-items: center; cursor: pointer; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.acciones .boton { flex: 1 1 150px; }
.boton:focus-visible, .fila:focus-visible, .chip:focus-visible, .nav a:focus-visible, .alerta:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 0; background: var(--fondo); font-size: 14px; font-weight: 600; color: var(--texto-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--verde); color: #fff; }

.opcion { display: block; width: 100%; text-align: left; cursor: pointer; background: var(--fondo); border: 2px solid transparent; border-radius: 20px; padding: 16px; }
.opcion[aria-pressed="true"] { border-color: var(--acento); background: var(--menta); }
.opcion .cabeza { display: flex; justify-content: space-between; gap: 12px; }
.opcion .grande { font-family: var(--display); font-size: 26px; font-weight: 800; color: var(--verde); line-height: 1; text-align: right; }

.check { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--fondo); cursor: pointer; }
.check + .check { margin-top: 8px; }
.check input { width: 22px; height: 22px; accent-color: var(--verde); flex: none; }
.check .centro { flex: 1; min-width: 0; }

/* ---------- Navegación inferior en píldoras ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--blanco); border-top: 1px solid var(--linea);
  padding: 10px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.nav-interno { display: flex; gap: 6px; max-width: 560px; margin: 0 auto; }
.nav a { height: 50px; flex: 0 0 56px; border-radius: 999px; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--apagado); text-decoration: none; font-size: 13px; font-weight: 600; cursor: pointer; }
.nav a svg { width: 22px; height: 22px; flex: none; }
.nav a[aria-current="page"] { flex: 1 1 auto; background: var(--menta); color: var(--verde); }
.nav a .rotulo { display: none; white-space: nowrap; }
.nav a[aria-current="page"] .rotulo { display: inline; }

/* ---------- Hojas emergentes, escáner, toast ---------- */
.fondo-capa { position: fixed; inset: 0; z-index: 50; background: rgba(16,35,26,.55); display: flex; align-items: flex-end; justify-content: center; }
.hoja {
  background: var(--blanco); width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  border-radius: 28px 28px 0 0; padding: 10px 20px calc(22px + env(safe-area-inset-bottom)); animation: sube .18s ease-out;
}
@keyframes sube { from { transform: translateY(24px); } }
.hoja .tirador { width: 40px; height: 5px; border-radius: 9px; background: var(--linea); margin: 4px auto 14px; }
.hoja h3 { font-size: 21px; font-weight: 800; margin-bottom: 6px; }
@media (min-width: 700px) { .fondo-capa { align-items: center; } .hoja { border-radius: 28px; } }
.escaner { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.escaner #lector { flex: 1; }
.escaner #lector video { object-fit: cover; }
.escaner .pie { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.escaner .texto { color: #fff; text-align: center; margin-bottom: 12px; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-alto) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; max-width: calc(100% - 32px); width: max-content; background: var(--tinta); color: #fff;
  padding: 12px 18px; border-radius: 999px; font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.visible { opacity: 1; }
#toast.error { background: var(--error); }
.imagen-cupon { display: block; width: 100%; max-width: 360px; margin: 0 auto; border-radius: 24px; }
.paso { display: flex; gap: 14px; align-items: flex-start; }
.paso .n { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--verde); color: #fff; display: grid; place-items: center; font: 800 18px var(--display); }
.paso b { font-family: var(--display); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
