/* Compras Mensajería — teléfono primero. Sin estilos en línea: la CSP solo permite 'self'. */
:root {
  --fondo: #f5f4f0; --tarjeta: #ffffff; --texto: #1f2328; --sec: #5f6368; --linea: #e4e1da;
  --primario: #2f6f5e; --primario-osc: #245647; --sobre-primario: #ffffff;
  --pedido: #c8452f; --pedido-claro: #fbe4de; --teja: #2f7d6d; --ok: #2e7d4f; --ok-claro: #e2f2e8;
  --aviso: #9a5b00; --aviso-claro: #fdf0d8; --urgente: #c62828; --urgente-claro: #fde3e3;
  --sombra: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --radio: 14px; --nav: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #1b2224; --tarjeta: #263033; --texto: #ececea; --sec: #a5aaa7; --linea: #333836;
    --primario: #3f8c77; --primario-osc: #2f6f5e; --pedido: #d65a4a; --pedido-claro: #3a2420; --teja: #2c7a6b;
    --ok: #5cb882; --ok-claro: #1f3328; --aviso: #e0a64a; --aviso-claro: #362a17;
    --urgente: #ef6b6b; --urgente-claro: #3b1f1f; --sombra: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.oculto { display: none !important; }

/* Encabezado */
.cabeza { position: sticky; top: 0; z-index: 20; background: var(--primario); color: var(--sobre-primario);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; }
.cabeza h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selector { background: rgba(255,255,255,.16); border: 0; color: inherit; border-radius: 999px; padding: 6px 12px;
  font-weight: 600; max-width: 55vw; }
.selector option { color: #000; }
.punto-red { width: 10px; height: 10px; border-radius: 50%; background: #9be3c3; flex: none; }
.punto-red.sin-red { background: #ffb4a2; }

main { padding: 12px 16px calc(var(--nav) + env(safe-area-inset-bottom) + 24px); max-width: 760px; margin: 0 auto; }

/* Barra inferior */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--tarjeta);
  border-top: 1px solid var(--linea); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; min-height: var(--nav); display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--sec); font-size: 12px; gap: 2px; position: relative; }
.nav a .ico { font-size: 22px; line-height: 1; }
.nav a.activo { color: var(--primario); font-weight: 700; }
.nav .globo { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--pedido); color: #fff;
  font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; padding: 0 5px; font-weight: 700; }

/* Avisos de estado */
.banda { border-radius: var(--radio); padding: 12px 14px; margin: 4px 0 14px; display: flex; gap: 10px; align-items: center;
  background: var(--tarjeta); box-shadow: var(--sombra); }
.banda .ico { font-size: 24px; }
.banda b { display: block; }
.banda.llamada { background: var(--aviso-claro); }
.banda.ruta { background: var(--ok-claro); }
.banda.sin-red { background: var(--pedido-claro); }
.cuenta { font-variant-numeric: tabular-nums; font-weight: 800; }

h2 { font-size: 15px; letter-spacing: .3px; text-transform: uppercase; color: var(--sec); margin: 22px 0 10px; }
h2 .cuantos { font-weight: 400; }
.vacio { color: var(--sec); padding: 18px 4px; text-align: center; }

/* Mosaico tipo Bring! */
.mosaico { display: grid; grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 8px; }
.ficha { position: relative; border: 0; padding: 6px 6px 0; background: var(--teja); color: #fff; border-radius: 12px;
  box-shadow: var(--sombra); display: flex; flex-direction: column; overflow: hidden; text-align: center; cursor: pointer;
  aspect-ratio: 1 / 1.12; }
.ficha .img { flex: 1; min-height: 0; background: #fff; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; overflow: hidden; }
.ficha .img img { width: 100%; height: 100%; object-fit: contain; }
.ficha .iniciales { font-size: 26px; font-weight: 800; color: var(--teja); }
.ficha .nom { font-size: 13px; line-height: 1.15; padding: 5px 2px 0; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ficha .espec { font-size: 12px; opacity: .92; padding: 0 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ficha.pedida { background: var(--pedido); }
.ficha.pedida .iniciales { color: var(--pedido); }
.ficha .marcas { position: absolute; top: 10px; left: 10px; display: flex; gap: 3px; }
.ficha .marcas span { background: rgba(255,255,255,.95); color: var(--texto); border-radius: 5px; font-size: 11px;
  font-weight: 800; padding: 1px 5px; line-height: 1.5; }
.ficha .marcas .u { background: var(--urgente); color: #fff; }
.ficha .marcas .n { background: #fff; color: var(--pedido); }
.ficha.otro { background: var(--tarjeta); color: var(--texto); border: 2px dashed var(--linea); box-shadow: none; }
.ficha.otro .img { background: transparent; font-size: 34px; color: var(--sec); }

.buscar { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linea); background: var(--tarjeta);
  font-size: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 999px; padding: 6px 12px;
  font-size: 14px; white-space: nowrap; }
.chip.activo { background: var(--primario); border-color: var(--primario); color: #fff; }

/* Filas y tarjetas */
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px 14px; margin-bottom: 10px; }
.fila { display: flex; gap: 12px; align-items: center; }
.fila .mini { width: 52px; height: 52px; border-radius: 10px; background: #fff; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--linea); }
.fila .mini img { width: 100%; height: 100%; object-fit: contain; }
.fila .mini .iniciales { font-size: 18px; }
.fila .cuerpo { flex: 1; min-width: 0; }
.fila .titulo { font-weight: 700; }
.fila .det { color: var(--sec); font-size: 14px; }
.etiquetas { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.etq { font-size: 12.5px; border-radius: 6px; padding: 2px 7px; background: var(--fondo); border: 1px solid var(--linea); }
.etq.mia { background: var(--pedido-claro); border-color: transparent; }
.etq.urg { background: var(--urgente-claro); color: var(--urgente); border-color: transparent; font-weight: 700; }
.etq.ok { background: var(--ok-claro); border-color: transparent; color: var(--ok); }
.etq.av { background: var(--aviso-claro); border-color: transparent; color: var(--aviso); }
.nota { font-size: 13.5px; color: var(--sec); font-style: italic; margin-top: 3px; }

/* Botones */
.btn { border: 1px solid var(--linea); border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--tarjeta);
  cursor: pointer; min-height: 46px; box-shadow: var(--sombra); }
.hoja .btn, .tarjeta .btn { background: var(--fondo); box-shadow: none; }
.btn.prim { background: var(--primario); color: #fff; border-color: transparent; }
.btn.peligro { background: var(--urgente-claro); color: var(--urgente); border-color: transparent; }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn.chico { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.ancho { width: 100%; }
.btn.grande { font-size: 20px; min-height: 64px; border-radius: 16px; }
.btn:disabled { opacity: .5; }
.botones { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.botones .btn { flex: 1; }

/* Hoja inferior */
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.hoja { background: var(--tarjeta); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 8px 16px
  calc(16px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto; }
.hoja .asa { width: 40px; height: 5px; border-radius: 3px; background: var(--linea); margin: 4px auto 10px; }
.hoja h3 { margin: 0 0 12px; font-size: 19px; }
.campo { display: block; margin: 12px 0; }
.campo > span { display: block; font-size: 14px; color: var(--sec); margin-bottom: 5px; font-weight: 600; }
.campo input, .campo select, .campo textarea { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--linea);
  background: var(--fondo); font-size: 16px; }
.paso { display: flex; align-items: center; gap: 8px; }
.paso button { width: 52px; height: 52px; border-radius: 12px; border: 0; background: var(--fondo); font-size: 26px; font-weight: 800; }
.paso input { text-align: center; font-size: 22px; font-weight: 800; flex: 1; }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.interruptor input { width: 24px; height: 24px; }

/* Avisos flotantes */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 12px); z-index: 60;
  background: #222; color: #fff; border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center;
  max-width: 600px; margin: 0 auto; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: #9be3c3; font-weight: 800; }

/* Entrada */
.entrada { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 20px 40px; }
.entrada .logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 16px; }
.entrada h1 { text-align: center; font-size: 24px; margin: 0 0 4px; }
.entrada p { text-align: center; color: var(--sec); margin: 0 0 20px; }
.error { color: var(--urgente); font-weight: 600; margin: 8px 0; min-height: 1.4em; }

/* José */
.tienda-cab { position: sticky; top: calc(env(safe-area-inset-top) + 56px); z-index: 10; background: var(--fondo);
  padding: 10px 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
.tienda-cab b { font-size: 18px; }
.precio { font-variant-numeric: tabular-nums; }
.precio.alto { color: var(--urgente); font-weight: 700; }
.factura-cab { font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.copiar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--linea); }
.copiar .valor { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-all; }
.hecho { color: var(--ok); font-weight: 700; }

/* Tablero */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px 14px; }
.kpi .n { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .t { color: var(--sec); font-size: 13.5px; }
.kpi.urg .n { color: var(--urgente); }
.tabla { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tabla th { text-align: left; color: var(--sec); font-size: 12.5px; font-weight: 600; padding: 6px 8px 6px 0;
  border-bottom: 2px solid var(--linea); }
.tabla td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--linea); }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub-nav { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 12px; }

/* «Necesito…» fijo abajo, cerca del pulgar (como en Bring!) */
main.con-necesito { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 96px); }
.necesito { position: fixed; left: 0; right: 0; bottom: calc(var(--nav) + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--tarjeta); border-top: 1px solid var(--linea); border-radius: 16px 16px 0 0;
  padding: 10px 16px; display: flex; gap: 10px; box-shadow: 0 -4px 14px rgba(0,0,0,.08); }
.necesito input { flex: 1; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--linea); background: var(--fondo);
  font-size: 17px; min-width: 0; }
.necesito button { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--teja); color: #fff;
  font-size: 30px; font-weight: 700; flex: none; line-height: 1; }
.titulo-lista { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; }
.titulo-lista h1 { font-size: 30px; margin: 0; line-height: 1.1; }
.titulo-lista select { border: 0; background: transparent; font-size: 30px; font-weight: 800; padding: 0; max-width: 100%;
  color: var(--texto); }
.seccion-cab { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.seccion-cab h2 { margin: 0; }

a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; color: inherit; }
a.btn.prim, a.btn.ok { color: #fff; }
a.chip { text-decoration: none; color: inherit; }
