/* =====================================================================
   MTA Publicidad - Estilos mobile-first
   Paleta: navy / teal / blanco (slate-gray como acento secundario)
   ===================================================================== */

:root {
  --navy: #0a1f33;
  --navy-dark: #071523;
  --navy-soft: #0f3a52;
  --teal: #14b8a6;
  --teal-dark: #0d9488;
  --slate: #64748b;
  --slate-light: #cbd5e1;
  --bg: #f4f7f9;
  --white: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(10, 31, 51, 0.08);
  --shadow-lg: 0 8px 24px rgba(10, 31, 51, 0.16);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  /* Tokens de superficie "suave" (líneas separadoras, fondos tenues,
     skeleton loader) — antes eran decenas de grises casi idénticos
     escritos a mano por toda la hoja; unificados aquí para que el modo
     oscuro los pueda redefinir en un solo lugar. */
  --borde: #e5e9ee;
  --superficie-sutil: #f2f6f8;
  --skeleton-base: #e9edf1;
  --skeleton-brillo: #f4f6f8;
  /* Blanco literal: para texto/íconos sobre fondos de color (navy, teal)
     y el "pomo" del interruptor — a propósito NO cambia en modo oscuro,
     a diferencia de --white (que sí es la superficie de las tarjetas y
     se redefine más abajo). */
  --blanco-fijo: #ffffff;
  /* Texto "fuerte" (títulos, valores destacados): navy en claro, casi
     blanco en oscuro — separado de --navy porque --navy también se usa
     como FONDO (topbar, botones, degradados) y esos deben seguir oscuros
     en los dos temas. */
  --texto-fuerte: var(--navy);
  color-scheme: light;
}

/* ---------------------------------------------------------------------
   Modo oscuro: sigue la preferencia del sistema por defecto, y se puede
   forzar con data-theme="dark" / "light" (control en Perfil, guardado
   en localStorage). El orden de las tres reglas importa: la de sistema
   solo aplica si no hay una elección explícita, y la explícita siempre
   gana al final.
   --------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy-soft: #163a52;
    --slate-light: #3a4e62;
    --bg: #0b1420;
    --white: #16222f;
    --text: #e7edf3;
    --text-muted: #93a4b8;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.5);
    --borde: #223243;
    --superficie-sutil: #1b2836;
    --skeleton-base: #1c2a38;
    --skeleton-brillo: #263748;
    --texto-fuerte: #f1f5f9;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy-soft: #163a52;
  --slate-light: #3a4e62;
  --bg: #0b1420;
  --white: #16222f;
  --text: #e7edf3;
  --text-muted: #93a4b8;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.5);
  --borde: #223243;
  --superficie-sutil: #1b2836;
  --skeleton-base: #1c2a38;
  --skeleton-brillo: #263748;
  --texto-fuerte: #f1f5f9;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  transition: background 0.2s ease, color 0.2s ease;
}

button, input, select, textarea {
  font-family: inherit;
}

a { color: var(--teal-dark); text-decoration: none; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ---------------------- Barra superior ---------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: var(--blanco-fijo);
  padding: calc(14px + var(--safe-top)) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}
.topbar .subtitulo {
  font-size: 12px;
  color: var(--slate-light);
  margin-top: 2px;
}
.topbar-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--blanco-fijo);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}
.topbar-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.22); }

.topbar-acciones {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.reloj-vivo {
  text-align: right;
  color: var(--blanco-fijo);
  line-height: 1.15;
  margin-right: 2px;
  font-variant-numeric: tabular-nums;
}
.reloj-vivo #reloj-hora { display: block; font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
.reloj-vivo .reloj-fecha { display: block; font-size: 10px; color: var(--slate-light); text-transform: capitalize; }

.actualizado-barra {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ecfdf5;
  color: #047857;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 0;
}
.punto-vivo {
  width: 7px; height: 7px; border-radius: 50%; background: #10b981;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  animation: latido 1.8s infinite;
}
@keyframes latido {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.55); }
  70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.banner-instalar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy);
  color: var(--blanco-fijo);
  padding: 10px 12px;
  animation: aparecer 0.25s ease;
}
.banner-instalar-icono {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
}
.banner-instalar-texto {
  flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25;
}
.banner-instalar-texto strong { font-size: 13px; }
.banner-instalar-texto span {
  font-size: 11px; color: var(--slate-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-chico { padding: 7px 14px; font-size: 12.5px; border-radius: 8px; flex-shrink: 0; }
.banner-instalar-cerrar {
  background: none; border: none; color: var(--slate-light);
  font-size: 15px; padding: 4px 2px; cursor: pointer; flex-shrink: 0;
}

/* ---------------------- Contenido ---------------------- */
.contenido {
  flex: 1;
  padding: 14px 14px calc(90px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pull-indicador {
  text-align: center;
  color: var(--slate);
  font-size: 12px;
  padding: 0;
  height: 0;
  overflow: hidden;
  transition: height 0.15s ease, padding 0.15s ease;
}
.pull-indicador.activo { height: 24px; padding: 6px 0; }

/* ---------------------- Tarjetas ---------------------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card-cliente, .card-pedido {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  border-left: 4px solid var(--teal);
}
.card-pedido.estado-diseno_grafico { border-left-color: #a78bfa; }
.card-pedido.estado-revelado_emulsionado { border-left-color: #60a5fa; }
.card-pedido.estado-impresion_secado { border-left-color: #fbbf24; }
.card-pedido.estado-listo_entrega { border-left-color: #14b8a6; }
.card-pedido.estado-entregado, .card-pedido.estado-archivado { border-left-color: #94a3b8; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-titulo { font-weight: 700; font-size: 15px; color: var(--texto-fuerte); }
.card-sub { font-size: 13px; color: var(--text-muted); }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ---------------------- Badges / etiquetas ---------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-etapa-diseno_grafico { background: #ede9fe; color: #6d28d9; }
.badge-etapa-revelado_emulsionado { background: #dbeafe; color: #1d4ed8; }
.badge-etapa-impresion_secado { background: #fef3c7; color: #b45309; }
.badge-etapa-listo_entrega { background: #ccfbf1; color: #0f766e; }
.badge-etapa-entregado { background: #dcfce7; color: #15803d; }
.badge-etapa-archivado { background: #e2e8f0; color: #475569; }
.badge-pago-pendiente { background: #fee2e2; color: var(--danger); }
.badge-pago-parcial { background: #fef3c7; color: var(--warning); }
.badge-pago-pagado { background: #dcfce7; color: var(--success); }

/* ---------------------- Botones ---------------------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  min-height: 44px;
}
.btn-primario { background: var(--teal); color: var(--blanco-fijo); }
.btn-primario:active { background: var(--teal-dark); }
.btn-secundario { background: var(--navy); color: var(--blanco-fijo); }
.btn-outline { background: transparent; border: 1.5px solid var(--slate-light); color: var(--text); }
.btn-whatsapp { background: #25d366; color: var(--blanco-fijo); }
.btn-peligro { background: #fee2e2; color: var(--danger); }
.btn-bloque { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }

/* ---------------------- Formularios ---------------------- */
.campo { margin-bottom: 14px; }
.campo label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-fuerte);
  margin-bottom: 6px;
}
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--slate-light);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--white);
  color: var(--text);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--teal);
}
.campo-fila { display: flex; gap: 10px; }
.campo-fila .campo { flex: 1; min-width: 0; }
@media (max-width: 359px) {
  .campo-fila-tamano { flex-wrap: wrap; }
  .campo-fila-tamano .campo { flex: 1 1 30%; }
}
.ayuda-campo { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.linea-extra-item { background: var(--superficie-sutil); border: 1px solid var(--borde); border-radius: 10px; padding: 8px; margin-bottom: 8px; }
.linea-extra-item .campo-fila:first-child { align-items: flex-end; }
.linea-extra-item .le-quitar { flex: 0 0 auto; align-self: flex-end; }


/* ---------------------- Biblioteca de Diseños ---------------------- */
.disenos-buscador {
  position: relative;
  margin-bottom: 12px;
}
.disenos-buscador input[type="search"] {
  width: 100%;
  padding: 12px 40px 12px 40px;
  border: 1px solid var(--borde);
  border-radius: 12px;
  font-size: 15px;
  background: var(--white);
  -webkit-appearance: none;
}
.disenos-buscador input[type="search"]:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20,184,166,0.15);
}
.disenos-buscador input[type="search"]::-webkit-search-cancel-button { display: none; }
.disenos-lupa {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  opacity: 0.75;
}
.disenos-limpiar {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--superficie-sutil);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  color: var(--slate);
  font-size: 12px;
  line-height: 1;
}
.disenos-conteo {
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 2px 8px;
}
.disenos-grupo { margin-bottom: 18px; }
.disenos-grupo-titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--texto-fuerte);
  padding: 0 2px 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--borde);
}
.disenos-grupo-conteo {
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  border-radius: 20px;
  padding: 1px 8px;
  flex: none;
}
.card-diseno { padding-bottom: 10px; }
.diseno-fila { display: flex; gap: 12px; align-items: flex-start; }
.diseno-icono {
  font-size: 26px;
  line-height: 1;
  flex: none;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--superficie-sutil);
  border-radius: 10px;
}
.diseno-info { min-width: 0; flex: 1; }
.diseno-info .card-sub {
  word-break: break-all;
  font-size: 12px;
}
.diseno-desc {
  font-size: 12.5px;
  color: var(--slate);
  margin-top: 4px;
}
.diseno-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
}
.chip-ext {
  background: var(--navy);
  color: #fff;
  border-radius: 5px;
  padding: 1px 6px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.diseno-etiquetas {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.diseno-etiquetas .tag {
  background: #eef7f6;
  color: var(--teal-dark);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
}
.diseno-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.diseno-acciones .btn {
  /* Dos por fila: así 4 botones quedan en una rejilla pareja en vez de
     dejar uno solo colgando en la última línea. */
  flex: 1 1 calc(50% - 4px);
  text-align: center;
  text-decoration: none;
  min-width: 0;
}
.diseno-acciones .btn-peligro {
  flex: 0 0 48px;
  padding-left: 0;
  padding-right: 0;
  color: #b3261e;
  border-color: #f0cfcc;
}
.diseno-nota {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-left: 2px;
}

/* Barra de progreso de subida */
.barra-progreso {
  height: 8px;
  background: var(--superficie-sutil);
  border-radius: 20px;
  overflow: hidden;
  margin: 12px 0 4px;
}
.barra-progreso-relleno {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width 0.15s ease;
}

/* Bloque de diseños dentro de la ficha del cliente */
.bloque-disenos-cliente {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--borde);
}
.bloque-titulo {
  font-size: 13px;
  font-weight: 700;
  color: var(--texto-fuerte);
  margin-bottom: 6px;
}
.fila-botones { display: flex; gap: 8px; }
.fila-botones .btn { flex: 1; }

/* ---------------------- Navegación inferior ---------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: var(--white);
  border-top: 1px solid var(--borde);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  z-index: 30;
  box-shadow: 0 -2px 10px rgba(10,31,51,0.06);
}
.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 1px;
  color: var(--slate);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.2px;
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
}
.nav-item .icono { font-size: 18px; }
/* Pantallas angostas (iPhone SE y similares): las 6 pestañas siguen cabiendo */
@media (max-width: 359px) {
  .nav-item { font-size: 8.5px; letter-spacing: -0.3px; }
  .nav-item .icono { font-size: 16.5px; }
}
.nav-item.activo { color: var(--teal-dark); }

/* Botón flotante (FAB) */
.fab {
  position: fixed;
  bottom: calc(72px + var(--safe-bottom));
  left: 50%;
  transform: translateX(calc(-50% + 200px));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--blanco-fijo);
  font-size: 28px;
  border: none;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
}
@media (max-width: 560px) {
  .fab { transform: translateX(calc(-50% + calc(50vw - 40px))); }
}
.fab:active { background: var(--teal-dark); }

/* Segundo botón flotante (lado izquierdo): siempre visible, para acciones
   rápidas que no dependen de la vista ni del rol (ej. enviar lista de precios). */
.fab-secundario {
  width: 50px;
  height: 50px;
  font-size: 22px;
  background: var(--navy);
  transform: translateX(calc(-50% - 200px));
}
@media (max-width: 560px) {
  .fab-secundario { transform: translateX(calc(-50% - calc(50vw - 36px))); }
}
.fab-secundario:active { background: var(--navy-dark, #061625); }

/* ---------------------- Stepper de producción (6 etapas) ---------------------- */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.step {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 22px;
}
.step:last-child { padding-bottom: 0; }
.step-linea {
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--slate-light);
}
.step:last-child .step-linea { display: none; }
.step.completado .step-linea { background: var(--teal); }
.step-punto {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--slate-light);
  color: var(--blanco-fijo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  z-index: 1;
}
.step.completado .step-punto { background: var(--teal); }
.step.actual .step-punto { background: var(--navy); box-shadow: 0 0 0 4px rgba(10,31,51,0.15); }
.step-texto { flex: 1; }
.step-titulo { font-weight: 700; font-size: 14px; color: var(--texto-fuerte); }
.step-fecha { font-size: 12px; color: var(--text-muted); }
.step.pendiente .step-titulo { color: var(--text-muted); }
.step-btn-avanzar {
  margin-top: 8px;
}

/* ---------------------- Login ---------------------- */
.login-pantalla {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
  padding: 24px;
}
.login-logo {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: var(--navy-soft);
  border: 2px solid var(--teal);
  color: var(--blanco-fijo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 26px;
  margin-bottom: 18px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-card h2 { margin: 0 0 4px; color: var(--texto-fuerte); }
.login-card p { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; }
.error-msg {
  background: #fee2e2;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.exito-msg {
  background: #dcfce7;
  color: var(--success);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------------------- Utilidades ---------------------- */
.oculto { display: none !important; }
.texto-centro { text-align: center; }
.texto-muted { color: var(--text-muted); }
.vacio-estado {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.vacio-estado .icono-grande { font-size: 40px; margin-bottom: 10px; }
.seccion-titulo {
  font-size: 13px;
  font-weight: 700;
  color: var(--texto-fuerte);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 18px 0 10px;
}
.fila-accion {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.tab-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--white);
  border: 1.5px solid var(--slate-light);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.tab-chip.activo { background: var(--navy); border-color: var(--navy); color: var(--blanco-fijo); }

.modal-fondo {
  position: fixed;
  inset: 0;
  background: rgba(10,31,51,0.5);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-hoja {
  background: var(--white);
  width: 100%;
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 88vh;
  overflow-y: auto;
  animation: subir 0.2s ease-out;
}
@keyframes subir {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-titulo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-titulo h3 { margin: 0; color: var(--texto-fuerte); }
.modal-cerrar {
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-muted);
}

.spinner {
  border: 3px solid var(--slate-light);
  border-top-color: var(--teal);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: girar 0.7s linear infinite;
  margin: 20px auto;
}
@keyframes girar { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--blanco-fijo);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-width: 90%;
  text-align: center;
}

.archivo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--borde);
  gap: 10px;
}
.archivo-item:last-child { border-bottom: none; }
.archivo-nombre { font-size: 13px; font-weight: 600; color: var(--texto-fuerte); word-break: break-word; }
.archivo-meta { font-size: 11px; color: var(--text-muted); }

.bitacora-fila { padding: 10px 0; border-bottom: 1px solid var(--borde); }
.bitacora-fila:last-child { border-bottom: none; }
.bitacora-titulo { font-size: 13px; font-weight: 700; color: var(--texto-fuerte); }
.bitacora-nota { font-size: 13px; color: var(--text); margin-top: 2px; }

.costo-caja {
  background: var(--navy);
  color: var(--blanco-fijo);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.costo-fila { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.costo-fila.total { font-weight: 700; font-size: 16px; border-top: 1px solid rgba(255,255,255,0.2); margin-top: 6px; padding-top: 10px; }

/* =====================================================================
   DASHBOARD / INICIO
   ===================================================================== */
.saludo-dashboard {
  color: var(--texto-fuerte);
  margin: 2px 0 16px;
}
.saludo-dashboard .titulo-saludo { font-size: 20px; font-weight: 800; }
.saludo-dashboard .sub-saludo { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  position: relative;
  overflow: hidden;
  animation: aparecer 0.35s ease both;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--navy));
}
.kpi-valor { font-size: 26px; font-weight: 800; color: var(--texto-fuerte); line-height: 1.1; }
.kpi-etiqueta { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }
.kpi-icono { font-size: 18px; margin-bottom: 4px; display: block; }
.kpi-card.kpi-alerta .kpi-valor { color: var(--danger); }
.kpi-card.kpi-dinero { grid-column: span 2; background: linear-gradient(135deg, var(--navy), var(--navy-soft)); }
.kpi-card.kpi-dinero .kpi-valor, .kpi-card.kpi-dinero .kpi-etiqueta { color: #fff; }
.kpi-card.kpi-dinero .kpi-etiqueta { color: #cbd5e1; }
.kpi-card.kpi-dinero::before { display: none; }

.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px 8px;
  margin-bottom: 16px;
}
.chart-titulo { font-size: 14px; font-weight: 700; color: var(--texto-fuerte); margin-bottom: 12px; }
.funnel-barras {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.funnel-fila { display: flex; align-items: center; gap: 8px; }
.funnel-etiqueta { width: 92px; font-size: 11px; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.funnel-pista { flex: 1; background: var(--superficie-sutil); border-radius: 999px; height: 18px; overflow: hidden; position: relative; }
.funnel-relleno {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--navy));
  width: 0%;
  transition: width 0.6s cubic-bezier(.22,1,.36,1);
}
.funnel-numero { width: 22px; text-align: right; font-size: 12px; font-weight: 700; color: var(--texto-fuerte); flex-shrink: 0; }

.ingresos-barras {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 90px;
  padding: 0 2px;
}
.ingresos-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.ingresos-barra {
  width: 100%;
  height: 2%;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--teal), var(--navy));
  transition: height 0.6s cubic-bezier(.22,1,.36,1);
}
.ingresos-eje {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
  padding: 0 2px;
}

.insight-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
  animation: aparecer 0.35s ease both;
}
.insight-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.insight-header .icono { font-size: 16px; }
.insight-header .titulo { font-weight: 700; font-size: 13.5px; color: var(--texto-fuerte); }
.insight-header .conteo {
  margin-left: auto; background: var(--bg); color: var(--text-muted);
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.insight-card.critico .conteo { background: #fee2e2; color: var(--danger); }
.insight-card.atencion .conteo { background: #fef3c7; color: var(--warning); }
.insight-fila {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--borde); font-size: 12.5px; gap: 8px;
}
.insight-fila:last-child { border-bottom: none; }
.insight-fila .nombre { font-weight: 600; color: var(--text); }
.insight-fila .detalle { color: var(--text-muted); font-size: 11.5px; }
.insight-fila .pill-dias {
  flex-shrink: 0; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: #fee2e2; color: var(--danger);
}
.insight-fila .pill-dias.pill-info { background: #dbeafe; color: #1d4ed8; }
.btn-icono-whatsapp {
  flex-shrink: 0; border: none; background: #dcfce7; color: #15803d;
  width: 28px; height: 28px; border-radius: 50%; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.todo-al-dia { text-align: center; padding: 24px 10px; color: var(--text-muted); }
.todo-al-dia .icono-grande { font-size: 32px; margin-bottom: 6px; }

/* =====================================================================
   SKELETON LOADERS (reemplazan al spinner genérico)
   ===================================================================== */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-brillo) 37%, var(--skeleton-base) 63%);
  background-size: 400% 100%;
  animation: brillo 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes brillo {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.skeleton-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.skeleton-linea { height: 12px; margin-bottom: 8px; }
.skeleton-linea.w-60 { width: 60%; }
.skeleton-linea.w-40 { width: 40%; }
.skeleton-linea.w-80 { width: 80%; }
.skeleton-chip { height: 20px; width: 70px; border-radius: 999px; display: inline-block; margin-right: 6px; }

@keyframes aparecer {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card, .card-pedido, .card-cliente { animation: aparecer 0.3s ease both; }

/* Micro-interacción táctil general para botones y tarjetas presionables */
.btn:active, .card-pedido:active, .card-cliente:active, .tab-chip:active, .nav-item:active {
  transform: scale(0.97);
}
.btn, .card-pedido, .card-cliente, .tab-chip, .nav-item {
  transition: transform 0.1s ease;
}

/* =====================================================================
   BÚSQUEDA GLOBAL
   ===================================================================== */
.buscador-overlay {
  position: fixed; inset: 0; background: rgba(10,31,51,0.5);
  z-index: 55; display: flex; flex-direction: column;
}
.buscador-caja {
  background: var(--white);
  padding: calc(12px + var(--safe-top)) 14px 12px;
  display: flex; gap: 8px; align-items: center;
  box-shadow: var(--shadow);
}
.buscador-caja input {
  flex: 1; border: 1.5px solid var(--slate-light); border-radius: 999px;
  padding: 11px 16px; font-size: 15px;
}
.buscador-caja input:focus { outline: none; border-color: var(--teal); }
.buscador-resultados { flex: 1; overflow-y: auto; padding: 12px 14px; background: var(--bg); }
.buscador-seccion-titulo { font-size: 12px; font-weight: 700; color: var(--slate); text-transform: uppercase; margin: 12px 0 8px; }
.resultado-item {
  background: var(--white); border-radius: 12px; padding: 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  box-shadow: var(--shadow);
}
.resultado-item .nombre { font-weight: 700; font-size: 14px; color: var(--texto-fuerte); }
.resultado-item .sub { font-size: 12px; color: var(--text-muted); }

/* =====================================================================
   GESTOS: deslizar tarjeta para avanzar etapa (Kanban de producción)
   ===================================================================== */
.card-swipe-wrap { position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 12px; }
.card-swipe-wrap .swipe-fondo {
  position: absolute; inset: 0; background: linear-gradient(90deg, var(--teal), var(--teal-dark));
  color: #fff; display: flex; align-items: center; padding: 0 18px; font-weight: 700; font-size: 13px;
}
.card-swipe-wrap .card-pedido {
  position: relative; z-index: 1; margin-bottom: 0; background: var(--white);
  touch-action: pan-y;
}
.swipe-pista { font-size: 11px; color: var(--text-muted); text-align: center; margin: -6px 0 12px; }


/* =====================================================================
   GESTO: deslizar una tarjeta a la izquierda para ver sus acciones
   ===================================================================== */
.pista-deslizar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--teal-dark);
  background: #eafaf7;
  border: 1px solid #d4f1ec;
  border-radius: 999px;
  text-align: center;
  padding: 7px 12px;
  margin: 2px 0 14px;
}
.fila-deslizable {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--superficie-sutil);
  box-shadow: var(--shadow);
}
.fila-deslizable .acciones-ocultas {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex;
  align-items: stretch;
}
.accion-swipe {
  border: none;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: filter 0.1s ease;
}
.accion-swipe .icono {
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
}
.accion-wa      { background: linear-gradient(160deg, #29c46f, #1f9e59); }
.accion-editar  { background: linear-gradient(160deg, var(--teal), var(--teal-dark)); }
.accion-borrar  { background: linear-gradient(160deg, #e5484d, #b3261e); }
.accion-swipe:active { filter: brightness(0.92); }

/* La tarjeta de adelante no lleva la animación de entrada ni el efecto de
   "pulsar": ambos usan transform y pisarían el desplazamiento del gesto.
   La animación de entrada se la queda el contenedor. */
.fila-deslizable { animation: aparecer 0.3s ease both; box-shadow: none; }
.deslizable-frente,
.deslizable-frente:active {
  animation: none !important;
  transition: none;
}
.deslizable-frente {
  position: relative;
  z-index: 1;
  margin-bottom: 0 !important;
  background: var(--white);
  box-shadow: var(--shadow);
  touch-action: pan-y;               /* el scroll vertical sigue siendo del navegador */
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}
.fila-deslizable.abierta .deslizable-frente {
  box-shadow: -6px 0 12px rgba(10,31,51,0.1);
}

/* Tarjeta de cliente: cabecera con avatar de iniciales para que la lista
   se lea de un vistazo, como una libreta de contactos del taller. */
.card-cliente { padding: 12px 14px; gap: 8px; }
.card-cliente .card-top { align-items: center; }
.cliente-encabezado { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cliente-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(155deg, var(--teal), var(--navy-soft));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
}
.cliente-info { min-width: 0; }
.cliente-info .card-titulo { font-size: 14.5px; }
.cliente-info .card-sub { font-size: 12.5px; }
.card-cliente .card-meta {
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--borde);
  gap: 4px 12px;
}
.card-cliente .card-meta .texto-muted { display: inline-flex; align-items: center; gap: 4px; }

/* Aviso con botón (Deshacer): más ancho y con el texto alineado a la
   izquierda, para que un nombre largo no se parta en una columna. */
.toast-accion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 14px;
  padding: 12px 16px;
  text-align: left;
  width: calc(100% - 28px);
  max-width: 420px;
  bottom: calc(92px + var(--safe-bottom));
}
.toast-accion > span {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.toast-accion button {
  background: none;
  border: none;
  color: var(--teal);
  font-weight: 800;
  font-size: 13px;
  padding: 4px 2px;
  cursor: pointer;
  flex: none;
}

/* Pedidos del cliente, dentro de su ficha */
.mini-pedido {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--superficie-sutil);
  cursor: pointer;
}
.mini-pedido:last-child { border-bottom: none; }
.mini-pedido-codigo { font-size: 13px; font-weight: 700; color: var(--texto-fuerte); }
.mini-pedido-sub { font-size: 12px; color: var(--text-muted); }
.btn-peligro { color: #b3261e; border-color: #f0cfcc; }

/* Papelera de clientes */
.enlace-discreto {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px 2px;
  margin-top: 4px;
  cursor: pointer;
  text-align: left;
  display: block;
}
.enlace-discreto:active { color: var(--teal-dark); }
.fila-papelera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--superficie-sutil);
  border: 1px dashed var(--borde);
  border-radius: 12px;
}
.fila-papelera > div { min-width: 0; }
.fila-papelera .mini-pedido-sub { word-break: break-word; }

/* =====================================================================
   FICHA IMPRIMIBLE
   ===================================================================== */
.hoja-impresion { font-family: -apple-system, Arial, sans-serif; color: #1e293b; padding: 30px; max-width: 700px; margin: 0 auto; }
.hoja-impresion h1 { color: #0a1f33; font-size: 22px; margin-bottom: 2px; }
.hoja-impresion .marca-impresion { color: #14b8a6; font-weight: 800; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 16px; }
.hoja-impresion table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.hoja-impresion td { padding: 7px 4px; border-bottom: 1px solid #e5e9ee; font-size: 13px; }
.hoja-impresion td:first-child { color: #64748b; width: 42%; }
.hoja-impresion .stepper-impresion { display: flex; gap: 6px; margin: 16px 0; flex-wrap: wrap; }
.hoja-impresion .paso-impresion { flex: 1; min-width: 90px; text-align: center; padding: 8px 4px; border-radius: 8px; font-size: 11px; font-weight: 700; background: #f1f5f9; color: #64748b; }
.hoja-impresion .paso-impresion.hecho { background: #ccfbf1; color: #0f766e; }

/* La barra superior nunca debe chocar con el reloj: el título se recorta */
.topbar > div:first-child { min-width: 0; flex: 1; }
.topbar h1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================================================================
   INVENTARIO DE FUNDAS
   ===================================================================== */
.inventario-tabs-vendedora {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-vendedora {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 1.5px solid var(--borde);
  background: var(--white);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.tab-vendedora .avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(155deg, var(--slate), var(--navy-soft));
}
.tab-vendedora.activa {
  border-color: var(--teal);
  background: #eafaf7;
  color: var(--teal-dark);
}
.tab-vendedora.activa .avatar-mini {
  background: linear-gradient(155deg, var(--teal), var(--teal-dark));
}

.color-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
}
.color-dot-chico { width: 10px; height: 10px; }

.btn-ingresar { background: #dcfce7; color: #15803d; }
.btn-sacar { background: #ffedd5; color: #c2410c; }

/* Fila compacta de una funda (con o sin gesto de deslizar). */
.fila-funda {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}
.fila-funda-estatica { margin-bottom: 10px; }
.fila-funda-info { min-width: 0; }
.fila-funda-nombre {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--texto-fuerte);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fila-funda-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.badge-tipo {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-tipo-boutique { background: #e7ecf7; color: var(--navy); }
.badge-tipo-camiseta { background: #fdf1de; color: #92601b; }
.fila-funda-medida, .fila-funda-color { white-space: nowrap; }
.fila-funda-cantidad {
  font-size: 22px;
  font-weight: 800;
  color: var(--teal-dark);
  line-height: 1;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}
.fila-funda-cantidad .unidad { font-size: 10.5px; font-weight: 600; color: var(--text-muted); display: block; }
.fila-funda-cantidad.alerta { color: var(--danger); }

.accion-ingresar { background: linear-gradient(160deg, #34d399, #059669); }
.accion-sacar    { background: linear-gradient(160deg, #fb923c, #c2410c); }

.inventario-precios-lista { margin-top: 4px; }
.fila-precio-proveedor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--borde);
  font-size: 13px;
}
.fila-precio-proveedor:last-child { border-bottom: none; }
.fila-precio-proveedor .fp-nombre { font-weight: 600; color: var(--text); }
.fila-precio-proveedor .fp-tipo { font-size: 11px; color: var(--text-muted); }
.fila-precio-proveedor .fp-precio { font-weight: 700; color: var(--texto-fuerte); white-space: nowrap; }
.fp-precios { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.fp-precio-fila { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.fp-precio-fila span:last-child { font-weight: 600; color: var(--text); min-width: 52px; text-align: right; }
.fp-precio-fila.fp-margen span:last-child { font-weight: 700; color: var(--teal, #0d9488); }

/* Botón "Préstamos" con contador de pendientes */
.badge-contador {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
}
.prestamo-fila { margin-bottom: 10px; }

/* =====================================================================
   INTEGRACIÓN PEDIDOS <-> INVENTARIO (buscador de funda + chequeo de stock)
   ===================================================================== */
.campo-funda-buscador {
  display: flex;
  align-items: center;
  gap: 8px;
}
.campo-funda-buscador .disenos-buscador { flex: 1; }

#pedido-funda-resultados {
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
  border-radius: var(--radius);
}
.resultado-funda-pedido {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--borde);
  border-top: none;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
}
.resultado-funda-pedido:first-child { border-top: 1px solid var(--borde); border-radius: 10px 10px 0 0; }
.resultado-funda-pedido:last-child { border-radius: 0 0 10px 10px; }
.resultado-funda-pedido:only-child { border-radius: 10px; }
.resultado-funda-pedido:hover { background: var(--superficie-sutil); }
.resultado-funda-nombre { font-weight: 600; flex: 1; }

.chequeo-stock {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}
.chequeo-ok { background: #dcfce7; color: #15803d; }
.chequeo-prestamo { background: #fef3c7; color: #92400e; }
.chequeo-bloqueado { background: #fee2e2; color: #b91c1c; }

.funda-vinculada-pedido {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text);
  background: #eef2ff;
  border-radius: var(--radius);
  padding: 8px 10px;
}

.aviso-info {
  font-size: 12.5px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eef2ff;
  border-radius: var(--radius);
  padding: 8px 10px;
}
.topbar-acciones { flex: none; }

/* =====================================================================
   AJUSTES: selector de tema + interruptor de sonido (Perfil)
   ===================================================================== */
.segmentado {
  display: flex;
  gap: 4px;
  background: var(--superficie-sutil);
  border-radius: 999px;
  padding: 4px;
}
.segmentado-opcion {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 6px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.segmentado-opcion.activo {
  background: var(--white);
  color: var(--texto-fuerte);
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .segmentado-opcion.activo { color: var(--teal); }
}
:root[data-theme="dark"] .segmentado-opcion.activo { color: var(--teal); }

.fila-ajuste {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}
.fila-ajuste:not(:last-child) { border-bottom: 1px solid var(--borde); }
.fila-ajuste-texto { min-width: 0; }
.fila-ajuste-titulo { font-size: 14px; font-weight: 700; color: var(--text); }
.fila-ajuste-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.interruptor {
  position: relative;
  width: 46px;
  height: 27px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--slate-light);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.interruptor::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--blanco-fijo);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s cubic-bezier(.2,.8,.3,1);
}
.interruptor.activo { background: var(--teal); }
.interruptor.activo::after { transform: translateX(19px); }

/* =====================================================================
   Agenda de entregas, semáforo de riesgo, "esperando...", carga por día
   ===================================================================== */
.chip-riesgo, .chip-espera {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.chip-riesgo.riesgo-rojo { background: #fee2e2; color: #b91c1c; }
.chip-riesgo.riesgo-amarillo { background: #fef3c7; color: #92400e; }
.chip-riesgo.riesgo-verde { background: #dcfce7; color: #166534; }
.chip-espera { background: #e0e7ff; color: #3730a3; }
.chip-espera.chip-cambios { background: #ffedd5; color: #9a3412; }

.aviso-cambios {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: #ffedd5; color: #7c2d12; font-size: 13px;
}
.aviso-cambios .btn-outline { border-color: #9a3412; color: #7c2d12; }

.fecha-agenda {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); margin: 8px 2px 4px;
}
.fila-agenda { cursor: pointer; }
.btn-agenda-wa { text-decoration: none; }

/* Tira de carga: una columna por día */
.carga-dias { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; margin-top: 10px; }
.carga-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.carga-num { font-size: 11px; font-weight: 700; color: var(--texto-fuerte); height: 14px; }
.carga-pista {
  width: 100%; height: 56px; background: var(--superficie-sutil); border-radius: 6px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.carga-barra { width: 100%; background: var(--teal); border-radius: 6px 6px 0 0; transition: height .4s ease; }
.carga-barra.alta { background: var(--danger); }
.carga-dia { font-size: 10px; color: var(--text-muted); text-transform: capitalize; }
.carga-fecha { font-size: 11px; font-weight: 700; color: var(--texto-fuerte); }
.carga-col.hoy .carga-pista { outline: 2px solid var(--teal); outline-offset: 1px; }

/* Acceso directo a la agenda en Inicio */
.tarjeta-atajo {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; margin: 12px 0;
}
.tarjeta-atajo:active { transform: scale(.99); }
.atajo-icono { font-size: 24px; }
.atajo-texto { flex: 1; min-width: 0; }
.atajo-titulo { font-weight: 700; color: var(--texto-fuerte); font-size: 14px; }
.atajo-sub { font-size: 12px; color: var(--text-muted); }
.atajo-flecha { font-size: 22px; color: var(--text-muted); }

/* Barra de avance (meta mensual) */
.progreso-fila { display: flex; align-items: center; gap: 10px; }
.progreso-pista { flex: 1; height: 10px; background: var(--superficie-sutil); border-radius: 20px; overflow: hidden; }
.progreso-relleno { height: 100%; background: var(--teal); border-radius: 20px; transition: width .5s ease; }
.progreso-relleno.meta-cumplida { background: var(--success); }
.progreso-numero { font-size: 13px; font-weight: 800; color: var(--texto-fuerte); min-width: 38px; text-align: right; }
.urgente-fila { cursor: pointer; }

@media (max-width: 360px) {
  .carga-dias { gap: 2px; }
  .carga-dia { font-size: 9px; }
}

/* Indicador de carga global */
#cargando-global {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.35);
}
#cargando-global.visible { display: flex; }
#cargando-global .cargando-caja {
  background: var(--card-bg, #fff); color: var(--text, #1e293b);
  padding: 18px 26px; border-radius: 14px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
#cargando-global .spinner { margin: 0 auto 8px; }
#cargando-global .cargando-texto { font-size: 13px; font-weight: 600; }
.check-sin-inventario { display: flex; gap: 8px; align-items: center; font-size: 12.5px; margin-top: 8px; }

.modo-fundas { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.modo-fundas label { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--slate-light, #cbd5e1); border-radius: 10px; font-size: 13px; cursor: pointer; }
.modo-fundas label small { display: block; font-size: 11.5px; opacity: .75; font-weight: 400; }
.modo-fundas input { margin-top: 3px; }

.caja-fundas { padding: 12px; border: 1px solid var(--slate-light, #cbd5e1); border-radius: 12px; background: rgba(20,184,166,0.05); }
.caja-fundas select, .caja-fundas input { width: 100%; }
.caja-fundas .etiqueta-chica { display: block; font-size: 12.5px; margin: 10px 0 4px; font-weight: 600; }

.nota-prestamo { margin-top:6px; padding:6px 10px; border-radius:8px; font-size:12.5px; background: rgba(250,204,21,0.15); }

.chip-vendedora { display:inline-flex; align-items:center; gap:4px; padding:2px 9px; border-radius:999px; font-size:11.5px; font-weight:600; background: rgba(100,116,139,0.14); color: var(--text, #1e293b); }
.chip-vend-valeria { background: rgba(20,184,166,0.16); }
.chip-vend-maria { background: rgba(168,85,247,0.15); }
.chip-vend-freddy { background: rgba(59,130,246,0.15); }
.card-empresa { font-size: 12.5px; font-weight: 600; color: var(--teal, #0f9d8f); margin-top: 1px; }

/* =====================================================================
   Pagos, abonos y recibos
   ===================================================================== */
.pago-caja { background: var(--white); border: 1px solid var(--borde); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.pago-cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.pago-cifras span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.pago-cifras strong { font-size: 18px; color: var(--texto-fuerte); font-variant-numeric: tabular-nums; }
.pago-verde { color: var(--success) !important; }
.pago-rojo { color: var(--danger) !important; }
.pago-barra { height: 8px; border-radius: 99px; background: var(--superficie-sutil); margin-top: 12px; overflow: hidden; }
.pago-barra i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--success)); border-radius: 99px; transition: width .4s; }
.pago-pct { font-size: 12px; color: var(--text-muted); margin-top: 6px; text-align: center; }
.pago-ganancia { font-size: 12.5px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--borde); }
.pago-ganancia span { color: var(--text-muted); font-size: 11px; display: block; }
.abono-form { margin-top: 12px; padding: 12px; border: 1px dashed var(--slate-light); border-radius: 12px; background: var(--superficie-sutil); }
.abono-atajos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.abono-atajos button { border: 1px solid var(--teal); color: var(--teal-dark); background: transparent; border-radius: 99px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.abonos-lista { margin-top: 14px; border-top: 1px solid var(--borde); padding-top: 8px; }
.abonos-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.abono-fila { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--borde); font-size: 14px; }
.abono-fila:last-child { border-bottom: 0; }
.abono-fila.anulado { opacity: .5; text-decoration: line-through; }
.abono-info { min-width: 0; }

.recibo { background: var(--white); border: 1px solid var(--borde); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); text-align: center; }
.recibo-cab { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.recibo-marca { background: var(--navy); color: var(--blanco-fijo); font-weight: 800; padding: 3px 9px; border-radius: 6px; letter-spacing: .08em; }
.recibo-num { font-size: 12px; margin-top: 10px; letter-spacing: .08em; color: var(--text-muted); }
.recibo-monto { font-size: 38px; font-weight: 800; color: var(--teal-dark); font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 2px; }
.recibo-sub { font-size: 12.5px; color: var(--text-muted); }
.recibo-filas { margin-top: 14px; border-top: 1px dashed var(--slate-light); text-align: left; }
.recibo-filas > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--borde); font-size: 13.5px; }
.recibo-filas span { color: var(--text-muted); flex-shrink: 0; }
.recibo-filas b { text-align: right; }
.recibo-pend { font-size: 16px !important; }
.recibo-nota { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; text-align: left; }
.btn-link-peligro { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--danger); font-size: 12.5px; text-decoration: underline; cursor: pointer; }

/* Estado de producción compacto */
.card-etapa { padding: 12px 14px; }
.etapa-compacta { margin-bottom: 10px; }
.etapa-barras { display: flex; gap: 4px; }
.etapa-barras i { flex: 1; height: 6px; border-radius: 99px; background: var(--superficie-sutil); }
.etapa-barras i.hecha { background: var(--teal); }
.etapa-barras i.actual { background: var(--navy-soft); box-shadow: 0 0 0 2px rgba(20,184,166,.35); }
.etapa-linea { margin-top: 8px; }
.etapa-actual { font-weight: 700; font-size: 15px; color: var(--texto-fuerte); }
.etapa-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.etapa-fin { text-align: center; font-weight: 600; color: var(--success); }

/* Formulario de pedido: origen, dueño y selector visual de fundas */
.origen-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.origen-op, .dueno-op { border: 1.5px solid var(--slate-light); background: var(--white); color: var(--text); border-radius: 12px; padding: 8px 6px; cursor: pointer; text-align: center; font: inherit; display: flex; flex-direction: column; gap: 2px; align-items: center; transition: border-color .15s, background .15s; }
.origen-op b { font-size: 12.5px; }
.origen-op small, .dueno-op small { font-size: 10.5px; color: var(--text-muted); }
.origen-op.activo, .dueno-op.activo { border-color: var(--teal); background: rgba(20,184,166,.12); box-shadow: 0 0 0 1px var(--teal) inset; }
.dueno-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dueno-op span { font-weight: 700; font-size: 14px; }
.funda-buscar { margin-bottom: 8px; }
.funda-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.funda-op { text-align: left; border: 1.5px solid var(--borde); border-left-width: 5px; background: var(--white); color: var(--text); border-radius: 12px; padding: 9px 10px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.funda-op.nivel-ok { border-left-color: var(--success); }
.funda-op.nivel-prestamo { border-left-color: var(--warning); }
.funda-op.nivel-bajo { border-left-color: var(--danger); }
.funda-op.activo { border-color: var(--teal); border-left-color: var(--teal); background: rgba(20,184,166,.14); box-shadow: 0 0 0 1px var(--teal) inset; }
.funda-op-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.funda-op-nombre { font-weight: 700; font-size: 13px; line-height: 1.2; overflow-wrap: anywhere; }
.funda-op-meta { font-size: 11px; color: var(--text-muted); }
.funda-op-stock { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.funda-op-stock em { font-style: normal; font-weight: 500; color: var(--text-muted); }
.fila-cant-inv { display: flex; gap: 8px; align-items: center; }
.fila-cant-inv input { flex: 1; }
.fila-cant-inv .btn { white-space: nowrap; width: auto; }
.mas-opciones { margin: 4px 0 14px; border: 1px solid var(--borde); border-radius: 12px; padding: 4px 12px; }
.mas-opciones summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 13.5px; color: var(--text-muted); }
.mas-opciones[open] summary { margin-bottom: 4px; }
#p-material-otro, #p-estilo-otro, #p-prod-otro { margin-top: 6px; }

/* Cupón de premio (vista previa dentro de la app) */
.cupon-vista { border-radius: 16px; padding: 16px; text-align: center; color: #fbf6e9; margin-bottom: 14px;
  background: linear-gradient(160deg, #0f3a52, #0a1f33 55%, #07182a); box-shadow: 0 0 0 1px rgba(217,180,74,.6), var(--shadow); }
.cupon-vista-cab { font-size: 10px; letter-spacing: .3em; font-weight: 800; color: #f6e3a1; }
.cupon-vista-para { margin-top: 8px; font-size: 13px; color: #d3e0ea; }
.cupon-vista-para b { color: #fff; }
.cupon-vista-premio { margin: 8px 0; font-size: 24px; font-weight: 800; line-height: 1.15; color: #f6e3a1; text-wrap: balance; }
.cupon-vista-pie { font-size: 11.5px; color: #9fb3c4; border-top: 1px dashed rgba(246,227,161,.4); padding-top: 8px; }
.cupon-vista-pie b { color: #fff; }
.premios-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-premio { border: 1.5px solid var(--slate-light); background: var(--white); color: var(--text); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip-premio.activo { border-color: var(--teal); background: rgba(20,184,166,.14); }

/* Aviso de versión nueva */
.aviso-actualizacion { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 9999; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--navy); color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.3); font-size: 13.5px; font-weight: 600; }
.aviso-actualizacion button { background: var(--teal); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 13px; }
.aviso-aprobado { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #dcfce7; color: #166534; font-size: 13px; font-weight: 600; }
.hilo-revisiones { margin-top: 10px; font-size: 13px; }
.hilo-revisiones summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.rev-fila { padding: 7px 10px; border-radius: 8px; margin-top: 5px; }
.rev-cli { background: #fff7ed; color: #7c2d12; }
.rev-eq { background: #f0fdfa; color: #115e59; }

/* Cotizaciones: disponibilidad de inventario */
.aviso-disp { margin: -4px 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; line-height: 1.35; }
.aviso-disp-ok { background: #dcfce7; color: #166534; }
.aviso-disp-prestamo { background: #fef3c7; color: #92400e; }
.aviso-disp-bajo { background: #fee2e2; color: #991b1b; }
.caja-precio-sugerido { background: #f0fdfa; border: 1.5px solid #99f6e4; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.cps-titulo { font-weight: 800; font-size: 13px; color: #0f766e; margin-bottom: 8px; }
.cps-grande { font-size: 26px; font-weight: 800; color: var(--navy); }
.cps-grande small { font-size: 13px; font-weight: 600; color: var(--muted, #64748b); }
.check-linea { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }

/* Ficha ordenada del pedido */
.ficha-estado{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0 10px;}
.ficha-estado:empty{display:none;}
.ficha-grid{display:grid;grid-template-columns:1fr 1fr;gap:1px;background:var(--borde,#e5e9ee);border:1px solid var(--borde,#e5e9ee);border-radius:12px;overflow:hidden;margin-bottom:12px;}
.ficha-dato{background:var(--card-bg,#fff);padding:9px 12px;display:flex;flex-direction:column;gap:2px;min-width:0;}
.ficha-dato span{font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:#6b7785;}
.ficha-dato strong{font-size:14px;font-weight:600;overflow-wrap:anywhere;}
.ficha-ancho{grid-column:1 / -1;}

/* Visor de fotos */
img[data-zoom]{cursor:zoom-in;}
#visor-img{position:fixed;inset:0;z-index:99999;background:rgba(5,10,20,.96);display:flex;align-items:center;justify-content:center;overflow:hidden;touch-action:none;}
#visor-img img{max-width:100vw;max-height:100vh;width:auto;height:auto;object-fit:contain;touch-action:none;user-select:none;-webkit-user-select:none;transition:none;}
#visor-img .visor-cerrar{position:absolute;top:max(12px,env(safe-area-inset-top));right:12px;z-index:2;width:44px;height:44px;border-radius:50%;border:0;background:rgba(255,255,255,.18);color:#fff;font-size:20px;cursor:pointer;}
#visor-img .visor-ayuda{position:absolute;bottom:max(14px,env(safe-area-inset-bottom));left:0;right:0;text-align:center;color:rgba(255,255,255,.65);font-size:12px;pointer-events:none;}

/* Cliente en su link */
.chip-ok{display:inline-flex;align-items:center;gap:4px;padding:3px 10px;border-radius:999px;background:#dcfce7;color:#15803d;font-size:12px;font-weight:700;}
.chip-nuevo{display:inline-block;margin-left:6px;padding:2px 8px;border-radius:999px;background:#ef4444;color:#fff;font-size:11px;font-weight:800;vertical-align:middle;}
.cli-subtitulo{font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.05em;color:#64748b;margin-bottom:6px;}
.cli-chat{display:flex;flex-direction:column;gap:6px;max-height:260px;overflow-y:auto;padding:2px 0;}
.cli-burbuja{max-width:88%;padding:8px 12px;border-radius:14px;font-size:13.5px;line-height:1.4;white-space:pre-wrap;word-break:break-word;}
.cli-burbuja small{display:block;font-size:10.5px;opacity:.7;margin-top:3px;}
.cli-b-cli{align-self:flex-start;background:#fff7ed;color:#7c2d12;border-bottom-left-radius:4px;}
.cli-b-eq{align-self:flex-end;background:#14b8a6;color:#fff;border-bottom-right-radius:4px;}
.cli-entrega{font-size:13.5px;line-height:1.5;background:#f0fdfa;border-radius:10px;padding:10px 12px;}
.cli-comp{display:flex;gap:10px;align-items:flex-start;padding:8px 0;border-bottom:1px solid #eef2f5;}
.cli-comp:last-child{border-bottom:none;}
.cli-comp img{width:64px;height:64px;object-fit:cover;border-radius:10px;border:1px solid #e5e9ee;flex-shrink:0;}
.chip-comp{margin-left:6px;font-size:11px;font-weight:700;padding:2px 8px;border-radius:999px;}
.chip-comp-pendiente{background:#fef3c7;color:#92400e;}.chip-comp-aprobado{background:#dcfce7;color:#15803d;}.chip-comp-rechazado{background:#fee2e2;color:#b91c1c;}

/* Flecha atrás */
.topbar-izq { display: flex; align-items: center; gap: 8px; min-width: 0; }
#btn-atras { font-size: 22px; font-weight: 700; min-width: 40px; }
#btn-atras.oculto { display: none; }
.modal-atras {
  background: var(--bg); border: none; width: 36px; height: 36px; border-radius: 50%;
  font-size: 20px; font-weight: 700; color: var(--texto-fuerte); margin-right: 10px; flex: none;
}
.modal-titulo .modal-atras + h3 { flex: 1; }
#cargando-global { pointer-events: all; }

/* =====================================================================
   EXPERIENCIA: movimiento y detalles
   ===================================================================== */
button, .btn, .nav-item, .tab-chip, .topbar-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.onda {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .18; transform: scale(0);
  animation: onda .55s ease-out forwards;
}
@keyframes onda { to { transform: scale(1); opacity: 0; } }

/* Cambio de pantalla */
#vista-raiz.entra-der { animation: entraDer .28s cubic-bezier(.2,.8,.2,1) both; }
#vista-raiz.entra-izq { animation: entraIzq .28s cubic-bezier(.2,.8,.2,1) both; }
@keyframes entraDer { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes entraIzq { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }

/* Las tarjetas entran una tras otra */
#vista-raiz.stagger .card-pedido, #vista-raiz.stagger .card-cliente, #vista-raiz.stagger .insight-card,
#vista-raiz.stagger .kpi-card, #vista-raiz.stagger .card { animation: aparecer .38s cubic-bezier(.2,.8,.2,1) both; }
#vista-raiz.stagger > :nth-child(2) { animation-delay: .04s; }
#vista-raiz.stagger > :nth-child(3) { animation-delay: .08s; }
#vista-raiz.stagger > :nth-child(4) { animation-delay: .12s; }
#vista-raiz.stagger > :nth-child(5) { animation-delay: .16s; }
#vista-raiz.stagger .kpi-card:nth-child(2) { animation-delay: .05s; }
#vista-raiz.stagger .kpi-card:nth-child(3) { animation-delay: .10s; }
#vista-raiz.stagger .kpi-card:nth-child(4) { animation-delay: .15s; }
#vista-raiz.stagger .kpi-card:nth-child(5) { animation-delay: .20s; }
#vista-raiz.stagger .card-pedido:nth-child(n+2), #vista-raiz.stagger .card-cliente:nth-child(n+2) { animation-delay: .05s; }
#vista-raiz.stagger .card-pedido:nth-child(n+4), #vista-raiz.stagger .card-cliente:nth-child(n+4) { animation-delay: .12s; }
#vista-raiz.stagger .card-pedido:nth-child(n+7), #vista-raiz.stagger .card-cliente:nth-child(n+7) { animation-delay: .2s; }

/* Pestaña inferior: el icono rebota al elegirla */
.nav-item.rebota .icono { animation: rebota .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes rebota { 0% { transform: scale(.7); } 60% { transform: scale(1.25) translateY(-3px); } 100% { transform: scale(1); } }
.nav-item.activo .icono { transform: translateY(-1px); }

/* Ventanas: fondo que se desvanece, hoja con rebote suave */
.modal-fondo { animation: velo .2s ease-out both; }
@keyframes velo { from { opacity: 0; } to { opacity: 1; } }
.modal-hoja { animation: subir2 .32s cubic-bezier(.2,.9,.3,1.1) both; }
@keyframes subir2 { from { transform: translateY(46px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-titulo { cursor: grab; }
.modal-titulo::before {
  content: ''; position: absolute; left: 50%; top: 8px; width: 38px; height: 4px; margin-left: -19px;
  border-radius: 4px; background: var(--slate-light, #cbd5e1); opacity: .7;
}
.modal-hoja { position: relative; padding-top: 28px; }

/* Avisos (toasts) que entran con resorte */
.toast { animation: toastIn .35s cubic-bezier(.2,1.2,.4,1) both; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 18px) scale(.94); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* Cargando: la caja aparece con suavidad */
#cargando-global.visible .cargando-caja { animation: cajaIn .22s cubic-bezier(.2,1.2,.4,1) both; }
@keyframes cajaIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

/* Presionar: se hunde un poco */
.btn:active, button:active { transition: transform .08s ease; }
.btn-primario:active, .btn-whatsapp:active { transform: scale(.96); }
.card-pedido, .card-cliente { transition: transform .15s ease, box-shadow .15s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}

.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { body.sub-vista .reloj-vivo { display: none; } }

/* =====================================================================
   INICIO COMPACTO
   ===================================================================== */
.saludo-compacto { margin-bottom: 10px; }
.saludo-compacto .titulo-saludo { font-size: 19px; }
.saludo-compacto .sub-saludo { font-size: 12px; margin-top: 2px; }
.inicio-seccion-titulo { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--text-muted); margin: 16px 2px 8px; }

.inicio-urgente { background: var(--white); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; border-left: 4px solid var(--danger, #dc2626); }
.inicio-urgente-cab { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px 6px; font-weight: 800; font-size: 13px; color: var(--texto-fuerte); }
.enlace-mini { background: none; border: none; color: var(--teal-dark); font-weight: 700; font-size: 12px; padding: 4px 0; }
.urgente-fila { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--borde, rgba(0,0,0,.06)); cursor: pointer; }
.urgente-fila:active { background: var(--bg); }
.urgente-ico { font-size: 18px; flex: none; }
.urgente-txt { flex: 1; min-width: 0; }
.urgente-txt .nombre { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urgente-txt .detalle { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-rojo { background: #fee2e2; color: #b91c1c; }
.inicio-todo-bien { display: flex; gap: 12px; align-items: center; background: var(--white); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); border-left: 4px solid #16a34a; }
.inicio-todo-bien > span { font-size: 22px; }

.fichas-fila { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.fichas-fila::-webkit-scrollbar { display: none; }
.ficha-etapa, .ficha-rapida {
  flex: 1 0 auto; scroll-snap-align: start; border: none; background: var(--white); color: var(--texto-fuerte);
  border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; min-width: 92px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
}
.ficha-etapa { border-top: 4px solid var(--teal); }
.ficha-etapa.etapa-diseno_grafico { border-top-color: #8b5cf6; }
.ficha-etapa.etapa-revelado_emulsionado { border-top-color: #3b82f6; }
.ficha-etapa.etapa-impresion_secado { border-top-color: #f59e0b; }
.ficha-etapa.etapa-listo_entrega { border-top-color: #16a34a; }
.fe-ico, .fr-ico { font-size: 16px; }
.fe-num, .fr-num { font-size: 24px; font-weight: 800; line-height: 1.05; }
.fr-num { font-size: 20px; }
.fr-num small { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.fe-nom, .fr-nom { font-size: 11px; font-weight: 700; color: var(--text-muted); line-height: 1.2; }
.ficha-rapida.fr-alerta { background: #fef2f2; } .ficha-rapida.fr-alerta .fr-num { color: var(--danger, #dc2626); }
.ficha-etapa:active, .ficha-rapida:active { transform: scale(.96); }
.fichas-rapidas .ficha-rapida { min-width: 98px; }

.acciones-rapidas { display: flex; gap: 8px; margin: 10px 0 4px; }
.acciones-rapidas .btn { flex: 1; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.resumen-mes { text-align: center; font-size: 12px; color: var(--text-muted); font-weight: 600; margin: 14px 0 4px; }

.filtro-activo { display: flex; justify-content: space-between; align-items: center; background: #ecfeff; color: var(--teal-dark); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; font-weight: 700; font-size: 13px; }
.filtro-activo button { border: none; background: none; color: var(--teal-dark); font-weight: 800; }

/* Campana */
#btn-alertas { position: relative; }
.campana-badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 2px solid var(--navy); line-height: 1; }
.campana-badge.oculto { display: none; }
#btn-alertas.campana-activa { animation: campana 2.4s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes campana { 0%,86%,100% { transform: rotate(0); } 89% { transform: rotate(14deg); } 92% { transform: rotate(-12deg); } 95% { transform: rotate(8deg); } 98% { transform: rotate(-4deg); } }
@media (max-width: 520px) { #btn-refrescar { display: none; } .reloj-vivo { display: none; } }
.urgente-fila .pill-dias { flex: none; font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px; background: #fef3c7; color: #92400e; white-space: nowrap; }
.urgente-fila .pill-dias.pill-rojo { background: #fee2e2; color: #b91c1c; }
.fichas-embudo { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; gap: 8px; }
.fichas-embudo .ficha-etapa { min-width: 0; padding: 9px 8px; }
.fichas-embudo .fe-nom { font-size: 10.5px; }
@media (min-width: 700px) { .fichas-embudo { grid-template-columns: repeat(4, minmax(120px, 1fr)); } }

/* ===== Equipo: tablón de avisos, orden de trabajo, cuenta con el taller ===== */
.accion-archivar { background: linear-gradient(160deg, #f59e0b, #b45309); }
.tablon { background: var(--white); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; margin-bottom: 12px; border-left: 4px solid var(--teal); }
.tablon.tablon-alerta { border-left-color: var(--danger); animation: tablon-pulso 2.4s ease-in-out infinite; }
@keyframes tablon-pulso { 0%,100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 3px rgba(220,38,38,.18), var(--shadow); } }
.tablon-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tablon-titulo { font-weight: 800; font-size: 14px; color: var(--text); }
.tablon-botones { display: flex; align-items: center; gap: 10px; }
.aviso-tablon { background: var(--superficie-sutil); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--borde); transition: transform .3s ease, opacity .3s ease, background .3s ease; }
.aviso-tablon.urgente { border-color: #fca5a5; background: rgba(220,38,38,.07); }
.aviso-tablon.pendiente { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(20,184,166,.18); }
.aviso-tablon.completo { background: rgba(22,163,74,.10); border-color: rgba(22,163,74,.45); }
.aviso-tablon.aviso-recibido { transform: scale(.97); opacity: .6; }
.aviso-cab { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.aviso-texto { font-size: 14px; color: var(--text); line-height: 1.35; word-break: break-word; }
.aviso-vistos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.visto-chip { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--white); border: 1px solid var(--borde); color: var(--text-muted); }
.visto-chip.ok { background: rgba(22,163,74,.12); border-color: rgba(22,163,74,.4); color: #15803d; }
.aviso-acc { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-enterado { animation: enterado-latido 1.8s ease-in-out infinite; }
@keyframes enterado-latido { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.btn-icono-mini { border: none; background: transparent; font-size: 16px; padding: 4px 6px; cursor: pointer; margin-left: auto; opacity: .75; }
.btn-icono-mini + .btn-icono-mini { margin-left: 0; }
.pill-ok { background: rgba(22,163,74,.15); color: #15803d; }
.ot-pendientes { margin-bottom: 12px; }
.bloque-dinero { background: var(--superficie-sutil); border-radius: 12px; padding: 10px 12px 4px; margin: 8px 0 12px; }
.taller-caja { border-left: 4px solid var(--teal); }
.equipo-lista { margin-top: 12px; border-top: 1px solid var(--borde); padding-top: 8px; }
.equipo-fila { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 4px 0; }
@media (prefers-reduced-motion: reduce) { .tablon.tablon-alerta, .btn-enterado { animation: none; } }
.tablon .pill-dias, .aviso-cab .pill-dias { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tablon .pill-rojo { background: #fee2e2; color: #b91c1c; }
.tablon-botones .btn, #tb-nuevo { white-space: nowrap; }

.tablon.tablon-alerta { background: #fee2e2; border-left-color: #b91c1c; border: 2px solid #dc2626; }
:root[data-theme="dark"] .tablon.tablon-alerta { background: #3b1317; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tablon.tablon-alerta { background: #3b1317; } }
.aviso-tablon.pendiente { background: rgba(220,38,38,.12); border: 2px solid #dc2626; box-shadow: none; }
.visto-chip.rojo { background: rgba(220,38,38,.12); border-color: #dc2626; color: #b91c1c; }
.visto-chip.medio { background: rgba(217,119,6,.13); border-color: #d97706; color: #b45309; }

.chip-vend-cesar { background: rgba(245,158,11,0.18); }
.chip-vend-rene { background: rgba(236,72,153,0.15); }
.chip-taller { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(20,184,166,.14); color: var(--teal-dark); }
.chip-taller.rojo { background: rgba(220,38,38,.14); color: #b91c1c; }
.chip-taller.verde { background: rgba(22,163,74,.14); color: #15803d; }
body.alerta-roja .topbar { background: linear-gradient(90deg, #7f1d1d, #b91c1c); animation: topbar-rojo 2s ease-in-out infinite; }
@keyframes topbar-rojo { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
@media (prefers-reduced-motion: reduce) { body.alerta-roja .topbar { animation: none; } }

/* Muestra del color de tinta (rombo) */
.punto-tinta{display:inline-block;width:15px;height:15px;border-radius:3px;transform:rotate(45deg) scale(.85);margin-right:9px;vertical-align:-1px;border:1px solid rgba(0,0,0,.3);}

.pago-envio-desglose { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; text-align: center; background: #f1f5f9; border-radius: 8px; padding: 6px 8px; }
