/* ═══════════════════════════════════════════════════════════════
   MyFlavorSupply ERP — Design System v5.0
   Estilo: Clean professional, sidebar verde, cards coloridas
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700;800;900&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --brand:        #1a4d2e;
  --brand-mid:    #2d7a4f;
  --brand-light:  #e8f5ee;
  --brand-dim:    rgba(26,77,46,.08);
  --brand-border: rgba(26,77,46,.2);
  --orange:       #f97316;
  --orange-dark:  #ea6800;
  --orange-dim:   rgba(249,115,22,.1);

  --bg:        #f4f6f8;
  --surface:   #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f0f2f5;
  --border:    #e5e7eb;
  --border-2:  #d1d5db;

  --text:   #111827;
  --text-2: #374151;
  --text-3: #9ca3af;

  --warn-dark:    #92400e;
    --ok:      #16a34a;
  --ok-dim:  rgba(22,163,74,.1);
  --warn:    #d97706;
  --warn-dim:rgba(217,119,6,.1);
  --err:     #dc2626;
  --err-dim: rgba(220,38,38,.1);
  --info:    #2563eb;
  --info-dim:rgba(37,99,235,.1);

  --sb-w:           240px;
  --sb-w-collapsed: 60px;
  --topbar-h:       58px;
  --radius:         8px;
  --radius-lg:      12px;
  --radius-xl:      18px;

  --font:      'Figtree', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --t: .15s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ────────────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100vh; }
.screen.active { display: flex; }

/* ── LOADING ────────────────────────────────────────────────── */
#screen-loading {
  align-items: center; justify-content: center;
  background: var(--bg);
  flex-direction: column;
}
.loading-wrap { text-align: center; width: 280px; }
.loading-logo {
  width: 72px; height: 72px;
  background: var(--brand);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin: 0 auto 28px;
  box-shadow: 0 8px 32px rgba(26,77,46,.3);
  animation: loading-pulse 2s ease-in-out infinite;
}
@keyframes loading-pulse { 0%,100%{transform:scale(1);box-shadow:0 8px 32px rgba(26,77,46,.3)} 50%{transform:scale(.96);box-shadow:0 4px 16px rgba(26,77,46,.2)} }
.loading-bar-track { height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.loading-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--brand), var(--brand-mid)); border-radius: 99px; transition: width .4s ease; }
.loading-text { font-size: 13px; color: var(--text-3); font-weight: 500; }

/* ── LOGIN ──────────────────────────────────────────────────── */
#screen-login {
  align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 20% 100%, rgba(26,77,46,.06), transparent),
    radial-gradient(ellipse 50% 40% at 80% 0%, rgba(249,115,22,.04), transparent);
}
.login-wrap { width: 100%; max-width: 420px; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; align-items: center; gap: 13px; margin-bottom: 32px; }
.login-logo-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  background: var(--brand);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 14px rgba(26,77,46,.3);
}
.login-company { font-size: 17px; font-weight: 900; color: var(--brand); letter-spacing: -.3px; }
.login-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.login-title { font-size: 24px; font-weight: 900; margin-bottom: 28px; color: var(--text); letter-spacing: -.4px; }
.login-err {
  background: var(--err-dim);
  border: 1.5px solid rgba(220,38,38,.2);
  border-radius: var(--radius);
  padding: 11px 14px; font-size: 13px; color: var(--err);
  margin-bottom: 18px; font-weight: 500;
}
.login-ver { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 22px; }

/* ── APP LAYOUT ─────────────────────────────────────────────── */
#screen-app { flex-direction: row; overflow: hidden; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w);
  height: 100vh;
  background: var(--brand);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden;
  transition: width var(--t);
  position: relative;
}
.sidebar.collapsed { width: var(--sb-w-collapsed); }

.sb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
  min-height: var(--topbar-h);
}
.sb-logo { display: flex; align-items: center; gap: 10px; overflow: hidden; min-width: 0; }
.sb-logo-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: rgba(255,255,255,.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: background var(--t);
}
.sb-logo-icon:hover { background: rgba(255,255,255,.3); }
.sb-logo-text {
  font-size: 15px; font-weight: 900; color: #fff;
  white-space: nowrap; overflow: hidden;
  letter-spacing: -.3px;
  transition: opacity var(--t), width var(--t);
}
.sidebar.collapsed .sb-logo-text { opacity: 0; width: 0; }

.sb-toggle {
  background: rgba(255,255,255,.1); border: none; cursor: pointer;
  color: #fff; padding: 6px; border-radius: 8px;
  flex-shrink: 0;
  transition: background var(--t);
  display: flex; align-items: center; justify-content: center;
}
.sb-toggle:hover { background: rgba(255,255,255,.2); }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 8px; }
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.88); border-radius: 99px; }

.sb-group-label {
  font-size: 9px; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(255,255,255,.80);
  padding: 14px 10px 5px;
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--t);
}
.sidebar.collapsed .sb-group-label { opacity: 0; pointer-events: none; }

.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; cursor: pointer; border: none;
  background: transparent; width: 100%; text-align: left;
  color: rgba(255,255,255,.92); font-size: 13px; font-weight: 600;
  font-family: var(--font); border-radius: 10px;
  transition: all var(--t);
  white-space: nowrap; overflow: hidden;
  margin-bottom: 2px;
}
.sb-item:hover { color: #fff; background: rgba(255,255,255,.12); }
.sb-item.active {
  color: #fff; background: rgba(255,255,255,.88);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--orange);
}
.sb-item-icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  padding: 4px;
  background: #f1f1f1;
  color: #6b6459;
  opacity: .85;
  transition: background-color .15s, color .15s, opacity .15s;
}
.sb-item-icon svg { width: 16px; height: 16px; display: block; }
.sb-item.active .sb-item-icon { opacity: 1; }

/* ── ICONS POR CATEGORÍA — v86.7 ──────────────────────────────
   Cada icono del sidebar tiene un fondo de color según la categoría
   del módulo. data-group viene de buildSidebar() en js/core/modules.js. */
.sb-item[data-group="principal"]      .sb-item-icon { background: #DBEAFE; color: #1E40AF; }
.sb-item[data-group="ventas"]         .sb-item-icon { background: #DCFCE7; color: #166534; }
.sb-item[data-group="operaciones"]    .sb-item-icon { background: #FEF3C7; color: #92400E; }
.sb-item[data-group="compras"]        .sb-item-icon { background: #EDE9FE; color: #5B21B6; }
.sb-item[data-group="finanzas"]       .sb-item-icon { background: #CCFBF1; color: #115E59; }
.sb-item[data-group="administracion"] .sb-item-icon { background: #FCE7F3; color: #9F1239; }
.sb-item[data-group="sistema"]        .sb-item-icon { background: #E0E7FF; color: #3730A3; }

/* Estado activo — colores más saturados para destacar */
.sb-item.active[data-group="principal"]      .sb-item-icon { background: #93C5FD; color: #1E3A8A; }
.sb-item.active[data-group="ventas"]         .sb-item-icon { background: #86EFAC; color: #14532D; }
.sb-item.active[data-group="operaciones"]    .sb-item-icon { background: #FCD34D; color: #78350F; }
.sb-item.active[data-group="compras"]        .sb-item-icon { background: #C4B5FD; color: #4C1D95; }
.sb-item.active[data-group="finanzas"]       .sb-item-icon { background: #5EEAD4; color: #134E4A; }
.sb-item.active[data-group="administracion"] .sb-item-icon { background: #F9A8D4; color: #831843; }
.sb-item.active[data-group="sistema"]        .sb-item-icon { background: #A5B4FC; color: #312E81; }

.sb-item-label { transition: opacity var(--t); }
.sidebar.collapsed .sb-item-label { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sb-item { justify-content: center; padding: 10px; }

.sb-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.88);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.sb-user { display: flex; align-items: center; gap: 9px; flex: 1; overflow: hidden; min-width: 0; }
.sb-user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #fff;
  border: 2px solid rgba(255,255,255,.88);
}
.sb-user-info { overflow: hidden; min-width: 0; }
.sb-user-name {
  font-size: 12px; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-role { font-size: 10px; color: rgba(255,255,255,.90); white-space: nowrap; }
.sidebar.collapsed .sb-user-info { display: none; }

.sb-logout {
  background: rgba(255,255,255,.88); border: none; cursor: pointer;
  color: #fff; padding: 7px; border-radius: 8px; flex-shrink: 0;
  transition: background var(--t); display: flex;
}
.sb-logout:hover { background: rgba(255,255,255,.88); }
.sidebar.collapsed .sb-logout { display: none; }

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: relative; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-menu {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 6px; border-radius: 8px;
  transition: all var(--t); display: flex;
}
.topbar-menu:hover { color: var(--text); background: var(--surface-3); }
.topbar-breadcrumb { font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }

/* ── TOPBAR RIGHT — v80.1 unificado ───────────────────────────
   Todos los hijos directos comparten la misma altura (32px) y
   se alinean al centro vertical. Esto evita que cada inyector
   (ui.js, sync.js, i18n, tenant.js) meta elementos de tamaños
   diferentes que terminan desalineados.
*/
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-right > * {
  display: inline-flex;
  align-items: center;
  height: 32px;
  flex-shrink: 0;
}
/* Contenedores vacíos no ocupan espacio */
.topbar-right > *:empty { display: none; }
/* Botones de navegación (Tienda, etc.) */
.topbar-nav-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t);
  line-height: 1;
}
.topbar-nav-btn:hover {
  background: var(--brand-light);
  border-color: var(--brand-border);
  color: var(--brand);
}
.topbar-nav-btn svg { flex-shrink: 0; display: block; }
.topbar-nav-btn span { display: inline-block; }

/* Botón de alertas (campana) */
.topbar-alert-btn {
  height: 32px;
  width: 32px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Selector de idioma (banderas) */
#topbar-lang-selector {
  height: 32px;
}
#topbar-lang-selector > * {
  height: 32px;
  display: inline-flex;
  align-items: center;
}
/* Forzar contenedor visible sobre fondo blanco (el JS pone styles inline
   pensados para fondo oscuro — los pisamos con !important) */
#topbar-lang-selector .mfs-lang-selector {
  background: var(--surface-3, #f3f4f6) !important;
  border: 1px solid var(--border, #e5e7eb) !important;
  height: 32px;
  padding: 2px !important;
  align-items: center;
}
#topbar-lang-selector .mfs-lang-selector button {
  font-size: 16px !important;
  padding: 0 6px !important;
  height: 26px !important;
  line-height: 1 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#topbar-lang-selector .mfs-lang-selector button[style*="background: rgba(255, 255, 255, 0.25)"] {
  background: var(--surface, #fff) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08) !important;
  opacity: 1 !important;
}

/* Plan badge (PRO, etc.) */
.topbar-plan {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.2px;
  padding: 0 11px;
  height: 24px;
  border-radius: 99px;
  background: var(--brand-light);
  color: var(--brand);
  border: 1.5px solid var(--brand-border);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.topbar-time {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  height: 32px;
}

/* Inbox badge (📬 buzón del equipo) — wrapper relativo para el dropdown */
#inbox-badge {
  position: relative;
  height: 32px;
  display: inline-flex;
  align-items: center;
}
.inbox-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #0ea5e9;
  color: #fff;
  border-radius: 99px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  text-align: center;
  line-height: 14px;
  border: 2px solid var(--surface, #fff);
}
.inbox-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.15);
  min-width: 340px;
  max-width: 400px;
  max-height: 480px;
  z-index: 9999;
  overflow: hidden;
  flex-direction: column;
}

/* Sync status (🟢 Sincronizado) */
#sync-status {
  font-size: 11px;
  font-weight: 600;
  height: 32px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* ── MODULE AREA ────────────────────────────────────────────── */
.module-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 24px 28px;
  background: var(--bg);
}
.module-area::-webkit-scrollbar { width: 5px; }
.module-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── MODULE HEADER ──────────────────────────────────────────── */
.mod-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px; gap: 16px;
}
.mod-title {
  font-size: 24px; font-weight: 900; color: var(--text);
  letter-spacing: -.5px; line-height: 1.1;
}
.mod-subtitle { font-size: 12px; color: var(--text-3); margin-top: 4px; font-weight: 500; }
.mod-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--t);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-mid));
  opacity: 0; transition: opacity var(--t);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--brand-border); }
.stat-card:hover::before { opacity: 1; }
.stat-card-n {
  font-size: 28px; font-weight: 900; line-height: 1;
  letter-spacing: -.5px; color: var(--text); margin-bottom: 6px;
}
.stat-card-l { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface);
}
.card-title { font-size: 13px; font-weight: 800; color: var(--text); letter-spacing: -.2px; }
.card-body { padding: 20px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ── TABLE ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 16px; text-align: left;
  font-size: 10px; font-weight: 800;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .8px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2);
}
td {
  padding: 12px 16px; font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
td.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── FORMS ──────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; letter-spacing: .1px; }
.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius);
  padding: 9px 12px; font-size: 13px; color: var(--text);
  font-family: var(--font); outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,77,46,.08);
}
.input::placeholder { color: var(--text-3); }
.select { cursor: pointer; }
.textarea { resize: vertical; min-height: 80px; }

/* ── BUTTONS — v86.12 ────────────────────────────────────────────
   Forma pill (radius 999px) y texto bold (700) para TODOS los botones.
   Cada variante mantiene su color por función:
     - primary: verde de marca (#16A344) — acciones principales
     - secondary: blanco con borde — acciones neutras
     - danger: rojo — acciones destructivas (borrar, cancelar)
     - ghost: transparente — acciones terciarias
     - orange: naranja — alertas/destacados
     - success: verde (sinónimo de primary)
     - warning: ámbar — advertencias */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 20px; border-radius: 999px !important;
  font-size: 13px; font-weight: 700 !important; font-family: var(--font);
  cursor: pointer; border: none; transition: all var(--t);
  white-space: nowrap; text-decoration: none;
  letter-spacing: -.1px; line-height: 1;
}
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: #16A344; color: #fff;
  box-shadow: 0 1px 3px rgba(22,163,68,.25);
}
.btn-primary:hover:not(:disabled) {
  background: #149436; transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22,163,68,.3);
}
.btn-secondary {
  background: var(--surface); border: 1.5px solid var(--border-2); color: var(--text-2);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #16A344; color: #16A344; }

.btn-danger { background: #dc2626; color: #fff; box-shadow: 0 1px 3px rgba(220,38,38,.25); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220,38,38,.3); }

.btn-ghost { background: none; color: var(--text-3); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-orange { background: var(--orange); color: #fff; box-shadow: 0 1px 3px rgba(249,115,22,.25); }
.btn-orange:hover:not(:disabled) { background: var(--orange-dark); transform: translateY(-1px); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; border-radius: 50%; }

/* ── v86.13: pill universal + tipografía Figtree para TODOS los <button> ──
   Cubre los ~87 botones que se renderizan inline en JS sin clase .btn
   (módulos antiguos como nomina, integraciones, contabilidad-bookkeeping).
   Solo afecta botones DENTRO del área de módulos y modales — no toca
   botones del browser, sidebar, header. */
#module-area button:not(.no-pill):not(.sb-item):not(.quick-card),
.modal-body button:not(.no-pill):not(.sb-item):not(.quick-card),
.modal button:not(.no-pill):not(.sb-item):not(.quick-card) {
  border-radius: 999px !important;
  font-weight: 700 !important;
  font-family: var(--font) !important;
  font-size: 13px;
  letter-spacing: -.1px;
}
/* Garantizar tamaño mínimo cuando es pill — evita que queden achatados */
#module-area button[style*="border-radius"]:not(.sb-item):not(.quick-card),
.modal-body button[style*="border-radius"]:not(.sb-item):not(.quick-card) {
  padding-left: 16px !important;
  padding-right: 16px !important;
}

/* ── PILL FILTERS — v86.7 ───────────────────────────────────────
   Pills de filtro consistentes en todo el ERP.
   Uso: <button class="pill-filter">Todos (12)</button>
        <button class="pill-filter active">Pendientes (3)</button>
   El estado activo usa verde marca (#16A344) en lugar de negro. */
.pill-filter {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-2, #e5ddc9);
  background: #ffffff;
  color: #5c6655;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pill-filter:hover:not(.active):not(:disabled) {
  background: var(--brand-light, #e8f5ee);
  border-color: var(--brand, #1a4d2e);
}
.pill-filter.active {
  background: #16A344;
  border-color: #16A344;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(22,163,68,.25);
}
.pill-filter.active:hover:not(:disabled) { background: #149436; border-color: #149436; }
.pill-filter:disabled { opacity: .4; cursor: not-allowed; }
.pill-filter .count { opacity: .85; margin-left: 2px; }

/* ── QUICK ACCESS CARDS (Dashboard) — v86.9 ─────────────────────
   Tarjetas de acceso rápido del Dashboard, agrupadas por categoría
   con el mismo color que el sidebar. Reemplaza el grid plano anterior. */
.quick-section { margin-bottom: 24px; }
.quick-section:last-child { margin-bottom: 0; }
.quick-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 10px 4px;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.quick-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5ddc9);
  border-radius: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  text-align: center;
  min-height: 120px;
}
.quick-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  border-color: transparent;
}
.quick-card-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: #f1f1f1;
  color: #6b6459;
  flex-shrink: 0;
}
.quick-card-icon svg { width: 32px; height: 32px; display: block; }
.quick-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #1a1f1a);
  line-height: 1.3;
}
.quick-card-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: #dc2626; color: #fff;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}

/* Color de fondo del icono según categoría — mismo mapeo que el sidebar */
.quick-card[data-group="principal"]      .quick-card-icon { background: #DBEAFE; color: #1E40AF; }
.quick-card[data-group="ventas"]         .quick-card-icon { background: #DCFCE7; color: #166534; }
.quick-card[data-group="operaciones"]    .quick-card-icon { background: #FEF3C7; color: #92400E; }
.quick-card[data-group="compras"]        .quick-card-icon { background: #EDE9FE; color: #5B21B6; }
.quick-card[data-group="finanzas"]       .quick-card-icon { background: #CCFBF1; color: #115E59; }
.quick-card[data-group="administracion"] .quick-card-icon { background: #FCE7F3; color: #9F1239; }
.quick-card[data-group="sistema"]        .quick-card-icon { background: #E0E7FF; color: #3730A3; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: .2px;
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-dim);    color: #15803d; }
.badge-warn    { background: var(--warn-dim);  color: #b45309; }
.badge-err     { background: var(--err-dim);   color: var(--err); }
.badge-info    { background: var(--info-dim);  color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--text-3); }
.badge-orange  { background: var(--orange-dim);color: var(--orange-dark); }

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(6px);
  animation: fade-in .15s ease;
}
@keyframes fade-in { from{opacity:0} to{opacity:1} }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto;
  animation: slide-up .2s ease;
  box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 720px; }
@keyframes slide-up { from{transform:translateY(20px);opacity:0} to{transform:none;opacity:1} }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 900; color: var(--text); letter-spacing: -.3px; }
.modal-close {
  background: var(--surface-3); border: none; cursor: pointer;
  color: var(--text-3); font-size: 16px; padding: 5px 8px;
  border-radius: 6px; transition: all var(--t); line-height: 1;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--surface);
}

/* ── TOAST ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px; font-size: 13px; color: var(--text); font-weight: 500;
  box-shadow: var(--shadow-lg); max-width: 320px;
  animation: toast-in .25s ease;
  pointer-events: all;
}
@keyframes toast-in { from{transform:translateX(20px);opacity:0} to{transform:none;opacity:1} }
.toast.ok   { border-left: 3px solid var(--ok); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.err  { border-left: 3px solid var(--err); }

/* ── UTILITIES ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.text-muted  { color: var(--text-3); }
.text-sm     { font-size: 12px; }
.mono        { font-family: var(--font-mono); font-size: 12px; }
.text-ok     { color: var(--ok); }
.text-warn   { color: var(--warn); }
.text-err    { color: var(--err); }
.text-info   { color: var(--info); }
.text-orange { color: var(--orange); }

.empty-state {
  text-align: center; padding: 56px 24px;
  color: var(--text-3); font-size: 13px; font-weight: 500;
}
.empty-state-icon { font-size: 44px; margin-bottom: 14px; opacity: .4; }

/* ── MODULE GRID (Dashboard style cards) ───────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  cursor: pointer;
  transition: all var(--t);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.module-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,.4));
  pointer-events: none;
}
.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: transparent;
}
.module-card-icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin: 0 auto 14px;
}
.module-card-label {
  font-size: 13px; font-weight: 700; color: var(--text);
  line-height: 1.3;
}
.module-card-badge {
  position: absolute; top: 10px; right: 10px;
  background: var(--err); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}

/* Card color variants */
.mc-green  { background: #f0fdf4; border-color: #bbf7d0; } .mc-green .module-card-icon  { background: #dcfce7; }
.mc-blue   { background: #eff6ff; border-color: #bfdbfe; } .mc-blue .module-card-icon   { background: #dbeafe; }
.mc-orange { background: #fff7ed; border-color: #fed7aa; } .mc-orange .module-card-icon { background: #ffedd5; }
.mc-purple { background: #faf5ff; border-color: #e9d5ff; } .mc-purple .module-card-icon { background: #f3e8ff; }
.mc-red    { background: #fff1f2; border-color: #fecdd3; } .mc-red .module-card-icon    { background: #ffe4e6; }
.mc-yellow { background: #fefce8; border-color: #fef08a; } .mc-yellow .module-card-icon { background: #fef9c3; }
.mc-teal   { background: #f0fdfa; border-color: #99f6e4; } .mc-teal .module-card-icon   { background: #ccfbf1; }
.mc-pink   { background: #fdf2f8; border-color: #f5d0fe; } .mc-pink .module-card-icon   { background: #fae8ff; }

/* ── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: var(--sb-w) !important;
    z-index: 500;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sb-overlay {
    display: none; position: fixed; inset: 0; z-index: 499;
    background: rgba(0,0,0,.4); backdrop-filter: blur(2px);
  }
  .sb-overlay.open { display: block; }
  .main-content { width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .module-area { padding: 14px 16px; }
  .topbar { padding: 0 14px; }
  .topbar-time { display: none; }
  .topbar-nav-btn span { display: none; }
  .topbar-nav-btn { padding: 6px 8px; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; max-width: 100vw; }
  .module-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 10px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card-n { font-size: 22px; }
  .module-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .mod-title { font-size: 20px; }
  .mod-header { flex-direction: column; gap: 10px; }
  .mod-actions { width: 100%; }
  .mod-actions .btn { flex: 1; justify-content: center; }
  .table-wrap { font-size: 12px; }
  td, th { padding: 8px 10px; }
  .topbar-plan { display: none; }
  .btn-full-mobile { width: 100%; justify-content: center; }
}

/* ── NAV BUTTONS ────────────────────────────────────────────── */
.topbar-nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1.5px solid var(--border);
  color: var(--text-2); font-size: 12px; font-weight: 700;
  font-family: var(--font); cursor: pointer;
  transition: all var(--t); white-space: nowrap;
}
.topbar-nav-btn:hover { background: var(--brand-light); border-color: var(--brand-border); color: var(--brand); }
.topbar-nav-btn svg { flex-shrink: 0; }


/* ── UX-RES-001: Responsive tables for mobile ─────────────────────────────── */
@media (max-width: 768px) {
    /* Hide secondary columns on mobile */
    .tbl-col-id,
    .tbl-col-updated,
    .tbl-col-created,
    .tbl-col-sku,
    th:nth-child(1):not(:only-child),
    td:nth-child(1):not(:only-child) { /* hide first column (usually ID) on narrow screens */
        display: none;
    }

    /* Sticky action column */
    .tbl-actions, .tbl-col-actions {
        position: sticky;
        right: 0;
        background: var(--surface);
        box-shadow: -2px 0 6px rgba(0,0,0,.06);
        z-index: 2;
    }

    /* Scrollable table container */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Compact table cells */
    .table th, .table td { padding: 8px 10px; font-size: 12px; white-space: nowrap; }

    /* Card layout for very small screens */
    @media (max-width: 480px) {
        .table-card-mobile tbody tr {
            display: block;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            margin-bottom: 10px;
            padding: 10px;
        }
        .table-card-mobile tbody td {
            display: flex;
            justify-content: space-between;
            padding: 4px 0;
            border: none;
            white-space: normal;
        }
        .table-card-mobile tbody td::before {
            content: attr(data-label);
            font-weight: 700;
            color: var(--t2);
            flex-shrink: 0;
            margin-right: 8px;
        }
        .table-card-mobile thead { display: none; }
    }
}

/* Table wrapper — always wrap tables */
.mod-body .table, .card .table {
    min-width: 100%;
}
.mod-body { overflow-x: auto; }

/* UX-VIS-001: Standardized button aliases */
.btn-success { background: #16A344; color: #fff; box-shadow: 0 1px 3px rgba(22,163,68,.25); }
.btn-success:hover:not(:disabled) { background: #149436; transform: translateY(-1px); }
.btn-warning { background: var(--warn); color: #fff; box-shadow: 0 1px 3px rgba(245,158,11,.25); }
.btn-warning:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }

/* ═══════════════════════════════════════════════════════════════════════
   SISTEMA DE ALERTAS
   ═══════════════════════════════════════════════════════════════════════ */

/* Botón de campana en topbar */
.topbar-alert-btn {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--t2, #4b5563);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.topbar-alert-btn:hover { background: var(--g100, #f1f5f9); color: var(--t1, #111827); }

.alert-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--surface, #fff);
}
.alert-badge-critical { background: #dc2626; }
.alert-badge-warning  { background: #f59e0b; }

/* Drawer lateral */
.alert-drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 9998;
    animation: alertFadeIn .2s;
}
.alert-drawer-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 380px;
    max-width: 95vw;
    background: var(--surface, #fff);
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: alertSlideIn .25s ease-out;
}
@keyframes alertFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes alertSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.alert-drawer-hdr {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.alert-close {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--t3, #9ca3af);
    padding: 4px 8px;
    border-radius: 6px;
}
.alert-close:hover { background: var(--g100, #f1f5f9); color: var(--t1, #111827); }

.alert-drawer-body {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}

.alert-group { margin-bottom: 12px; }
.alert-group-hdr {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--t2, #4b5563);
    background: var(--g50, #f9fafb);
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 0.5px;
}
.alert-count {
    background: var(--g200, #e5e7eb);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    color: var(--t1, #111827);
}

.alert-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    transition: background .15s;
}
.alert-item:hover { background: var(--g50, #f9fafb); }
.alert-item-body { flex: 1; min-width: 0; }
.alert-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--t1, #111827);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alert-detail {
    font-size: 11px;
    color: var(--t3, #9ca3af);
}
.alert-dismiss {
    background: transparent;
    border: none;
    color: var(--t3, #9ca3af);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    flex-shrink: 0;
    font-weight: 700;
    transition: all .15s;
}
.alert-dismiss:hover { background: #dcfce7; color: #15803d; }

/* Responsive: drawer full-width en mobile */
@media (max-width: 640px) {
    .alert-drawer-panel { width: 100vw; }
}

/* ═══════════════════════════════════════════════════════════════
   v78.1 — UX-RES-001: Tablas responsive
   En pantallas <640px las tablas se transforman en "cards" verticales
   donde cada fila se apila y cada celda muestra su label arriba.
   
   Funciona automáticamente si la tabla:
     - tiene <thead> con <th> que define los nombres de columna
     - O cada <td> tiene atributo data-label="Nombre columna"
   
   Para excluir una tabla del comportamiento responsive (ej: tabla
   editable de pedidos donde necesitas ver todo), agrega clase
   .table-no-mobile-cards a la <table>.
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    /* Por default, tablas se vuelven cards en mobile */
    table:not(.table-no-mobile-cards) { 
        display: block; 
        width: 100%;
    }
    table:not(.table-no-mobile-cards) thead {
        display: none;  /* ocultar header, los labels van en cada td */
    }
    table:not(.table-no-mobile-cards) tbody {
        display: block;
    }
    table:not(.table-no-mobile-cards) tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid var(--g200, #e5e7eb);
        border-radius: 8px;
        padding: 8px;
        background: #fff;
    }
    table:not(.table-no-mobile-cards) td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 6px 4px;
        border: none;
        border-bottom: 1px solid #f3f4f6;
        text-align: right;
        font-size: 13px;
    }
    table:not(.table-no-mobile-cards) td:last-child {
        border-bottom: none;
    }
    /* Label antes del valor: usar data-label (preferido) o ::before genérico */
    table:not(.table-no-mobile-cards) td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--t3, #6b7280);
        text-align: left;
        margin-right: 8px;
        flex-shrink: 0;
    }
    /* Botones en celdas se quedan a la derecha sin label */
    table:not(.table-no-mobile-cards) td.actions,
    table:not(.table-no-mobile-cards) td:has(button) {
        justify-content: center;
        background: #f9fafb;
        margin-top: 4px;
        border-radius: 4px;
    }
    
    /* Buttons grandes en mobile (touch targets) */
    .btn, button.btn-primary, button.btn-secondary {
        min-height: 44px;  /* iOS recommended touch target */
    }
    
    /* Modales ocupan toda la pantalla */
    .modal-overlay .modal,
    .modal.open .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }
}


/* ══ MONITOR DE OPERACIONES — v86.14 ════════════════════════════════
   5 pestañas: Operaciones · Cerradas · Stock · Lotes · Equipo
   Modo TV (botón fullscreen escala la tipografía)
   Fondo claro consistente con el ERP. */
.mon-root { font-family: var(--font, 'Figtree', system-ui, sans-serif); }

.mon-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border: 0.5px solid var(--border, #e5ddc9);
    border-bottom: none; border-radius: 12px 12px 0 0;
    background: var(--surface-2, #f9f7ee);
}
.mon-brand { display: flex; align-items: center; gap: 12px; }
.mon-dot-live {
    width: 10px; height: 10px; border-radius: 50%; background: #16A344;
    box-shadow: 0 0 0 0 rgba(22,163,68,.6); animation: monPulse 1.6s infinite;
}
@keyframes monPulse {
    0%   { box-shadow: 0 0 0 0   rgba(22,163,68,.6); }
    70%  { box-shadow: 0 0 0 10px rgba(22,163,68,0); }
    100% { box-shadow: 0 0 0 0   rgba(22,163,68,0); }
}
.mon-brand-t { font-size: 18px; font-weight: 700; letter-spacing: -.3px; color: var(--text-1); }
.mon-brand-s { font-size: 11px; color: var(--text-3, #888780); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 2px; }

.mon-clock-w { text-align: right; }
.mon-clock { font-family: 'DM Mono', monospace; font-size: 24px; font-weight: 700; color: #16A344; letter-spacing: 1px; }
.mon-clock-d { font-size: 11px; color: var(--text-3, #888780); margin-top: 2px; }

.mon-tv-btn {
    background: transparent; border: 0.5px solid var(--border-2, #d4c8a8);
    padding: 6px 14px; border-radius: 999px;
    font-size: 11px; cursor: pointer; font-weight: 700;
    font-family: var(--font); color: var(--text-2);
}
.mon-tv-btn:hover { background: var(--surface, #fff); border-color: #16A344; color: #16A344; }
.mon-tv-btn.on { background: #16A344; border-color: #16A344; color: #fff; }

.mon-body {
    border: 0.5px solid var(--border, #e5ddc9); border-top: none;
    border-radius: 0 0 12px 12px;
    background: var(--surface, #fff); padding: 16px;
}

.mon-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.mon-tab {
    background: transparent; border: 0.5px solid var(--border-2, #d4c8a8);
    padding: 7px 16px; border-radius: 999px; font-size: 12px;
    cursor: pointer; font-family: var(--font); font-weight: 700;
    color: var(--text-2);
}
.mon-tab:hover { border-color: #16A344; color: #16A344; }
.mon-tab.on { background: #16A344; border-color: #16A344; color: #fff; }
.mon-tab .n { opacity: .7; margin-left: 4px; font-family: 'DM Mono', monospace; }

.mon-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }
.mon-kpis-4 { grid-template-columns: repeat(4, 1fr); }
.mon-kpi {
    background: var(--surface-2, #f9f7ee); border-radius: 8px;
    padding: 12px 10px; text-align: center;
    border: 0.5px solid transparent; transition: all .25s;
}
.mon-kpi.alert { border-color: #DC2626; background: #FEE2E2; }
.mon-kpi.warn  { border-color: #F59E0B; background: #FEF3C7; }
.mon-kpi-n { font-family: 'DM Mono', monospace; font-size: 24px; font-weight: 700; line-height: 1; }
.mon-kpi-l { font-size: 9px; color: var(--text-3, #888780); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 5px; font-weight: 700; }

.mon-filters {
    display: flex; gap: 6px; padding: 8px 12px; margin-bottom: 10px;
    background: var(--surface-2, #f9f7ee); border-radius: 8px;
    flex-wrap: wrap; align-items: center;
}
.mon-f-lbl { font-size: 10px; color: var(--text-3, #888780); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; margin-right: 6px; }
.mon-f-chip {
    padding: 5px 12px; border-radius: 999px; font-size: 11px;
    cursor: pointer; border: 0.5px solid var(--border, #e5ddc9);
    background: var(--surface, #fff); font-weight: 700;
    font-family: var(--font); color: var(--text-2);
}
.mon-f-chip:hover { border-color: #16A344; }
.mon-f-chip.on { background: #16A344; color: #fff; border-color: #16A344; }
.mon-f-chip .ct { opacity: .7; margin-left: 4px; font-family: 'DM Mono', monospace; }

.mon-sem {
    display: flex; gap: 14px; padding: 10px 12px;
    background: var(--surface-2, #f9f7ee); border-radius: 8px;
    margin-bottom: 10px; align-items: center; flex-wrap: wrap;
}
.mon-sem-d { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.mon-sem-l { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.mon-sem-l.r { background: #DC2626; box-shadow: 0 0 8px rgba(220,38,38,.5); }
.mon-sem-l.y { background: #F59E0B; box-shadow: 0 0 8px rgba(245,158,11,.5); }
.mon-sem-l.g { background: #16A344; box-shadow: 0 0 8px rgba(22,163,68,.5); }
.mon-sem-d b { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 700; }

.mon-tbl-h, .mon-tbl-r { display: grid; gap: 10px; padding: 9px 12px; align-items: center; }
.mon-tbl-h {
    background: var(--surface-2, #f9f7ee);
    border: 0.5px solid var(--border, #e5ddc9); border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: var(--text-3, #888780); text-transform: uppercase;
    letter-spacing: 1.2px; font-size: 9px; font-weight: 700;
}
.mon-tbl-rows {
    border: 0.5px solid var(--border, #e5ddc9); border-top: none;
    border-radius: 0 0 8px 8px; max-height: 480px; overflow-y: auto;
    background: var(--surface, #fff);
}
.mon-tbl-r {
    border-top: 0.5px solid var(--border, #e5ddc9);
    font-size: 13px; transition: background .25s;
}
.mon-tbl-r:first-child { border-top: none; }
.mon-tbl-r:hover { background: var(--surface-2, #f9f7ee); }

.mon-g-live  { grid-template-columns: 110px 1fr 80px 105px 130px 60px; }
.mon-g-cer   { grid-template-columns: 110px 1fr 80px 105px 110px 70px; }
.mon-g-stock { grid-template-columns: 70px 1fr 60px 55px 75px 100px; }
.mon-g-lots  { grid-template-columns: 90px 1fr 55px 85px 55px 90px 145px; }

.mon-id { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text-3, #888780); }
.mon-nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-1); }
.mon-tot { text-align: right; font-family: 'DM Mono', monospace; font-weight: 700; color: var(--text-1); }
.mon-tot-big { font-size: 16px; }
.mon-t-num { font-family: 'DM Mono', monospace; text-align: right; }
.mon-t-time { color: var(--text-3, #888780); font-size: 11px; text-align: right; font-family: 'DM Mono', monospace; }
.mon-t-resp { font-size: 12px; color: var(--text-3, #888780); }
.mon-t-resp b { color: var(--text-1); font-weight: 700; }
.mon-empty { padding: 40px 14px; text-align: center; color: var(--text-3, #888780); font-size: 13px; }

.mon-pill {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 999px;
    font-size: 10px; font-weight: 700;
    white-space: nowrap; letter-spacing: .3px;
    text-transform: uppercase; font-family: var(--font);
}
.mon-p-nuevo  { background: #DBEAFE; color: #1E3A8A; }
.mon-p-conf   { background: #DCFCE7; color: #166534; }
.mon-p-ruta   { background: #EDE9FE; color: #5B21B6; }
.mon-p-prep   { background: #FEF3C7; color: #92400E; }
.mon-p-carga  { background: #FCE7F3; color: #9F1239; }
.mon-p-camino { background: #CCFBF1; color: #115E59; }
.mon-p-ok     { background: #BBF7D0; color: #14532D; }
.mon-p-warn   { background: #FED7AA; color: #9A3412; }
.mon-p-crit   { background: #DC2626; color: #fff; }
.mon-p-cancel { background: #7F1D1D; color: #fff; }

.mon-row-crit { background: #FEE2E2 !important; box-shadow: inset 3px 0 0 #DC2626; }
.mon-row-warn { background: #FEF3C7 !important; box-shadow: inset 3px 0 0 #F59E0B; }

.mon-flash-up     { animation: monFlashUp 1.5s ease-out; }
.mon-flash-down   { animation: monFlashDown 1.5s ease-out; }
.mon-flash-cancel { animation: monFlashCancel 1.5s ease-out; }
@keyframes monFlashUp     { 0% { background: rgba(22,163,68,.25); } 100% { background: transparent; } }
@keyframes monFlashDown   { 0% { background: rgba(245,158,11,.3); } 100% { background: transparent; } }
@keyframes monFlashCancel { 0% { background: rgba(220,38,38,.35); } 100% { background: transparent; } }

.mon-team-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-bottom: 0.5px solid var(--border, #e5ddc9);
}
.mon-team-card:last-child { border-bottom: none; }
.mon-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; flex-shrink: 0; letter-spacing: -.5px;
    font-family: var(--font);
}
.mon-av-blue  { background: #DBEAFE; color: #1E40AF; }
.mon-av-amber { background: #FEF3C7; color: #92400E; }
.mon-av-teal  { background: #CCFBF1; color: #115E59; }
.mon-av-pink  { background: #FCE7F3; color: #9F1239; }
.mon-av-gray  { background: #F1EFE8; color: #5F5E5A; }

.mon-team-info { flex: 1; min-width: 0; }
.mon-team-name { font-size: 13px; font-weight: 700; color: var(--text-1); }
.mon-team-stats { font-size: 11px; color: var(--text-3, #888780); margin-top: 2px; font-family: 'DM Mono', monospace; }

.mon-bar { height: 6px; background: var(--border, #e5ddc9); border-radius: 3px; overflow: hidden; }
.mon-bar > div { height: 100%; transition: width .4s; border-radius: 3px; }
.mon-bar-g { background: #16A344; }
.mon-bar-y { background: #F59E0B; }
.mon-bar-r { background: #DC2626; }

/* ── MODO TV (escala todo para legibilidad desde lejos) ── */
.mon-root.mon-tv .mon-brand-t { font-size: 26px; }
.mon-root.mon-tv .mon-clock { font-size: 34px; }
.mon-root.mon-tv .mon-kpi-n { font-size: 38px; }
.mon-root.mon-tv .mon-kpi-l { font-size: 11px; }
.mon-root.mon-tv .mon-tbl-r { padding: 14px 14px; font-size: 15px; }
.mon-root.mon-tv .mon-tot-big { font-size: 20px; }
.mon-root.mon-tv .mon-pill { padding: 5px 14px; font-size: 12px; }
.mon-root.mon-tv .mon-body { padding: 22px; }
.mon-root.mon-tv .mon-tab { padding: 9px 22px; font-size: 14px; }
.mon-root.mon-tv .mon-tabs { margin-bottom: 18px; }
.mon-root.mon-tv .mon-team-card { padding: 16px; }
.mon-root.mon-tv .mon-avatar { width: 44px; height: 44px; font-size: 14px; }
.mon-root.mon-tv .mon-team-name { font-size: 15px; }
.mon-root.mon-tv .mon-team-stats { font-size: 12px; }
