/* App de pedidos Valvosanitaria. Movil primero; sin fuentes ni librerias externas. */
:root {
  --azul: #14365e;
  --azul-2: #1d4a7e;
  --azul-claro: #e8eef6;
  --fondo: #f3f6fa;
  --tarjeta: #ffffff;
  --texto: #18222f;
  --suave: #5b6878;
  --borde: #d7dee8;
  --verde: #067647;
  --verde-claro: #e7f6ee;
  --rojo: #b42318;
  --rojo-claro: #fdecea;
  --ambar: #8a5a00;
  --ambar-claro: #fff4d6;
  --radio: 12px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.4; color: var(--texto); background: var(--fondo);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.oculto { display: none !important; }

/* Barra superior */
.barra {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 8px 12px; background: var(--azul); color: #fff;
  padding-top: max(8px, env(safe-area-inset-top));
}
.barra h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .sub { display: block; font-size: 12px; font-weight: 400; opacity: .8; }
.btn-icono {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer;
}
.btn-icono:hover, .btn-icono:focus-visible { background: rgba(255, 255, 255, .14); outline: none; }
.btn-icono svg { width: 22px; height: 22px; }

main { max-width: 760px; margin: 0 auto; padding: 12px 12px 120px; }

/* Tarjetas y secciones */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.tarjeta h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); }

/* Campos */
.campo { display: block; margin-bottom: 12px; }
.campo > span { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 500; color: var(--suave); }
.entrada {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.entrada:focus { border-color: var(--azul-2); box-shadow: 0 0 0 3px rgba(29, 74, 126, .15); }
textarea.entrada { min-height: 70px; resize: vertical; }
.fila { display: flex; gap: 10px; }
.fila > * { flex: 1; min-width: 0; }

/* Selector (abre una busqueda) */
.selector {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 12px;
  border: 1px solid var(--borde); border-radius: 10px; background: #fff; text-align: left; cursor: pointer;
}
.selector:focus-visible { outline: 3px solid rgba(29, 74, 126, .25); }
.selector .txt { flex: 1; min-width: 0; }
.selector .principal { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selector .secundario { display: block; font-size: 13px; color: var(--suave); }
.selector .vacio { color: var(--suave); font-weight: 400; }
.selector svg { width: 20px; height: 20px; color: var(--suave); flex: none; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover:not(:disabled) { background: var(--azul-2); }
.btn-verde { background: var(--verde); color: #fff; }
.btn-secundario { background: #fff; color: var(--azul); border-color: var(--borde); }
.btn-peligro { background: #fff; color: var(--rojo); border-color: #f1c4bf; }
.btn-bloque { width: 100%; }
.btn-texto { background: none; border: 0; color: var(--azul-2); font-weight: 600; padding: 8px 4px; cursor: pointer; }

/* Chips (plazos de letras, filtros) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 0 14px; border: 1px solid var(--borde); border-radius: 999px; background: #fff;
  font-weight: 500; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--azul); border-color: var(--azul); color: #fff; }
.segmento { display: flex; padding: 4px; margin-bottom: 12px; background: var(--azul-claro); border-radius: 999px; }
.segmento button { flex: 1; min-height: 38px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--azul); cursor: pointer; }
.segmento button[aria-pressed="true"] { background: #fff; box-shadow: var(--sombra); }

/* Etiquetas de estado */
.etiqueta { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.e-borrador { background: #eef1f5; color: #445063; }
.e-confirmado, .e-descargado { background: var(--azul-claro); color: var(--azul); }
.e-generado, .e-facturado { background: var(--verde-claro); color: var(--verde); }
.e-observado { background: var(--ambar-claro); color: var(--ambar); }
.e-anulado { background: var(--rojo-claro); color: var(--rojo); }
.e-excede { background: var(--ambar-claro); color: var(--ambar); }

/* Lista de pedidos */
.pedido { display: block; width: 100%; text-align: left; cursor: pointer; }
.pedido .cab { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.pedido .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.pedido .cli { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pedido .pie { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--suave); }
.pedido .total { font-weight: 700; color: var(--texto); font-variant-numeric: tabular-nums; }

/* Items del pedido */
.item { display: flex; gap: 10px; width: 100%; padding: 12px 0; border: 0; border-top: 1px solid var(--borde); background: none; text-align: left; cursor: pointer; }
.item:first-child { border-top: 0; }
.item .det { flex: 1; min-width: 0; }
.item .cod { font-size: 13px; font-weight: 600; color: var(--suave); }
.item .des { font-weight: 500; }
.item .calc { font-size: 13px; color: var(--suave); }
.item .imp { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vacio-lista { padding: 18px 0; text-align: center; color: var(--suave); }

/* Barra inferior de totales */
.totales {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--borde);
  box-shadow: 0 -2px 10px rgba(16, 24, 40, .08); padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.totales .contenido { max-width: 760px; margin: 0 auto; }
.totales .montos { display: flex; justify-content: space-between; font-size: 13px; color: var(--suave); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.totales .montos b { font-size: 18px; color: var(--texto); }
.totales .acciones { display: flex; gap: 8px; }
.totales .acciones .btn { flex: 1; }

/* Hoja (pantalla superpuesta para busquedas y edicion de items) */
.hoja-fondo { position: fixed; inset: 0; z-index: 40; background: rgba(16, 24, 40, .45); display: flex; align-items: flex-end; justify-content: center; }
.hoja {
  width: 100%; max-width: 760px; max-height: 94vh; display: flex; flex-direction: column; background: var(--fondo);
  border-radius: 18px 18px 0 0; overflow: hidden; animation: subir .18s ease-out;
}
@keyframes subir { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.hoja .barra { position: static; border-radius: 0; }
.hoja .cuerpo { flex: 1; overflow-y: auto; padding: 12px; }
.hoja .pie-hoja { display: flex; gap: 8px; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--borde); }
.hoja .pie-hoja .btn { flex: 1; }
.resultado { display: block; width: 100%; padding: 12px; margin-bottom: 8px; border: 1px solid var(--borde); border-radius: 10px; background: #fff; text-align: left; cursor: pointer; }
.resultado:disabled { opacity: .55; cursor: not-allowed; }
.resultado .linea1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.resultado .linea2 { font-size: 13px; color: var(--suave); }

/* Informacion del articulo */
.info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.info div { padding: 8px; background: #fff; border: 1px solid var(--borde); border-radius: 10px; text-align: center; }
.info small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--suave); text-transform: uppercase; }
.info b { font-variant-numeric: tabular-nums; }
.volumen { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.volumen span { padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--borde); }
.volumen span.activo { background: var(--verde-claro); border-color: #a6dcbf; color: var(--verde); font-weight: 600; }
.calculo { display: flex; justify-content: space-between; padding: 12px; border-radius: 10px; background: var(--azul-claro); font-variant-numeric: tabular-nums; }

/* Avisos */
.aviso { padding: 10px 12px; margin-bottom: 12px; border-radius: 10px; font-size: 14px; }
.aviso-error { background: var(--rojo-claro); color: var(--rojo); }
.aviso-ambar { background: var(--ambar-claro); color: var(--ambar); }
.aviso-ok { background: var(--verde-claro); color: var(--verde); }
.aviso-info { background: var(--azul-claro); color: var(--azul); }

/* Mensaje flotante */
.toast {
  position: fixed; left: 50%; bottom: 120px; z-index: 60; transform: translateX(-50%); max-width: 90vw;
  padding: 10px 16px; border-radius: 10px; background: #18222f; color: #fff; font-size: 14px; box-shadow: var(--sombra);
}

/* Ingreso */
.ingreso { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ingreso .caja { width: 100%; max-width: 380px; }
.marca { text-align: center; margin-bottom: 20px; }
.marca .logo { display: inline-flex; width: 56px; height: 56px; align-items: center; justify-content: center; border-radius: 16px; background: var(--azul); color: #fff; font-size: 26px; font-weight: 700; }
.marca h1 { margin: 10px 0 2px; font-size: 22px; }
.marca p { margin: 0; color: var(--suave); }

/* Boton flotante */
.flotante { position: fixed; right: 16px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 15; box-shadow: 0 4px 14px rgba(20, 54, 94, .35); }

/* Tabla de administracion */
.usuario-fila { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.usuario-fila .datos { min-width: 0; }
.usuario-fila .nombre { font-weight: 600; }
.usuario-fila .meta { font-size: 13px; color: var(--suave); }
.acciones-usuario { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.acciones-usuario .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }

.cargando { padding: 30px; text-align: center; color: var(--suave); }
.derecha { text-align: right; }
.monto { font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { main { padding-top: 20px; } .info { grid-template-columns: repeat(6, 1fr); } }
.btn svg { width: 20px; height: 20px; flex: none; }
/* Totales mas legibles */
.totales .montos { align-items: flex-end; color: var(--texto); }
.totales .montos small { display: block; font-size: 13px; font-weight: 500; color: var(--suave); }
.totales .montos strong { display: block; font-size: 16px; font-weight: 600; color: var(--texto); }
.totales .montos b { display: block; font-size: 21px; }
.rejilla-letras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
