/* ============================================================
   MaFel Core — Design System
   ============================================================
   Prefijo `mf-` en todas las clases para evitar colisiones con
   los estilos existentes. Este archivo NO se carga en base.html
   todavía; se usa solo en /playground/ hasta aprobar el look.
   ============================================================ */

:root {
  /* ── Azules principales ─────────────────────────────── */
  --mf-navy-900: #0F1C2E;
  --mf-navy-800: #1E3A5F;
  --mf-navy-700: #152A4A;
  --mf-navy-600: #1E40AF;
  --mf-navy-500: #3B82F6;
  --mf-blue-400: #60A5FA;
  --mf-blue-100: #DBEAFE;
  --mf-blue-50:  #EFF6FF;

  /* ── Grises ─────────────────────────────────────────── */
  --mf-slate-900: #0F1C2E;
  --mf-slate-700: #334155;
  --mf-slate-600: #475569;
  --mf-slate-500: #64748B;
  --mf-slate-400: #94A3B8;
  --mf-slate-300: #CBD5E1;
  --mf-slate-200: #E2E8F0;
  --mf-slate-100: #F1F5F9;
  --mf-slate-50:  #F8F9FA;

  /* ── Bordes ─────────────────────────────────────────── */
  --mf-border:       #E4E4E7;
  --mf-border-light: #F1F5F9;

  /* ── Semánticos ─────────────────────────────────────── */
  --mf-green-50:  #D1FAE5;
  --mf-green-600: #059669;
  --mf-green-700: #065F46;
  --mf-amber-50:  #FEF3C7;
  --mf-amber-600: #D97706;
  --mf-amber-700: #92400E;
  --mf-red-50:    #FEE2E2;
  --mf-red-600:   #DC2626;
  --mf-red-700:   #991B1B;
  --mf-purple-50: #F3E8FF;
  --mf-purple-600: #7C3AED;
  --mf-purple-700: #6B21A8;
  --mf-cyan-50:   #CFFAFE;
  --mf-cyan-100:  #A5F3FC;
  --mf-cyan-600:  #0891B2;
  --mf-cyan-700:  #155E75;

  /* ── Radius ─────────────────────────────────────────── */
  --mf-radius-sm: 4px;
  --mf-radius-md: 6px;
  --mf-radius-lg: 8px;
  --mf-radius-xl: 12px;

  /* ── Tipografía ─────────────────────────────────────── */
  --mf-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mf-font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* ============================================================
   Reset scoped — solo dentro de .mf-scope para no contaminar
   el resto del sistema mientras convivimos con el CSS viejo.
   ============================================================ */
.mf-scope,
.mf-scope * {
  box-sizing: border-box;
}

.mf-scope {
  font-family: var(--mf-font-sans);
  color: var(--mf-slate-700);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT raíz — sidebar dual + contenido + footer
   Sidebars sticky: quedan fijos mientras el contenido scrollea.
   ============================================================ */
.mf-app {
  display: flex;
  align-items: flex-start; /* crítico para que position:sticky funcione en flex children */
  min-height: calc(100vh - 48px);
}

.mf-content {
  flex: 1;
  min-width: 0;            /* evita desbordes horizontales con tablas largas */
  padding: 20px 24px;
  background: var(--mf-slate-50);
}

.mf-content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.mf-content-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--mf-navy-900);
  letter-spacing: -0.3px;
  margin: 0;
}

.mf-content-breadcrumb {
  font-size: 11px;
  color: var(--mf-slate-500);
  margin-top: 4px;
  font-family: var(--mf-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mf-content-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   TIPOGRAFÍA — utilidades de jerarquía
   Regla: tamaños permitidos 22 / 14 / 13 / 12 / 11 / 10 px.
          weights 400 (normal) o 500 (medium). Nunca > 500.
   ============================================================ */

/* Subtítulo / meta bajo el H1 — "X resultados", norma ISO, etc. */
.mf-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--mf-slate-500);
  line-height: 1.4;
  margin: 4px 0 14px;
}

/* Texto muted mono — timestamps, autor, "hace X días" */
.mf-muted {
  font-size: 11px;
  font-weight: 400;
  color: var(--mf-slate-400);
  font-family: var(--mf-font-mono);
}

/* Texto secundario — nombres, descripciones cortas */
.mf-text-sm {
  font-size: 12px;
  font-weight: 400;
  color: var(--mf-slate-500);
}

/* Título de sección interna en panel (mono uppercase) */
.mf-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--mf-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--mf-font-mono);
  margin-bottom: 4px;
}

/* ============================================================
   Tipografía por defecto dentro de .mf-content
   Para templates que no usan las clases mf-* explícitas, que hereden
   los tamaños del sistema. Los inline styles siguen ganando sobre esto.
   ============================================================ */
.mf-content h1 {
  font-size: 22px;
  font-weight: 500;
  color: var(--mf-navy-900);
  letter-spacing: -0.3px;
  margin: 0 0 4px;
  font-family: var(--mf-font-sans);
}
.mf-content h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--mf-navy-900);
  margin: 16px 0 8px;
  font-family: var(--mf-font-sans);
}
.mf-content h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--mf-navy-900);
  margin: 12px 0 6px;
  font-family: var(--mf-font-sans);
}
.mf-content h4 {
  font-size: 11px;
  font-weight: 500;
  color: var(--mf-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--mf-font-mono);
  margin: 10px 0 4px;
}

/* Tablas sin la clase .mf-table — aplicar look base */
.mf-content table {
  font-size: 13px;
  font-family: var(--mf-font-sans);
  color: var(--mf-slate-700);
}
.mf-content table th {
  font-size: 10px;
  color: var(--mf-slate-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--mf-font-mono);
}
.mf-content table td {
  color: var(--mf-slate-700);
}

/* Botones nativos sin clase .mf-btn — darles el look base para que no
   queden como botones browser-default */
.mf-content button:not([class*="mf-"]):not([class*="btn-"]):not([class*="dash-tab"]):not([class*="cc-"]):not([class*="tr-"]),
.mf-content input[type="submit"]:not([class*="mf-"]) {
  padding: 8px 14px;
  border-radius: var(--mf-radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--mf-border);
  background: #fff;
  color: var(--mf-slate-700);
  font-family: var(--mf-font-sans);
}

/* ============================================================
   TOPBAR — barra superior del contenido con alertas / acciones
   Va dentro de .mf-content, arriba del content-header.
   ============================================================ */
.mf-topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 14px;
  margin-bottom: 8px;
  border-bottom: 0.5px solid var(--mf-border);
}
.mf-topbar-spacer { flex: 1; }

.mf-topbar-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--mf-radius-md);
  background: #fff;
  border: 0.5px solid var(--mf-border);
  color: var(--mf-slate-500);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.mf-topbar-btn:hover {
  background: var(--mf-slate-50);
  color: var(--mf-navy-900);
  border-color: var(--mf-slate-300);
}
.mf-topbar-btn svg {
  width: 17px;
  height: 17px;
}
.mf-topbar-btn.alert {
  color: var(--mf-amber-700);
  background: var(--mf-amber-50);
  border-color: var(--mf-amber-50);
}
.mf-topbar-btn.alert:hover { background: #fde68a; }

.mf-topbar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--mf-red-600);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mf-font-mono);
  line-height: 1;
  border: 1.5px solid #fff;
}
.mf-topbar-badge.info {
  background: var(--mf-navy-600);
}
.mf-topbar-badge.amber {
  background: var(--mf-amber-600);
}
.mf-topbar-badge.purple {
  background: var(--mf-purple-600);
}

/* ============================================================
   SIDEBAR RAIL — nivel 1 (solo iconos)
   ============================================================ */
.mf-rail {
  width: 60px;
  background: var(--mf-navy-900);
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  gap: 3px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.mf-rail-logo {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
}
.mf-rail-logo::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 10px;
  right: 10px;
  height: 1px;
  background: var(--mf-navy-800);
}

.mf-rail-item {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mf-slate-400);
  text-decoration: none;
  position: relative;
  transition: all 0.15s;
}
.mf-rail-item:hover {
  background: var(--mf-navy-700);
  color: var(--mf-slate-200);
}
.mf-rail-item.active {
  background: var(--mf-navy-800);
  color: var(--mf-blue-400);
}
.mf-rail-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--mf-blue-400);
  border-radius: 0 3px 3px 0;
}
.mf-rail-item svg {
  width: 18px;
  height: 18px;
}
.mf-rail-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50px;
  background: var(--mf-navy-900);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
  border: 1px solid var(--mf-navy-800);
}
.mf-rail-item:hover[data-tooltip]::after {
  opacity: 1;
}

.mf-rail-user {
  margin: auto auto 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mf-navy-500);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

/* ============================================================
   SIDEBAR SUB — nivel 2 (contextual)
   ============================================================ */
.mf-sub {
  background: #fff;
  border-right: 0.5px solid var(--mf-border);
  padding: 16px 0;
  display: flex;
  flex-direction: column;

  /* Drawer mode: oculto por default. Se abre con click en el ícono activo
     del rail (mf-chrome.js) o con la clase .is-open aplicada. */
  position: fixed;
  top: 0;
  bottom: 48px;          /* descontar altura del footer */
  left: 60px;            /* empieza justo después del rail */
  width: 240px;
  overflow-y: auto;
  transform: translateX(calc(-100% - 60px));
  opacity: 0;
  pointer-events: none;
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1),
              opacity 200ms ease;
  z-index: 45;
  box-shadow: 8px 0 24px rgba(15, 28, 46, 0.10);
}
.mf-sub.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Backdrop para cierre al clickear fuera */
.mf-sub-backdrop {
  position: fixed;
  top: 0;
  left: 60px;
  right: 0;
  bottom: 48px;
  background: rgba(15, 28, 46, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 44;
}
.mf-sub-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Hint visual: el ícono del rail activo es clickeable para toggle */
.mf-rail-item.active {
  cursor: pointer;
}

/* ============================================================
   Banner global de avisos (críticos / advertencia)
   Fijo al tope del viewport, sobre TODAS las páginas del LIMS.
   Se llena por mafel-chrome.js con polling al endpoint banner.
   ============================================================ */
.mf-banner {
  position: fixed;
  top: 0;
  left: 60px;   /* después del rail */
  right: 0;
  z-index: 55;  /* arriba del sub-drawer (45) pero bajo modales (100) */
  min-height: 38px;
  padding: 8px 16px 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mf-font-sans);
  font-size: 13px;
  color: #fff;
  background: var(--mf-red-600);
  box-shadow: 0 2px 8px rgba(15,28,46,0.15);
  animation: mf-banner-in 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.mf-banner[hidden] { display: none !important; }
.mf-banner.tone-advertencia {
  background: var(--mf-amber-600);
  color: #fff;
}
.mf-banner.tone-critico {
  background: var(--mf-red-600);
  color: #fff;
}
@keyframes mf-banner-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mf-banner-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  opacity: 0.9;
}
.mf-banner-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.mf-banner-title {
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
}
.mf-banner-text {
  opacity: 0.95;
  flex: 1;
  min-width: 0;
}
.mf-banner-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  opacity: 0.8;
  flex-shrink: 0;
}
.mf-banner-close:hover { opacity: 1; }

/* Cuando el banner está visible empujamos el contenido para no taparlo */
body.has-mf-banner .mf-content { padding-top: 46px; }
body.has-mf-banner .mf-rail    { padding-top: 46px; }
body.has-mf-banner .mf-sub     { top: 46px; }

.mf-sub-header {
  padding: 0 16px 14px;
  border-bottom: 0.5px solid var(--mf-border);
  margin-bottom: 8px;
}
.mf-sub-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--mf-navy-900);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}
.mf-sub-subtitle {
  font-size: 11px;
  color: var(--mf-slate-500);
  margin-top: 2px;
}

.mf-sub-items {
  padding: 0 10px;
  flex: 1;
  overflow-y: auto;
}
.mf-sub-section {
  padding: 10px 8px 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--mf-slate-400);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: var(--mf-font-mono);
}

.mf-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--mf-slate-700);
  font-size: 12px;
  margin-bottom: 2px;
  text-decoration: none;
  transition: background 0.1s;
}
.mf-sub-item:hover {
  background: var(--mf-slate-100);
}
.mf-sub-item.active {
  background: var(--mf-blue-50);
  color: var(--mf-navy-600);
  font-weight: 500;
}
.mf-sub-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.mf-sub-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--mf-red-50);
  color: var(--mf-red-700);
  font-weight: 500;
  font-family: var(--mf-font-mono);
}

.mf-sub-user {
  padding: 12px 14px;
  border-top: 0.5px solid var(--mf-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.mf-sub-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mf-navy-500);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
}
.mf-sub-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--mf-navy-900);
}
.mf-sub-user-role {
  font-size: 10px;
  color: var(--mf-slate-500);
  font-family: var(--mf-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mf-sub-user-pass {
  font-size: 10px;
  color: var(--mf-slate-500);
  margin-top: 3px;
  font-family: var(--mf-font-mono);
}
.mf-sub-user-pass.alerta  { color: var(--mf-amber-600); }
.mf-sub-user-pass.critica { color: var(--mf-amber-700); font-weight: 600; }
.mf-sub-user-pass.vencida { color: var(--mf-red-600); font-weight: 600; }

/* La card del usuario es clickeable — sutil hover */
a.mf-sub-user { color: inherit; transition: background 0.1s; }
a.mf-sub-user:hover { background: var(--mf-slate-50); }

/* ============================================================
   FOOTER
   ============================================================ */
.mf-footer {
  background: var(--mf-navy-900);
  color: var(--mf-slate-400);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  border-top: 1px solid var(--mf-navy-800);
  height: 48px;
}
.mf-footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mf-footer-name {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.mf-footer-company {
  color: var(--mf-blue-400);
  font-size: 10px;
  font-family: var(--mf-font-mono);
  line-height: 1.2;
}
.mf-footer-sep {
  width: 0.5px;
  height: 24px;
  background: var(--mf-navy-800);
}
.mf-footer-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  font-family: var(--mf-font-mono);
  font-size: 10px;
}
.mf-footer-meta span { color: var(--mf-slate-400); }
.mf-footer-meta strong { color: var(--mf-slate-300); font-weight: 500; }
.mf-footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mf-green-600);
  margin-right: 4px;
  display: inline-block;
}
.mf-footer-links {
  margin-left: auto;
  display: flex;
  gap: 14px;
}
.mf-footer-links a {
  color: var(--mf-slate-400);
  text-decoration: none;
  transition: color 0.15s;
}
.mf-footer-links a:hover { color: #fff; }

/* ============================================================
   BOTONES
   ============================================================ */
.mf-btn {
  padding: 8px 14px;
  border-radius: var(--mf-radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--mf-border);
  background: #fff;
  color: var(--mf-slate-700);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mf-font-sans);
  transition: all 0.15s;
  text-decoration: none;
}
.mf-btn:hover { background: var(--mf-slate-50); }
.mf-btn:active { transform: scale(0.98); }
.mf-btn svg { width: 14px; height: 14px; }

.mf-btn-primary {
  background: var(--mf-navy-600);
  color: #fff;
  border: none;
}
.mf-btn-primary:hover { background: var(--mf-navy-900); }

.mf-btn-secondary {
  background: var(--mf-navy-900);
  color: #fff;
  border: none;
}
.mf-btn-secondary:hover { background: var(--mf-navy-800); }

.mf-btn-danger {
  background: var(--mf-red-50);
  color: var(--mf-red-700);
  border-color: var(--mf-red-50);
}
.mf-btn-danger:hover { background: #fecaca; }

.mf-btn-success {
  background: var(--mf-green-50);
  color: var(--mf-green-700);
  border-color: var(--mf-green-50);
}
.mf-btn-success:hover { background: #bbf7d0; }

.mf-btn-warning {
  background: var(--mf-amber-50);
  color: var(--mf-amber-700);
  border-color: var(--mf-amber-50);
}
.mf-btn-warning:hover { background: #fde68a; }

.mf-btn-info {
  background: var(--mf-blue-50);
  color: var(--mf-navy-600);
  border-color: var(--mf-blue-50);
}
.mf-btn-info:hover { background: var(--mf-blue-100); }

/* Botón sin fondo, estilo link discreto. Útil para acciones secundarias
   en tablas densas que no deben competir con el contenido. */
.mf-btn-ghost {
  background: transparent;
  color: var(--mf-slate-600);
  border-color: transparent;
}
.mf-btn-ghost:hover { background: var(--mf-slate-100); color: var(--mf-navy-900); }

.mf-btn-sm { padding: 4px 10px; font-size: 11px; }
.mf-btn-xs { padding: 3px 8px; font-size: 10px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.mf-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.mf-stat {
  background: #fff;
  border: 0.5px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
  padding: 12px 14px;
}
.mf-stat-label {
  font-size: 11px;
  color: var(--mf-slate-500);
  margin-bottom: 4px;
  font-family: var(--mf-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mf-stat-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--mf-navy-900);
  letter-spacing: -0.3px;
}
.mf-stat-change {
  font-size: 11px;
  margin-top: 2px;
  color: var(--mf-green-600);
  font-family: var(--mf-font-mono);
}
.mf-stat-change.negative { color: var(--mf-red-600); }

/* ============================================================
   PANELES
   ============================================================ */
.mf-panel {
  background: #fff;
  border: 0.5px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.mf-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.mf-panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--mf-navy-900);
}
.mf-panel-action {
  font-size: 12px;
  color: var(--mf-navy-600);
  cursor: pointer;
  text-decoration: none;
}
.mf-panel-action:hover { text-decoration: underline; }

/* ============================================================
   TABLAS
   ============================================================ */
.mf-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.mf-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  color: var(--mf-slate-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 0.5px solid var(--mf-border);
  font-family: var(--mf-font-mono);
}
.mf-table td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--mf-border-light);
  color: var(--mf-slate-700);
}
.mf-table tr:last-child td { border-bottom: none; }
.mf-table tr:hover td { background: var(--mf-slate-50); }

.mf-code {
  font-family: var(--mf-font-mono);
  font-size: 11px;
  color: var(--mf-navy-600);
  font-weight: 500;
}

/* ============================================================
   BADGES / TAGS
   ============================================================ */
.mf-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
  display: inline-block;
  font-family: var(--mf-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mf-tag-green  { background: var(--mf-green-50);  color: var(--mf-green-700);  }
.mf-tag-blue   { background: var(--mf-blue-100);  color: var(--mf-navy-600);   }
.mf-tag-amber  { background: var(--mf-amber-50);  color: var(--mf-amber-700);  }
.mf-tag-red    { background: var(--mf-red-50);    color: var(--mf-red-700);    }
.mf-tag-purple { background: var(--mf-purple-50); color: var(--mf-purple-700); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.mf-form-group { margin-bottom: 12px; }
.mf-form-label {
  font-size: 11px;
  color: var(--mf-slate-500);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  font-family: var(--mf-font-mono);
}
.mf-form-input,
.mf-form-select,
.mf-form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 0.5px solid var(--mf-border);
  border-radius: var(--mf-radius-md);
  font-size: 13px;
  color: var(--mf-navy-900);
  font-family: var(--mf-font-sans);
  background: #fff;
  transition: border-color 0.15s;
}
.mf-form-input:focus,
.mf-form-select:focus,
.mf-form-textarea:focus {
  outline: 2px solid var(--mf-blue-100);
  border-color: var(--mf-navy-600);
}
.mf-form-textarea { resize: vertical; min-height: 72px; }

.mf-form-row   { display: grid; gap: 10px; }
.mf-form-row-2 { grid-template-columns: 1fr 1fr; }
.mf-form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================
   WIZARD (pasos horizontales)
   ============================================================ */
.mf-wizard {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  background: #fff;
  padding: 12px 16px;
  border-radius: var(--mf-radius-lg);
  border: 0.5px solid var(--mf-border);
}
.mf-wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--mf-slate-400);
  flex-shrink: 0;
}
.mf-wizard-step .num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mf-slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  color: var(--mf-slate-400);
  font-size: 11px;
  flex-shrink: 0;
}
.mf-wizard-step.done       { color: var(--mf-green-600); }
.mf-wizard-step.done .num  { background: var(--mf-green-50); color: var(--mf-green-700); }
.mf-wizard-step.active     { color: var(--mf-navy-600); font-weight: 500; }
.mf-wizard-step.active .num{ background: var(--mf-navy-600); color: #fff; }
.mf-wizard-line {
  flex: 1;
  height: 1px;
  background: var(--mf-border);
  margin: 0 4px;
  min-width: 8px;
}
/* Mobile: ocultar labels, dejar solo los círculos numerados. */
@media (max-width: 520px) {
  .mf-wizard-step .lbl { display: none; }
  .mf-wizard { padding: 10px 12px; }
}

/* ============================================================
   TIMELINE
   ============================================================ */
.mf-timeline { display: flex; flex-direction: column; gap: 10px; }
.mf-timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--mf-border-light);
}
.mf-timeline-item:last-child { border-bottom: none; padding-bottom: 0; }
.mf-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.mf-timeline-dot-green { background: var(--mf-green-600); }
.mf-timeline-dot-blue  { background: var(--mf-navy-600);  }
.mf-timeline-dot-amber { background: var(--mf-amber-600); }
.mf-timeline-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--mf-navy-900);
}
.mf-timeline-desc {
  font-size: 11px;
  color: var(--mf-slate-500);
  margin-top: 2px;
}

/* ─── Tooltip de ayuda reusable (hover + foco de teclado) ─────────────── */
.mf-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--mf-border);
  background: var(--mf-slate-50);
  color: var(--mf-slate-500);
  font-family: var(--mf-font-mono);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}
.mf-help[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 135%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  white-space: normal;
  text-align: left;
  line-height: 1.35;
  background: var(--mf-navy-900);
  color: #fff;
  font-family: var(--mf-font-sans);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--mf-navy-800);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 200;
}
.mf-help:hover[data-tooltip]::after,
.mf-help:focus[data-tooltip]::after,
.mf-help:focus-visible[data-tooltip]::after {
  opacity: 1;
}

/* ─── Bloque estadístico informativo de réplicas (valoración) ────────── */
.mf-estadistica {
  margin-top: 16px;
  padding: 14px 16px;
  border: 0.5px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
  background: var(--mf-slate-50);
}
.mf-estadistica-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mf-estadistica-titulo {
  font-family: var(--mf-font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mf-slate-500);
}
.mf-estadistica-resultado {
  font-size: 20px;
  font-weight: 500;
  color: var(--mf-navy-900);
  margin-bottom: 12px;
}
.mf-estadistica-ic {
  font-size: 13px;
  color: var(--mf-slate-500);
  font-family: var(--mf-font-mono);
}
.mf-estadistica-stats {
  margin-bottom: 14px;
}
.mf-estadistica-stats .mf-stat-value {
  font-size: 16px;
  font-family: var(--mf-font-mono);
}
.mf-estadistica-ic-rango {
  font-size: 14px;
}
.mf-estadistica-subtitulo {
  font-family: var(--mf-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mf-slate-500);
  margin: 10px 0 4px;
}
.mf-estadistica-tabla .mf-num {
  text-align: right;
  font-family: var(--mf-font-mono);
}
.mf-estadistica-tabla .mf-estadistica-total td {
  font-weight: 600;
  color: var(--mf-navy-900);
  border-top: 0.5px solid var(--mf-border);
}
.mf-estadistica-nota {
  font-size: 11px;
  color: var(--mf-slate-500);
  margin: 10px 0 0;
  line-height: 1.4;
}
.mf-estadistica-na {
  font-size: 12px;
  color: var(--mf-slate-500);
}
.mf-estadistica-factores {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 12px;
}
.mf-estadistica-formula {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 8px;
  padding: 8px 10px;
  background: #fff;
  border: 0.5px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
}
.mf-estadistica-formula code {
  font-family: var(--mf-font-mono);
  font-size: 12px;
  color: var(--mf-navy-900);
}
.mf-estadistica-formula-vars {
  font-family: var(--mf-font-mono);
  font-size: 11px;
  color: var(--mf-slate-500);
  margin-top: 2px;
}

/* ─── Reorganización por grupos (cajas con encabezado de acento) ──────── */
.mf-estadistica-grupo {
  background: #fff;
  border: 0.5px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.mf-estadistica-grupo-hdr {
  border-left: 3px solid var(--mf-blue-400);
  padding-left: 8px;
  margin-bottom: 8px;
  font-family: var(--mf-font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mf-navy-900);
}
/* Estándares: crudo (neutro) → corregido (neutro, borde izq. de acento) */
.mf-estadistica-crudo {
  margin-bottom: 4px;
}
.mf-estadistica-corregida {
  border-left: 3px solid var(--mf-blue-400);
  background: var(--mf-slate-50);
  border-radius: 0 var(--mf-radius-lg) var(--mf-radius-lg) 0;
  padding: 8px 10px;
  margin-top: 4px;
}
.mf-estadistica-sep {
  text-align: center;
  font-family: var(--mf-font-mono);
  font-size: 10px;
  color: var(--mf-slate-500);
  margin: 6px 0;
}
/* Tabla de muestras: divisor entre columnas de entrada y de salida */
.mf-estadistica-tabla th.mf-col-sep,
.mf-estadistica-tabla td.mf-col-sep {
  border-left: 1px solid var(--mf-border);
}

/* ─── Caja "Fórmula aplicada · EE" — único bloque con fondo de acento ─── */
.mf-formula-aplicada-acento {
  background: var(--mf-blue-50);
  border-left: 3px solid var(--mf-blue-400);
}

/* ─── Dot plot de dispersión (escala de % real, SVG server-side, sin JS) ─ */
.mf-dotplot {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 4px 0 8px;
}
.mf-dotplot-band {
  fill: var(--mf-blue-100);
  opacity: 0.55;
}
.mf-dotplot-axis {
  stroke: var(--mf-slate-500);
  stroke-width: 0.25;
}
.mf-dotplot-tick {
  stroke: var(--mf-border);
  stroke-width: 0.25;
}
.mf-dotplot-tick-lbl {
  fill: var(--mf-slate-500);
  font-family: var(--mf-font-mono);
  font-size: 3px;
}
.mf-dotplot-mean {
  stroke: var(--mf-navy-600);
  stroke-width: 0.4;
  stroke-dasharray: 1.2 0.8;
}
.mf-dotplot-pt {
  fill: var(--mf-navy-600);
  fill-opacity: 0.7;
  stroke: #fff;
  stroke-width: 0.2;
}
.mf-dotplot-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--mf-font-mono);
  font-size: 10px;
  color: var(--mf-slate-500);
}
.mf-dotplot-key-pt,
.mf-dotplot-key-mean,
.mf-dotplot-key-band {
  display: inline-block;
  vertical-align: middle;
  margin-right: 3px;
}
.mf-dotplot-key-pt {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mf-navy-600);
}
.mf-dotplot-key-mean {
  width: 12px;
  height: 0;
  border-top: 2px dashed var(--mf-navy-600);
}
.mf-dotplot-key-band {
  width: 12px;
  height: 8px;
  background: var(--mf-blue-100);
}

/* Individual value plot de disolución (paso 2.1b) — %Q por vaso vs. líneas
   de criterio USP <711>. Puntos con el mismo estilo que el dot-plot; las
   líneas de criterio traen su color inline (verde/gris/ámbar/rojo). */
.mf-ivp {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 4px 0 8px;
}
.mf-ivp-pt {
  fill: var(--mf-navy-600);
  fill-opacity: 0.75;
  stroke: #fff;
  stroke-width: 0.2;
}

/* ── Gráfico de dispersión reusable (mf-disp) — arquetipos A/B/C/D ──────────
   Geometría precalculada en core/services/grafico_dispersion.py; viewBox de
   ancho 680 con área de dibujo insetada en [70,610]. overflow:visible es la
   segunda red contra el recorte de rótulos de los extremos. */
.mf-disp-wrap {
  margin: 8px 0 4px;
}
.mf-disp-titulo {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mf-slate-700);
  margin-bottom: 2px;
}
.mf-disp {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  overflow: visible;
  margin: 2px 0 6px;
}
.mf-disp text {
  font-family: var(--mf-font-sans, system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
}
.mf-disp-band {
  fill: var(--mf-blue-100);
  opacity: 0.6;
}
.mf-disp-range {
  fill: var(--mf-green-50);
}
.mf-disp-axis {
  stroke: var(--mf-slate-400);
  stroke-width: 1;
}
.mf-disp-grid {
  stroke: var(--mf-border);
  stroke-width: 1;
}
.mf-disp-spec {
  stroke: var(--mf-red-600);
  stroke-width: 2;
}
.mf-disp-spec-lbl {
  fill: var(--mf-red-600);
  font-size: 12px;
  font-weight: 600;
}
.mf-disp-mean {
  stroke: var(--mf-purple-600);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}
.mf-disp-mean-lbl {
  fill: var(--mf-purple-600);
  font-size: 11.5px;
  font-weight: 600;
}
.mf-disp-pt {
  fill: var(--mf-navy-600);
  stroke: #fff;
  stroke-width: 1.5;
}
.mf-disp-pt-total {
  fill: var(--mf-purple-600);
  stroke: #fff;
  stroke-width: 1.5;
}
.mf-disp-tick-lbl,
.mf-disp-ytick-lbl {
  fill: var(--mf-slate-500);
  font-size: 11px;
}
.mf-disp-value-lbl {
  fill: var(--mf-navy-600);
  font-size: 12px;
  font-weight: 600;
}
/* Halo detrás del rótulo de valor (arq. D): recorta la línea del lollipop alrededor del
   texto (color de la superficie; el gráfico asume fondo claro, igual que stroke:#fff). */
.mf-disp-halo {
  fill: var(--mf-bg-card, #ffffff);
}
/* Fuera de límite (fracción > 1) → color crítico en punto/línea/rótulo (arq. D). */
.mf-disp-pt-crit {
  fill: var(--mf-red-600);
  stroke: #fff;
  stroke-width: 1.5;
}
.mf-disp-stem-crit {
  stroke: var(--mf-red-600);
  stroke-width: 2;
}
.mf-disp-value-lbl-crit {
  fill: var(--mf-red-600);
}
/* Marcador de overflow (fracción > 1.25×, anclada al borde derecho del plot, arq. D). */
.mf-disp-overflow {
  fill: var(--mf-red-600);
  font-size: 18px;
  font-weight: 700;
}
.mf-disp-row-lbl {
  fill: var(--mf-slate-700);
  font-size: 12.5px;
}
.mf-disp-row-lbl-total {
  fill: var(--mf-slate-900);
  font-size: 12.5px;
  font-weight: 600;
}
.mf-disp-stem {
  stroke: var(--mf-navy-600);
  stroke-width: 2;
}
.mf-disp-stem-total {
  stroke: var(--mf-purple-600);
  stroke-width: 2;
}
.mf-disp-reporte {
  stroke: var(--mf-slate-500);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}
.mf-disp-eje-lbl,
.mf-disp-unidad {
  fill: var(--mf-slate-600);
  font-size: 11.5px;
}
/* Rótulo de línea de criterio USP <711> (disolución): el color (fill) llega inline
   por criterio — color semántico compartido con el PNG del PDF, no un token. */
.mf-disp-crit-lbl {
  font-size: 11px;
  font-weight: 600;
}

/* Ecuación del caso USP <905> (uniformidad): fórmula con valores sustituidos del motor. */
.mf-ecuacion-caso {
  margin: 10px 0 4px;
  padding: 8px 12px;
  background: var(--mf-slate-50);
  border-left: 3px solid var(--mf-navy-600);
  border-radius: 0 6px 6px 0;
}
.mf-ecuacion-caso-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--mf-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}
.mf-ecuacion-caso-expr {
  font-family: var(--mf-font-mono, ui-monospace, monospace);
  font-size: 13px;
  color: var(--mf-slate-900);
  font-variant-numeric: tabular-nums;
}

/* Guía de etapas (stepper) — disolución S1/S2/S3, uniformidad L1/L2. */
.mf-guia {
  margin: 12px 0 4px;
}
.mf-guia-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}
.mf-guia-paso {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--mf-border);
}
.mf-guia-icono {
  font-weight: 700;
}
.mf-guia-cumplida {
  background: var(--mf-green-50);
  color: var(--mf-green-700);
  border-color: var(--mf-green-600);
}
.mf-guia-no_cumplida {
  background: var(--mf-red-50);
  color: var(--mf-red-700);
  border-color: var(--mf-red-600);
}
.mf-guia-pendiente {
  background: var(--mf-amber-50);
  color: var(--mf-amber-700);
  border-color: var(--mf-amber-600);
}
.mf-guia-futura {
  background: transparent;
  color: var(--mf-slate-400);
}
.mf-guia-texto {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
}
.mf-guia-texto-ok {
  background: var(--mf-green-50);
  border-left: 3px solid var(--mf-green-600);
  color: var(--mf-green-700);
}
.mf-guia-texto-warn {
  background: var(--mf-amber-50);
  border-left: 3px solid var(--mf-amber-600);
  color: var(--mf-amber-700);
}

/* ============================================================
   OVERRIDES DE RECURSOS (PR-6d)
   Clases propias del panel de autorizaciones de recursos.
   Solo agregan selectores nuevos: no pisan nada existente.
   ============================================================ */
.mf-ovr-aviso {
  border-left: 4px solid var(--mf-amber-600);
  background: var(--mf-amber-50);
}
.mf-ovr-aviso-titulo {
  font-size: 13px;
  font-weight: 600;
  color: var(--mf-amber-700);
  margin-bottom: 6px;
}
.mf-ovr-acciones {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ============================================================
   UTILIDADES DE ESPACIADO/DISPLAY (V-3 validación OQ)
   Genéricas a propósito — reemplazan `style="..."` inline en
   templates existentes cuando se los toca (convención del repo,
   ver CLAUDE.md "Design system / UI conventions").
   ============================================================ */
.mf-mt-24 {
  margin-top: 24px;
}
.mf-mb-8 {
  margin-bottom: 8px;
}
.mf-mb-12 {
  margin-bottom: 12px;
}
.mf-mb-16 {
  margin-bottom: 16px;
}
.mf-inline-block {
  display: inline-block;
}
.mf-inline {
  display: inline;
}

/* V-8 Bloque 9 (validación): mismo criterio que el bloque de arriba —
   generico, reemplaza `style="..."` inline en validacion/templates/. */
.mf-eyebrow {
  font-size: 11px;
  color: var(--mf-slate-500);
  font-family: var(--mf-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.mf-msg-error {
  font-size: 13px;
  color: var(--mf-red-700);
}
.mf-msg-ok {
  font-size: 13px;
  color: var(--mf-green-700);
}
