:root {
  --azul: #0f1c2e; --azul2: #1c2e45; --verde: #3aa335; --verde-osc: #2b7d27; --verde-claro: #e3f1e2;
  --fondo: #f4f6f8; --linea: #e2e7ed; --borde: #c9d3df; --gris: #5b6472; --texto2: #33435a; --rojo: #8a1c1c;
  --titulo: Montserrat, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--azul); font: 15px/1.4 Inter, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#vista { flex: 1; outline: none; padding-bottom: 96px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2 { font-family: var(--titulo); margin: 0; }
h1 { font-size: 20px; font-weight: 800; }
h2 { font-size: 15px; font-weight: 700; }
[hidden] { display: none !important; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Encabezados */
.barra { background: #fff; border-bottom: 1px solid var(--linea); padding: 8px; display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 5; }
.barra h1 { flex: 1; font-size: 18px; }
.ico-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.portada { background: var(--azul); color: #fff; padding: 18px 20px 64px; display: flex; flex-direction: column; gap: 16px; }
.portada .marca { display: flex; align-items: center; gap: 10px; }
.portada .logo { width: 42px; height: 42px; border-radius: 10px; background: #fff; padding: 3px; }
.portada .marca b { font-family: var(--titulo); font-size: 15px; letter-spacing: .04em; display: block; }
.portada .marca small { color: #c9d3df; }
.portada .saludo small { color: #c9d3df; display: block; }
.portada .saludo strong { font-family: var(--titulo); font-size: 22px; line-height: 1.2; }
.cuerpo { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.subir { margin-top: -48px; }

/* Botones */
.btn { min-height: 48px; border-radius: 12px; border: 0; padding: 0 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-verde { background: var(--verde-osc); color: #fff; }
.btn-claro { background: #fff; border: 1px solid var(--borde); color: var(--azul); }
.btn-rojo { background: #fff; border: 1px solid var(--borde); color: var(--rojo); }
.btn-ancho { width: 100%; }
.btn[disabled] { opacity: .5; }
.foto-grande { background: var(--verde-osc); color: #fff; border-radius: 18px; padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 10px 24px rgba(15, 28, 46, .18); }
.foto-grande .ic { width: 52px; height: 52px; border-radius: 14px; background: #236b20; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.foto-grande b { font-family: var(--titulo); font-size: 18px; display: block; }

/* Tarjetas y listas */
.tarjeta { background: #fff; border-radius: 14px; padding: 12px 14px; }
.rejilla2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rejilla3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.acceso { background: #fff; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; font-weight: 600; min-height: 44px; }
.fila { background: #fff; border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px; }
.fila .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fila .txt small, .gris { color: var(--gris); font-size: 12px; }
.mini { width: 52px; height: 52px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--linea); flex-shrink: 0; }
.vacio { text-align: center; color: var(--gris); padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vacio img { width: 120px; border-radius: 16px; }

/* Biblioteca */
.buscar { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 12px; background: #eef1f4; }
.buscar input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--borde); background: #fff; white-space: nowrap; font-size: 13px; flex-shrink: 0; }
.chip[aria-pressed="true"] { background: var(--azul); color: #fff; border-color: var(--azul); font-weight: 600; }
.prod { background: #fff; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.prod .img { aspect-ratio: 1; background-color: #fff; background-image: repeating-conic-gradient(#f1f4f7 0% 25%, #fff 0% 50%); background-size: 14px 14px; display: flex; align-items: center; justify-content: center; }
.prod .img img { width: 100%; height: 100%; object-fit: contain; }
.prod .pie { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.prod .pie b { font-weight: 600; }
.tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background-color: #fff; background-image: repeating-conic-gradient(#f1f4f7 0% 25%, #fff 0% 50%); background-size: 12px 12px; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: contain; }
.tile[aria-pressed="true"] { border-color: var(--verde); }
.tile .marca-sel { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--verde); display: none; align-items: center; justify-content: center; }
.tile[aria-pressed="true"] .marca-sel { display: flex; }
.tile .pend { position: absolute; left: 6px; bottom: 6px; font-size: 10px; font-weight: 700; background: #fff3c4; color: #6b5300; padding: 2px 6px; border-radius: 6px; }
.acciones { position: fixed; left: 50%; transform: translateX(-50%); bottom: 86px; width: min(536px, calc(100% - 24px)); background: var(--azul); border-radius: 16px; padding: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; z-index: 6; }
.acciones button { min-height: 50px; border: 0; border-radius: 12px; background: var(--azul2); color: #fff; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.acciones button:first-child { background: var(--verde-osc); }

/* Formularios */
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--gris); }
label.campo input, label.campo select { height: 46px; border: 1px solid var(--borde); border-radius: 10px; padding: 0 12px; font-size: 15px; color: var(--azul); background: #fff; font-weight: 500; }
.usos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.uso { position: relative; }
.uso input { position: absolute; opacity: 0; }
.uso span { min-height: 100px; border-radius: 12px; border: 1px solid var(--borde); background: #fff; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; font-size: 12px; font-weight: 700; }
.uso small { font-weight: 400; color: var(--gris); font-size: 11px; }
.uso input:checked + span { border: 2px solid var(--verde); background: var(--verde-claro); }
.uso input:focus-visible + span { outline: 3px solid #1d4ed8; }
.muestra { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--borde); background: #fff; }
.muestra.cuadros { background-image: repeating-conic-gradient(#dfe5ec 0% 25%, #fff 0% 50%); background-size: 10px 10px; }
.vista-previa { border-radius: 14px; background: #fff; min-height: 180px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 2px dashed var(--borde); }
.vista-previa img { max-height: 320px; object-fit: contain; }
.interruptor { min-height: 48px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #eef1f4; }
.interruptor span { flex: 1; }
.interruptor input { width: 22px; height: 22px; accent-color: var(--verde); }

/* Menú de abajo */
#menu { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; background: #fff; border-top: 1px solid var(--linea); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 6px calc(10px + env(safe-area-inset-bottom)); z-index: 7; }
#menu a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--gris); }
#menu a[aria-current="page"] { color: var(--azul); font-weight: 600; }
#menu .centro span { width: 56px; height: 56px; border-radius: 50%; background: var(--verde-osc); color: #fff; display: flex; align-items: center; justify-content: center; margin-top: -24px; box-shadow: 0 6px 16px rgba(43, 125, 39, .4); }

/* Visor y avisos */
.visor { position: fixed; inset: 0; background: rgba(10, 18, 30, .92); z-index: 20; display: flex; flex-direction: column; }
.visor .img { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; }
.visor .img img { max-height: 100%; background-image: repeating-conic-gradient(#e8ecf1 0% 25%, #fff 0% 50%); background-size: 16px 16px; border-radius: 8px; }
.visor .pie { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
#aviso { position: fixed; left: 50%; transform: translateX(-50%); top: 16px; background: var(--azul); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 8px 20px rgba(0, 0, 0, .2); }
.cargando { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 12px; text-align: center; }
.cargando img { width: 140px; border-radius: 16px; animation: flota 1.6s ease-in-out infinite; }
@keyframes flota { 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .cargando img { animation: none; } }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 24px; }
.login img.logo { width: 220px; margin: 0 auto; border-radius: 12px; }
.error { color: var(--rojo); font-size: 14px; }
