/* Agente de roturas de stock: identidad del 19 Congreso ANECORM (Valencia, 14 al 16 de octubre de 2026).
   Colores muestreados del banner oficial: ambar de "ANECORM" #F2A618, verde azulado del lema #3AB4B1, crema de fondo #FCF7ED. */

@font-face { font-family: "Outfit"; src: url("/static/fonts/Outfit-latin.woff2") format("woff2"); font-weight: 500 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("/static/fonts/PublicSans-latin.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  --tinta: #12263f;
  --tinta-suave: #4a5b70;
  --fondo: #f3faf9;
  --crema: #fcf7ed;
  --superficie: #ffffff;
  --linea: #dbe8e6;
  --teal: #3ab4b1;
  --teal-profundo: #0f6f6c;
  --teal-suave: #ddf3f1;
  --ambar: #f2a618;
  --ambar-suave: #fef1d2;
  --ambar-texto: #7a4b00;
  --critico: #b3261e;
  --critico-suave: #fdecea;
  --display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --texto: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --sombra: 0 1px 2px rgba(18, 38, 63, .06), 0 10px 26px -14px rgba(18, 38, 63, .22);
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); color: var(--tinta); font: 400 1.1rem/1.5 var(--texto); }
h1, h2, h3 { font-family: var(--display); color: var(--tinta); }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 600; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .5rem; }
h3 { font-size: 1rem; font-weight: 600; margin: .5rem 0 .4rem; }
p { margin: 0; }
.envoltorio { max-width: 80rem; margin-inline: auto; padding-inline: 16px; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cabecera: dos logos, titulo y cinta del congreso */
.cabecera { background: var(--crema); border-bottom: 3px solid transparent; border-image: linear-gradient(90deg, var(--teal), var(--ambar)) 1; padding-block: .75rem .6rem; }
.cab-fila { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.4rem; }
.marcas { display: flex; align-items: center; gap: 1rem; flex: none; }
.marcas img { display: block; width: auto; }
.logo-ia { height: 42px; }
.logo-an { height: 54px; }
.marcas-sep { width: 1px; height: 40px; background: var(--linea); }
.titulo { flex: 1 1 18rem; min-width: 0; }
.lead { color: var(--tinta-suave); font-size: .95rem; line-height: 1.35; margin-top: .25rem; }
.cinta { flex: 0 1 auto; max-width: 100%; font-family: var(--display); font-weight: 600; font-size: .95rem; line-height: 1.2; color: var(--tinta);
  padding: .45rem 1rem; border-radius: 999px; background: linear-gradient(90deg, var(--teal), #8ecf8f 55%, var(--ambar)); }
.aviso { margin-top: .55rem; font-size: .85rem; line-height: 1.3; color: var(--tinta-suave); padding: .3rem .8rem; border-radius: 999px;
  background: rgba(255, 255, 255, .75); border: 1px solid var(--linea); }
.aviso strong { color: var(--tinta); font-weight: 600; }

/* Franja de resumen */
.franja { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding-block: .75rem; }
.contadores { display: flex; gap: .5rem; width: 21rem; max-width: 100%; }
.contador { flex: 1; display: flex; flex-direction: column; align-items: center; padding: .35rem .5rem; border-radius: 14px; font-size: .85rem; line-height: 1.2; border: 1px solid transparent; }
.contador .n { font-family: var(--display); font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.contador.critico { background: var(--critico-suave); color: var(--critico); border-color: #f3c4bf; }
.contador.riesgo { background: var(--ambar-suave); color: var(--ambar-texto); border-color: #f5d58a; }
.contador.ok { background: var(--teal-suave); color: var(--teal-profundo); border-color: #a9dcd9; }
.leyenda { flex: 1 1 16rem; font-size: .85rem; line-height: 1.35; color: var(--tinta-suave); }
.leyenda strong { color: var(--tinta); font-weight: 600; }
.avisos { display: flex; flex-direction: column; gap: .15rem; flex: 1 1 16rem; min-width: 0; }
.avisos:not(:has(> p:not([hidden]))) { display: none; }
#msg-error, #msg-recalculo { font-size: .85rem; line-height: 1.25; padding: .15rem .8rem; border-radius: 999px; }
#msg-error { color: var(--critico); background: var(--critico-suave); }
#msg-recalculo { color: var(--ambar-texto); background: var(--ambar-suave); font-weight: 600; }
#msg-error[hidden], #msg-recalculo[hidden] { display: none; }
.franja:has(.avisos > p:not([hidden])) .leyenda { display: none; }

/* Botones, campos y enfoque */
button { font: 600 .95rem/1.2 var(--texto); cursor: pointer; border-radius: 999px; padding: .5rem 1.1rem; border: 1.5px solid transparent; }
button:disabled { opacity: .6; cursor: wait; }
#btn-restablecer { background: var(--superficie); color: var(--teal-profundo); border-color: var(--teal); }
#btn-restablecer:hover { background: var(--teal-suave); }
#chat-enviar { background: var(--ambar); color: var(--tinta); }
#chat-enviar:hover:not(:disabled) { background: #f7b73f; }
button:focus-visible, input:focus-visible, .celda-desc:focus-visible { outline: 3px solid var(--teal-profundo); outline-offset: 2px; }
input { font-family: var(--texto); color: var(--tinta); }

/* Paneles */
.rejilla { display: grid; gap: 1rem; padding-block: 0 1rem; grid-template-columns: 1fr; }
.panel { background: var(--superficie); border: 1px solid var(--linea); border-radius: 18px; padding: 1rem 1.1rem; min-width: 0; box-shadow: var(--sombra); }
.p-tabla h2, .p-detalle h2, .p-chat h2 { margin: 0 0 .35rem; }

/* Tabla */
.tabla-scroll { overflow: auto; max-height: 34rem; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
th, td { padding: .35rem .22rem; border-bottom: 1px solid var(--linea); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--superficie); font-size: .8rem; font-weight: 600; color: var(--tinta-suave); white-space: normal; }
th.num { white-space: normal; }
.num { text-align: right; white-space: nowrap; }
td:first-child { white-space: nowrap; font-weight: 600; }
tbody tr:hover { background: #f1faf9; }
tr[data-estado="critico"] { background: #fdf3f2; }
tr[data-estado="riesgo"] { background: #fff9e8; }
/* La barra de color va en la primera celda: Safari no pinta sombras en las filas de una tabla */
tr[data-estado="critico"] td:first-child { box-shadow: inset 4px 0 0 var(--critico); }
tr[data-estado="riesgo"] td:first-child { box-shadow: inset 4px 0 0 var(--ambar); }
tr[data-estado="critico"]:hover { background: #fbe9e7; }
tr[data-estado="riesgo"]:hover { background: #fff3d1; }
.celda-desc { cursor: pointer; text-decoration: underline; text-decoration-color: var(--teal); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.celda-desc:hover { color: var(--teal-profundo); }
.etiqueta { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.etiqueta::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.etiqueta.critico { color: var(--critico); background: var(--critico-suave); }
.etiqueta.riesgo { color: var(--ambar-texto); background: var(--ambar-suave); }
.etiqueta.ok { color: var(--teal-profundo); background: var(--teal-suave); }
td input { width: 3.8rem; font-size: inherit; text-align: right; padding: .2rem .3rem; border: 1.5px solid #c5dad7; border-radius: 10px; background: #fff; }
td input:hover { border-color: var(--teal); }
td input[aria-invalid="true"] { border-color: var(--critico); background: var(--critico-suave); }
#tabla-productos.desactualizada tbody { opacity: .55; }

/* Detalle */
.vacio, .nota { color: var(--tinta-suave); font-size: .85rem; line-height: 1.35; }
.p-detalle h2 { font-size: 1rem; margin: 0 0 .15rem; line-height: 1.25; }
.p-detalle h3 { font-size: .8rem; font-weight: 600; margin: 0 0 .15rem; color: var(--tinta-suave); font-family: var(--texto); }
.p-detalle ol { margin: 0 0 .3rem; padding-left: 1.2rem; }
.p-detalle li { font-size: .85rem; line-height: 1.35; margin-bottom: .1rem; }
.p-detalle li::marker { color: var(--teal-profundo); font-weight: 700; }
.p-detalle .nota { margin: 0; font-size: .78rem; line-height: 1.25; }
#detalle.mas-abajo::after { content: "más abajo"; position: sticky; bottom: 0; display: block; margin: -1.6rem -.6rem 0; padding-top: 1.1rem; height: 1.6rem;
  font-size: .72rem; line-height: 1.6rem; text-align: center; color: var(--teal-profundo); font-weight: 600; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--superficie) 70%); }

/* Chat */
.p-chat { padding-block: .45rem; }
.ejemplos { display: flex; flex-wrap: wrap; gap: .2rem .3rem; margin-bottom: .3rem; }
.ejemplo { background: var(--superficie); color: var(--tinta); border: 1.5px solid #bfe0de; font-size: .85rem; font-weight: 500; padding: .1rem .55rem; line-height: 1.3; white-space: nowrap; }
.ejemplo:hover:not(:disabled) { background: var(--teal-suave); border-color: var(--teal); }
#chat-mensajes { display: flex; flex-direction: column; gap: .5rem; overflow-y: auto; min-height: 8.75rem; max-height: 22rem; margin-bottom: .3rem; }
.mensaje { padding: .4rem .7rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; max-width: 95%; font-size: .88rem; line-height: 1.4; }
.mensaje.user { background: var(--teal-profundo); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.mensaje.assistant { background: var(--fondo); border: 1px solid var(--linea); align-self: flex-start; border-bottom-left-radius: 4px; }
.mensaje.error { color: var(--critico); background: var(--critico-suave); border-color: #f3c4bf; }
#chat-form { display: flex; gap: .5rem; }
#chat-form input { flex: 1; min-width: 0; font-size: 1rem; padding: .35rem .9rem; border: 1.5px solid #c5dad7; border-radius: 999px; }
#chat-form button { padding-block: .35rem; }

/* Acceso */
body.acceso { display: grid; place-items: center; min-height: 100vh; background: var(--crema); }
.caja-acceso { background: var(--superficie); border: 1px solid var(--linea); border-radius: 22px; padding: 1.75rem; max-width: 27rem; margin: 16px; box-shadow: var(--sombra); }
.caja-acceso .marcas { margin-bottom: 1.1rem; }
.caja-acceso h1 { font-size: 1.6rem; margin-bottom: .5rem; }
.caja-acceso p { color: var(--tinta-suave); font-size: 1rem; margin-bottom: 1rem; }
.caja-acceso label { display: block; margin-bottom: .3rem; font-weight: 600; }
.caja-acceso input { width: 100%; font-size: 1rem; padding: .55rem .9rem; border: 1.5px solid #c5dad7; border-radius: 12px; margin-bottom: .9rem; }
.caja-acceso button { background: var(--ambar); color: var(--tinta); width: 100%; padding-block: .65rem; }
.caja-acceso button:hover { background: #f7b73f; }
.caja-acceso .cinta { display: inline-block; margin-bottom: 1rem; font-size: .85rem; color: var(--tinta); }
.caja-acceso .logo-ia { height: 40px; } .caja-acceso .logo-an { height: 52px; }
#error-acceso { color: var(--critico); margin: .6rem 0 0; font-size: .95rem; }

/* Movil: una columna; los avisos de red quedan fijos arriba para verse aunque se edite mas abajo */
@media (max-width: 69.99rem) {
  .col-der { display: contents; }
  .avisos { position: fixed; top: 0; left: 16px; right: 16px; z-index: 5; flex-basis: auto; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); border-radius: 14px; }
  .cinta { white-space: normal; }
}

/* Pantalla ancha: tabla, detalle y chat a la vez, sin scroll de pagina */
@media (min-width: 70rem) {
  body.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  body.app .cabecera { flex: none; padding-block: .45rem .4rem; }
  body.app .lead-largo { display: none; }
  body.app h1 { font-size: 1.55rem; }
  body.app .lead { font-size: .9rem; margin-top: .1rem; }
  body.app .aviso { margin-top: .35rem; padding-block: .15rem; }
  body.app .franja { flex: none; flex-wrap: nowrap; padding-block: .35rem; width: 100%; }
  body.app .franja .contador { flex-direction: row; gap: .4rem; align-items: baseline; justify-content: center; padding: .15rem .5rem; }
  body.app .franja .contador .n { font-size: 1.5rem; }
  body.app .franja button { padding-block: .35rem; }
  body.app .avisos { flex: 1 1 16rem; }
  body.app .rejilla { flex: 1; min-height: 0; width: 100%; gap: .5rem .75rem; padding-bottom: .5rem;
    grid-template-columns: minmax(0, 1fr) min(34rem, calc(100vw - 730px)); grid-template-rows: minmax(0, 1fr); }
  .p-tabla { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; min-height: 0; padding-block: .6rem .4rem; }
  .p-tabla .tabla-scroll { flex: 1; min-height: 0; max-height: none; }
  /* Columna derecha: el chat conserva su altura minima y, si el detalle no cabe, el detalle hace
     scroll interno en vez de empujar la caja de escribir fuera de la ventana. */
  .col-der { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
  .p-detalle { flex: 0 1 auto; overflow-y: auto; min-height: 0; padding-block: .45rem; }
  .p-chat { flex: 1 1 0; min-height: 17.75rem; display: flex; flex-direction: column; }
  .p-chat #chat-mensajes { flex: 1 1 0; min-height: 0; max-height: none; }
}
