/* Garantías · estilos */
:root {
  --fondo: #f3f5f6; --tarjeta: #fff; --texto: #1b2326; --suave: #667479; --linea: #e3e8ea;
  --marca: #0f766e; --marca-2: #0b5f58; --acento: #f08a24;
  --rojo: #d92d20; --rojo-f: #fef3f2; --ambar: #b54708; --ambar-f: #fffaeb; --verde: #067647; --verde-f: #ecfdf3; --gris-f: #eff2f3;
  --sombra: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08); --radio: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0e1415; --tarjeta: #172022; --texto: #eaf0f1; --suave: #93a3a7; --linea: #263235;
    --marca: #3fc1b3; --marca-2: #5fd3c6; --rojo: #f97066; --rojo-f: #3a1a18; --ambar: #fdb022; --ambar-f: #33260d;
    --verde: #47cd89; --verde-f: #10291d; --gris-f: #212c2f; --sombra: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto);
  padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.oculto { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--texto); }
a { color: var(--marca); }

.acceso { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.acceso-marca { text-align: center; margin-bottom: 24px; }
.acceso-marca .logo { font-size: 56px; }
.acceso-marca h1 { font-size: 32px; margin: 4px 0; }
.acceso-marca p { color: var(--suave); margin: 0; }

.cabecera { position: sticky; top: 0; z-index: 5; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; background: var(--fondo); }
.cabecera h1 { font-size: 26px; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px 16px; }

.barra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; align-items: center;
  background: var(--tarjeta); border-top: 1px solid var(--linea); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav { flex: 1; background: none; border: 0; font-size: 11px; color: var(--suave); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.nav span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.nav.activa { color: var(--marca); font-weight: 600; }
.nav.activa span { filter: none; opacity: 1; }
.mas { width: 58px; height: 58px; margin-top: -26px; border: 0; border-radius: 50%; background: var(--marca); color: #fff; font-size: 30px; box-shadow: 0 4px 12px rgba(15,118,110,.4); }

.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; }
.form { display: grid; gap: 12px; }
.form label, .campo { display: grid; gap: 4px; font-size: 13px; color: var(--suave); }
.form input, .form select, .form textarea, .campo input, .campo select {
  width: 100%; border: 1px solid var(--linea); background: var(--fondo); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.form textarea { min-height: 70px; resize: vertical; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: var(--rojo); margin: 0; min-height: 1.2em; font-size: 14px; }

.boton { border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 12px; padding: 12px 16px; font-weight: 600; }
.boton.principal { background: var(--marca); border-color: var(--marca); color: #fff; }
.boton.peligro { color: var(--rojo); }
.boton.ancho { width: 100%; }
.boton:disabled { opacity: .5; }

/* resumen y filtros */
.resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.cifra { background: var(--tarjeta); border-radius: 12px; padding: 10px; text-align: center; box-shadow: var(--sombra); border: 0; }
.cifra b { display: block; font-size: 22px; }
.cifra span { font-size: 12px; color: var(--suave); }
.cifra.on { outline: 2px solid var(--marca); }
.buscar { width: 100%; border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 12px; padding: 11px 14px; font-size: 16px; margin-bottom: 12px; }

.lista { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--linea); width: 100%; background: none; text-align: left; }
.fila:last-child { border-bottom: 0; }
.miniatura { width: 48px; height: 48px; border-radius: 10px; background: var(--gris-f) center/cover no-repeat; display: grid; place-items: center; font-size: 22px; flex: none; }
.cuerpo { flex: 1; min-width: 0; }
.t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s { font-size: 13px; color: var(--suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; flex: none; }
.est.caducada { background: var(--rojo-f); color: var(--rojo); }
.est.pronto { background: var(--ambar-f); color: var(--ambar); }
.est.vigente { background: var(--verde-f); color: var(--verde); }
.est.sin_fecha { background: var(--gris-f); color: var(--suave); }
.vacio { text-align: center; color: var(--suave); padding: 36px 16px; }
.vacio .grande { font-size: 48px; }
.pista { font-size: 13px; color: var(--suave); margin: 6px 2px 0; }

/* hoja */
.hoja-fondo { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 720px; margin: 0 auto; max-height: 94vh; overflow-y: auto;
  background: var(--fondo); border-radius: 20px 20px 0 0; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
.hoja-asa { width: 40px; height: 4px; background: var(--linea); border-radius: 9px; margin: 0 auto 10px; }
.hoja-cerrar { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--tarjeta); }
.hoja h2 { font-size: 20px; margin: 4px 40px 12px 0; }
.apila { display: grid; gap: 10px; }
.opcion { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; border: 0; border-radius: var(--radio); background: var(--tarjeta); box-shadow: var(--sombra); width: 100%; }
.opcion .ic { font-size: 30px; }
.opcion b { display: block; }
.opcion small { color: var(--suave); }

.articulo { background: var(--tarjeta); border-radius: var(--radio); padding: 12px; display: grid; gap: 10px; box-shadow: var(--sombra); }
.articulo .cab { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.articulo .cab input[type=checkbox] { width: 20px; height: 20px; }
.banda { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.banda.ambar { background: var(--ambar-f); color: var(--ambar); }
.banda.ok { background: var(--verde-f); color: var(--verde); }
.vista-doc { display: flex; gap: 10px; flex-wrap: wrap; }
.vista-doc a { display: block; }
.vista-doc img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; background: var(--gris-f); display: block; }
.pdf-chip { width: 92px; height: 92px; border-radius: 10px; background: var(--gris-f); display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--texto); text-decoration: none; }
.pdf-chip b { display: block; font-size: 28px; }
.ficha { display: grid; gap: 0; background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; margin: 12px 0; }
.ficha div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--linea); font-size: 15px; }
.ficha div:last-child { border-bottom: 0; }
.ficha span { color: var(--suave); }
.ficha b { text-align: right; font-weight: 600; word-break: break-word; }
.gran-estado { text-align: center; padding: 16px; border-radius: var(--radio); margin: 8px 0; font-weight: 700; font-size: 18px; }
.gran-estado small { display: block; font-weight: 400; font-size: 13px; margin-top: 2px; }
.gran-estado.caducada { background: var(--rojo-f); color: var(--rojo); }
.gran-estado.pronto { background: var(--ambar-f); color: var(--ambar); }
.gran-estado.vigente { background: var(--verde-f); color: var(--verde); }
.gran-estado.sin_fecha { background: var(--gris-f); color: var(--suave); }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.ocupado { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: grid; place-content: center; justify-items: center; gap: 12px; color: #fff; }
.rueda { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; animation: gira 0.9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.aviso { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 50; max-width: 520px; margin: 0 auto;
  background: #1b2326; color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

.adj { position: relative; }
.quita { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: #1b2326; color: #fff; font-size: 12px; line-height: 1; }
.boton small { font-weight: 400; color: var(--suave); font-size: 12px; }
