/* =====================================================================
   Pedidos Faiter — estilo admin de Shopify con más vida (mismo sistema que el panel de Bleu).
   Reglas en DESIGN.md: SIEMPRE seguirlas. Claro por defecto (botón sol/luna para oscuro).
   Menú lateral gris muy claro con íconos, contenido blanco con borde fino, Inter, azul con función.
   Animaciones de 150–250 ms sin rebote, apagadas con prefers-reduced-motion. Sin recursos externos (CSP 'self').
   Los nombres de clase son los de siempre (las vistas no cambian); solo cambia cómo se ven.
   ===================================================================== */

@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/static/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/static/fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ================================================================ tokens */
:root {
  color-scheme: light;
  --azul: #1b5cff;
  --azul-hover: #134ee6;
  --azul-suave: #eaf0ff;
  --azul-texto: #1546c7;
  --texto: #1a1c21;
  --texto-2: #5c6170;
  --texto-3: #8a8f9c;
  --fondo: #f4f5f7;
  --fondo-2: #eceef2;
  --blanco: #ffffff;
  --campo: #ffffff;
  --borde: #e3e5ea;
  --borde-2: #d3d6dd;
  --fila-hover: #f8f9fb;
  --verde: #1f8a4c; --verde-suave: #e3f5ea; --verde-punto: #2fb366;
  --amarillo: #8a5a00; --amarillo-suave: #fff3d1; --amarillo-punto: #e9a800;
  --rojo: #b42318; --rojo-suave: #fde8e6; --rojo-punto: #e5483b; --rojo-boton: #d92d20; --rojo-boton-hover: #b42318;
  --violeta: #5b3fd6; --violeta-suave: #efebfe;
  --gris: #4d5260; --gris-suave: #eceef2; --gris-punto: #a3a8b4;
  --wa-fondo: #e7fbe9; --wa-texto: #111b21;
  --tooltip-fondo: #1a1c21; --tooltip-texto: #ffffff;
  --sombra-flota: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .14);
  --radio: 8px;
  --radio-ch: 6px;
  --lateral: 240px;
  --curva: cubic-bezier(.2, 0, 0, 1);
  --rapido: 150ms;
  --medio: 200ms;
  --serie-1: #1b5cff;
  --sube: #12a594; --sube-suave: #e0f5f2; --baja: #e54d2e; --baja-suave: #fdebe7; --curso: #a3a8b4;
  /* nombres del diseño anterior (algunas vistas y pantallas sueltas los usan) */
  --primario: var(--azul); --primario-claro: var(--azul); --primario-suave: var(--azul-suave);
  --superficie: var(--blanco); --superficie-2: var(--fondo); --titulo: var(--texto); --suave: var(--texto-2); --tenue: var(--texto-3);
  --borde-fuerte: var(--borde-2); --exito-texto: var(--verde); --exito-fondo: var(--verde-suave);
  --alerta-texto: var(--rojo); --alerta-fondo: var(--rojo-suave); --aviso-texto: var(--amarillo); --aviso-fondo: var(--amarillo-suave);
  --acento: var(--azul); --linea: var(--borde);
}
/* Oscuro (botón sol/luna): mismos roles, neutros grafito. */
:root[data-tema=oscuro] {
  color-scheme: dark;
  --azul: #4c7dff;
  --azul-hover: #6a92ff;
  --azul-suave: #1c2742;
  --azul-texto: #a9c0ff;
  --texto: #eceef2;
  --texto-2: #a5abb8;
  --texto-3: #767d8c;
  --fondo: #111317;
  --fondo-2: #1c1f25;
  --blanco: #181b20;
  --campo: #121418;
  --borde: #2a2e36;
  --borde-2: #3a3f49;
  --fila-hover: #1d2026;
  --verde: #6fd59b; --verde-suave: #15301f; --verde-punto: #39c06f;
  --amarillo: #f2c665; --amarillo-suave: #33280e; --amarillo-punto: #e9a800;
  --rojo: #ff9a92; --rojo-suave: #3a1715; --rojo-punto: #f0645a; --rojo-boton: #e5483b; --rojo-boton-hover: #f0645a;
  --violeta: #b9a8ff; --violeta-suave: #261f45;
  --gris: #c0c4cd; --gris-suave: #23262d; --gris-punto: #6b717e;
  --wa-fondo: #0d3b31; --wa-texto: #e9edef;
  --tooltip-fondo: #eceef2; --tooltip-texto: #111317;
  --sombra-flota: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .55);
  --sube: #2bb5a0; --sube-suave: #12302b; --baja: #f0645a; --baja-suave: #3a1a15; --curso: #6b717e;
}

/* ================================================================ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--fondo); }
body {
  margin: 0; min-height: 100vh; background: var(--fondo); color: var(--texto);
  font: 400 14px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--azul-suave); }
a { color: var(--azul); text-decoration: none; transition: color var(--rapido) var(--curva); }
a:hover { color: var(--azul-hover); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; line-height: 1.3; color: var(--texto); margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--texto); margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; color: var(--texto); margin: 16px 0 8px; }
p { margin: 0 0 10px; }
small { font-size: 13px; }
details > summary { cursor: pointer; color: var(--texto-2); font-weight: 500; }
details > summary:hover { color: var(--texto); }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tabla, .num, .tile strong, .resumen-linea, .pedido-card-datos dd, .contador-sel, .resumen-cifras strong, .totales dd { font-variant-numeric: tabular-nums; }

/* ================================================================ armazón: menú lateral + contenido */
.app {
  display: grid; grid-template-columns: var(--lateral) minmax(0, 1fr); min-height: 100vh;
  /* el gris del menú llega hasta abajo aunque la página sea más larga que la pantalla */
  background: linear-gradient(90deg, var(--fondo) calc(var(--lateral) - 1px), var(--borde) calc(var(--lateral) - 1px) var(--lateral), var(--fondo) var(--lateral));
}
.app.sin-menu { grid-template-columns: minmax(0, 1fr); background: var(--fondo); }
.lateral {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 18px 12px 14px; background: var(--fondo); border-right: 1px solid var(--borde);
}
.lateral-barra { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 10px 18px; }
.logo-marca { display: block; width: 112px; height: auto; }
:root:not([data-tema=oscuro]) .logo-marca { filter: invert(1); }   /* el logo es blanco: en claro se ve negro */
.menu-boton {
  display: none; place-items: center; width: 38px; height: 38px; border-radius: var(--radio-ch); cursor: pointer;
  color: var(--texto); background: var(--blanco); border: 1px solid var(--borde);
}
.lateral-cuerpo { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.menu { display: grid; gap: 2px; align-content: start; }
.menu a {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radio-ch);
  color: var(--texto-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background-color var(--rapido) var(--curva), color var(--rapido) var(--curva);
}
.menu a:hover { background: var(--fondo-2); color: var(--texto); text-decoration: none; }
.menu a.activo { background: var(--azul-suave); color: var(--azul-texto); font-weight: 600; }
.menu a.activo svg.i { color: var(--azul); }
/* Íconos del menú en cuadrito de color (versión C, 02/12): cada sección con su tono; la activa se rellena. */
.menu .caja { display: grid; place-items: center; width: 28px; height: 28px; margin-left: -4px; border-radius: 7px; flex: none;
  background: color-mix(in srgb, var(--c) 15%, transparent); transition: background-color var(--rapido) var(--curva); }
.menu .caja svg.i, .menu a.activo .caja svg.i { width: 17px; height: 17px; stroke-width: 1.9; color: var(--c); }
.menu a:hover .caja { background: color-mix(in srgb, var(--c) 24%, transparent); }
.menu a.activo .caja { background: var(--c); }
.menu a.activo .caja svg.i { color: #fff; }
.menu-grupo { margin: 14px 10px 4px; font-size: 12px; font-weight: 600; color: var(--texto-3); }
.identidad { margin-top: auto; border-top: 1px solid var(--borde); padding: 14px 8px 8px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.identidad > div { min-width: 0; }
.identidad > div strong { display: block; font-weight: 600; color: var(--texto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identidad > div span { display: block; font-size: 13px; color: var(--texto-3); }
.salir { margin: 0; }
.salir .boton {
  justify-content: flex-start; gap: 10px; width: 100%; height: 34px; min-height: 0; padding: 0 10px; border: 0;
  background: transparent; color: var(--texto-2); font-weight: 500;
}
.salir .boton:hover { background: var(--fondo-2); color: var(--texto); }

.avatar {
  --av: var(--azul-suave); --avt: var(--azul-texto);
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--av); color: var(--avt); font-weight: 650; font-size: 13px; text-transform: uppercase;
}

.contenido { min-width: 0; width: 100%; max-width: 1320px; padding: 0 32px 64px; }
.sin-menu .contenido { max-width: 1200px; margin: 0 auto; }
/* barra de arriba: fecha de hoy a la izquierda, tema y avisos a la derecha */
.cabecera {
  position: sticky; top: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 0 -32px 4px; padding: 10px 32px; min-height: 56px;
  background: color-mix(in srgb, var(--fondo) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--borde);
}
.ceja { margin: 0; color: var(--texto-2); font-size: 13px; font-weight: 500; }
.ceja::first-letter { text-transform: uppercase; }
.iconos-cabecera { display: flex; gap: 8px; }
.campana {
  position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radio-ch);
  background: var(--blanco); border: 1px solid var(--borde); color: var(--texto-2); text-decoration: none; cursor: pointer;
  font: inherit; padding: 0;
  transition: background-color var(--rapido) var(--curva), border-color var(--rapido) var(--curva), color var(--rapido) var(--curva);
}
.campana:hover { color: var(--texto); border-color: var(--borde-2); text-decoration: none; }
.campana svg { width: 18px; height: 18px; }
.campana.critica { color: var(--rojo); border-color: color-mix(in srgb, var(--rojo-punto) 45%, var(--borde)); }
.contador {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--rojo-punto); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--fondo);
}
.campana.tema .icono-luna, :root[data-tema=oscuro] .campana.tema .icono-sol { display: none; }
:root[data-tema=oscuro] .campana.tema .icono-luna { display: block; }

/* acceso (login y cambio de clave sin menú) */
.marca-acceso { display: flex; justify-content: center; margin: 56px 0 8px; }
.marca-acceso img { width: min(220px, 60vw); height: auto; }
.marca-acceso .logo-claro { display: none; }
:root:not([data-tema=oscuro]) .marca-acceso .logo-oscuro { filter: invert(1); }
.angosta { max-width: 400px; margin: 24px auto; padding: 24px; }
.angosta h1, .angosta h2 { margin-bottom: 16px; }

/* ================================================================ encabezado de página */
.encabezado { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 16px; padding: 24px 0 20px; margin: 0; }
.encabezado h1 { margin: 0; }
.subtitulo { margin: 4px 0 0; color: var(--texto-2); font-size: 14px; max-width: 75ch; }
.atras { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--texto-2); }
.atras:hover { color: var(--texto); }

/* ================================================================ secciones blancas */
.bloque, .tarjeta, section.tarjeta {
  background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; margin-bottom: 20px;
}
.tarjeta + .tarjeta, .tarjeta + p, form.tarjeta { margin-bottom: 20px; }
.contenido > section:not(.tarjeta):not(.bloque) { margin-bottom: 24px; }
.bloque > h2:first-child, .tarjeta > h2:first-child { margin-top: 0; }
.bloque > h2 + .nota, .bloque > .nota { margin: -6px 0 14px; font-size: 13px; }
.bloque > h2 + .tabla-scroll, .bloque > h2 + .vacio { margin-top: 4px; }
.bloque-cabecera { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.bloque-cabecera h2 { margin: 0; }
.bloque-cabecera .nota { margin: 2px 0 0; font-size: 13px; }
.bloque.angosto { max-width: 640px; }
.bloque.interno { background: var(--fondo); border-color: var(--borde); padding: 16px; margin-bottom: 12px; }
.bloque.interno:last-child { margin-bottom: 0; }
.ancha-media { max-width: 640px; }
.form-venta { max-width: 820px; }
section > h2 { margin-top: 20px; }
.bloque > h2, .bloque-cabecera > div > h2 { margin-top: 0; }
hr.separador { border: 0; border-top: 1px solid var(--borde); margin: 12px 0; }

.rejilla-2 { display: grid; gap: 0 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); align-items: start; }
.rejilla-tarjetas { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); align-items: start; margin-bottom: 20px; }
.rejilla-tarjetas > .bloque { margin: 0; height: 100%; }
.rejilla-tarjetas.dos { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.rejilla-tarjetas .boton { margin-top: 4px; }
.grilla-modulos { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.modulo { display: block; color: var(--texto); font-weight: 600; text-decoration: none; transition: border-color var(--rapido) var(--curva); }
.modulo:hover { border-color: var(--azul); text-decoration: none; }

/* ================================================================ recuadros de cifras (tiles) */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin: 0; }
.tiles.dinero { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tiles.cuatro { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); margin: 0 0 20px; }
.tiles.cinco { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.contenido > .tiles { margin-bottom: 20px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px 15px;
  background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); color: var(--texto); text-decoration: none;
  transition: border-color var(--rapido) var(--curva), background-color var(--rapido) var(--curva);
}
.bloque .tile { background: var(--blanco); }
.tile span { font-size: 13px; font-weight: 500; color: var(--texto-2); }
.tile strong { font-size: 24px; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; color: var(--texto); overflow-wrap: anywhere; }
.tiles.dinero strong { font-size: 22px; white-space: nowrap; }
.tiles.cinco strong { font-size: 20px; }
.tile small { font-size: 12.5px; color: var(--texto-3); overflow-wrap: anywhere; }
a.tile { color: var(--texto); }
a.tile::after {   /* flecha: se puede abrir */
  content: ''; position: absolute; top: 16px; right: 14px; width: 7px; height: 7px;
  border-top: 1.6px solid var(--texto-3); border-right: 1.6px solid var(--texto-3); transform: rotate(45deg);
  transition: transform var(--rapido) var(--curva), border-color var(--rapido) var(--curva);
}
a.tile:hover { border-color: var(--borde-2); background: var(--fila-hover); text-decoration: none; color: var(--texto); }
a.tile:hover::after { border-color: var(--azul); transform: translateX(2px) rotate(45deg); }
.tile.principal { background: var(--azul-suave); border-color: color-mix(in srgb, var(--azul) 30%, transparent); }
.tile.principal span, .tile.principal small { color: var(--azul-texto); }
.tile.principal strong { color: var(--azul-texto); }

/* ================================================================ etiquetas de estado (pastilla + punto) */
.pill, .estado {
  --f: var(--gris-suave); --t: var(--gris); --p: var(--gris-punto);
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: 999px; border: 0;
  background: var(--f); color: var(--t); font-size: 12.5px; font-weight: 550; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.pill::before, .estado::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--p); flex: none; }
.pill.ambar, .estado { --f: var(--amarillo-suave); --t: var(--amarillo); --p: var(--amarillo-punto); }   /* estado en curso */
.pill.verde, .estado-entregado, .estado-finalizado { --f: var(--verde-suave); --t: var(--verde); --p: var(--verde-punto); }
.pill.rojo, .estado-rechazado, .estado-anulado, .estado-devuelto { --f: var(--rojo-suave); --t: var(--rojo); --p: var(--rojo-punto); }
.pill.azul { --f: var(--azul-suave); --t: var(--azul-texto); --p: var(--azul); }
.pill:not(.verde):not(.ambar):not(.rojo):not(.azul) { --f: var(--gris-suave); --t: var(--gris); --p: var(--gris-punto); }
button.pill { cursor: pointer; font-family: inherit; }
.etiqueta { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--gris-suave); color: var(--gris); }
.contador-sel {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px;
  background: var(--fondo-2); color: var(--texto); font-size: 12.5px; font-weight: 650;
}

/* ================================================================ botones */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 36px; padding: 0 14px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; color: #fff; background: var(--azul);
  border: 1px solid transparent; border-radius: var(--radio-ch); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--rapido) var(--curva), border-color var(--rapido) var(--curva), color var(--rapido) var(--curva), transform 60ms;
}
.boton:hover { background: var(--azul-hover); color: #fff; text-decoration: none; }
.boton:active { transform: scale(.98); }
.boton.chico { width: auto; min-height: 32px; padding: 0 12px; font-size: 13px; }
.boton.secundario { background: var(--blanco); color: var(--texto); border-color: var(--borde-2); }
.boton.secundario:hover { background: var(--fondo); color: var(--texto); border-color: var(--borde-2); }
.boton.rojo, .peligro-fondo { background: var(--rojo-boton); color: #fff; }
.boton.rojo:hover { background: var(--rojo-boton-hover); color: #fff; }
.boton[disabled], .boton[disabled]:hover { opacity: .45; cursor: not-allowed; transform: none; }
summary.boton { list-style: none; display: inline-flex; }
summary.boton::-webkit-details-marker { display: none; }
.desplegable > summary.boton { color: #fff; margin-top: 0; }
.desplegable > summary.boton.secundario { color: var(--texto); }
.desplegable[open] > summary.boton { background: var(--azul-hover); }
.desplegable[open] > summary.boton.secundario { background: var(--fondo); }
.desplegable summary:not(.boton) { color: var(--azul); margin-top: 8px; }
/* Jerarquía (retoque 07/11): azul = la acción principal del bloque; las de ayuda van con borde. */
.boton:is([data-marcar], [data-desmarcar], [data-copiar], [data-alternar], [data-detalle], [data-mostrar-todo], #vaciar-carrito),
a.boton[href="/almacen?fecha="] { background: var(--blanco); color: var(--texto); border-color: var(--borde-2); }
.boton:is([data-marcar], [data-desmarcar], [data-copiar], [data-alternar], [data-detalle], [data-mostrar-todo], #vaciar-carrito):hover,
a.boton[href="/almacen?fecha="]:hover { background: var(--fondo); color: var(--texto); }
.boton-icono {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radio-ch);
  background: var(--azul-suave); color: var(--azul-texto); font-size: 11px; font-weight: 700; text-decoration: none;
  transition: background-color var(--rapido) var(--curva), color var(--rapido) var(--curva);
}
.boton-icono:hover { background: var(--azul); color: #fff; text-decoration: none; }
.boton-icono svg { width: 18px; height: 18px; }
.enlace { background: none; border: 0; padding: 0; font: inherit; color: var(--azul); cursor: pointer; }
.enlace:hover { text-decoration: underline; text-underline-offset: 3px; }
.botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.botones form { margin: 0; }
.botones.columna { flex-direction: column; align-items: flex-start; }
.botones > input, .botones > select { width: auto; margin: 0; flex: 0 1 auto; }
.botones > input.corto { width: 6rem; }
.acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.acciones form { margin: 0; }
.barra-acciones { margin-bottom: 16px; }
.pie-form { margin-top: 16px; text-align: center; }
.pie-tabla { display: flex; justify-content: flex-end; margin-top: 12px; }
.tabla + .boton, .tabla-scroll + .boton { margin-top: 12px; }
.barra-lote {
  position: sticky; bottom: 12px; z-index: 5; margin-top: 16px; padding: 12px 14px;
  background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra-flota);
}

/* ================================================================ campos */
label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 550; color: var(--texto); }
label small, .campo-titulo + small { display: block; font-size: 12.5px; font-weight: 400; color: var(--texto-2); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 36px; padding: 7px 10px;
  font: inherit; font-size: 14px; font-weight: 400; color: var(--texto); background: var(--campo);
  border: 1px solid var(--borde-2); border-radius: var(--radio-ch);
  transition: border-color var(--rapido) var(--curva), box-shadow var(--rapido) var(--curva);
}
input::placeholder, textarea::placeholder { color: var(--texto-3); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--texto-3) 60%, var(--borde-2)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px color-mix(in srgb, var(--azul) 18%, transparent); }
input[disabled], select[disabled], textarea[disabled] { background: var(--fondo); color: var(--texto-2); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--azul); box-shadow: none; }
input[type=file] { padding: 6px; }
textarea { resize: vertical; }
select { padding-right: 28px; }
fieldset { border: 1px solid var(--borde); border-radius: var(--radio); margin: 0 0 16px; padding: 12px 14px; }
legend { font-weight: 600; padding: 0 4px; }
.fila-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 0; }
.fila-form label { margin: 0; flex: 1 1 180px; }
.fila-form > input, .fila-form > select { width: auto; flex: 1 1 140px; margin: 0; }
.fila-form .corto, input.corto { flex: 0 0 5.5rem; width: 5.5rem; }
.fila-form label.casilla { flex: 0 0 auto; }
.casilla { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.casilla input { width: 16px; margin: 0; }
.casillas { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.casillas-lista { max-height: 220px; overflow-y: auto; padding: 8px 12px; margin-top: 6px; border: 1px solid var(--borde-2); border-radius: var(--radio-ch); background: var(--campo); }
.casillas-lista .casilla { margin: 4px 0; font-size: 13.5px; }
.columnas { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.campos { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: end; }
.campos > label, .campos > .boton { margin-bottom: 10px; }
.campos.dos-col { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.campo-grupo { margin-bottom: 16px; }
.campo-titulo { display: block; font-size: 13px; font-weight: 550; }
.campo-fijo { margin-top: 6px; padding: 7px 10px; min-height: 36px; border: 1px dashed var(--borde-2); border-radius: var(--radio-ch); color: var(--texto-2); }
.filtros { margin-bottom: 16px; }
.filtros-linea { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 16px; }
.filtros-linea label { margin: 0; flex: 0 1 220px; }
.filtros-linea label.ancho { flex: 1 1 280px; }
.filtros-boletas { flex: 1 1 auto; }
.filtros-boletas label { flex: 0 1 190px; }
.selector-periodo { margin: 0; }
.selector-periodo label { flex: 0 1 auto; }
.selector-mes { display: grid; gap: 6px; margin: 0; max-width: 280px; }
.selector-mes label { margin: 0; }
.selector-mes select { margin: 0; }
.select-rutero { min-width: 180px; }
.segmentado { display: inline-flex; padding: 3px; gap: 2px; background: var(--fondo-2); border-radius: 8px; margin-bottom: 16px; }
.segmentado label { margin: 0; display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: var(--radio-ch); font-weight: 500; color: var(--texto-2); cursor: pointer; transition: background-color var(--rapido) var(--curva), color var(--rapido) var(--curva); }
.segmentado input { width: auto; margin: 0; }
.segmentado label:has(input:checked) { background: var(--blanco); color: var(--texto); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.emoji-input { font-size: 1.4rem; max-width: 8rem; }
.emojis { display: flex; flex-wrap: wrap; gap: 4px; margin: -6px 0 16px; }
.emojis button { font-size: 1.3rem; line-height: 1; padding: 6px; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio-ch); cursor: pointer; }
.emojis button:hover { border-color: var(--azul); }
.form-venta > .boton { margin-bottom: 16px; }

/* ================================================================ tablas */
.tabla-scroll { overflow-x: auto; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); }
.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th, .tabla td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--borde); }
.tabla th { font-size: 13px; font-weight: 500; color: var(--texto-2); background: var(--fondo); white-space: nowrap; }
.tabla tbody tr { transition: background-color var(--rapido) var(--curva); }
.tabla tbody tr:hover { background: var(--fila-hover); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla td > a:first-child { white-space: nowrap; }
.tabla a { font-weight: 500; }
.tabla .num { text-align: right; white-space: nowrap; }
.tabla tfoot th, .tabla tfoot td { border-top: 1px solid var(--borde-2); border-bottom: 0; background: var(--blanco); color: var(--texto); font-weight: 650; font-size: 13.5px; }
.tabla tr.seleccionada td, .seleccionada { background: var(--azul-suave); }
.tabla .fila-total td { border-top: 1px solid var(--borde-2); font-weight: 650; background: var(--fondo); }
.tabla .botones { flex-wrap: nowrap; }
.tabla .celda-acciones .botones { flex-wrap: wrap; }
.tabla .boton { white-space: nowrap; }
.tabla a.boton { color: #fff; }
.tabla a.boton.secundario, .tabla a.boton[data-detalle] { color: var(--texto); }
.tabla a.boton:hover { text-decoration: none; }
.tabla .botones.columna form { margin: 0; }
.celda-cliente { min-width: 220px; }
.celda-acciones { min-width: 330px; }
.sin-corte { white-space: nowrap; }
.prendas { font-size: 13px; }
.emoji-celda { font-size: 1.1rem; }
.miniatura { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; border: 1px solid var(--borde); display: block; background: var(--fondo); }
.acciones-columna { display: grid; gap: 6px; min-width: 170px; }
.acciones-columna .boton { width: 100%; }
.motivo-envio { min-width: 11rem; max-width: 16rem; }
.motivo-envio small { display: block; color: var(--rojo); line-height: 1.35; }
.motivo-envio small + small { margin-top: 4px; }

/* pestañas */
.pestanas { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--borde); }
.pestanas a { padding: 8px 12px; margin-bottom: -1px; color: var(--texto-2); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent; transition: color var(--rapido) var(--curva), border-color var(--rapido) var(--curva); }
.pestanas a:hover { color: var(--texto); text-decoration: none; border-bottom-color: var(--borde-2); }
.pestanas a.activa { color: var(--texto); font-weight: 600; border-bottom-color: var(--azul); }

/* listas */
.lista-editable { list-style: none; margin: 0; padding: 0; }
.lista-editable li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.lista-editable li:last-child { border-bottom: 0; }
.lista-editable li > form:first-child, .lista-editable li > span { flex: 1 1 auto; }
.lista-seleccion { list-style: none; margin: 0; padding: 0; border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; background: var(--blanco); }
.lista-seleccion li + li { border-top: 1px solid var(--borde); }
.lista-seleccion a { display: block; padding: 12px 16px; color: var(--texto); text-decoration: none; transition: background-color var(--rapido) var(--curva); }
.lista-seleccion a:hover { background: var(--fila-hover); text-decoration: none; }
details.archivados > summary { margin-bottom: 12px; }

/* ================================================================ mensajes */
.alerta, .exito, .aviso {
  display: block; padding: 10px 14px; margin: 0 0 16px; border-radius: var(--radio); font-size: 13.5px; border: 1px solid transparent;
}
.alerta { background: var(--rojo-suave); color: var(--rojo); border-color: color-mix(in srgb, var(--rojo-punto) 25%, transparent); }
.exito { background: var(--verde-suave); color: var(--verde); border-color: color-mix(in srgb, var(--verde-punto) 25%, transparent); }
.aviso { background: var(--amarillo-suave); color: var(--amarillo); border-color: color-mix(in srgb, var(--amarillo-punto) 30%, transparent); }
.alerta ul { margin: 4px 0 0; padding-left: 20px; }
.alerta-stock { border-left: 3px solid var(--amarillo-punto); }
.alerta-stock ul { display: flex; flex-wrap: wrap; gap: 2px 18px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; }
.nota { color: var(--texto-2); font-size: 13px; }
.vacio { color: var(--texto-2); }
p.vacio, td.vacio { padding: 20px 0; text-align: left; }
.peligro { color: var(--rojo); }
.apagado { opacity: .55; }
.sin-margen { margin: 0; }
.con-margen { margin-top: 12px; }
.multilinea { white-space: pre-line; }
.emoji-grande { font-size: 1.5rem; }
/* Aviso flotante de las acciones rápidas (Domicilios): entra desde abajo y no mueve la pantalla. */
.aviso-rapido { position: fixed; right: 16px; bottom: 16px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); margin: 0; box-shadow: var(--sombra-flota); font-weight: 500; }

/* ================================================================ fichas y datos */
.ficha { display: grid; gap: 12px 24px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin: 0; }
.ficha dt { font-size: 13px; color: var(--texto-2); }
.ficha dd { margin: 0; overflow-wrap: anywhere; }
.ficha .ancho { grid-column: 1 / -1; }
.ficha-datos { display: grid; gap: 14px 28px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 0; }
.ficha-datos dt { font-size: 13px; font-weight: 500; color: var(--texto-2); }
.ficha-datos dd { margin: 2px 0 0; color: var(--texto); }
.resumen-datos { display: grid; gap: 8px 24px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin: 0; font-size: 13.5px; }
.resumen-datos > div { display: flex; gap: 6px; flex-wrap: wrap; }
.resumen-datos .ancho { grid-column: 1 / -1; }
.resumen-datos dt { color: var(--texto-2); }
.resumen-datos dd { margin: 0; color: var(--texto); font-weight: 500; }
.resumen-linea { margin: 16px 0; color: var(--texto-2); }
.resumen-linea strong { color: var(--texto); }
.historial { margin: 0; padding-left: 20px; }
.historial > li { margin-bottom: 8px; }
.historial > li::marker { color: var(--texto-3); }
.cambios { margin: 4px 0 0; padding-left: 16px; color: var(--texto-2); font-size: 13px; }
.clave-temporal { font: 600 1.5rem/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; padding: 10px; text-align: center; background: var(--fondo); border-radius: var(--radio); user-select: all; }
.clave-oculta { font-family: ui-monospace, Menlo, Consolas, monospace; margin-right: 6px; }

/* ================================================================ ventas: carrito y totales */
.linea { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 0; border-bottom: 1px solid var(--borde); }
.linea select, .linea input { margin: 0; }
.linea .corto { width: 100%; }
.linea .quitar { justify-self: start; align-self: center; }
@media (min-width: 760px) { .linea { grid-template-columns: 1fr 1.4fr 1fr .8fr 5rem auto; align-items: center; } }
#agregar-linea { margin-top: 12px; }
#carrito { margin-top: 16px; }
.selector-carrito .botones { margin-top: 4px; }
.selector-carrito .alerta { margin: 12px 0 0; }
.totales { display: grid; gap: 8px 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 16px 0 0; }
.totales div { background: var(--fondo); border-radius: var(--radio); padding: 8px 12px; }
.totales dt { font-size: 12.5px; color: var(--texto-2); }
.totales dd { margin: 0; font-weight: 600; }
.totales .destacado { background: var(--azul-suave); color: var(--azul-texto); }
.totales .destacado dt { color: inherit; }
.resumen-cifras {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1px; margin: 16px 0;
  background: var(--borde); border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden;
}
.resumen-cifras > span { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: var(--blanco); }
.resumen-cifras small { font-size: 12.5px; font-weight: 500; color: var(--texto-2); }
.resumen-cifras strong { font-size: 15px; font-weight: 650; color: var(--texto); }
.resumen-cifras .total { background: var(--azul-suave); }
.resumen-cifras .total small, .resumen-cifras .total strong { color: var(--azul-texto); }
.resumen-cifras .total strong { font-size: 17px; }
.factura-datos { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--borde); }
.factura-datos > .casilla { margin-bottom: 12px; }
.factura-campos { display: none; }
.factura-datos:has(input[name=quiere_factura]:checked) .factura-campos { display: grid; }
.factura-campos .ancho { grid-column: 1 / -1; margin: 0 0 8px; }
.sedes-sugeridas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.sedes-sugeridas small { flex-basis: 100%; }
.sede-opcion { cursor: pointer; font: inherit; font-size: 12.5px; }
.sede-opcion:hover { --f: var(--azul-suave); --t: var(--azul-texto); }
.sede-opcion.elegida { --f: var(--azul); --t: #fff; --p: #fff; }
.sede-ok { color: var(--verde); font-weight: 600; }
.sedes-todas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-height: 16rem; overflow-y: auto; padding: 8px; border: 1px solid var(--borde); border-radius: var(--radio); }
[data-sede-fuera] { margin-top: 8px; font-size: 13px; align-items: flex-start; }

/* ================================================================ almacén, domicilios, reparto */
.lista-tarjetas { display: grid; gap: 12px; }
.pedido-card, .pedido-tarjeta {
  background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px;
  transition: border-color var(--rapido) var(--curva);
}
.pedido-tarjeta { margin-bottom: 12px; }
.pedido-tarjeta p { margin: 6px 0; }
.pedido-tarjeta form { margin-top: 8px; }
.pedido-card-cab { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; margin-bottom: 12px; }
.pedido-card-cab .casilla { margin: 2px 0 0; }
.pedido-card-cab strong { font-size: 15px; font-weight: 650; color: var(--texto); }
.pedido-card-datos { display: grid; gap: 6px 20px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 0 0 14px; font-size: 13.5px; }
.pedido-card-datos dt { display: inline; font-weight: 400; color: var(--texto-2); }
.pedido-card-datos dd { display: inline; margin: 0 0 0 4px; color: var(--texto); font-weight: 500; }
.pedido-card-datos .ancho { grid-column: 1 / -1; }
.pedido-card-datos.una-columna { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.botones-contacto { display: flex; flex-wrap: wrap; gap: 8px; }
.monto-grande { font-size: 20px; font-weight: 650; }
.panel-accion { display: grid; gap: 8px; padding: 8px 0; min-width: 220px; }
.panel-accion label { margin: 0; }
.desplegable .panel-accion { min-width: 200px; }
.celda-acciones .panel-accion input[type=number] { width: 6.5rem; }
.acciones-rutero { margin-top: 12px; }
.acciones-rutero > details { flex: 1 1 220px; }
.acciones-rutero summary.boton { width: 100%; text-align: center; }
.apilado-movil { }
.fila-conteo { display: flex; gap: 6px; align-items: center; }
.fila-conteo input { width: 6.5rem; margin: 0; }
.lote-acciones { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.lote-acciones .fila-form { flex: 1 1 26rem; }
.lote-acciones .fila-form label { max-width: 18rem; }
.plantilla { border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px 16px; margin-top: 12px; background: var(--fondo); }
.vista-mensaje { white-space: pre-wrap; font-family: inherit; font-size: 13.5px; line-height: 1.5; background: var(--wa-fondo); color: var(--wa-texto); border-radius: var(--radio); padding: 12px 14px; margin: 12px 0; max-height: 46vh; overflow: auto; }
.vista-etiqueta { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; background: var(--fondo); border: 1px dashed var(--borde-2); border-radius: var(--radio); padding: 12px 14px; margin: 12px 0 0; }
.etiqueta-venta.nueva { border-color: color-mix(in srgb, var(--azul) 45%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--azul) 12%, transparent); }

/* ================================================================ avisos del vigilante */
.aviso-item { border-left: 3px solid var(--borde-2); }
.aviso-item.aviso-critico { border-left-color: var(--rojo-punto); }
.aviso-item.aviso-alto { border-left-color: var(--amarillo-punto); }
.aviso-item.aviso-medio { border-left-color: var(--azul); }
.aviso-item h3 { margin: 8px 0 4px; }
.aviso-item p { margin: 4px 0; }
.aviso-cabeza { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.aviso-accion { margin-left: auto; }
.aviso-ejemplo { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--fondo); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px; max-height: 320px; overflow: auto; }

/* ================================================================ gráfico */
.grafico { position: relative; margin: 8px 0 16px; }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico .grilla { stroke: var(--borde); stroke-width: 1; }
.grafico .base { stroke: var(--borde-2); stroke-width: 1; }
.grafico .barra { fill: var(--serie-1); }
.grafico .activa .barra { fill: var(--azul-hover); }
.grafico .eje { fill: var(--texto-3); font-size: 11px; }
.grafico .valor { fill: var(--texto); font-size: 12px; font-weight: 600; }
.grafico .zona { fill: transparent; cursor: default; outline: none; }
.grafico .zona:focus-visible { stroke: var(--azul); stroke-width: 1; }
.grafico-tooltip { position: absolute; transform: translate(-50%, calc(-100% - 6px)); pointer-events: none; white-space: nowrap; padding: 5px 9px; border-radius: var(--radio-ch); font-size: 12.5px; font-weight: 600; background: var(--tooltip-fondo); color: var(--tooltip-texto); box-shadow: var(--sombra-flota); }


/* ================================================================ gráfico de tendencia (estilo trading)
   Tramos de la línea según suba o baje contra el periodo anterior; área azul muy suave; promedio móvil punteado;
   barras de variación % aparte (arriba sube, abajo baja). Sube/baja validados para daltonismo; siempre con ▲/▼. */
.tendencia { margin-top: 4px; }
.tendencia-cab { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 32px; margin-bottom: 12px; }
.tendencia-principal { display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: 2px 10px; }
.tendencia-etiqueta { grid-column: 1 / -1; font-size: 13px; color: var(--texto-2); }
.tendencia-principal strong { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tendencia-contra { font-size: 13px; color: var(--texto-3); }
.cambio {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12.5px; font-weight: 650;
  font-variant-numeric: tabular-nums; white-space: nowrap; background: var(--gris-suave); color: var(--texto);
}
.cambio.sube { background: var(--sube-suave); color: color-mix(in srgb, var(--sube) 70%, var(--texto)); }
.cambio.baja { background: var(--baja-suave); color: color-mix(in srgb, var(--baja) 75%, var(--texto)); }
.tendencia-datos { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.tendencia-datos dt { font-size: 13px; color: var(--texto-2); }
.tendencia-datos dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.tendencia-datos small { color: var(--texto-3); font-weight: 400; }
.tendencia-leyenda { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0 0 4px; padding: 0; font-size: 12.5px; color: var(--texto-2); }
.tendencia-leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.ley { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--curso); }
.ley.sube { border-color: var(--sube); } .ley.baja { border-color: var(--baja); }
.ley.curso { border-top-style: dashed; }
.ley.promedio { border-top: 2px dashed var(--texto-3); }
.tendencia svg { overflow: visible; }
.tendencia .area { fill: var(--azul); opacity: .07; }
.tendencia .tramo { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke: var(--curso); }
.tendencia .tramo.sube { stroke: var(--sube); }
.tendencia .tramo.baja { stroke: var(--baja); }
.tendencia .tramo.igual { stroke: var(--texto-3); }
.tendencia .tramo.curso { stroke-dasharray: 5 5; }
.tendencia .promedio { fill: none; stroke: var(--texto-3); stroke-width: 1.5; stroke-dasharray: 3 4; }
.tendencia .punto { fill: var(--curso); stroke: var(--blanco); stroke-width: 2; transition: r var(--rapido) var(--curva); }
.tendencia .punto.sube { fill: var(--sube); } .tendencia .punto.baja { fill: var(--baja); } .tendencia .punto.igual { fill: var(--texto-3); }
.tendencia .punto.activa { r: 6.5; }
.tendencia .cruz { stroke: var(--texto-3); stroke-width: 1; stroke-dasharray: 2 3; }
.tendencia .anotacion { fill: var(--texto-2); font-size: 12px; font-weight: 600; }
.tendencia .valor { fill: var(--texto); font-size: 13px; font-weight: 650; }
.tendencia .zona { fill: transparent; outline: none; cursor: crosshair; }
.tendencia-sub { margin: 10px 0 0; font-size: 12.5px; color: var(--texto-2); }
.tendencia .var { fill: var(--curso); opacity: .9; transition: opacity var(--rapido) var(--curva); }
.tendencia .var.sube { fill: var(--sube); } .tendencia .var.baja { fill: var(--baja); }
.tendencia .var.curso { opacity: .45; }
.tendencia-variacion:has(.var.activa) .var:not(.activa) { opacity: .35; }
.grafico-tooltip:has(.tt-valor) { display: grid; gap: 2px; white-space: nowrap; padding: 8px 11px; text-align: left; font-weight: 500; }
.grafico-tooltip:has(.tt-valor)[hidden] { display: none; }
.tt-titulo { font-size: 12px; opacity: .75; }
.tt-valor { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tt-detalle { font-size: 12px; opacity: .85; }
.grafico-tooltip .cambio { justify-self: start; margin-top: 3px; height: 20px; font-size: 12px; }
.grafico-tooltip .cambio.sube { background: var(--sube); color: #fff; }
.grafico-tooltip .cambio.baja { background: var(--baja); color: #fff; }
.grafico-tooltip .cambio.curso { background: transparent; color: inherit; padding: 0; opacity: .75; }
@media (prefers-reduced-motion: no-preference) {
  /* La línea se dibuja de izquierda a derecha al verse (.visible lo pone app.js). */
  .js .tendencia:not(.visible) .tendencia-linea .tramo, .js .tendencia:not(.visible) .tendencia-linea .punto { opacity: 0; }
  .tendencia.visible .tramo, .tendencia.visible .punto { animation: aparecer 260ms var(--curva) backwards; animation-delay: calc(var(--i, 0) * 25ms); }
  .tendencia .area { transition: opacity 400ms var(--curva); }
  .js .tendencia:not(.visible) .area { opacity: 0; }
}
@media (max-width: 900px) {
  .tendencia-principal strong { font-size: 24px; }
  /* En el celular el gráfico guarda un ancho legible y se desliza de lado (arranca en las semanas más nuevas). */
  .tendencia-lienzo { overflow-x: auto; margin: 0 -16px; padding: 0 16px; overscroll-behavior-x: contain; scrollbar-width: none; }
  .tendencia-lienzo::-webkit-scrollbar { display: none; }
  .tendencia-lienzo > svg, .tendencia-lienzo > .tendencia-sub { min-width: 760px; }
  .tendencia .eje { font-size: 13px; }
  .tendencia .valor, .tendencia .anotacion { font-size: 14px; }
}

/* ================================================================ ventana "Detalle de pedido" */
.dialogo {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--borde);
  border-radius: 12px; background: var(--blanco); color: var(--texto); box-shadow: var(--sombra-flota);
}
.dialogo::backdrop { background: rgba(16, 20, 28, .45); }
.dialogo-cab {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: var(--blanco); border-bottom: 1px solid var(--borde);
}
.dialogo-cab h2 { margin: 0; font-size: 16px; }
.dialogo-cab .botones { flex-wrap: nowrap; }
.dialogo-cerrar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radio-ch); border: 1px solid var(--borde-2);
  background: var(--blanco); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer;
  transition: background-color var(--rapido) var(--curva);
}
.dialogo-cerrar:hover { background: var(--fondo); }
.dialogo-cerrar[hidden] { display: none; }
.dialogo-cerrar.copiado { color: var(--verde); border-color: color-mix(in srgb, var(--verde-punto) 40%, transparent); background: var(--verde-suave); }
.dialogo-cuerpo { padding: 18px 20px 20px; overflow: auto; }
.dialogo.dialogo-editar { width: min(1100px, calc(100vw - 32px)); height: calc(100vh - 48px); }
.dialogo.dialogo-editar[open] { display: flex; flex-direction: column; }
.dialogo-editar .dialogo-cuerpo { flex: 1; padding: 0; overflow: hidden; }
.marco-editar { display: block; width: 100%; height: 100%; border: 0; background: var(--fondo); }
.app.en-ventana { background: var(--fondo); }
.app.en-ventana .contenido { max-width: none; padding: 4px 20px 32px; }
.pie-dialogo { margin: 14px 0 0; font-size: 13px; }

/* ================================================================ celular */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); background: var(--fondo); }
  /* el menú es una barra fija arriba con ☰; se despliega encima del contenido */
  .lateral {
    position: sticky; top: 0; z-index: 40; height: auto; max-height: 100dvh; padding: 8px 16px; border-right: 0;
    border-bottom: 1px solid var(--borde); background: color-mix(in srgb, var(--fondo) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  }
  .lateral-barra { padding: 0; }
  .logo-marca { width: 92px; }
  .menu-boton { display: inline-grid; }
  .js .lateral-cuerpo { display: none; }
  .js .lateral.abierto .lateral-cuerpo { display: flex; overflow-y: auto; max-height: calc(100dvh - 60px); padding: 12px 0 6px; }
  .menu a { height: 42px; font-size: 15px; }
  .identidad { margin-top: 12px; }
  .contenido { padding: 0 16px 40px; }
  .cabecera { position: static; margin: 0 -16px; padding: 8px 16px; min-height: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; border-bottom: 0; }
  .encabezado { padding-top: 6px; }
  .encabezado { padding: 6px 0 16px; }
  .bloque, .tarjeta { padding: 16px; }
  .bloque.interno { padding: 14px; }
  .tiles:not(.dinero) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tiles:not(.dinero) .tile { padding: 12px 12px 13px; }
  .tiles:not(.dinero) .tile strong { font-size: 20px; }
  .tiles.dinero { gap: 10px; }
  .tile strong { font-size: 21px; }
  .filtros-linea label { flex: 1 1 100%; }
  .pedido-card-datos.una-columna { grid-template-columns: 1fr; }
  .apilado-movil, .bloque-cabecera .botones { justify-content: flex-start; }
  .lista-tarjetas .pedido-card { padding: 14px; }
  /* campos de 16 px: el celular no hace zoom al tocarlos */
  input, select, textarea { font-size: 16px; min-height: 42px; }
  .boton { min-height: 40px; }
  .boton.chico { min-height: 36px; }
}
@media (max-width: 600px) {
  .dialogo, .dialogo.dialogo-editar { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
}

/* ================================================================ movimiento (todo se apaga con prefers-reduced-motion) */
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } }
@keyframes subir { from { opacity: 0; transform: translateY(8px); } }
@keyframes crecer { from { transform: scaleY(0); } }
@keyframes desplegar { from { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-salir { to { opacity: 0; } }
@keyframes vt-entrar { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: no-preference) {
  /* Cambio de pantalla: el menú queda quieto y el contenido entra con un fundido de 200 ms. */
  @view-transition { navigation: auto; }
  .lateral { view-transition-name: lateral; }
  .cabecera { view-transition-name: cabecera; }
  ::view-transition-group(lateral), ::view-transition-group(cabecera) { animation-duration: 0s; }
  ::view-transition-old(root) { animation: vt-salir 120ms ease-in both; }
  ::view-transition-new(root) { animation: vt-entrar 200ms var(--curva) both; }
  /* Entrada escalonada corta: --i lo pone app.js (posición dentro del grupo). */
  .contenido > *:not(.cabecera), .rejilla-2 > *, .rejilla-tarjetas > *, .lista-tarjetas > *, .tiles > * {
    animation: aparecer 220ms var(--curva) backwards; animation-delay: calc(var(--i, 0) * 30ms);
  }
  .aviso-rapido { animation: subir 200ms var(--curva) backwards; }
  .dialogo[open] { animation: aparecer 200ms var(--curva) backwards; }
  .dialogo[open]::backdrop { animation: vt-entrar 200ms ease backwards; }
  .desplegable[open] > .panel-accion, .desplegable[open] > form { animation: desplegar 180ms var(--curva) backwards; }
  .lateral.abierto .lateral-cuerpo { animation: desplegar 200ms var(--curva) backwards; }
  @media (hover: hover) {
    .pedido-card:hover { border-color: var(--borde-2); }
  }
  /* Barras de los gráficos: crecen desde la base cuando el gráfico entra en pantalla (.visible lo pone app.js). */
  .grafico .barra { transform-box: fill-box; transform-origin: 50% 100%; transition: fill var(--rapido); }
  .js .grafico:not(.visible) .barra { transform: scaleY(0); }
  .grafico.visible .barra { animation: crecer 500ms var(--curva) backwards; animation-delay: calc(min(var(--i, 0), 40) * 15ms); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.contenido.sin-animacion *, .contenido.sin-animacion > * { animation: none !important; }

/* Al imprimir siempre en claro y sin menú. */
@media print {
  :root, :root[data-tema=oscuro] {
    color-scheme: light; --fondo: #fff; --fondo-2: #f4f5f7; --blanco: #fff; --campo: #fff; --texto: #1a1c21; --texto-2: #5c6170; --borde: #e3e5ea; --borde-2: #d3d6dd;
  }
  .lateral, .cabecera { display: none; }
  .app { grid-template-columns: 1fr; background: #fff; }
}
