*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Figtree, la letra de DESIGN.md. Servida desde el propio ERP y no desde Google, para no
   depender de un servicio de fuera ni mandarle la IP de los restaurantes.
   Origen: @fontsource-variable/figtree 5.3.0 (subconjunto latin: tildes, ñ, «», ¿¡, €).
   Licencia SIL OFL 1.1 en /static/fonts/OFL.txt. */
@font-face {
  font-family: "Figtree";
  src: url('/static/fonts/figtree-latin-wght-normal.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Colores de DESIGN.md: mismos nombres y valores (tests/test_marco_visual.py lo vigila).
     Si cambia uno, cambia en DESIGN.md y aquí a la vez. */
  --marino: #1F2A44;
  --naranja: #ED6B1F;
  --naranja-suave: #FFF4EA;
  --naranja-borde: #F6C9A6;
  --fondo: #F4F3F0;
  --superficie: #FFFFFF;
  --tinta: #1B2230;
  --tinta-suave: #5E6678;
  --tinta-lateral: #C9D1E4;
  --borde: #DAD8D2;
  --borde-campo: #8A8578;
  --etiqueta: #EEF0F5;
  --etiqueta-tinta: #3A4664;
  --ok: #1E7A36;
  --ok-suave: #E3F3E7;
  --aviso: #9A5D00;
  --aviso-suave: #FFF1D6;
  --ko: #C62828;
  --ko-suave: #FBE3E3;

  --marino-hover: #2B3858;
  --r-control: 8px;
  --r-tarjeta: 12px;
  /* Hueco blanco y anillo naranja: se ve sobre marino y sobre blanco. */
  --anillo: 0 0 0 2px #fff, 0 0 0 4px var(--naranja);
  --sombra-modal: 0 20px 50px rgba(0,0,0,.25);
  --sidebar-w: 190px;

  /* Nombres viejos, como alias de los nuevos: las plantillas que aún los usan siguen
     funcionando hasta que se repase cada una (fases 2 a 5 del #38). No usar en código nuevo. */
  --amarillo: var(--naranja);
  --amarillo-oscuro: var(--naranja);
  --marca-tinta: var(--marino);
  --gris-oscuro: var(--marino);
  --gris-medio: var(--tinta-suave);
  --gris-claro: var(--fondo);
  --tinta-900: var(--tinta);
  --tinta-700: var(--tinta-suave);
  --tinta-500: var(--tinta-suave);
  --tinta-400: #8E96A8;
  --blanco: var(--superficie);
  --borde-fuerte: var(--borde-campo);
  --rojo: var(--ko);
  --rojo-fuerte: var(--ko);
  --rojo-bg: var(--ko-suave);
  --verde: var(--ok);
  --verde-fuerte: var(--ok);
  --verde-bg: var(--ok-suave);
  --ambar: var(--aviso);
  --ambar-bg: var(--aviso-suave);
  --azul: #2563eb;   /* no es de marca; lo usan plantillas de fases posteriores */
  --r-sm: var(--r-control);
  --r: var(--r-control);
  --r-lg: var(--r-tarjeta);
  --sombra-sm: none;
  --sombra: none;
}

body {
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  background: var(--fondo);
  color: var(--tinta);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Barras de desplazamiento de la página y de todo lo que hace scroll (tablas anchas, cajas):
   finas, en marino translúcido sobre el fondo claro, sin flechas; nunca la gris del sistema
   (#231). El menú lateral lleva la suya, en tinta del lateral (.sidebar-nav, más abajo).
   Mismo reparto que allí: Chrome y Edge con ::-webkit-scrollbar, que deja quitar las flechas;
   scrollbar-color solo donde no existe (Firefox), porque Chrome lo preferiría y volverían. */
:root {
  --barra-clara: color-mix(in srgb, var(--marino) 24%, transparent);
  --barra-clara-viva: color-mix(in srgb, var(--marino) 45%, transparent);
}
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-width: thin; scrollbar-color: var(--barra-clara) transparent; }
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--barra-clara); border: 3px solid transparent; border-radius: 999px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--barra-clara-viva); }
::-webkit-scrollbar-thumb:active { background-color: var(--marino); }
::-webkit-scrollbar-button { display: none; }

a { color: inherit; }
/* Sin esto el navegador pone Arial en campos y botones. Solo la familia: el tamaño lo fija cada pieza. */
button, input, select, textarea { font-family: inherit; }
h1, h2, h3 { line-height: 1.25; color: var(--tinta); text-wrap: balance; }

/* ── LOGIN ── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--marino); padding: 1rem; }
.login-box { background: var(--superficie); border-radius: var(--r-tarjeta); padding: 2.5rem 2rem; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--marino); }
.login-logo span { color: var(--naranja); }
.login-marca { font-size: 1.05rem; font-weight: 700; color: var(--marino); margin-top: .15rem; }
.login-sub { font-size: .9rem; color: var(--tinta-suave); margin-top: .3rem; }
.login-enlace { color: var(--tinta-suave); display: inline-flex; align-items: center; min-height: 44px; }
.login-enlace:hover { color: var(--marino); }

/* ── FORMULARIOS ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; color: var(--tinta-suave); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; min-height: 40px; padding: .55rem .8rem; border: 1px solid var(--borde-campo); border-radius: var(--r-control);
  font-size: .95rem; font-family: inherit; color: var(--tinta); background: var(--superficie); transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--marino); box-shadow: var(--anillo);
}
/* Solo ver (#285): quien no puede editar recibe las casillas `readonly` dentro de un
   `.solo-ver`, y se leen como texto. Dos clases y la etiqueta: gana a `.form-group input`,
   `.precio-cell input` y a las casillas propias de cada pantalla. */
.solo-ver input[readonly], .solo-ver textarea[readonly] {
  border-color: transparent; background: transparent; box-shadow: none; cursor: default;
}
.alerta-error { background: var(--ko-suave); color: var(--ko); border: 1px solid var(--ko); border-radius: var(--r-sm); padding: .7rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.alerta-ok { background: var(--ok-suave); color: var(--ok); border: 1px solid var(--ok); border-radius: var(--r-sm); padding: .7rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
/* Aviso que pide decidir antes de seguir (p. ej. un segundo pedido para el mismo día, #238)
   o que señala algo pendiente (las reservas de la web sin entrar en la bandeja, #3).
   Texto en tinta: el ámbar solo marca el borde y el fondo (Semáforo de DESIGN.md). El enlace
   de la bandeja ya hereda la tinta por la regla general `a { color: inherit; }`. */
.alerta-aviso { background: var(--aviso-suave); color: var(--tinta); border: 1px solid var(--aviso); border-radius: var(--r-sm); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .95rem; }
.alerta-aviso > strong { display: block; color: var(--aviso); margin-bottom: .3rem; }
.alerta-aviso ul { margin: .3rem 0 .6rem; padding-left: 1.2rem; }
.alerta-aviso-acciones { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .7rem; }
.alerta-aviso-acciones .btn { min-height: 44px; }
/* El aviso entero es un enlace (p. ej. «Tienes un envío por recibir» en Inicio y Envíos, #295). */
.aviso-enlace { display: block; text-decoration: none; }
.aviso-enlace:hover { border-color: var(--marino); }
.aviso-enlace:focus-visible { outline: none; box-shadow: var(--anillo); }
/* Una línea de explicación bajo el título de una pantalla. */
.nota-pagina { color: var(--tinta-suave); font-size: .875rem; margin: 0 0 .8rem; max-width: 70ch; }
/* Ayuda de una etiqueta corta («+3p», «Abierto», «Ped.»…, #295): se explica al pasar el ratón,
   al llegar con el teclado o al tocarla en la tablet (base.html le pone y quita .abierta). El
   texto va en data-ayuda y no dentro de la etiqueta: así no se cuela en las etiquetas de las
   tablas en móvil, que salen del texto de la cabecera. No sale en papel. */
.ayuda { position: relative; cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.ayuda::after {
  content: attr(data-ayuda); display: none; position: absolute; z-index: 40; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); width: max-content; max-width: min(18rem, 80vw); padding: .5rem .7rem;
  border-radius: var(--r-sm); background: var(--marino); color: var(--superficie);
  font-size: .8125rem; font-weight: 400; line-height: 1.35; letter-spacing: normal; text-transform: none;
  text-align: left; white-space: normal;
}
.ayuda.abierta::after, .ayuda:focus-visible::after { display: block; }
.ayuda:focus-visible { outline: none; box-shadow: var(--anillo); border-radius: 4px; }
@media (hover: hover) { .ayuda:hover::after { display: block; } }
@media print { .ayuda::after { display: none !important; } .ayuda { text-decoration: none; } }
/* Marca corta en ámbar dentro de una fila (p. ej. «llegó después del corte» en la bandeja, #3). */
.etiqueta-aviso { background: var(--aviso-suave); color: var(--aviso); border-radius: 6px; padding: .05rem .4rem; font-weight: 600; }

/* ── BOTONES (táctiles) ──
   Uno relleno (marino) por pantalla: la acción principal. El resto, de contorno. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.1rem; min-height: 40px;
  border: 1px solid var(--borde-campo); border-radius: var(--r-control);
  font-family: inherit; font-size: .9rem; font-weight: 700; line-height: 1; white-space: nowrap;
  background: var(--superficie); color: var(--marino);
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--fondo); }
.btn:focus-visible { outline: none; box-shadow: var(--anillo); }
.btn:disabled, .btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }
/* Por qué un botón está desactivado, al lado del botón (#287). */
.motivo-desactivado { font-size: .85rem; color: var(--tinta-500); }

.btn-primary { background: var(--marino); color: #fff; border-color: var(--marino); }
.btn-primary:hover { background: var(--marino-hover); border-color: var(--marino-hover); }
.btn-secondary { background: var(--superficie); color: var(--marino); border-color: var(--borde-campo); }
.btn-secondary:hover { background: var(--fondo); }
.btn-danger { background: var(--ko); color: #fff; border-color: var(--ko); }
.btn-danger:hover { background: #A52020; border-color: #A52020; }
.btn-success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-success:hover { background: #17742F; border-color: #17742F; }
.btn-dark { background: var(--marino); color: #fff; border-color: var(--marino); }
.btn-dark:hover { background: var(--marino-hover); border-color: var(--marino-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--marino); }
.btn-ghost:hover { background: var(--etiqueta); border-color: transparent; }

.btn-sm { padding: .35rem .75rem; min-height: 30px; font-size: .82rem; gap: .35rem; }
.btn-full { width: 100%; }

/* ── LAYOUT PRINCIPAL ── */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--marino); color: var(--tinta-lateral); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.sidebar-logo { padding: 1.2rem 1rem .8rem; font-size: 15px; font-weight: 800; color: #fff; }
.sidebar-logo span { color: var(--naranja); }
.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; overscroll-behavior: contain;
  /* Barra de desplazamiento fina en el tono del lateral, no la gris del sistema (#231). Se ve
     siempre, suave, porque es la única pista de que el menú sigue hacia abajo; al pasar por
     el menú se aviva. Chrome y Edge usan ::-webkit-scrollbar, que deja quitar las flechas; si
     se les pusiera scrollbar-color, lo usarían en su lugar y volverían las flechas. Por eso
     scrollbar-color va solo para los navegadores sin ::-webkit-scrollbar (Firefox). */
  --barra: color-mix(in srgb, var(--tinta-lateral) 22%, transparent);
  --barra-viva: color-mix(in srgb, var(--tinta-lateral) 45%, transparent); }
@supports not selector(::-webkit-scrollbar) {
  .sidebar-nav { scrollbar-width: thin; scrollbar-color: var(--barra) transparent; }
  .sidebar-nav:hover { scrollbar-color: var(--barra-viva) transparent; }
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--barra); border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }
.sidebar-nav:hover::-webkit-scrollbar-thumb { background-color: var(--barra-viva); }
.sidebar-nav::-webkit-scrollbar-button { display: none; }
.sidebar-nav a { display: block; position: relative; margin: 1px 8px; padding: .45rem .65rem; border-radius: 6px; color: var(--tinta-lateral); text-decoration: none; font-size: .9rem; transition: background .12s, color .12s; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a:focus-visible { outline: none; box-shadow: var(--anillo); }
.sidebar-nav a.activo { background: rgba(255,255,255,.12); color: #fff; font-weight: 700; }
/* La marca naranja de la entrada activa, pegada al borde del lateral. */
.sidebar-nav a.activo::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--naranja); }
.sidebar-nav .seccion { padding: .85rem 1.1rem .2rem; font-size: 12px; font-weight: 600; color: var(--tinta-lateral); opacity: .7; }
/* Grupos plegables y favoritos del menú (#231). El título del grupo es un <summary>: se pincha
   entero para plegar o desplegar, con una flecha que gira. */
.sidebar-nav .grupo > summary { display: flex; align-items: center; justify-content: space-between; margin: 0 8px; padding-left: .65rem; padding-right: .65rem; border-radius: 6px; list-style: none; cursor: pointer; user-select: none; transition: opacity .12s; }
.sidebar-nav .grupo > summary::-webkit-details-marker { display: none; }
.sidebar-nav .grupo > summary::after { content: ""; width: 6px; height: 6px; margin-right: 4px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.sidebar-nav .grupo[open] > summary::after { transform: rotate(45deg); }
.sidebar-nav .grupo > summary:hover { opacity: 1; }
.sidebar-nav .grupo > summary:focus-visible { outline: none; box-shadow: var(--anillo); opacity: 1; }
.sidebar-nav .fila { position: relative; }
.sidebar-nav .fila > a { padding-right: 1.6rem; }
/* La estrella sale al pasar por el enlace; fijada, se queda rellena en blanco. No en naranja:
   el naranja del lateral es solo «dónde estás» (Naranja Escaso, DESIGN.md). */
.sidebar-nav .fijar { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--tinta-lateral); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s; }
.sidebar-nav .fijar svg { fill: none; }
.sidebar-nav .fila:hover .fijar, .sidebar-nav .fijar:focus-visible { opacity: .8; }
.sidebar-nav .fijar:hover { color: #fff; opacity: 1; }
.sidebar-nav .fijar:focus-visible { outline: none; box-shadow: var(--anillo); }
.sidebar-nav .fijar[aria-pressed="true"] { color: #fff; opacity: .9; }
.sidebar-nav .fijar[aria-pressed="true"] svg { fill: currentColor; }
/* Sin ratón (tablet) no hay «pasar por encima»: la estrella se ve siempre, más suave. */
@media (hover: none) { .sidebar-nav .fijar { opacity: .45; } }
.sidebar-footer { padding: .9rem 1.1rem; border-top: 1px solid rgba(255,255,255,.12); font-size: .82rem; color: var(--tinta-lateral); }
.sidebar-footer a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.sidebar-footer a:hover { color: var(--tinta-lateral); }
/* «Cerrar sesión» es un formulario (POST /logout, issue #49), no un enlace. El botón se
   pinta como el enlace que era: sin caja y con la letra y el color de donde esté. */
.form-salir { display: inline; margin: 0; }
.boton-enlace { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: inherit; }
.sidebar-footer .boton-enlace { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.sidebar-footer .boton-enlace:hover { color: var(--tinta-lateral); }
.sidebar-footer .boton-enlace:focus-visible { outline: none; box-shadow: var(--anillo); border-radius: 4px; }

/* Contenido */
.contenido { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--superficie); padding: .8rem 1.75rem; border-bottom: 1px solid var(--borde); font-size: .875rem; font-weight: 600; color: var(--tinta-suave); }
.main { padding: 1.75rem; overflow-y: auto; }
.main-inner { width: 100%; max-width: 1280px; margin: 0 auto; }
.pagina-titulo { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.3rem; color: var(--tinta); }

/* Encabezado de página (título + acciones) */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-head .pagina-titulo { margin-bottom: 0; }
.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.page-resumen { color: var(--tinta); margin-top: .2rem; }

/* Filtros de una lista: grupos de opciones que son enlaces y se aplican al pulsar. */
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.filtro { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.filtro-nombre { font-size: .8125rem; font-weight: 600; color: var(--tinta-suave); }
.opciones { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--borde-campo); border-radius: var(--r-control); background: var(--superficie); overflow: hidden; }
.opciones a { display: inline-flex; align-items: center; min-height: 38px; padding: 0 .8rem; font-size: .9rem; font-weight: 600; color: var(--tinta-suave); text-decoration: none; }
.opciones a + a { border-left: 1px solid var(--borde); }
.opciones a:hover { background: var(--fondo); color: var(--tinta); }
.opciones a[aria-current] { background: var(--marino); color: #fff; font-weight: 700; }
/* Hacia dentro: el grupo recorta lo que se sale. */
.opciones a:focus-visible { outline: 2px solid var(--naranja); outline-offset: -3px; }
.campo { min-height: 40px; padding: .4rem .7rem; font-size: .9rem; color: var(--tinta); background: var(--superficie); border: 1px solid var(--borde-campo); border-radius: var(--r-control); }
.campo:focus-visible { outline: none; border-color: var(--marino); box-shadow: var(--anillo); }

/* Lista: la tarjeta sin relleno y la fila que empieza por lo que la identifica. */
.card.tabla-card { padding: 0; overflow: hidden; }
.fila-nombre { display: block; font-weight: 700; }
.fila-dato { display: block; font-size: .8125rem; font-weight: 400; color: var(--tinta-suave); }
.fila-acciones { display: flex; justify-content: flex-end; gap: .4rem; }
.cifra { font-variant-numeric: tabular-nums; white-space: nowrap; }
.etiqueta { display: inline-block; padding: .1rem .55rem; border-radius: 6px; font-size: .8125rem; font-weight: 600; background: var(--etiqueta); color: var(--etiqueta-tinta); white-space: nowrap; }
.etiqueta-aviso { background: var(--aviso-suave); color: var(--aviso); }
.etiqueta-ok { background: var(--ok-suave); color: var(--ok); }
.card-cabecera-cuadre { padding: .9rem 1.2rem .6rem; }
.card-cabecera-cuadre .card-titulo { margin-bottom: .3rem; }
.card-cabecera-cuadre p { margin: .25rem 0; }
tbody td.vacio { padding: 2rem 1rem; text-align: center; color: var(--tinta-suave); }

/* Tarjetas */
.card { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); padding: 1.25rem 1.4rem; margin-bottom: 1.1rem; }
.card-titulo { font-size: 1.125rem; font-weight: 800; margin-bottom: .8rem; color: var(--tinta); }
/* Tarjetas clicables (envueltas en <a> o con .card-link) */
a > .card, .card-link { transition: border-color .15s; }
a:hover > .card, .card-link:hover { border-color: var(--borde-campo); }

/* Tablas */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th { text-align: left; padding: .6rem .85rem; font-weight: 600; font-size: .8125rem; color: var(--tinta-suave); border-bottom: 1px solid var(--borde); }
tbody td { padding: .62rem .85rem; border-bottom: 1px solid var(--borde); vertical-align: middle; color: var(--tinta); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--fondo); }

.badge { display: inline-block; padding: .2rem .6rem; border-radius: 20px; font-size: .74rem; font-weight: 700; }
.badge-admin { background: #f9ecd8; color: #a05000; }
.badge-oficina { background: #dceeff; color: #1a5fad; }
.badge-tienda { background: #d8f5e3; color: #1a7a3f; }
.badge-obrador { background: #f0d8ff; color: #6a1aad; }
.badge-activo { background: #d8f5e3; color: #1a7a3f; }
.badge-inactivo { background: var(--rojo-bg); color: var(--rojo); }

/* ── CATÁLOGO (vista centrada en producto) ── */
.icon { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; }

/* Pestañas */
.cat-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--borde); margin-bottom: 1.2rem; }
.cat-tab { padding: .6rem 1.1rem; color: var(--gris-medio); text-decoration: none; font-size: .92rem; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.cat-tab:hover { color: var(--gris-oscuro); }
.cat-tab.activo { color: var(--marino); border-bottom-color: var(--marino); }

/* Maestro-detalle */
.cat-layout { display: grid; grid-template-columns: 240px 1fr; gap: 1.2rem; align-items: start; }
.cat-rail { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); overflow: hidden; }
.cat-rail-search { position: relative; padding: .7rem; border-bottom: 1px solid #eee; }
.cat-rail-search input { width: 100%; padding: .45rem .6rem .45rem 2rem; border: 1px solid var(--borde-fuerte); border-radius: var(--r-sm); font-size: .88rem; }
.cat-rail-search input:focus { outline: none; border-color: var(--marino); box-shadow: var(--anillo); }
.cat-rail-search .icon { position: absolute; left: 1.2rem; top: 50%; transform: translateY(-50%); color: #aaa; }
.cat-prod-list { max-height: 60vh; overflow-y: auto; }
.cat-prod-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; text-align: left; padding: .6rem .9rem; border: none; background: none; border-left: 3px solid transparent; cursor: pointer; font-size: .9rem; color: var(--gris-oscuro); border-bottom: 1px solid #f3f3f3; }
.cat-prod-item:hover { background: #fafafa; }
/* Fila del rail: enlace + flechas de orden */
.cat-prod-row { display: flex; align-items: stretch; border-bottom: 1px solid #f3f3f3; }
.cat-prod-row .cat-prod-item { flex: 1; border-bottom: none; min-width: 0; }
.cat-prod-arrows { display: flex; flex-direction: column; justify-content: center; padding-right: .4rem; }
.cat-prod-arrows button { border: none; background: none; cursor: pointer; font-size: .55rem; color: #bbb; padding: .15rem .3rem; line-height: 1; }
.cat-prod-arrows button:hover { color: var(--gris-oscuro); }
.cat-prod-arrows button:disabled { color: #eee; cursor: default; }
.cat-prod-item.activo { background: var(--etiqueta); border-left-color: var(--marino); font-weight: 700; }
.cat-prod-item.inactivo span.nombre { color: #aaa; text-decoration: line-through; }
.cat-prod-item .punto { width: 8px; height: 8px; border-radius: 50%; background: var(--verde); flex-shrink: 0; }
.cat-prod-item.inactivo .punto { background: #ccc; }
.cat-rail-foot { padding: .7rem; border-top: 1px solid #eee; }

.cat-panel { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); padding: 1.4rem; }
.cat-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #eee; margin-bottom: 1.2rem; }
.cat-panel-head h2 { font-size: 1.25rem; }
.cat-panel-head .meta { font-size: .85rem; color: var(--gris-medio); margin-top: .25rem; }
.cat-panel-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.cat-section { margin-bottom: 1.6rem; }
.cat-nota { font-size: .875rem; color: var(--tinta-suave); margin-bottom: .6rem; max-width: 65ch; }
.cat-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #999; font-weight: 700; margin-bottom: .7rem; }

/* Botones de acción compactos dentro de tarjetas/paneles del catálogo */
.cat-card-actions .btn, .cat-panel-actions .btn-sm { min-height: 30px; }

/* Rejilla de precios por tamaño */
.precio-row { display: grid; grid-template-columns: 150px repeat(3, 1fr); gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid #f3f3f3; }
.precio-row.head { border-bottom: 1px solid #ddd; padding-bottom: .35rem; }
.precio-row.head span { font-size: .72rem; color: #999; font-weight: 700; text-transform: uppercase; }
.precio-row .tam { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .9rem; }
.precio-row .tam small { font-weight: 400; color: #aaa; }
.precio-cell { display: flex; align-items: center; gap: .3rem; }
.precio-cell input { width: 100%; max-width: 90px; padding: .35rem .5rem; border: 1px solid var(--borde-fuerte); border-radius: 5px; font-size: .88rem; text-align: right; }
.precio-cell input:focus { outline: none; border-color: var(--marino); box-shadow: var(--anillo); }
.precio-cell input:disabled { background: #f6f6f6; color: #ccc; }
.precio-cell .eur { color: #bbb; font-size: .8rem; }
.precio-row.off .precio-cell { opacity: .4; }

/* Control segmentado de estado de sabor */
.sabor-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid #f3f3f3; }
.sabor-row .nombre { font-weight: 600; font-size: .9rem; }
.seg { display: inline-flex; border: 1px solid var(--borde-fuerte); border-radius: var(--r-sm); overflow: hidden; }
.seg button { padding: .3rem .7rem; border: none; background: var(--blanco); cursor: pointer; font-size: .8rem; font-weight: 600; color: #777; transition: background .12s; }
.seg form + form button { border-left: 1px solid #eee; }
/* Hacia dentro: el grupo recorta lo que se sale, y sobre marino el anillo del navegador no se ve. */
.seg button:focus-visible { outline: 2px solid var(--naranja); outline-offset: -3px; }
.seg button:hover { background: #fafafa; }
.seg button.on-prod { background: #dcfce7; color: #15803d; }
.seg button.on-enc { background: #fef3c7; color: #b45309; }
.seg button.on-dest { background: var(--marino); color: #fff; }
.seg button.on-out { background: #fee2e2; color: #b91c1c; }
.seg button.on-az { background: #e0f2fe; color: #075985; }
.seg button.on-gl { background: #ede9fe; color: #6d28d9; }
.seg-dieta { border-color: #cdd8e6; }

/* Casillas de variante en el formulario de pedido */
.celda-dieta { white-space: nowrap; }
.chk-dieta { display: inline-flex; align-items: center; gap: .2rem; font-size: .78rem; font-weight: 600; color: #555; cursor: pointer; margin-right: .5rem; }
.chk-dieta input[type=checkbox] { cursor: pointer; }
.chk-dieta.off { color: #c2c2c2; cursor: not-allowed; }
.chk-dieta.off input[type=checkbox] { cursor: not-allowed; }

/* Etiqueta de variante (sin azúcar / sin gluten) allí donde se lee un pedido */
.etq { display: inline-block; padding: .1rem .45rem; border-radius: 4px; font-size: .7rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; vertical-align: middle; }
.etq-az { background: #e0f2fe; color: #075985; }
.etq-gl { background: #ede9fe; color: #6d28d9; }

/* Pestaña Sin azúcar / Sin gluten: las dos listas de consulta */
.dietas-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.dieta-col { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); overflow: hidden; }
.dieta-col-head { padding: .8rem 1.1rem; font-weight: 800; font-size: .95rem; letter-spacing: .03em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.dieta-col-head .cuenta { font-size: .78rem; font-weight: 600; opacity: .75; text-transform: none; letter-spacing: 0; }
.dieta-col-az .dieta-col-head { background: #e0f2fe; color: #075985; }
.dieta-col-gl .dieta-col-head { background: #ede9fe; color: #6d28d9; }
.dieta-grupo { padding: .8rem 1.1rem; border-top: 1px solid #f1f5f9; }
.dieta-grupo h4 { margin: 0 0 .45rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #999; font-weight: 700; }
.dieta-grupo ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; }
.dieta-grupo li { background: #f6f7f9; border: 1px solid var(--borde); border-radius: 20px; padding: .18rem .65rem; font-size: .84rem; font-weight: 600; }
.dieta-vacio { padding: 2rem 1.1rem; text-align: center; color: #999; font-size: .88rem; }
@media (max-width: 780px) { .dietas-cols { grid-template-columns: 1fr; } }

/* Multiselección: Producción/Encargo juntos, Out despegado a la derecha */
.seg-grupo { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .5rem .9rem; }
.seg-out { border-color: #e5c4c4; }
/* Sabor con Out marcado: deshabilitado visualmente, manda sobre los otros flags */
.sabor-row.deshabilitado .nombre { color: #b0b0b0; text-decoration: line-through; }
.sabor-row.deshabilitado .seg:not(.seg-out) { opacity: .45; }

.cat-flash { background: #dcfce7; color: #15803d; border-radius: var(--r-sm); padding: .5rem .9rem; font-size: .88rem; font-weight: 600; margin-bottom: 1rem; display: inline-flex; align-items: center; gap: .4rem; }
.cat-empty { text-align: center; padding: 3rem 1rem; color: #999; }

/* Cuadros (sabores / tamaños) */
.cat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.cat-card { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); padding: 1rem 1.1rem; display: flex; flex-direction: column; }
.cat-card.off { opacity: .55; }
.cat-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.cat-card-head h3 { font-size: 1rem; }
.cat-card-head .sub { font-size: .78rem; color: #aaa; font-weight: 400; }
.cat-card-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.cat-card-actions .btn { padding: .25rem .5rem; }
.asign-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #999; font-weight: 700; margin-bottom: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid var(--borde-fuerte); background: var(--blanco); color: #888; border-radius: 20px; padding: .25rem .7rem; font-size: .82rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; transition: border-color .12s, background .12s; }
.chip:hover { border-color: #bbb; }
.chip.on { background: var(--etiqueta); border-color: var(--marino); color: var(--marino); }
.chip.on .tick { color: var(--marino); }
.chip .tick { display: none; }
.chip.on .tick { display: inline-flex; }

@media (max-width: 760px) {
  .cat-layout { grid-template-columns: 1fr; }
  .cat-prod-list { max-height: 40vh; }
  .main { padding: 1.1rem; }
}

/* Reservas de la web (#3): tarjeta de cada reserva sin entrar y títulos de sus bloques. */
.reserva-web .card-titulo { margin-bottom: .2rem; }
.reserva-web-datos { color: var(--tinta-suave); margin-bottom: .8rem; }
.reserva-web-motivo { color: var(--aviso); margin-top: .8rem; }
.reserva-web-acciones { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.reserva-web-descartar { margin-top: .6rem; }
.reservas-web-titulo { font-size: 1.125rem; font-weight: 800; margin: 2rem 0 .3rem; color: var(--tinta); }
.reservas-web-ayuda { color: var(--tinta-suave); margin-bottom: .8rem; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.abierto { display: flex; }
.modal { background: var(--superficie); border-radius: var(--r-tarjeta); padding: 1.5rem; width: 100%; max-width: 440px; box-shadow: var(--sombra-modal); }
.modal h3 { margin-bottom: 1rem; }
.modal-footer { display: flex; gap: .8rem; justify-content: flex-end; margin-top: 1.2rem; }

/* ══════════════════════════════════════════════════════════════
   PAPEL: lo impreso no cambia con el repaso de pantalla (#38).
   La hoja de rutas y las fichas de envío no fijan letra ni color propios: los heredan de
   aquí. En papel conservan los de siempre, porque cambiar la letra mueve saltos de línea
   y de página. Va ANTES del bloque móvil a propósito: un A4 mide menos de 900 px, así que
   ese bloque también se aplica al imprimir y tiene que seguir ganando.
   ══════════════════════════════════════════════════════════════ */
@media print {
  :root {
    --fondo: #f1f5f9; --borde: #e2e8f0; --borde-campo: #cbd5e1;
    --tinta: #0f172a; --tinta-suave: #64748b; --tinta-700: #334155; --tinta-400: #94a3b8;
    --r-tarjeta: 10px;
  }
  body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; }
  button, input, select, textarea { font-family: revert; }
  h1, h2, h3 { text-wrap: wrap; }
  .pagina-titulo { font-size: 1.4rem; font-weight: 700; }
  .card-titulo { font-size: 1rem; font-weight: 700; }
  thead th { background: #f8fafc; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  tbody td { color: var(--tinta-700); }
  .card, table.tabla-movil tbody tr, table.tabla-movil tfoot tr { box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.09); }
}

/* ══════════════════════════════════════════════════════════════
   MÓVIL / TABLET  (≤ 900px)
   Nada de aquí abajo afecta a escritorio.
   ══════════════════════════════════════════════════════════════ */

/* Cajón: en escritorio el botón y el velo no existen */
.nav-toggle { display: none; }
.sidebar-velo { display: none; }
/* Envoltorio de tablas que no caben: sin efecto mientras quepan */
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {

  /* ── Layout: el sidebar sale del flujo ── */
  .layout { display: block; }
  .contenido { min-height: 100vh; min-height: 100dvh; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
    width: 82vw; max-width: 300px; height: 100vh; height: 100dvh;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.abierto { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.3); }

  .sidebar-velo {
    display: block; position: fixed; inset: 0; z-index: 150;
    background: rgba(15,23,42,.55);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .sidebar-velo.abierto { opacity: 1; pointer-events: auto; }

  /* Enlaces del menú al tamaño del dedo */
  .sidebar-nav a { padding: .8rem 1.15rem; font-size: .98rem; }
  .sidebar-nav .seccion { padding-top: 1rem; }
  .sidebar-nav .fila > a { padding-right: 3rem; }
  .sidebar-nav .grupo > summary { min-height: 44px; padding: .4rem 1.15rem; }
  .sidebar-nav .fijar { width: 40px; height: 40px; right: 10px; }
  .sidebar-logo { padding: 1.1rem 1.15rem; }
  /* «Cambiar contraseña» y «Cerrar sesión», también al tamaño del dedo (#289) */
  .sidebar-footer a, .sidebar-footer .boton-enlace { display: inline-flex; align-items: center; min-height: 44px; }

  /* ── Topbar con hamburguesa, siempre a mano ── */
  .topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .75rem;
    box-shadow: 0 1px 3px rgba(15,23,42,.07);
  }
  .topbar-texto { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex-shrink: 0; margin-left: -.25rem;
    border: none; background: none; border-radius: var(--r-sm);
    color: var(--tinta-700); cursor: pointer;
  }
  .nav-toggle:active { background: var(--gris-claro); }

  .main { padding: 1rem .8rem; }
  .pagina-titulo { font-size: 1.2rem; }

  /* ── Formularios ──
     Safari iOS hace auto-zoom (y ya no vuelve) en cualquier campo por debajo de
     16px. Va con !important a propósito: 17 plantillas fijan el tamaño con
     style="" en línea y si no, ganan ellas. */
  input, select, textarea { font-size: 16px !important; }
  .n { font-size: 1.1rem !important; }  /* ya estaba por encima de 16px */

  /* ── Objetivos táctiles ── */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select, textarea { min-height: 44px !important; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }

  .btn { min-height: 44px; padding: .6rem 1rem; }
  .btn-sm, .cat-card-actions .btn, .cat-panel-actions .btn-sm { min-height: 38px; }
  .page-head { align-items: stretch; }
  .page-actions { width: 100%; }
  .opciones a, .campo { min-height: 44px; }
  .opciones a { padding: 0 .6rem; }
  /* Cada fila ya es una tarjeta: la de fuera sobraría. */
  .card.tabla-card { background: none; border: 0; border-radius: 0; overflow: visible; }
  /* Una tabla ancha ya es una pila de tarjetas: su caja de scroll (base.html) no hace
     falta y recortaría la sombra de cada tarjeta por los lados. */
  .tabla-scroll-ancha { overflow: visible; }
  .fila-acciones { flex-wrap: wrap; }
  .fila-acciones .btn { flex: 1 1 8rem; }
  .page-actions .btn { flex: 1 1 auto; }

  /* Chips, segmentados y filas del rail del catálogo */
  .chip, .seg button { min-height: 38px; padding: .5rem .9rem; }
  .cat-prod-item { padding: .75rem .9rem; }
  /* Las flechas de orden pasan a estar en fila: 36px cada una sin doblar el alto */
  .cat-prod-arrows { flex-direction: row; align-items: center; gap: .2rem; }
  .cat-prod-arrows button { min-width: 36px; min-height: 36px; font-size: .7rem; }

  /* Enlaces y botones dentro de celdas de tabla: que se puedan pulsar */
  table.tabla-movil td a, .tabla-scroll td a { display: inline-flex; align-items: center; min-height: 36px; }
  table.tabla-movil td button, .tabla-scroll td button { min-height: 36px; min-width: 36px; }

  /* Rejillas de 2-3 columnas puestas con style="" en línea → una sola columna.
     Las de auto-fill/minmax ya se adaptan solas y no se tocan.
     minmax(0,1fr) y no 1fr: 1fr no baja del ancho mínimo de su contenido, así que
     una sola fila que no se parte ensanchaba toda la columna y la página se salía
     por la derecha (issue #190, Nuevo pedido a 390 px). */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] { grid-template-columns: minmax(0, 1fr) !important; }

  /* ── Tarjetas y contenedores ── */
  .card { padding: 1rem; }
  .modal { max-height: 88vh; max-height: 88dvh; overflow-y: auto; }
  .cat-layout { grid-template-columns: 1fr; }
  .cat-panel { padding: 1rem; }
  .precio-row { grid-template-columns: 90px repeat(3, 1fr); gap: .35rem; }
  .precio-cell input { max-width: none; }
  .sabor-row { flex-wrap: wrap; }

  /* ══ TABLAS ══
     ≥4 columnas → cada fila es una tarjeta (las marca el JS de base.html).
     Las de 2-3 columnas caben, solo se envuelven en scroll por si acaso. */
  table.tabla-movil,
  table.tabla-movil tbody,
  table.tabla-movil tfoot,
  table.tabla-movil tr,
  table.tabla-movil td { display: block; }
  table.tabla-movil thead { display: none; }

  table.tabla-movil tbody tr,
  table.tabla-movil tfoot tr {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--r-tarjeta);
    padding: .2rem .9rem .35rem;
    margin-bottom: .7rem;
  }
  table.tabla-movil tbody tr:hover { background: var(--superficie); }

  table.tabla-movil tbody td,
  table.tabla-movil tfoot td {
    display: flex; align-items: center; justify-content: space-between; gap: .9rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--gris-claro);
    text-align: left;
    color: var(--tinta);
  }
  table.tabla-movil tr td:last-child { border-bottom: none; }

  table.tabla-movil td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--tinta-400);
  }

  /* Primera celda = título de la tarjeta */
  table.tabla-movil td.celda-titulo {
    display: block;
    font-size: 1rem; font-weight: 700;
    padding: .55rem 0 .5rem;
    border-bottom: 1px solid var(--borde);
  }
  table.tabla-movil td.celda-titulo::before { content: none; }

  /* Celdas sin cabecera (acciones, totales, "no hay datos") a lo ancho */
  table.tabla-movil td.celda-ancha { display: block; text-align: center; }
  table.tabla-movil td.celda-ancha::before { content: none; }
  table.tabla-movil td.celda-ancha .btn { width: 100%; margin-top: .15rem; }

  /* Reservas de la web (#3). Un desplegable con nombres largos no se encoge solo: a lo ancho
     de su tarjeta y nunca más, o se sale por la derecha y queda cortado. */
  .reserva-web select, table.tabla-equivalencias select { width: 100%; max-width: 100%; }
  /* Líneas de la reserva: el texto arriba a todo lo ancho y debajo su pareja o el desplegable. */
  table.reserva-web-lineas, .reserva-web-lineas tbody, .reserva-web-lineas tr, .reserva-web-lineas td { display: block; }
  .reserva-web-lineas tr { padding: .6rem 0; border-bottom: 1px solid var(--borde); }
  .reserva-web-lineas tr:hover { background: none; }
  .reserva-web-lineas tbody td { padding: 0; border: 0; }
  .reserva-web-lineas td + td { margin-top: .4rem; }
  .reserva-web-acciones .btn { flex: 1 1 auto; }
  /* Equivalencias: tabla-movil de tres columnas (lista.html). Arriba el nombre de la web, que
     es lo que se reconoce; debajo el código en tinta suave y el desplegable a lo ancho. */
  table.tabla-equivalencias tbody tr { display: flex; flex-direction: column; }
  table.tabla-equivalencias td.eq-nombre { display: block; order: -1; font-size: 1rem; font-weight: 700; padding-bottom: 0; border-bottom: 0; }
  table.tabla-equivalencias td.eq-nombre:empty { display: none; }
  table.tabla-equivalencias td.eq-codigo { display: block; font-size: .8125rem; color: var(--tinta-suave); padding-top: .15rem; }
  table.tabla-equivalencias td.eq-pareja { display: block; }
}
