/* Inventario Fácil CR - estilos. Celular primero (360 px), botones de 44 px o más. */
:root {
  --verde: #0b6b4a;
  --verde-osc: #084f37;
  --verde-claro: #e3f4ea;
  --borde: #cfd8d3;
  --fondo: #f3f6f4;
  --tarjeta: #ffffff;
  --texto: #1c2622;
  --suave: #4a5751;
  --error: #b3261e;
  --error-fondo: #fdeceb;
  --alerta: #7a4100;
  --alerta-fondo: #fff1d6;
  --alerta-borde: #e9b96e;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color: var(--texto); background: var(--fondo); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #1e88e5; outline-offset: 2px; }
main:focus { outline: none; }

.contenedor { max-width: 720px; margin: 0 auto; padding: 0 16px; }
main.contenedor { padding-top: 12px; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

.barra { background: var(--verde); color: #fff; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
.barra .marca { color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; }
.barra .marca span { opacity: .8; }
.barra { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.barra .ir-ajustes { color: #fff; text-decoration: none; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; }
.barra .ir-ajustes[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }

h1 { font-size: 22px; margin: 4px 0 12px; overflow-wrap: anywhere; }
h1:focus { outline: none; }
h2 { font-size: 17px; margin: 20px 0 8px; }
p { margin: 0 0 10px; }
.suave { color: var(--suave); font-size: 14px; }

/* Botones y enlaces con forma de botón */
button, .boton {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border: 1px solid var(--borde); border-radius: 10px;
  background: #fff; color: var(--texto); cursor: pointer; text-decoration: none; text-align: center;
}
button:hover, .boton:hover { background: #eef3f0; }
button:disabled { opacity: .5; cursor: not-allowed; }
.prim { background: var(--verde); border-color: var(--verde); color: #fff; }
.prim:hover { background: var(--verde-osc); }
.peligro { color: var(--error); border-color: #e6b3af; }
.enlace { border: 0; background: none; color: var(--verde); text-decoration: underline; padding: 8px 4px; min-height: 44px; }
.enlace:hover { background: none; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.acciones > * { flex: 1 1 140px; }
.grandes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.grandes .boton { min-height: 64px; font-size: 18px; font-weight: 600; }
.grandes .ancho { grid-column: 1 / -1; }

/* Avisos */
.aviso { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--verde-claro); border: 1px solid #9fd3b5; }
.aviso.error { background: var(--error-fondo); border-color: #f2b8b5; color: var(--error); }
.aviso.alerta { background: var(--alerta-fondo); border-color: var(--alerta-borde); color: var(--alerta); }
.aviso .acciones { margin: 8px 0 0; }
#avisos:empty { display: none; }

/* Tarjetas de inicio */
.tarjetas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tarjeta { display: block; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 12px; color: inherit; text-decoration: none; }
a.tarjeta:hover { border-color: var(--verde); }
.tarjeta .titulo { font-size: 14px; color: var(--suave); }
.tarjeta .cifra { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tarjeta.ancha { grid-column: 1 / -1; }
.tarjeta.ancha .cifra { font-size: 20px; }
.tarjeta.alerta { border-color: var(--alerta-borde); background: var(--alerta-fondo); color: var(--alerta); }

/* Etiquetas de estado (el significado va en texto, no solo en color) */
.etiqueta { display: inline-block; font-size: 13px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.etiqueta.bajo { color: var(--alerta); background: var(--alerta-fondo); border-color: var(--alerta-borde); }
.etiqueta.negativo { color: var(--error); background: var(--error-fondo); border-color: #f2b8b5; }
.etiqueta.archivado, .etiqueta.anulado { color: var(--suave); background: #eceeed; border-color: #c9cfcc; }

/* Búsqueda y filtros */
.buscador { position: sticky; top: 0; background: var(--fondo); padding: 6px 0 8px; z-index: 2; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--suave); font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--texto); min-width: 0; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid #9aa8a1; border-radius: 9px; background: #fff; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input.invalido, select.invalido { border-color: var(--error); background: #fff5f4; }
.filtros { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.filtros button { flex: 0 0 auto; border-radius: 999px; min-height: 40px; padding: 6px 14px; }
.filtros button[aria-pressed="true"] { background: var(--verde); border-color: var(--verde); color: #fff; }

/* Lista de productos */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { margin: 0 0 8px; }
.fila-producto { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 10px 12px; color: inherit; text-decoration: none; min-height: 56px; width: 100%; text-align: left; font: inherit; cursor: pointer; }
.fila-producto:hover { border-color: var(--verde); background: var(--tarjeta); }
.fila-producto .nombre { font-weight: 600; overflow-wrap: anywhere; }
.fila-producto .detalle { font-size: 13px; color: var(--suave); overflow-wrap: anywhere; }
.fila-producto .izq { min-width: 0; }
.fila-producto .der { text-align: right; flex: 0 0 auto; }
.fila-producto .stock { font-weight: 700; font-variant-numeric: tabular-nums; }
.vacio { background: var(--tarjeta); border: 1px dashed var(--borde); border-radius: 12px; padding: 16px; text-align: center; color: var(--suave); }

/* Ficha */
.cabeza-ficha { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stock-grande { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; }
.datos { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 12px; margin: 12px 0; }
.datos dt { color: var(--suave); font-size: 14px; }
.datos dd { margin: 0; overflow-wrap: anywhere; }
.historial { list-style: none; margin: 0; padding: 0; }
.historial li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.historial li.es-anulado .cant { text-decoration: line-through; color: var(--suave); }
.historial .info { min-width: 0; overflow-wrap: anywhere; }
.historial .cant { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.historial .der { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Formularios */
.formulario { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 14px; }
.campos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.campos .ancho { grid-column: 1 / -1; }
.error-campo { color: var(--error); font-size: 14px; font-weight: 400; }
.ayuda { font-weight: 400; font-size: 13px; color: var(--suave); }
.segmentado { display: flex; border: 1px solid var(--verde); border-radius: 10px; overflow: hidden; margin: 0 0 12px; padding: 0; }
.segmentado legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.segmentado label { flex: 1; flex-direction: row; justify-content: center; align-items: center; min-height: 48px; font-size: 17px; color: var(--verde); cursor: pointer; position: relative; }
.segmentado input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.segmentado label:has(input:checked), .segmentado label.marcado { background: var(--verde); color: #fff; }
.segmentado label:has(input:focus-visible) { outline: 3px solid #1e88e5; outline-offset: -3px; }
.elegido { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--verde-claro); border: 1px solid #9fd3b5; border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.elegido .nombre { font-weight: 700; overflow-wrap: anywhere; }
.resultados { list-style: none; margin: 8px 0 12px; padding: 0; }
.resultados li { margin: 0 0 6px; }

/* Diálogo de confirmación */
dialog { border: 0; border-radius: 14px; padding: 18px; max-width: min(420px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.3); color: var(--texto); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog p { font-size: 17px; }

/* Barra inferior */
.nav-inferior { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: #fff; border-top: 1px solid var(--borde); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav-inferior a { flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; color: var(--suave); text-decoration: none; font-size: 13px; font-weight: 600; }
.nav-inferior a span { font-size: 20px; line-height: 1; }
.nav-inferior a[aria-current="page"] { color: var(--verde); box-shadow: inset 0 3px 0 var(--verde); }

.cargando { color: var(--suave); }

@media (max-width: 380px) {
  .campos { grid-template-columns: 1fr; }
  .tarjeta .cifra { font-size: 22px; }
}

/* Reposición */
.fila-repo { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 10px 12px; }
.fila-repo .izq { min-width: 0; }
.fila-repo .nombre { font-weight: 600; color: var(--texto); overflow-wrap: anywhere; }
.fila-repo .detalle { font-size: 13px; color: var(--suave); overflow-wrap: anywhere; }
.fila-repo .detalle:empty { display: none; }
.fila-repo .der { flex: 0 0 auto; font-size: 13px; }
.fila-repo.sin-pedir { opacity: .6; }
.con-unidad { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--texto); }
.con-unidad input { width: 84px; text-align: right; }
.total-repo { font-weight: 700; margin-top: 12px; }
.solo-impresion { display: none; }
.tabla-impresion { width: 100%; border-collapse: collapse; }
.tabla-impresion th, .tabla-impresion td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #999; }
.tabla-impresion td:last-child, .tabla-impresion th:last-child { text-align: right; white-space: nowrap; }
a.boton[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.mas-vendidos ol { margin: 6px 0 0; padding-left: 22px; }
.mas-vendidos li { padding: 4px 0; }
.mas-vendidos li a { color: var(--texto); }
.mas-vendidos .cant { float: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Ajustes, importar y restaurar (etapa 4) */
.filtro-categoria { margin-top: 8px; }
.campo-archivo { margin: 12px 0; }
.campo-archivo input[type="file"] { padding: 10px; background: var(--tarjeta); }
.pasos { padding-left: 22px; }
.pasos li { margin: 6px 0; }
.pasos .enlace { padding: 0 4px; }
.ayuda-csv { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.ayuda-csv summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.errores-csv { background: var(--error-fondo); border: 1px solid #f2b8b5; border-radius: 12px; padding: 10px 14px 10px 30px; max-height: 320px; overflow-y: auto; overflow-wrap: anywhere; }
.errores-csv li { margin: 4px 0; }
.privacidad { padding-left: 20px; }
.privacidad li { margin: 6px 0; }

@media print {
  .nav-inferior, .barra, .acciones, .buscador, .no-imprimir, #avisos, main > .aviso { display: none !important; }
  main:has(.solo-impresion) > h1 { display: none !important; }
  .solo-impresion { display: block !important; }
  body { background: #fff; }
  main.contenedor { padding-bottom: 0; }
}
