/* ============================================================
   Estilos propios de la plataforma (login, modales, formularios,
   edición en línea). Complementan dashboard.css sin modificarlo.
   ============================================================ */

/* ---------- Pantalla de acceso (estilo dashboard · ISO 9001) ---------- */
.login-screen[hidden], #app[hidden] { display: none; }
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 28px;
}
.login-shell {
  display: grid; grid-template-columns: 1.15fr 1fr;
  width: 100%; max-width: 1060px; min-height: 560px;
  background: #fff; border: 1px solid var(--border); border-top: 4px solid var(--corp);
  border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.login-left {
  background: #fbfcfe; border-right: 1px solid var(--border);
  color: var(--text); padding: 48px 50px 36px;
  display: flex; flex-direction: column;
}
.login-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.login-lockup { height: 76px; width: auto; display: block; max-width: 100%; }
.login-cert { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.login-cert img { height: 165px; width: auto; display: block; max-width: 100%; border-radius: 10px; box-shadow: var(--shadow-md); }
.login-cert-text strong { display: block; font-size: 14px; font-weight: 800; color: var(--text-strong); letter-spacing: -0.2px; }
.login-cert-text span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.login-brand-eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-muted); }
.login-brand-name { font-size: 17px; font-weight: 800; color: var(--text-strong); letter-spacing: -0.3px; margin-top: 2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.login-headline {
  font-size: 27px; line-height: 1.22; font-weight: 800; color: var(--text-strong);
  letter-spacing: -0.8px; margin: 44px 0 30px;
}
.login-points { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.login-points li { display: flex; align-items: flex-start; gap: 11px; font-size: 13px; color: var(--text); line-height: 1.5; }
.login-clause {
  flex-shrink: 0; margin-top: 1px; white-space: nowrap;
  background: var(--corp-soft); border: 1px solid #bfdbfe; color: var(--corp);
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.4px;
  padding: 3px 9px; border-radius: 999px; min-width: 58px; text-align: center;
}
.login-left-foot { margin-top: auto; padding-top: 30px; }
.login-stats {
  display: flex; gap: 20px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border); padding-top: 16px;
}
.login-stats strong { color: var(--text-strong); font-weight: 800; }
.login-left-legal { margin-top: 10px; font-size: 9px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase; color: var(--text-muted); }
.login-right {
  background: #fff; padding: 52px 50px 36px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-right h1 { font-size: 30px; font-weight: 800; color: var(--corp); letter-spacing: -0.8px; border-left: 4px solid #c01830; padding-left: 14px; }
.login-welcome { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; margin: 10px 0 26px; max-width: 380px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .form-input { padding: 12px 14px; font-size: 14px; border-radius: 10px; }
.btn-lg { padding: 13px 18px; font-size: 14px; border-radius: 10px; }
.login-error {
  display: none; background: var(--red-soft); color: var(--red); border: 1px solid #fecaca;
  border-radius: 8px; padding: 9px 12px; font-size: 12px; font-weight: 600;
}
.login-error.show { display: block; }
.login-help { margin-top: 18px; font-size: 12px; font-weight: 700; color: var(--primary); text-align: center; }
.login-foot {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted); text-align: center;
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; max-width: 460px; min-height: 0; }
  .login-left { display: none; }
  .login-right { padding: 44px 34px 32px; }
}

/* ---------- Formularios ---------- */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 11px; font-weight: 700; color: var(--text-strong); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea {
  font-family: inherit; font-size: 13px; color: var(--text-strong);
  background: #fff; border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.form-textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.form-hint { font-size: 11px; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 12.5px; font-weight: 700; letter-spacing: 0.1px;
  border-radius: 9px; padding: 9px 16px; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, box-shadow .15s, transform .1s; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; stroke-width: 2.4; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 8px -2px rgba(37, 99, 235, 0.45); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--slate-50); color: var(--text-strong); }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 11px; font-size: 11.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Header: usuario ---------- */
.user-badge {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px 6px 7px;
  box-shadow: var(--shadow); text-align: left;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--corp), var(--primary));
  color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.user-badge-name { font-size: 12px; font-weight: 700; color: var(--text-strong); line-height: 1.2; }
.user-badge-role { font-size: 10px; color: var(--text-muted); }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--slate-50); color: var(--text-strong); }
.icon-btn svg { width: 14px; height: 14px; stroke-width: 2.2; }

/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 18px 18px; overflow-y: auto; backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 520px; background: #fff; border-radius: 16px;
  box-shadow: 0 25px 60px -12px rgba(2, 6, 23, 0.5); overflow: hidden;
  animation: modal-in .18s ease-out;
}
.modal.modal-lg { max-width: 760px; }
.modal.modal-xl { max-width: 1000px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-h {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--border); background: var(--slate-50);
}
.modal-h .modal-title { flex: 1; font-size: 14px; font-weight: 800; color: var(--text-strong); letter-spacing: -0.2px; }
.modal-b { padding: 20px; display: flex; flex-direction: column; gap: 14px; max-height: 65vh; overflow-y: auto; }
.modal-f {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border); background: var(--slate-50);
}

/* ---------- Avisos (toast) ---------- */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px;
  background: #0f172a; color: #f1f5f9; font-size: 12.5px; font-weight: 600;
  border-radius: 11px; padding: 12px 16px; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease-out;
}
.toast.toast-error { background: #7f1d1d; color: #fee2e2; }
.toast.toast-success { background: #14532d; color: #dcfce7; }
.toast.toast-info { background: #1e3a8a; color: #dbeafe; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Edición en línea (FODA y Partes) ---------- */
.editable-item { position: relative; }
.item-actions {
  position: absolute; top: 6px; right: 6px; display: none; gap: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 7px;
  padding: 2px; box-shadow: var(--shadow-md);
}
.editable-item:hover .item-actions { display: inline-flex; }
.item-actions button {
  width: 22px; height: 22px; border: none; background: transparent; cursor: pointer;
  border-radius: 5px; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.item-actions button:hover { background: var(--slate-50); color: var(--primary-dark); }
.item-actions button.act-del:hover { background: var(--red-soft); color: var(--red); }
.item-actions svg { width: 12px; height: 12px; stroke-width: 2.4; }

.add-inline {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  font-family: inherit; font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  background: transparent; border: 1.5px dashed var(--border); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; width: 100%; justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
}
.add-inline:hover { color: var(--primary-dark); border-color: var(--primary); background: rgba(37, 99, 235, 0.04); }
.add-inline svg { width: 12px; height: 12px; stroke-width: 2.6; }

/* Barra de herramientas de vista (selector de análisis, acciones) */
.view-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.view-toolbar .spacer { flex: 1; }
.view-toolbar .form-select { width: auto; min-width: 220px; }

/* ---------- Matriz de permisos ---------- */
.perm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.perm-table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--border);
}
.perm-table th.center, .perm-table td.center { text-align: center; }
.perm-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.perm-table tr:last-child td { border-bottom: none; }
.perm-table .perm-section td {
  background: var(--slate-50); font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-muted); padding: 6px 10px;
}
.perm-table input[type="radio"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

/* ---------- Selectores de color e ícono ---------- */
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; border: 2px solid transparent;
  transition: transform .12s, border-color .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected { border-color: var(--text-strong); box-shadow: 0 0 0 2px #fff inset; }
.icon-pick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-pick {
  width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--border);
  background: #fff; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .12s, color .12s, background .12s;
}
.icon-pick:hover { border-color: var(--primary); color: var(--primary-dark); }
.icon-pick.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.icon-pick svg { width: 16px; height: 16px; stroke-width: 2; }

/* ---------- Estados vacíos ---------- */
.empty-state {
  text-align: center; padding: 42px 20px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state svg { width: 34px; height: 34px; stroke-width: 1.6; opacity: 0.5; }
.empty-state .empty-title { font-size: 13px; font-weight: 700; color: var(--text); }
.empty-state .empty-sub { font-size: 12px; max-width: 420px; }

/* ---------- Tablas con scroll ---------- */
.table-scroll { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: 10px; }
.table-scroll .data-table th { z-index: 2; }

/* ---------- Chips de estado ---------- */
.chip.chip-violet { background: #ede9fe; color: #6d28d9; }
.chip.chip-gray { background: #f1f5f9; color: #475569; }

/* Cursor por defecto en breadcrumbs clicables */
.breadcrumb a { cursor: pointer; }
.sidebar-link { -webkit-tap-highlight-color: transparent; }

/* Sección administración del sidebar */
.sb-bg-admin-usuarios { background: #1e3a8a; }
.sb-bg-admin-carga { background: #0369a1; }
.sb-bg-admin-actividad { background: #475569; }

/* ============================================================
   Refinamiento general (presentación en auditorías)
   ============================================================ */

/* Entrada suave de cada vista */
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.main-content > .view.active { animation: view-in 0.22s ease-out; }

/* Cabecera con acento corporativo más marcado */
.header { border-top-width: 4px; }
.header h1 { letter-spacing: -0.5px; }
.header-brand { display: flex; align-items: center; gap: 13px; }
.header-logo { width: 44px; height: 44px; display: block; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(15, 23, 42, .2)); }

/* Tarjetas y paneles: sombras más suaves y consistentes */
.panel { transition: box-shadow 0.18s; }
.ctx-card, .perf-card { cursor: pointer; }

/* Tablas: cabecera más definida y filas más respirables */
.data-table th { background: #f8fafc; }
.data-table td { line-height: 1.5; }

/* Scrollbars discretos (WebKit) */
.table-scroll::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .modal-b::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .modal-b::-webkit-scrollbar-thumb {
  background: #cbd5e1; border-radius: 99px; border: 2px solid transparent; background-clip: content-box;
}
.table-scroll::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track, .modal-b::-webkit-scrollbar-track { background: transparent; }

/* Selects y date inputs alineados con el resto del sistema */
.form-select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* Botones dentro de tablas: alineación vertical fina */
.data-table .icon-btn { vertical-align: middle; margin-left: 4px; }

/* ---------- Resumen de Desempeño: cifras del gráfico circular más grandes ---------- */
.dsp-resumen .dash-donut-num { font-size: 38px; }
.dsp-resumen .dash-donut-num span { font-size: 19px; }
.dsp-resumen .perf-aspect { padding: 11px 14px; }
.dsp-resumen .perf-aspect-label { font-size: 11px; }
.dsp-resumen .perf-aspect-name { font-size: 13.5px; }
.dsp-resumen .perf-aspect-val { font-size: 30px; }

/* ---------- Emisión de documentos controlados (7.5) ---------- */
.doc-emit-head { background: var(--corp-soft); border: 1px solid #bfdbfe; border-radius: 10px; padding: 11px 13px; }
.doc-emit-code {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; font-weight: 800; color: white; background: var(--corp);
  padding: 3px 10px; border-radius: 7px; margin-right: 9px;
}
.doc-emit-title { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.doc-emit-ver { font-size: 11.5px; color: var(--corp); margin-top: 7px; }
.doc-emit-user {
  font-size: 13px; font-weight: 700; color: var(--text-strong);
  background: var(--slate-50); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px;
}

/* Franja de estado documental del módulo: el estado es automático, se deriva
   de comparar el contenido de la plataforma con la última autorización. */
.doc-state {
  display: flex; align-items: center; gap: 12px; margin-top: 12px;
  padding: 11px 14px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--slate-50);
}
.doc-state .ds-ico { display: inline-flex; width: 30px; height: 30px; flex: 0 0 30px; align-items: center; justify-content: center; border-radius: 9px; background: white; border: 1px solid var(--border); color: var(--text-muted); }
.doc-state .ds-ico svg { width: 15px; height: 15px; }
.doc-state .ds-txt { flex: 1; font-size: 11.5px; color: var(--text-muted); line-height: 1.6; }
.doc-state .ds-title { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-strong); margin-bottom: 1px; }
.doc-state .btn { flex: 0 0 auto; }
.doc-state-ok { background: var(--green-soft); border-color: #bbf7d0; }
.doc-state-ok .ds-ico { color: var(--green); border-color: #bbf7d0; }
.doc-state-ok .ds-title { color: #166534; }
.doc-state-warn { background: var(--amber-soft); border-color: #fde68a; }
.doc-state-warn .ds-ico { color: #b45309; border-color: #fde68a; }
.doc-state-warn .ds-title { color: #92400e; }
.doc-state-wait { background: #f5f3ff; border-color: #ddd6fe; }
.doc-state-wait .ds-ico { color: #7c3aed; border-color: #ddd6fe; }
.doc-state-wait .ds-title { color: #6d28d9; }

/* Campana de notificaciones */
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: var(--red); color: white;
  font-size: 9px; font-weight: 800; display: inline-flex; align-items: center;
  justify-content: center; border: 2px solid white; line-height: 1;
}
.notif-item { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: white; }
.notif-item.unread { background: var(--primary-soft); border-color: #bfdbfe; }
.notif-item .n-ico { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--slate-50); border: 1px solid var(--border); color: var(--text-muted); }
.notif-item .n-ico svg { width: 13px; height: 13px; }
.notif-item .n-title { font-size: 11.5px; font-weight: 800; color: var(--text-strong); }
.notif-item .n-detail { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 2px; }
.notif-item .n-date { font-size: 9.5px; color: var(--text-muted); margin-top: 3px; }

/* Checklist de requisitos de contraseña */
.pass-check { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.pass-check .pc-rule { font-size: 10.5px; color: var(--text-muted); }
.pass-check .pc-rule.ok { color: var(--green); font-weight: 700; }

/* ============================================================
   Matriz de cumplimiento: indicadores × sucursales
   ============================================================ */
/* Sin desplazamiento horizontal: la tabla reparte el ancho disponible
   (layout fijo) y solo se desplaza en vertical si hay muchas filas. */
.mx-wrap { overflow-x: hidden; overflow-y: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: 10px; }
.mx-table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-size: 11px; }
.mx-table th, .mx-table td { border-bottom: 1px solid var(--border); padding: 5px 4px; overflow: hidden; }

/* Encabezados fijos */
.mx-table thead th {
  position: sticky; top: 0; z-index: 3; background: #f8fafc;
  border-bottom: 2px solid var(--border); vertical-align: bottom;
}
.mx-ind-head, .mx-table td.mx-ind {
  position: sticky; left: 0; z-index: 2; background: #ffffff;
  width: 236px; text-align: left; padding-left: 9px;
  border-right: 2px solid var(--border);
}
.mx-ind-head { z-index: 4; background: #f8fafc; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.mx-suc-head { text-align: center; }
.mx-suc-code { display: block; font-size: 10.5px; font-weight: 800; color: var(--text-strong); }
.mx-suc-name { display: block; font-size: 8px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-pct-head { width: 52px; text-align: center; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); background: #eef4ff !important; border-left: 2px solid var(--border); }

/* Celda de indicador */
.mx-ind-name { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-strong); line-height: 1.35; }
.mx-ind-code { display: inline-block; font-size: 9px; font-weight: 800; color: var(--text-muted); background: var(--slate-50); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 5px; vertical-align: 1px; }
.mx-ind-meta { display: block; font-size: 9.5px; color: var(--text-muted); margin-top: 1px; }

/* Celdas de cumplimiento */
.mx-cell { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mx-mark { display: block; font-size: 12px; font-weight: 800; line-height: 1.1; }
.mx-val { display: block; font-size: 8px; opacity: .8; }
/* Modo compacto: solo ✓/✗ (los valores quedan en el tooltip) */
.mx-table.mx-compact .mx-val { display: none; }
.mx-table.mx-compact .mx-mark { font-size: 13px; }
.mx-table.mx-compact th, .mx-table.mx-compact td { padding: 6px 3px; }
.mx-ok { background: #f0fdf4; color: #15803d; }
.mx-no { background: #fef2f2; color: #b91c1c; }
.mx-na { background: var(--slate-50); color: #cbd5e1; font-weight: 700; }
.mx-pct { text-align: center; font-weight: 800; font-size: 11.5px; background: #f8fbff; border-left: 2px solid var(--border); font-variant-numeric: tabular-nums; }

/* Fila de proceso */
.mx-group td { background: #eef4ff; border-bottom: 1px solid #bfdbfe; }
.mx-group td.mx-ind { background: #e5edfd !important; font-size: 11.5px; font-weight: 800; color: var(--corp); text-transform: uppercase; letter-spacing: .3px; }
.mx-group-n { font-weight: 700; color: var(--primary); text-transform: none; letter-spacing: 0; }
.mx-group-cell, .mx-group-pct { font-weight: 800; font-size: 11px; }
.mx-table tbody tr:not(.mx-group):hover td { background: #fffbeb; }
.mx-table tbody tr:not(.mx-group):hover td.mx-ind { background: #fffbeb !important; }

/* Pie: cumplimiento por sucursal */
.mx-table tfoot td { position: sticky; bottom: 0; z-index: 3; background: #f1f5f9; border-top: 2px solid var(--border); border-bottom: none; }
.mx-table tfoot td.mx-ind { z-index: 4; background: #e2e8f0 !important; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--text-strong); }
.mx-foot-cell, .mx-global { font-weight: 800; font-size: 12px; }

.mx-legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 10px 2px 2px; font-size: 10.5px; color: var(--text-muted); }
.mx-key { display: inline-flex; width: 17px; height: 17px; border-radius: 4px; align-items: center; justify-content: center; font-weight: 800; font-size: 10px; margin-right: 4px; vertical-align: -4px; }

/* ============================================================
   Herramientas de análisis de causa (Riesgos y NC)
   ============================================================ */

/* ---------- 5 ¿Por qué?: cadena visual hacia la causa raíz ---------- */
.p5-chain { display: flex; flex-direction: column; }
.p5-step {
  display: flex; gap: 12px; align-items: flex-start;
  background: white; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; box-shadow: var(--shadow);
}
.p5-num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--corp));
  color: white; font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 5px -1px rgba(37, 99, 235, .5);
}
.p5-label { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--primary); }
.p5-text { font-size: 12.5px; color: var(--text); line-height: 1.5; margin-top: 2px; }
.p5-connector { position: relative; display: flex; flex-direction: column; align-items: center; height: 30px; margin: 2px 0; }
.p5-connector::before { content: ''; width: 2px; flex: 1; background: linear-gradient(var(--primary), var(--indigo)); }
.p5-connector::after { content: ''; border: 5px solid transparent; border-top-color: var(--indigo); margin-top: -1px; }
.p5-conn-q {
  position: absolute; top: 50%; left: 50%; transform: translate(16px, -50%);
  font-size: 8.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--indigo); background: var(--indigo-soft); padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.p5-step.p5-root { background: linear-gradient(135deg, #fef2f2, #ffffff); border-color: #fecaca; border-left: 4px solid var(--red); }
.p5-root .p5-num { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 2px 6px -1px rgba(220, 38, 38, .5); }
.p5-root .p5-label { color: var(--red); }
.p5-root .p5-text { color: #7f1d1d; font-weight: 600; }
.p5-root-badge {
  display: inline-block; font-size: 8.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: white; background: var(--red); padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1px;
}

/* ---------- Ishikawa: diagrama de espina de pescado (6M) ---------- */
.fishbone { overflow-x: auto; }
.fishbone-in { min-width: 620px; display: flex; flex-direction: column; }
.fb-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-right: 164px; }
.fb-branch { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.fb-bone { width: 3px; height: 20px; border-radius: 2px; flex-shrink: 0; }
.fb-top .fb-bone { transform: skewX(-26deg); }
.fb-bottom .fb-bone { transform: skewX(26deg); }
.fb-cat {
  width: 100%; background: white; border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 10px; box-shadow: var(--shadow); border-top-width: 3px; border-top-style: solid;
}
.fb-bottom .fb-cat { border-top-width: 1px; border-top-style: solid; border-top-color: var(--border); border-bottom-width: 3px; border-bottom-style: solid; }
.fb-cat-name { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.fb-cat-name .fb-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.fb-cause { font-size: 10.5px; color: var(--text); line-height: 1.4; padding: 2px 0; display: flex; gap: 5px; }
.fb-cause::before { content: '‣'; flex-shrink: 0; opacity: .55; }
.fb-cat.fb-empty { border-style: dashed; background: var(--slate-50); box-shadow: none; opacity: .8; }
.fb-cat.fb-empty .fb-none { font-size: 10px; color: var(--text-muted); font-style: italic; }
.fb-spine { display: flex; align-items: center; }
.fb-spine-tail { width: 9px; height: 9px; border-radius: 50%; background: var(--indigo); flex-shrink: 0; }
.fb-spine-line { flex: 1; height: 3px; border-radius: 2px; background: linear-gradient(90deg, #c7d2fe, var(--indigo)); }
.fb-spine-arrow { border: 8px solid transparent; border-left: 11px solid var(--indigo); border-right: 0; flex-shrink: 0; }
.fb-head {
  width: 145px; flex-shrink: 0; margin-left: 6px;
  background: linear-gradient(135deg, #ef4444, #b91c1c); color: white;
  border-radius: 10px; padding: 8px 11px; box-shadow: 0 3px 8px -2px rgba(220, 38, 38, .45);
}
.fb-head-label { font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; opacity: .85; display: block; }
.fb-head-text { font-size: 10.5px; font-weight: 700; line-height: 1.35; margin-top: 2px; }
.fb-caption { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* ---------- Pareto: gráfico de barras + curva acumulada ---------- */
.pareto-chart { background: white; border: 1px solid var(--border); border-radius: 9px; padding: 10px 8px 4px; box-shadow: var(--shadow); }
.pareto-legend-keys { display: flex; gap: 14px; justify-content: center; font-size: 9.5px; color: var(--text-muted); padding: 2px 0 8px; flex-wrap: wrap; }
.pareto-legend-keys .pk { display: inline-flex; align-items: center; gap: 5px; }
.pareto-legend-keys .pk-bar { width: 11px; height: 11px; border-radius: 3px; }
.pareto-legend-keys .pk-line { width: 16px; height: 2.5px; border-radius: 2px; background: #312e81; position: relative; }
.pareto-rows { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.pareto-row { display: flex; gap: 8px; align-items: baseline; font-size: 11px; line-height: 1.4; }
.pareto-row .pr-code {
  flex-shrink: 0; width: 26px; text-align: center; font-size: 9.5px; font-weight: 800;
  border-radius: 5px; padding: 1px 0;
}
.pareto-row .pr-name { flex: 1; min-width: 0; font-weight: 600; color: var(--text-strong); }
.pareto-row .pr-stats { flex-shrink: 0; font-size: 10px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Impresión: informe limpio para auditorías */
@media print {
  .sidebar, .header-meta, .view-toolbar, .item-actions, .add-inline, .icon-btn,
  .breadcrumb, #toast-root, #modal-root { display: none !important; }
  .app-body { grid-template-columns: 1fr; }
  .header { position: static; box-shadow: none; }
  .main-content { padding: 10px 0; }
  .panel, .ctx-card, .perf-card, .module { box-shadow: none !important; break-inside: avoid; }
  body { background: #fff; }
}

/* ---------- Desempeño · tabla de indicadores ---------- */
/* Misma tabla en la pestaña Indicadores y en el detalle de cada sucursal:
   filas más compactas y celdas que envuelven sin desbordar su columna. */
.dsp-ind-table th { padding: 9px 12px; }
.dsp-ind-table td { padding: 9px 12px; }
.dsp-ind-table td, .dsp-ind-table th { overflow-wrap: break-word; }
.dsp-ind-table .code { white-space: nowrap; }

/* ---------- Causa raíz · vista ampliada ---------- */
/* El mismo contenido de la herramienta (5 porqués, Ishikawa, Pareto) en un
   modal ancho y con tipografías mayores para analizarlo con calma. */
.causa-zoom { padding: 4px 2px; }
.causa-zoom .p5-text { font-size: 14px; line-height: 1.6; }
.causa-zoom .p5-label { font-size: 11px; }
.causa-zoom .fb-cause { font-size: 12.5px; line-height: 1.5; }
.causa-zoom .fb-cat-name { font-size: 11px; }
.causa-zoom .fb-head-text { font-size: 13px; }
.causa-zoom .fb-caption { font-size: 11px; }
.causa-zoom .pareto-chart svg { width: 100%; height: auto; }
.causa-zoom .pareto-row .pr-name { font-size: 12.5px; }
.causa-zoom .pareto-row .pr-stats { font-size: 11.5px; }
