/* ============================================================================
   Pedidos IBS — panel de almacén
   Identidad visual: Azulejos La Estrella (azulejos.jrhub.site)
   Navy #12213d + rojo #e31e24 (solo indicadores/badges/progreso) + fondo sand.
   Sin dependencias externas: fuentes autohospedadas en assets/fonts/.
   ============================================================================ */

/* ---------- Fuentes autohospedadas (variables, subset latin) ---------- */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/playfair-display-latin.woff2") format("woff2");
}

/* ---------- Tokens de marca (globals.css de azulejoslaestrella) ---------- */

:root {
  --brand-50:  #eef3fb;
  --brand-100: #d6e2f3;
  --brand-200: #adc5e7;
  --brand-300: #7b9dd4;
  --brand-500: #2a4f95;
  --brand-600: #1c3a73;
  --brand-700: #12213d;
  --brand-800: #0d182c;
  --brand-900: #060c19;

  --accent-500: #e31e24;
  --accent-600: #c9171c;

  --terra-100: #f4d8c3;
  --terra-400: #c67840;
  --terra-600: #874523;

  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-muted: #f0f3f8;
  --fg: #12162a;
  --fg-muted: rgba(18, 22, 42, 0.7);
  --fg-subtle: rgba(18, 22, 42, 0.5);
  --border: rgba(18, 33, 61, 0.1);
  --border-strong: rgba(18, 33, 61, 0.18);

  --exito: #2e7d4f;
  --exito-texto: #1e6a40;
  --exito-fondo: #e9f3ea;
  --exito-borde: #c3ddc9;
  --ambar-texto: #8a5a0a;
  --ambar-fondo: #f7e8cf;

  --header-bg: rgba(7, 8, 11, 0.85);

  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 4px 8px rgba(0, 0, 0, 0.06), 0 24px 48px rgba(0, 0, 0, 0.18);

  --radius-card: 1.25rem;
  --radius-control: 0.65rem;
  --radius-pill: 999px;
  --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-base: 220ms;

  --font-display: "Playfair Display", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--fg);
  background: var(--bg);
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
}

a { color: var(--brand-600); }

button { font: inherit; cursor: pointer; }

::selection { background: var(--accent-500); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 3px;
  border-radius: 6px;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin: 0;
}

/* ---------- Login ---------- */

.pagina-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem 1rem;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(165deg, var(--brand-900) 0%, var(--brand-700) 55%, var(--brand-800) 100%);
  background-size: 32px 32px, 32px 32px, cover;
}

.login-envoltorio {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
}

.login-logo {
  width: min(280px, 72%);
  height: auto;
  display: block;
}

.tarjeta-login {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-card);
  padding: 2rem 2.1rem 2.2rem;
  box-shadow: var(--shadow-elevated);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tarjeta-login h1 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 0.4rem;
}

.subtitulo {
  color: var(--fg-muted);
  margin: 0.35rem 0 1.5rem;
  font-size: 0.9rem;
}

.tarjeta-login label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  margin: 1rem 0 0.3rem;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.tarjeta-login input {
  width: 100%;
  padding: 0.68rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-control);
  font: inherit;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: border-color var(--duration-base) var(--ease-standard);
}

.tarjeta-login input::placeholder { color: rgba(255, 255, 255, 0.35); }

.tarjeta-login input:focus {
  outline: 2px solid var(--accent-500);
  outline-offset: 0;
  border-color: var(--accent-500);
}

.tarjeta-login button {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.8rem;
  min-height: 48px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: #fff;
  border: 0;
  border-radius: var(--radius-control);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.85rem;
  transition: filter var(--duration-base) var(--ease-standard),
    transform var(--duration-base) var(--ease-standard);
}

.tarjeta-login button:hover { filter: brightness(1.08); }
.tarjeta-login button:active { transform: scale(0.985); }

.alerta {
  background: #fdeceb;
  color: var(--accent-600);
  border: 1px solid #f2c4c2;
  border-radius: var(--radius-control);
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}

/* ---------- Cabecera (siempre oscura, como la web corporativa) ---------- */

.cabecera {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1rem;
  flex-wrap: wrap;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem 1.4rem;
}

.cabecera-logo {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.cabecera-logo img {
  height: 26px;
  width: auto;
  display: block;
}

.cabecera nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.cabecera nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0.55rem 0;
  transition: color var(--duration-base) var(--ease-standard);
}

.cabecera nav a:hover { color: var(--accent-500); }

.usuario-actual {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.78rem;
}

.enlace-salir {
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.95rem !important;
}

/* ---------- Título de página + sync ---------- */

.pagina-titulo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 1.1rem;
}

.pagina-titulo h1 {
  font-size: 1.9rem;
  color: var(--brand-700);
}

.sync { font-size: 0.82rem; color: var(--fg-muted); }

.sync-atrasada {
  color: var(--accent-600);
  font-weight: 600;
  background: #fdeceb;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-pill);
}

/* ---------- Contenido ---------- */

.contenido { padding: 1.2rem 1.4rem 3rem; max-width: 1400px; margin: 0 auto; }

.contenido-estrecho { max-width: 760px; }

.pagina-preparacion { font-size: 16px; }

/* ---------- Pestañas (indicador activo en rojo de marca) ---------- */

.pestanas {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.2rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-strong);
  scrollbar-width: none;
}

.pestanas::-webkit-scrollbar { display: none; }

.pestana {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  min-height: 48px;
  color: var(--fg-muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition: color var(--duration-base) var(--ease-standard);
}

.pestana:hover { color: var(--brand-700); }

.pestana.activa { color: var(--brand-700); }

.pestana.activa::after {
  content: "";
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent-500);
}

.pestana-num {
  background: rgba(18, 33, 61, 0.08);
  color: var(--fg-muted);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0;
}

.pestana.activa .pestana-num { background: var(--accent-600); color: #fff; }

/* ---------- Tarjetas de factura ---------- */

.lista-facturas { display: flex; flex-direction: column; gap: 0.8rem; }

.tarjeta-factura {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.05rem 1.25rem;
  text-decoration: none;
  color: var(--fg);
  box-shadow: var(--shadow-soft);
  transition: transform 0.45s var(--ease-standard),
    box-shadow 0.45s var(--ease-standard),
    border-color 0.45s var(--ease-standard);
}

.tarjeta-factura:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-strong);
}

.tarjeta-factura:active { transform: scale(0.99); background: var(--bg-muted); }

.factura-completa { border-left: 4px solid var(--exito); }

.tarjeta-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.factura-codigo {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand-700);
}

.factura-codigo-xl { font-size: 2.1rem; }

.factura-fecha { color: var(--fg-muted); font-size: 0.88rem; white-space: nowrap; }

.factura-cliente { color: var(--fg-muted); margin: 0.3rem 0 0.55rem; }

.cliente-codigo { color: var(--fg-subtle); font-size: 0.8rem; margin-left: 0.4rem; }

.sin-lineas { color: var(--fg-subtle); font-size: 0.82rem; }

/* ---------- Barras de progreso (rojo de marca) ---------- */

.barra {
  display: inline-block;
  width: 70px;
  height: 7px;
  background: rgba(18, 33, 61, 0.1);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.barra-relleno {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-600), var(--accent-500));
  transition: width 0.45s var(--ease-standard);
}

.progreso-fila { margin-top: 0.5rem; }

.barra-ancha { flex: 1; width: auto; height: 9px; }

.progreso-texto { font-size: 0.88rem; font-weight: 700; color: var(--brand-600); white-space: nowrap; }

.factura-completa .progreso-texto { color: var(--exito-texto); }

.vacio-lista {
  text-align: center;
  color: var(--fg-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  padding: 2.2rem 1rem;
}

/* ---------- Ficha de factura (preparar.php) ---------- */

.enlace-volver { font-weight: 700; text-decoration: none; }

.ficha-factura {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: 1.2rem 1.35rem 1.25rem;
  margin-bottom: 1rem;
}

.ficha-factura .factura-codigo-xl {
  display: block;
  padding-bottom: 0.55rem;
  margin-bottom: 0.55rem;
  position: relative;
}

/* Línea de degradado de marca bajo el número (brand → accent → terra) */
.ficha-factura .factura-codigo-xl::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-500) 0%, var(--accent-500) 55%, var(--terra-400) 100%);
  border-radius: var(--radius-pill);
}

.ficha-factura .factura-cliente { margin: 0 0 0.25rem; font-size: 1rem; }

.banner-completa {
  background: var(--exito-fondo);
  color: var(--exito-texto);
  border: 1px solid var(--exito-borde);
  border-radius: var(--radius-card);
  padding: 0.9rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1rem;
}

/* ---------- Líneas de picking (toda la fila es botón táctil) ---------- */

.lista-lineas { display: flex; flex-direction: column; gap: 0.6rem; }

.form-linea { margin: 0; }

.linea {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  width: 100%;
  min-height: 68px;
  padding: 0.8rem 0.95rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow-soft);
  text-align: left;
  color: var(--fg);
  font-size: 1rem;
  transition: background var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard),
    transform var(--duration-base) var(--ease-standard);
}

.linea:active { transform: scale(0.985); background: var(--bg-muted); }

.linea:disabled { opacity: 0.6; }

.check {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 2px solid var(--brand-300);
  border-radius: 0.8rem;
  background: #fff;
  position: relative;
  transition: background var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard);
}

.linea-preparada {
  background: var(--exito-fondo);
  border-color: var(--exito-borde);
}

.linea-preparada .check {
  background: var(--exito);
  border-color: var(--exito);
}

.linea-preparada .check::after {
  content: "";
  position: absolute;
  left: 15px;
  top: 7px;
  width: 12px;
  height: 22px;
  border: solid #fff;
  border-width: 0 4px 4px 0;
  transform: rotate(45deg);
}

.linea-datos { flex: 1; display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }

.linea-articulo {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--fg-subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.linea-descripcion { font-size: 1.02rem; line-height: 1.35; overflow-wrap: anywhere; }

.linea-preparada .linea-descripcion { color: var(--fg-muted); }

.linea-cantidad {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-700);
  white-space: nowrap;
}

.linea-preparada .linea-cantidad { color: var(--exito-texto); }

/* ---------- Filtros (pedidos.php) ---------- */

.filtros {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: 1rem 1.15rem;
}

.campo { display: flex; flex-direction: column; gap: 0.3rem; }

.campo label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.campo input,
.campo select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  font: inherit;
  min-width: 150px;
  background: #fff;
  color: var(--fg);
}

.campo input:focus, .campo select:focus {
  outline: 2px solid var(--brand-500);
  border-color: var(--brand-500);
}

.campo-acciones { flex-direction: row; align-items: center; gap: 0.8rem; }

.campo-acciones button {
  padding: 0.55rem 1.4rem;
  min-height: 44px;
  background: var(--brand-700);
  color: #fff;
  border: 0;
  border-radius: var(--radius-control);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  transition: background var(--duration-base) var(--ease-standard);
}

.campo-acciones button:hover { background: var(--brand-600); }

.enlace-limpiar { font-size: 0.88rem; }

.resumen { color: var(--fg-muted); font-size: 0.88rem; margin: 0.9rem 0 0.6rem; }

/* ---------- Tabla de facturas ---------- */

.tabla-envoltorio {
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.tabla-pedidos { width: 100%; border-collapse: collapse; min-width: 760px; }

.tabla-pedidos th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-muted);
  padding: 0.75rem 0.9rem;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}

.tabla-pedidos td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.fila-pedido:hover td { background: var(--bg); }

.num { text-align: right; white-space: nowrap; }

.num-pedido { font-weight: 700; white-space: nowrap; }

.num-pedido a {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--brand-700);
  text-decoration: none;
}

.num-pedido a:hover { color: var(--accent-600); }

.vacio { text-align: center; color: var(--fg-muted); padding: 2rem !important; }

.btn-detalle {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-600);
  white-space: nowrap;
  transition: border-color var(--duration-base) var(--ease-standard),
    background var(--duration-base) var(--ease-standard);
}

.btn-detalle:hover { border-color: var(--brand-500); background: var(--brand-50); }

/* Badges de estado (rojo reservado a estados destacados) */

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-pendiente   { background: var(--ambar-fondo); color: var(--ambar-texto); }
.badge-preparacion { background: var(--brand-100); color: var(--brand-600); }
.badge-parcial     { background: var(--terra-100); color: var(--terra-600); }
.badge-servido     { background: var(--exito-fondo); color: var(--exito-texto); }
.badge-otro        { background: rgba(18, 33, 61, 0.08); color: var(--fg-muted); }

/* ---------- Detalle de líneas ---------- */

.fila-detalle > td { background: var(--bg); padding: 0.85rem 1.2rem; }

.tabla-lineas { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

.tabla-lineas th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border-strong);
}

.tabla-lineas td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }

/* ---------- Paginación ---------- */

.paginacion {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.4rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.paginacion a {
  color: var(--brand-700);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.45rem 1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: var(--bg-elevated);
  transition: border-color var(--duration-base) var(--ease-standard),
    background var(--duration-base) var(--ease-standard);
}

.paginacion a:hover { border-color: var(--brand-500); background: var(--brand-50); }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .contenido { padding: 0.9rem 0.8rem 2.2rem; }
  .filtros { gap: 0.6rem; }
  .campo input, .campo select { min-width: 120px; }
  .cabecera { padding: 0.65rem 0.9rem; }
  .cabecera-logo img { height: 22px; }
  .cabecera nav { gap: 0.8rem; }
  .pagina-titulo h1 { font-size: 1.65rem; }
  .factura-codigo-xl { font-size: 1.8rem; }
  .tarjeta-login { padding: 1.6rem 1.4rem 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Salir como form POST (mismo aspecto que el enlace) ---------- */
.form-salir { display: inline-flex; margin: 0; }
button.enlace-salir {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.95rem;
  transition: border-color var(--duration-base) var(--ease-standard);
}
button.enlace-salir:hover { border-color: var(--accent, #e31e24); color: #fff; }

/* ---------- Info de quién preparó la línea ---------- */
.linea-preparado-info {
  display: block;
  font-size: 0.72rem;
  color: var(--exito-texto);
  margin-top: 0.15rem;
}

/* ---------- Tablero kanban (panel de oficina) ---------- */
.contenido-ancho { max-width: 1400px; margin-inline: auto; }

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
  margin-top: 1rem;
}

.kanban-col {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 0.75rem;
  min-height: 8rem;
}

.kanban-col-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem 0.75rem;
  border-bottom: 3px solid var(--border-strong);
  margin-bottom: 0.75rem;
}
.kanban-col-cabecera h2 {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}
.kanban-col-num {
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.6rem;
}

/* Color de etapa en el borde de cabecera (identidad: navy / terra / verde) */
.col-pendiente   .kanban-col-cabecera { border-bottom-color: #12213d; }
.col-preparacion .kanban-col-cabecera { border-bottom-color: #c67840; }
.col-preparada   .kanban-col-cabecera { border-bottom-color: var(--exito); }
.col-preparacion .kanban-col-num { color: #874523; }
.col-preparada   .kanban-col-num { color: var(--exito-texto); }

.kanban-col-lista {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 72vh;
  overflow-y: auto;
  padding: 0.1rem;
}

.tarjeta-kanban { padding: 0.85rem 1rem; }
.tarjeta-kanban .factura-codigo { font-size: 1.05rem; }

.vacio-columna,
.nota-columna {
  color: var(--fg-subtle);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.75rem 0;
}

/* Móvil: columnas apiladas a ancho completo */
@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
  .kanban-col-lista { max-height: none; overflow-y: visible; }
}

/* ---------- Historial: agrupación por día ---------- */
.grupo-fecha {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 0.4rem;
  margin: 1.6rem 0 0.8rem;
}
.grupo-fecha:first-of-type { margin-top: 1rem; }
.grupo-fecha-num {
  font-size: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.55rem;
}

/* ---------- Panel admin: KPIs y verificación de datos ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}
.kpi {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.kpi-valor {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-brand-700, #12213d);
}
.kpi-etiqueta {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.kpi-ok .kpi-valor { color: #1d7a3f; }
.kpi-alerta { border-color: rgba(201, 23, 28, 0.45); }
.kpi-alerta .kpi-valor { color: #c9171c; }

.verificacion {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (max-width: 800px) {
  .verificacion { grid-template-columns: 1fr; }
}
.verificacion-bloque {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: 1rem 1.1rem;
}
.verificacion-titulo {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 0.75rem;
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 0.4rem;
}
.tabla-sync {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.tabla-sync th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  padding: 0.3rem 0.5rem;
}
.tabla-sync td {
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--border);
}
.tabla-sync small { color: var(--fg-subtle); }
.aviso {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.55rem 0.25rem;
  border-top: 1px solid var(--border);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background var(--duration-base) var(--ease-standard);
}
.aviso:first-of-type { border-top: none; }
.aviso:hover { background: var(--bg-muted); }
.aviso-tipo {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c9171c;
  border: 1px solid rgba(201, 23, 28, 0.45);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.5rem;
}
.aviso-ok { color: #1d7a3f; font-size: 0.9rem; }

/* ---------- Tablero: conmutador de densidad ---------- */
.tablero-herramientas {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.6rem;
}
.btn-densidad {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-standard);
}
.btn-densidad:hover { border-color: var(--color-brand-700, #12213d); color: var(--fg); }
.btn-densidad[aria-pressed="true"] {
  background: var(--color-brand-700, #12213d);
  border-color: var(--color-brand-700, #12213d);
  color: #fff;
}

/* Vista compacta: tarjetas reducidas a lo esencial */
.kanban-compacta .kanban-col-lista { gap: 0.4rem; }
.kanban-compacta .tarjeta-kanban { padding: 0.45rem 0.65rem; }
.kanban-compacta .tarjeta-kanban .factura-codigo { font-size: 0.95rem; }
.kanban-compacta .tarjeta-kanban .factura-fecha { font-size: 0.68rem; }
.kanban-compacta .tarjeta-kanban .factura-cliente {
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-compacta .tarjeta-kanban .cliente-codigo { display: none; }
.kanban-compacta .tarjeta-kanban .badge { display: none; }
.kanban-compacta .tarjeta-kanban .barra { height: 3px; }
.kanban-compacta .tarjeta-kanban .progreso-fila { margin-top: 0.15rem; }
.kanban-compacta .tarjeta-kanban .progreso-texto { font-size: 0.68rem; }

/* ---------- Historial admin: tabla ---------- */
.tabla-historial {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.tabla-historial th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border-strong);
}
.tabla-historial td {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--border);
}
.tabla-historial .fila-grupo td {
  background: var(--bg-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.tabla-historial .num-factura {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-brand-700, #12213d);
  text-decoration: none;
}
.tabla-historial .num-factura:hover { text-decoration: underline; }
.tabla-historial tbody tr:not(.fila-grupo):hover { background: var(--bg-muted); }
@media (max-width: 800px) {
  .tabla-historial-envoltura { overflow-x: auto; }
  .tabla-historial { min-width: 640px; }
}

/* ---------- Flujo 4 columnas ---------- */
.kanban-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .kanban-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kanban-4 { grid-template-columns: 1fr; } }
.col-listo     .kanban-col-cabecera { border-bottom-color: #2a4f95; }
.col-entregado .kanban-col-cabecera { border-bottom-color: #1d7a3f; }
.col-entregado .tarjeta-kanban { opacity: 0.75; }

/* Botones de confirmación del flujo */
.form-flujo { margin: 0.75rem 0; }
.btn-confirmar {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: #1d7a3f;
  border: 0;
  border-radius: var(--radius-card);
  padding: 0.95rem 1rem;
  min-height: 52px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: filter var(--duration-base) var(--ease-standard);
}
.btn-confirmar:hover { filter: brightness(1.08); }
.btn-entregar { background: var(--color-brand-700, #12213d); }
.btn-deshacer {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}
.form-flujo-inline { display: inline-block; margin-left: 0.6rem; }
.banner-listo { background: #eef3fb; color: #12213d; border: 1px solid #adc5e7; }
.banner-entregado { background: #e6f4ea; color: #1d7a3f; border: 1px solid #9fd4af; }

/* Botón densidad en la cabecera oscura */
.btn-densidad-cabecera {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.85);
}
.btn-densidad-cabecera:hover { border-color: #fff; color: #fff; }
.btn-densidad-cabecera[aria-pressed="true"] {
  background: #e31e24;
  border-color: #e31e24;
  color: #fff;
}

/* ---------- Historial: chips de estado de entrega ---------- */
.chip-ok, .chip-falta, .chip-espera {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}
.chip-ok    { color: #1d7a3f; background: #e6f4ea; border: 1px solid #9fd4af; }
.chip-falta { color: #c9171c; background: #fdecec; border: 1px solid #f2b3b5; }
.chip-espera { color: #8a5a00; background: #fdf3e0; border: 1px solid #eccf94; }
.historial-separado { margin-top: 1.75rem; }

/* ---------- Modal de detalle de pedido ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(7, 8, 11, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-caja {
  position: relative;
  width: min(760px, 100%);
  height: min(88vh, 920px);
  background: var(--bg);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}
.modal-caja iframe { width: 100%; height: 100%; border: 0; display: block; }
.modal-cerrar {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
body.en-modal .cabecera { display: none; }
body.en-modal .contenido { padding-top: 1rem; }

/* Scroll fino y delicado en las columnas del tablero */
.kanban-col-lista {
  scrollbar-width: thin;
  scrollbar-color: rgba(18, 33, 61, 0.18) transparent;
}
.kanban-col-lista::-webkit-scrollbar { width: 5px; }
.kanban-col-lista::-webkit-scrollbar-track { background: transparent; }
.kanban-col-lista::-webkit-scrollbar-thumb {
  background: rgba(18, 33, 61, 0.18);
  border-radius: 999px;
}
.kanban-col-lista::-webkit-scrollbar-thumb:hover { background: rgba(18, 33, 61, 0.35); }

/* ---------- Gestión de usuarios ---------- */
.form-usuario-inline {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.form-usuario-inline input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 0.85rem;
  background: var(--bg-muted);
  color: var(--fg);
  width: 180px;
}
.btn-peligro { color: var(--accent-600); border-color: rgba(201, 23, 28, 0.4); }
.btn-peligro:hover { background: rgba(227, 30, 36, 0.08); }

/* Sección activa del menú en rojo (convención de la web corporativa) */
.cabecera nav a.activo { color: var(--accent-500); }

/* ---------- Devoluciones ---------- */
.linea-solo-lectura { cursor: default; }
.btn-devolucion {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--terra-600);
  margin: 0.75rem 0;
}
.btn-devolucion:hover { filter: brightness(1.1); }
.linea-devolucion { cursor: default; }
.linea-cantidad-input {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}
.linea-cantidad-input input {
  width: 90px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  font: inherit;
  background: var(--bg-muted);
  color: var(--fg);
  text-align: right;
}
.linea-cantidad-input small { color: var(--fg-subtle); }
.campo-motivo { margin: 1rem 0; }
.campo-motivo input { width: 100%; }
.kpi-enlace { text-decoration: none; transition: border-color var(--duration-base) var(--ease-standard); }
.kpi-enlace:hover { border-color: var(--brand-500); }
.campo-crece { flex: 1; min-width: 260px; }
.campo-crece select { width: 100%; }
.kanban-devoluciones { grid-template-columns: repeat(3, 1fr); margin-top: 0.5rem; }
@media (max-width: 900px) { .kanban-devoluciones { grid-template-columns: 1fr; } }

/* Títulos de sección del Historial */
.seccion-titulo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--fg);
  margin: 2rem 0 0.25rem;
}
.seccion-titulo:first-of-type { margin-top: 1rem; }

/* Subir factura: inputs de la tabla de revisión */
.celda-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 0.88rem;
  background: var(--bg-muted);
  color: var(--fg);
}
.celda-codigo { max-width: 140px; }
.celda-cantidad { max-width: 110px; text-align: right; }
a.btn-densidad { text-decoration: none; display: inline-block; }

/* CTA destacado (Subir factura): rojo corporativo, píldora, icono y microinteracción */
.boton-enlace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.6rem 1.6rem;
  min-height: 46px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(227, 30, 36, 0.3);
  transition: transform var(--duration-base) var(--ease-standard),
    box-shadow var(--duration-base) var(--ease-standard),
    filter var(--duration-base) var(--ease-standard);
}
.boton-enlace svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}
.boton-enlace:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 8px 20px rgba(227, 30, 36, 0.35);
}
.boton-enlace:active { transform: translateY(0) scale(0.98); }

/* --- Botón en estado "procesando" (subir factura con IA) --- */
.boton-cargando {
  pointer-events: none;
  opacity: 0.8;
}
.boton-cargando::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 10px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
}
@keyframes girar {
  to { transform: rotate(360deg); }
}

/* --- Contenido dentro de ventana emergente: misma escala compacta del tablero --- */
body.en-modal { font-size: 15px; }
body.en-modal .contenido { padding: 1rem 1.2rem 1.6rem; }
body.en-modal .pagina-titulo h1 { font-size: 1.35rem; }
body.en-modal .factura-codigo-xl { font-size: 1.35rem; }
body.en-modal .ficha-factura { padding: 0.85rem 1rem 0.9rem; margin-bottom: 0.7rem; }
body.en-modal .ficha-factura .factura-cliente { font-size: 0.85rem; }
body.en-modal .banner-completa { padding: 0.6rem 0.8rem; font-size: 0.9rem; }
body.en-modal .progreso-texto { font-size: 0.78rem; }
body.en-modal .lista-lineas { gap: 0.4rem; }
body.en-modal .linea { min-height: 0; padding: 0.5rem 0.7rem; gap: 0.7rem; border-radius: 0.7rem; }
body.en-modal .check { width: 26px; height: 26px; border-radius: 0.45rem; border-width: 2px; }
body.en-modal .linea-preparada .check::after {
  left: 8px;
  top: 3px;
  width: 7px;
  height: 13px;
  border-width: 0 3px 3px 0;
}
body.en-modal .linea-articulo { font-size: 0.62rem; }
body.en-modal .linea-descripcion { font-size: 0.8rem; line-height: 1.3; }
body.en-modal .linea-cantidad { font-size: 0.95rem; }
body.en-modal .tabla-lineas { font-size: 0.8rem; }
body.en-modal .filtros { padding: 0.8rem 0.9rem; }
body.en-modal .nota-columna { font-size: 0.75rem; }

/* --- Dock inferior de navegación (móvil, tipo app) --- */
.dock { display: none; }

@media (max-width: 640px) {
  /* La navegación pasa al dock; la cabecera queda con logo + usuario + salir */
  .cabecera nav > a { display: none; }
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  body.pagina-login { padding-bottom: 0; }

  .dock {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.35rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
  }
  .dock a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.4rem 0 0.25rem;
    border-radius: 0.7rem;
    transition: color var(--duration-base) var(--ease-standard);
  }
  .dock a svg { width: 23px; height: 23px; }
  .dock a.activo { color: #fff; }
  .dock a.activo svg { color: var(--accent-500); }
  body.en-modal .dock { display: none; }
  body.en-modal { padding-bottom: 0; }

  /* KPIs como tira deslizable */
  .kpis {
    display: flex;
    overflow-x: auto;
    gap: 0.55rem;
    padding-bottom: 0.3rem;
    scrollbar-width: none;
  }
  .kpis::-webkit-scrollbar { display: none; }
  .kpis .kpi, .kpis a.kpi { flex: 0 0 31%; min-width: 105px; }

  /* Tablero: columnas a pantalla casi completa con swipe y snap */
  .kanban-4 {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 0.7rem;
    padding-bottom: 0.4rem;
    scrollbar-width: none;
  }
  .kanban-4::-webkit-scrollbar { display: none; }
  .kanban-4 .kanban-col {
    flex: 0 0 84%;
    scroll-snap-align: start;
  }
}

/* --- Móvil: tarjetas y picking con la misma escala compacta del tablero --- */
@media (max-width: 640px) {
  .pagina-titulo h1 { font-size: 1.4rem; }

  /* Tarjetas de factura (listas de almacén e historial) */
  .tarjeta-factura { padding: 0.6rem 0.8rem; }
  .tarjeta-factura .factura-codigo { font-size: 1.05rem; }
  .factura-cliente { margin: 0.12rem 0 0.3rem; font-size: 0.8rem; }
  .factura-fecha { font-size: 0.7rem; }
  .progreso-fila { margin-top: 0.3rem; }
  .progreso-texto { font-size: 0.72rem; }
  .grupo-fecha { font-size: 0.95rem; }

  /* Ficha de la factura abierta */
  .ficha-factura { padding: 0.75rem 0.9rem 0.8rem; margin-bottom: 0.65rem; }
  .factura-codigo-xl { font-size: 1.4rem; }
  .ficha-factura .factura-cliente { font-size: 0.83rem; }
  .banner-completa { padding: 0.6rem 0.75rem; font-size: 0.88rem; }

  /* Líneas de picking: fila fina, check táctil moderado */
  .lista-lineas { gap: 0.42rem; }
  .linea {
    min-height: 0;
    padding: 0.5rem 0.65rem;
    gap: 0.65rem;
    border-radius: 0.75rem;
  }
  .check { width: 30px; height: 30px; border-radius: 0.55rem; }
  .linea-preparada .check::after {
    left: 9px;
    top: 4px;
    width: 8px;
    height: 15px;
    border-width: 0 3px 3px 0;
  }
  .linea-articulo { font-size: 0.62rem; }
  .linea-descripcion { font-size: 0.83rem; line-height: 1.3; }
  .linea-cantidad { font-size: 0.98rem; }
  .linea-preparado-info { font-size: 0.66rem; }
}
