/* ==========================================================================
   VARIABLES Y TEMA VISUAL FULL PIZZA MULTI-TEMPLATE
   ========================================================================== */
:root {
  --fp-yellow: #f59e0b;
  --fp-yellow-hover: #d97706;
  --fp-yellow-light: #fffbeb;
  --fp-yellow-badge: #fef3c7;
  --fp-yellow-border: #fcd34d;

  --fp-dark: #18181b;
  --fp-dark-hover: #27272a;
  --fp-slate: #3f3f46;
  
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;

  /* Estados de Cumplimiento Inspection UI */
  --pass-green: #10b981;
  --pass-green-dark: #065f46;
  --pass-green-bg: #ecfdf5;
  --pass-green-border: #6ee7b7;

  --fail-red: #ef4444;
  --fail-red-dark: #991b1b;
  --fail-red-bg: #fef2f2;
  --fail-red-border: #fca5a5;

  --na-slate: #64748b;
  --na-slate-bg: #f1f5f9;
  --na-slate-border: #cbd5e1;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 4px 12px -2px rgba(24, 24, 27, 0.06), 0 2px 6px -1px rgba(24, 24, 27, 0.03);
  --shadow-hover: 0 12px 24px -4px rgba(24, 24, 27, 0.1), 0 4px 8px -2px rgba(24, 24, 27, 0.04);
  --shadow-sticky: 0 -4px 16px rgba(0, 0, 0, 0.08);

  --transition-base: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  letter-spacing: -0.01em;
}

/* Franja Ajedrezada Full Pizza */
.checker-pattern-bar {
  height: 6px;
  width: 100%;
  background-image: 
    linear-gradient(45deg, #18181b 25%, transparent 25%), 
    linear-gradient(-45deg, #18181b 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #18181b 75%), 
    linear-gradient(-45deg, transparent 75%, #18181b 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
  background-color: #fbbf24;
}

.app-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
  flex: 1;
}

/* Vistas SPA */
.spa-view {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.spa-view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: viewSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes viewSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Navbar Global */
.main-navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 45;
  box-shadow: var(--shadow-subtle);
}

.navbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo-img {
  height: 42px;
  width: auto;
  object-fit: contain;
  display: block;
}

.brand-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--fp-yellow-badge);
  color: #92400e;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--fp-yellow-border);
  display: none;
}

@media (min-width: 640px) {
  .brand-pill { display: inline-block; }
}

.auditor-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-alt);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.auditor-avatar {
  width: 26px;
  height: 26px;
  background: var(--fp-dark);
  color: #ffffff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.auditor-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.auditor-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.auditor-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Botones UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition-base);
  min-height: 44px;
}

.btn-fp-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28);
}

.btn-fp-gold:hover {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.38);
}

.btn-fp-dark {
  background-color: var(--fp-dark);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(24, 24, 27, 0.2);
}

.btn-fp-dark:hover {
  background-color: var(--fp-dark-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-subtle);
}

.btn-secondary:hover {
  background-color: var(--bg-card-alt);
  border-color: var(--text-light);
}

.btn-danger-outline {
  background-color: #ffffff;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn-danger-outline:hover {
  background-color: #fef2f2;
  border-color: #f87171;
}

.btn-outline-excel {
  background-color: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  min-height: 36px;
  box-shadow: none;
}

.btn-outline-excel:hover {
  background-color: var(--bg-card-alt);
  color: #15803d;
  border-color: #86efac;
}

/* Badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chip-gold { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #78350f; border: 1px solid #d97706; }
.chip-success { background: var(--pass-green-bg); color: var(--pass-green-dark); border: 1px solid var(--pass-green-border); }
.chip-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.chip-danger { background: var(--fail-red-bg); color: var(--fail-red-dark); border: 1px solid var(--fail-red-border); }

/* Estado de la auditoría en el historial: una sola línea, punto de
   color + nombre corto (el nombre completo va en el title). */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-oro { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.status-bueno { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.status-accion { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.status-intervencion { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.status-critica { background: #b91c1c; color: #ffffff; border-color: #991b1b; }

/* Badges de Plantilla */
.template-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.tpl-360 { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.tpl-weekend { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.tpl-cea { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.tpl-mercancia { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

/* BANNER DE BORRADOR RECUPERADO */
.draft-recovery-banner {
  display: none;
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
  animation: fadeInView 0.3s ease-out forwards;
}

.draft-recovery-banner.active { display: flex; }

.draft-text-content {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: #92400e;
}

.draft-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-draft-resume {
  background: #d97706;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.btn-draft-resume:hover { background: #b45309; }

.btn-draft-discard {
  background: transparent;
  color: #b45309;
  border: 1px solid #fcd34d;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-draft-discard:hover { background: #fde68a; }

/* ==========================================================================
   MODAL DE SELECCIÓN DE PLANTILLA DE AUDITORÍA
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeInOverlay 0.25s ease-out forwards;
}

.modal-overlay.open { display: flex; }

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-window {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: zoomModal 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes zoomModal {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.btn-close-modal { flex-shrink: 0; }

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--fp-dark);
  letter-spacing: -0.02em;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
}

.btn-close-modal:hover { color: var(--fp-dark); background: var(--bg-card-alt); }

.modal-body {
  padding: 22px 22px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.template-selection-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  transition: all var(--transition-base);
  background: #ffffff;
  position: relative;
}

.template-selection-card:hover {
  border-color: var(--fp-yellow);
  background: #fffdfa;
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.tpl-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.tpl-card-content { flex: 1; }

.tpl-card-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 8px;
}

.tpl-card-top-row .template-badge { margin-top: 2px; }

.tpl-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--fp-dark);
}

.tpl-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.tpl-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ==========================================================================
   VISTA 1: DASHBOARD
   ========================================================================== */
.dashboard-view {
  padding: 24px 0 60px;
}

.dashboard-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .dashboard-hero {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.hero-title-group h1 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--fp-dark);
  letter-spacing: -0.03em;
}

.hero-title-group p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.hero-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.hero-buttons .btn { width: 100%; }

@media (min-width: 640px) {
  .hero-buttons {
    flex-direction: row;
    align-items: center;
    width: auto;
  }
  .hero-buttons .btn { width: auto; }
}

/* KPIs */
.kpi-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .kpi-container { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .kpi-container { grid-template-columns: repeat(3, 1fr); }
}

.kpi-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.kpi-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.kpi-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-color);
}

.kpi-box.kpi-gold::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kpi-box.kpi-dark::before { background: var(--fp-dark); }
.kpi-box.kpi-red::before { background: var(--fail-red); }

.kpi-header-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.kpi-main-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--fp-dark);
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.kpi-foot-detail {
  margin-top: 10px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-icon-bubble {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Filtros del panel */
.dash-filters {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

.dash-filters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

@media (min-width: 900px) {
  .dash-filters-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

.dash-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.dash-filter[hidden] { display: none; }

.dash-filter > span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.dash-filter select,
.dash-filter input {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card-alt);
  color: var(--text-main);
  font: inherit;
  font-size: 0.86rem;
}

.dash-filter select:focus,
.dash-filter input:focus {
  outline: none;
  border-color: var(--fp-yellow);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.dash-filters-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
}

.dash-filters-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-link-clear {
  background: none;
  border: none;
  padding: 4px 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fp-yellow-hover);
  cursor: pointer;
}

.btn-link-clear:hover { text-decoration: underline; }

/* MÓDULO DE RANKING DE LOCALES */
.benchmark-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.benchmark-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .benchmark-header { flex-direction: column; align-items: flex-start; }
}

.benchmark-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--fp-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}












.ranking-missing {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ranking-missing strong { color: var(--fp-slate); }

.ranking-empty {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* Análisis (pestañas Calidad, Seguimiento y Auditores) */
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

@media (min-width: 1024px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-card.an-wide { grid-column: 1 / -1; }
}

.an-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  min-width: 0;
}

.an-card h4 {
  margin: 0 0 2px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--fp-dark);
}

.an-hint {
  margin: 0 0 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.an-empty {
  margin: 6px 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.an-chart { width: 100%; height: auto; display: block; }
.an-grid { stroke: var(--border-color); stroke-width: 1; }
.an-guide { stroke: var(--fp-yellow); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.an-axis { font-size: 11px; fill: var(--text-muted); }
.an-line { fill: none; stroke: var(--fp-dark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.an-point { fill: var(--fp-dark); stroke: var(--bg-card-alt); stroke-width: 2; }
.an-hit { fill: transparent; cursor: pointer; }
.an-dot:hover .an-point { fill: var(--fp-yellow-hover); }

.an-group + .an-group { margin-top: 14px; }

.an-group-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.an-bar-row { padding: 5px 0; }
.an-bar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 0.8rem; margin-bottom: 4px; }
.an-bar-label { color: var(--text-main); }
.an-bar-value { font-weight: 800; color: var(--text-main); white-space: nowrap; }
.an-bar-track { display: block; height: 8px; background: var(--border-color); border-radius: 4px; overflow: hidden; }
.an-bar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }

.an-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.an-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 6px;
  border-bottom: 1px solid var(--border-color);
}

.an-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  color: var(--text-main);
}

.an-table tr:last-child td { border-bottom: none; }
.an-item-title { margin-top: 3px; font-weight: 600; line-height: 1.3; }
.an-item-sub { font-size: 0.72rem; color: var(--text-muted); }
.an-crit { font-size: 0.75rem; }
.an-up { color: #15803d; font-weight: 700; }
.an-down { color: var(--fail-red-dark); font-weight: 700; }

.an-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.an-kpis > div {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.an-kpis strong { font-size: 1.2rem; color: var(--fp-dark); }
.an-kpis span { font-size: 0.7rem; color: var(--text-muted); line-height: 1.3; }
.an-kpis .an-alert strong { color: var(--fail-red-dark); }

/* Tabla Historial */
.audits-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.audits-panel-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #ffffff;
}

.panel-head-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .panel-head-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.panel-title-wrap h2 {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--fp-dark);
}

.panel-title-wrap p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.panel-controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
}

.search-box-wrap input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  font-size: 0.86rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-base);
}

.search-box-wrap input:focus {
  border-color: var(--fp-yellow);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.search-lens-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* Filtros Rápidos */
.filter-tabs-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  /* Insinúa que hay más pestañas fuera de pantalla (ej. "Fin de
     Semana" se corta en mobile) sin depender de JS — se desvanece
     el borde derecho siempre, sin importar la posición de scroll. */
  mask-image: linear-gradient(to right, black calc(100% - 28px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent 100%);
}

.filter-tab-btn {
  background: var(--bg-card-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-base);
}

.filter-tab-btn:hover { background: #e2e8f0; color: var(--fp-dark); }
.filter-tab-btn.active { background: var(--fp-dark); color: #ffffff; border-color: var(--fp-dark); }

.table-scroll-wrap {
  width: 100%;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.history-table th {
  background-color: #fafbfc;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.history-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.92rem;
  vertical-align: middle;
}

.history-table tbody tr:hover { background-color: #fafaf9; }

.sucursal-name {
  font-weight: 700;
  color: var(--fp-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sucursal-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 24px;
}

.score-meter-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-bar-mini {
  width: 80px;
  height: 8px;
  background: #e4e4e7;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

@media (max-width: 680px) {
  .history-table thead { display: none; }
  .history-table, .history-table tbody, .history-table tr, .history-table td {
    display: block;
    width: 100%;
  }
  .history-table tr {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
  }
  .history-table td {
    padding: 6px 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .history-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  .history-table td[data-label="Sucursal"] {
    display: block;
    margin-bottom: 8px;
  }
  .history-table td[data-label="Sucursal"]::before { display: none; }
  .sucursal-sub { margin-left: 0; }
}

.reset-demo-wrap {
  text-align: center;
  margin-top: 18px;
}

.btn-reset-demo {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-decoration: underline;
  cursor: pointer;
}

.btn-reset-demo:hover { color: #ef4444; }

/* ==========================================================================
   VISTA 2: AUDITORÍA (INSPECTION APP DINÁMICA POR PLANTILLA)
   ========================================================================== */
.audit-view { padding: 0 0 120px; }

/* Sticky Bar */
.audit-top-bar {
  position: sticky;
  top: 62px;
  z-index: 35;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  margin: 0 -16px 20px;
  padding: 12px 16px 14px;
  box-shadow: var(--shadow-subtle);
}

.audit-top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.btn-return {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-base);
}

.btn-return:hover { background: var(--bg-card-alt); color: var(--fp-dark); }

.top-meta-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-badge-active {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #fcd34d;
  font-variant-numeric: tabular-nums;
}

.timer-dot-blink {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulseBlink 1s infinite;
}

@keyframes pulseBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Barra de Progreso Dinámica */
.audit-progress-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.progress-count-text { color: var(--text-muted); }
.progress-score-badge { font-size: 1rem; font-weight: 800; color: #d97706; white-space: nowrap; }

@media (max-width: 420px) {
  .progress-info-row { flex-direction: column; align-items: flex-start; gap: 2px; }
}

.progress-track-styled {
  width: 100%;
  height: 10px;
  background: #e4e4e7;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-active {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Selector de Sucursal y Auditor */
.audit-meta-banner {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}

.audit-inputs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .audit-inputs-grid { grid-template-columns: 1.2fr 1fr; }
}

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fp-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-select, .input-text {
  width: 100%;
  padding: 11px 14px;
  font-size: 0.92rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  min-height: 46px;
}

.input-select:focus, .input-text:focus {
  border-color: var(--fp-yellow);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

/* Fieldsets dinámicos */
.qsr-fieldset {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 18px 12px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
  /* Los <fieldset> tienen un min-width implícito basado en su
     contenido (un default histórico de los navegadores) que ignora
     width:100% en los hijos y rompe el scroll horizontal de tablas
     anchas como el Kardex. min-width:0 lo desactiva. */
  min-width: 0;
}

.qsr-fieldset legend {
  float: none;
  width: auto;
  padding: 6px 14px;
  background: var(--fp-dark);
  color: #ffffff;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.checklist-rows {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Kardex de Inventario (Adm. Mercancía) */
.kardex-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 14px;
  min-width: 780px;
}

.kardex-table th {
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.kardex-table td {
  padding: 6px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

/* Columna de insumo fija: en mobile la tabla se desplaza horizontalmente
   (7 campos + teórico + diferencia no caben en pantalla), pero el
   nombre del insumo debe seguir visible sin importar cuánto se
   desplace el auditor hacia la derecha. */
.kardex-table th:first-child,
.kardex-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-card);
  box-shadow: 2px 0 5px rgba(24, 24, 27, 0.06);
  /* Ancho acotado a propósito: algunos nombres de insumo son largos
     ("PALETA DE CHOCOLATE BLANCO CON GALLETA...") y sin tope la
     columna fija crecía hasta ocupar casi toda la pantalla en
     mobile, dejando sin espacio visible al resto de la tabla. Con
     un ancho fijo + wrap de texto, la columna ocupa siempre lo
     mismo sin importar el nombre. */
  width: 132px;
  max-width: 132px;
}

.kardex-table th:first-child { z-index: 2; background: var(--bg-card-alt); }

.kardex-row.state-exceeds td:first-child { background: var(--fail-red-bg); }

.kardex-product-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fp-dark);
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  padding-right: 6px;
}

.kardex-product-unit {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kardex-input {
  width: 84px;
  padding: 7px 8px;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: right;
  outline: none;
}

.kardex-input:focus {
  border-color: var(--fp-yellow);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.kardex-theoretical, .kardex-difference {
  font-size: 0.9rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
  padding-right: 10px;
}

.kardex-row.state-ok .kardex-difference { color: var(--pass-green-dark); }
.kardex-row.state-exceeds .kardex-difference { color: var(--fail-red-dark); }
.kardex-row.state-exceeds { background: var(--fail-red-bg); }

@media (max-width: 640px) {
  .kardex-table { min-width: 640px; }
  .kardex-input { width: 60px; padding: 6px; font-size: 0.8rem; }
  .kardex-table th, .kardex-table td { padding: 6px 5px; }
  .kardex-table th:first-child, .kardex-table td:first-child { width: 104px; max-width: 104px; }
  .kardex-product-name { font-size: 0.76rem; }
}

.kardex-empty-state {
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  font-style: italic;
}

/* Ítem de Inspección */
.inspection-item-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  transition: all var(--transition-base);
  overflow: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.inspection-item-card.state-pass {
  border-color: var(--pass-green);
  background: #fbfdfc;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
}

.inspection-item-card.state-fail {
  border-color: var(--fail-red);
  background: #fffafa;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.08);
}

.inspection-item-card.state-na {
  border-color: var(--na-slate);
  background: #f8fafc;
}

.item-header-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-badge-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.item-badge-index {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-knockout-critical {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Criticidad del punto (Supervisión 360 V2.1) — informa el peso en el
   puntaje; no es knockout, por eso va más sobria que el badge de arriba. */
.badge-criticality {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.badge-criticality-crit { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-criticality-major { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-criticality-minor { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

.item-question-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--fp-dark);
  line-height: 1.35;
}

.item-question-guide {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.knockout-warning-pill {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #991b1b;
  font-size: 0.8rem;
  font-weight: 700;
  align-items: center;
  gap: 6px;
}

.knockout-warning-pill.visible { display: flex; }

/* Botonera Segmentada */
.segmented-compliance-control {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

@media (max-width: 480px) {
  .segmented-compliance-control {
    grid-template-columns: 1fr 1fr 65px;
    gap: 6px;
  }
}

.segmented-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.segmented-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.segmented-pill {
  width: 100%;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  transition: all var(--transition-base);
}

.segmented-option.btn-pass:hover .segmented-pill { background: rgba(16, 185, 129, 0.1); color: var(--pass-green-dark); }
.segmented-option.btn-pass input:checked ~ .segmented-pill {
  background: #ffffff;
  color: var(--pass-green-dark);
  border: 2px solid var(--pass-green);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}

.segmented-option.btn-fail:hover .segmented-pill { background: rgba(239, 68, 68, 0.1); color: var(--fail-red-dark); }
.segmented-option.btn-fail input:checked ~ .segmented-pill {
  background: #ffffff;
  color: var(--fail-red-dark);
  border: 2px solid var(--fail-red);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}

.segmented-option.btn-na:hover .segmented-pill { background: rgba(100, 116, 139, 0.1); color: var(--fp-dark); }
.segmented-option.btn-na input:checked ~ .segmented-pill {
  background: #ffffff;
  color: var(--fp-dark);
  border: 2px solid var(--na-slate);
  box-shadow: 0 2px 6px rgba(100, 116, 139, 0.15);
}

/* Acordeón de No Conformidades */
.item-observations-accordion {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  background: #fffefb;
  border-top: 1px dashed transparent;
  transition: max-height 0.4s ease, opacity 0.35s ease, padding 0.4s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-observations-accordion.open {
  max-height: 520px;
  opacity: 1;
  padding: 14px 0 0;
  border-top: 1px dashed #fcd34d;
}

.obs-tag-prompt {
  font-size: 0.84rem;
  font-weight: 800;
  color: #b45309;
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-obs-input {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-base);
}

.item-obs-input:focus {
  border-color: var(--fp-yellow);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

/* Grid de Plan de Acción */
.action-plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px;
}

@media (min-width: 640px) {
  .action-plan-grid { grid-template-columns: 1fr 1fr 1.2fr; }
}

.action-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-field label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.action-field select, .action-field input {
  padding: 8px 10px;
  font-size: 0.84rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
}

.obs-evidence-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-photo-tool {
  background: #ffffff;
  color: var(--fp-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-base);
}

.btn-photo-tool:hover { background: #f1f5f9; border-color: var(--fp-dark); }

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.photo-gallery:empty { margin-top: 0; }

.photo-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  flex-shrink: 0;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.btn-remove-photo-x, .btn-remove-evidence-x {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: none;
  width: 20px;
  height: 20px;
  font-size: 11px;
  line-height: 1;
  border-radius: 0 0 0 6px;
  cursor: pointer;
}

.evidence-section-wrap { display: contents; }

.evidence-category-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.evidence-category-header strong {
  font-size: 0.94rem;
  color: var(--fp-dark);
}

.evidence-category-hint {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: #64748b;
}

/* Dock Flotante Inferior */
.audit-dock-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  padding: 14px 16px;
  z-index: 40;
  box-shadow: var(--shadow-sticky);
}

.audit-dock-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dock-summary-info {
  display: flex;
  flex-direction: column;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.dock-summary-info strong { font-size: 1.05rem; color: var(--fp-dark); }

/* ==========================================================================
   VISTA 3: COMPLETADO
   ========================================================================== */
.completed-view {
  padding: 30px 0 70px;
}

/* .spa-view.active ya pone display:block (misma especificidad que la
   regla de arriba en .spa-view), pero esta vista necesita flex para
   centrar el pliego del reporte — de ahí el selector compuesto, en vez
   de "display: flex" suelto en .completed-view, que ganaría siempre
   por venir después en la hoja de estilos y dejaría este reporte
   ocupando espacio en el layout aunque no estuviera activo. */
.completed-view.active {
  display: flex;
  justify-content: center;
}

.report-wrap {
  width: 100%;
  max-width: 780px;
}

.sheet-checker-strip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background-image: 
    linear-gradient(45deg, #18181b 25%, transparent 25%), 
    linear-gradient(-45deg, #18181b 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #18181b 75%), 
    linear-gradient(-45deg, transparent 75%, #18181b 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
  background-color: #fbbf24;
}

.btn-clear-sig {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.btn-clear-sig:hover { color: #ef4444; }

.signature-canvas-element {
  width: 100%;
  height: 110px;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  touch-action: none;
}

.signature-img-rendered {
  width: 100%;
  height: 110px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
}

/* Botones Vista Completado */
.completed-btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .completed-btn-group { flex-direction: row; }
  .completed-btn-group .btn { flex: 1; }
}

/* Toast */
.toast-tray {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  background: var(--fp-dark);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
  pointer-events: auto;
  border-left: 4px solid var(--fp-yellow);
}

.toast-item.show { opacity: 1; transform: translateY(0); }

/* ==========================================================================
   INFORME EJECUTIVO (vista en pantalla — mismo formato que el PDF)
   ========================================================================== */
.rp-sheet {
  position: relative;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 32px 18px 20px;
  margin-bottom: 24px;
  color: #27272a;
  font-size: 0.86rem;
}

@media (min-width: 640px) {
  .rp-sheet { padding: 40px 40px 24px; }
}

.rp-letterhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2.5px solid var(--fp-yellow);
}

.rp-logo { height: 52px; width: auto; flex-shrink: 0; }

.rp-letterhead-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 2px;
}

.rp-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b45309;
}

.rp-letterhead-text h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--fp-dark);
  line-height: 1.2;
}

.rp-meta { font-size: 0.74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.rp-visit {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  margin: 0 0 22px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

@media (min-width: 640px) {
  .rp-visit { grid-template-columns: repeat(4, 1fr); }
}

.rp-visit dt {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.rp-visit dd { margin: 0; font-weight: 700; color: var(--fp-dark); }
.rp-visit dd.rp-sub { font-weight: 400; font-size: 0.78rem; color: var(--text-muted); }

.rp-section { margin-bottom: 26px; }

.rp-section-title {
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 4px solid var(--fp-yellow);
  font-size: 1rem;
  font-weight: 800;
  color: var(--fp-dark);
}

.rp-subtitle {
  margin: 20px 0 8px;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--fp-dark);
}

.rp-note { margin: -4px 0 8px; font-size: 0.74rem; color: var(--text-muted); }

/* Resumen ejecutivo */
.rp-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 640px) {
  .rp-summary { flex-direction: row; align-items: stretch; }
}

.rp-result {
  --lvl: #b45309;
  flex-shrink: 0;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px 16px;
  border: 2px solid var(--lvl);
  border-radius: var(--radius-sm);
  text-align: center;
}

.rp-level-oro { --lvl: #a16207; }
.rp-level-bueno { --lvl: #0f766e; }
.rp-level-accion { --lvl: #b45309; }
.rp-level-intervencion, .rp-level-critica { --lvl: #b91c1c; }

.rp-result-label {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rp-result-score { font-size: 2.3rem; font-weight: 800; line-height: 1.1; color: var(--lvl); }
.rp-result-level { font-size: 0.82rem; font-weight: 800; color: var(--lvl); }

.rp-summary-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.rp-intro { margin: 0; line-height: 1.55; }

.rp-scale { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

.rp-scale-seg {
  display: flex;
  flex-direction: column;
  padding: 6px 4px;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.3;
}

.rp-scale-seg strong { font-size: 0.7rem; }
.rp-scale-seg.is-active { background: var(--lvl); color: #ffffff; }

.rp-alert {
  margin-top: 12px;
  padding: 9px 12px;
  border-left: 4px solid #b91c1c;
  background: var(--fail-red-bg);
  color: var(--fail-red-dark);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 0 6px 6px 0;
}

.rp-comment {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--fp-yellow);
  background: var(--fp-yellow-light);
  border-radius: 0 6px 6px 0;
}

.rp-comment span {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b45309;
}

.rp-comment p { margin: 4px 0 0; white-space: pre-line; line-height: 1.5; }

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

.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.rp-table th {
  background: var(--fp-dark);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 7px 8px;
  white-space: nowrap;
}

.rp-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.rp-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table .center { text-align: center; }
.rp-table .muted { color: var(--text-light); }
.rp-table .is-bad { color: #b91c1c; font-weight: 800; }
.rp-table tr.is-fail td { background: #fef2f2; }

.rp-row-strong td { font-weight: 700; background: #fffbeb; }
.rp-row-sub td { font-size: 0.76rem; color: var(--text-muted); background: #f8fafc; }
.rp-row-total td {
  font-weight: 800;
  color: var(--fp-dark);
  background: #fef3c7;
  border-top: 2px solid var(--fp-yellow);
  border-bottom: none;
}
.rp-row-group td {
  background: #f1f5f9;
  font-weight: 800;
  color: var(--fp-dark);
  font-size: 0.76rem;
}
.rp-row-group td span { font-weight: 500; color: var(--text-muted); }

.rp-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.rp-bar span { width: 38px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.rp-bar-track { flex: 1; height: 7px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.rp-bar-fill { height: 100%; border-radius: 999px; }
.rp-bar-ok { background: #15803d; }
.rp-bar-warn { background: var(--fp-yellow); }
.rp-bar-bad { background: #b91c1c; }

.rp-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}
.rp-pill-pass { background: #dcfce7; color: #15803d; }
.rp-pill-fail { background: #fee2e2; color: #b91c1c; }
.rp-pill-na { background: #f1f5f9; color: var(--text-muted); }

.rp-tag-crit {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #b91c1c;
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 800;
  vertical-align: middle;
}

.rp-points-table td:first-child { width: 36px; }

/* No conformidades */
.rp-nc-table td { vertical-align: top; }
.rp-nc-main td { border-bottom: none; padding-bottom: 2px; }
.rp-nc-title { font-weight: 700; color: var(--fp-dark); }
.rp-nc-obs td { color: var(--text-muted); font-size: 0.78rem; padding-top: 0; }
.rp-nc-code {
  font-weight: 800;
  color: #b45309;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
}
.rp-sev { font-weight: 800; white-space: nowrap; }
.rp-sev-crit { color: #b91c1c; }
.rp-sev-major { color: #b45309; }
.rp-sev-minor { color: var(--text-muted); }
.rp-annex-ref { font-weight: 700; color: #b45309; white-space: nowrap; }

.rp-annex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 640px) {
  .rp-annex-grid { grid-template-columns: repeat(4, 1fr); }
}

.rp-annex-item { margin: 0; }
.rp-annex-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
.rp-annex-item figcaption { margin-top: 3px; font-size: 0.7rem; color: var(--text-muted); }
.rp-annex-item figcaption strong { color: #b45309; }

.rp-empty {
  margin: 0;
  padding: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  color: #15803d;
  font-weight: 600;
}

.rp-reconstructed {
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid var(--fp-yellow-border);
  border-radius: 6px;
  color: #92400e;
  font-size: 0.76rem;
}

/* Firmas */
.rp-declaration { margin: 0 0 14px; line-height: 1.5; font-size: 0.8rem; }

.rp-sign-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 640px) {
  .rp-sign-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}

.rp-sign-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rp-sign-line {
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px solid var(--fp-dark);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.rp-sign-fields { margin: 8px 0 0; }
.rp-sign-fields div { display: flex; gap: 6px; align-items: baseline; margin-bottom: 4px; font-size: 0.78rem; }
.rp-sign-fields dt { width: 52px; flex-shrink: 0; color: var(--text-muted); }
.rp-sign-fields dd {
  flex: 1;
  margin: 0;
  min-height: 1.1em;
  font-weight: 700;
  color: var(--fp-dark);
  border-bottom: 1px solid var(--border-color);
}

.rp-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Comentario del auditor (formulario) */
.auditor-comment-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.auditor-comment-card label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
  color: var(--fp-dark);
}

.auditor-comment-card label span { font-weight: 500; font-size: 0.8rem; color: var(--text-muted); }

.auditor-comment-card textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.auditor-comment-card textarea:focus { outline: 2px solid var(--fp-yellow); border-color: transparent; }
.auditor-comment-count { margin-top: 4px; text-align: right; font-size: 0.72rem; color: var(--text-light); }

/* Impresión (Ctrl+P): el PDF oficial es el del botón, esto es respaldo */
@media print {
  body { background: #ffffff !important; }
  .checker-pattern-bar, .main-navbar, .completed-btn-group, .toast-tray, .btn-clear-sig, .draft-recovery-banner, .modal-overlay {
    display: none !important;
  }
  .rp-sheet { box-shadow: none !important; border: none !important; padding: 0 !important; }
}

/* ==========================================================================
   INICIO DE SESIÓN
   ========================================================================== */
/* El atributo hidden siempre gana sobre display:flex/inline-flex de .btn, etc. */
[hidden] { display: none !important; }

.btn-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: 2px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-nav-icon:hover { background: #f1f5f9; color: var(--fp-dark); }
.btn-logout:hover { background: #fee2e2; color: #b91c1c; }

@media (max-width: 480px) {
  .auditor-profile { padding: 4px 6px 4px 8px; gap: 4px; }
  .auditor-meta { display: none; }
}

.login-view.active {
  display: flex;
  justify-content: center;
  padding: 48px 0 80px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px 24px;
}

.login-logo { height: 64px; width: auto; align-self: center; }

.login-card h1 {
  margin: 10px 0 2px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--fp-dark);
}

.login-sub { margin: 0 0 22px; text-align: center; font-size: 0.88rem; color: var(--text-muted); }

.login-card label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fp-dark);
}

.login-card input {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
}

.login-card input:focus { outline: 2px solid var(--fp-yellow); border-color: transparent; }

.login-error {
  margin: -4px 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--fail-red-bg);
  color: var(--fail-red-dark);
  font-size: 0.84rem;
  font-weight: 600;
}

.login-help { margin: 16px 0 0; text-align: center; font-size: 0.76rem; color: var(--text-light); }

/* Estado de sincronización del borrador */
.draft-sync-status {
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
}

.draft-sync-status[data-state="saved"] { color: #15803d; }
.draft-sync-status[data-state="offline"] { color: #b45309; }

.login-hint { margin: -8px 0 14px; font-size: 0.74rem; color: var(--text-light); }

.btn-link {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* ==========================================================================
   USUARIOS Y PERMISOS
   ========================================================================== */
.users-view { padding-bottom: 60px; }

.roles-legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

@media (min-width: 720px) {
  .roles-legend { grid-template-columns: repeat(3, 1fr); }
}

.role-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.role-card p { margin: 6px 0 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

.role-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.role-admin { background: var(--fp-dark); color: #fbbf24; }
.role-auditor { background: #fef3c7; color: #92400e; }
.role-consulta { background: #e0f2fe; color: #075985; }

.users-panel {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.users-toolbar .input-text { max-width: 340px; }
.users-count { font-size: 0.8rem; color: var(--text-muted); }

.user-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.user-row:last-child { border-bottom: none; }
.user-row.is-inactive { background: #f8fafc; }
.user-row.is-inactive .user-info strong { color: var(--text-muted); }

@media (min-width: 900px) {
  .user-row { grid-template-columns: minmax(0, 1fr) 230px auto; align-items: center; }
}

.user-main { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.user-main .auditor-avatar { width: 34px; height: 34px; flex-shrink: 0; }
.user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-info strong { color: var(--fp-dark); font-size: 0.92rem; }
.user-info span { font-size: 0.8rem; color: var(--text-muted); overflow-wrap: anywhere; }
.user-info .user-last { font-size: 0.72rem; color: var(--text-light); }
.user-me { font-weight: 500; color: var(--text-light); font-size: 0.8rem; }

.user-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.user-status {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-on { background: var(--pass-green-bg); color: var(--pass-green-dark); }
.status-off { background: #e2e8f0; color: #475569; }
.status-none { background: #fff7ed; color: #9a3412; }
.status-pending { background: #fef3c7; color: #92400e; }

.user-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }

@media (min-width: 900px) {
  .user-actions { justify-content: flex-end; }
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; min-height: 34px; }

.users-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 0.88rem; }
.users-error { color: var(--fail-red-dark); }

.modal-narrow { max-width: 460px; }

.user-form { display: flex; flex-direction: column; gap: 14px; }

.user-active-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--fp-dark);
  cursor: pointer;
}

.user-active-toggle input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--fp-dark); }
.user-active-toggle small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.78rem; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.temp-pass-intro { margin: 0 0 14px; font-size: 0.88rem; line-height: 1.5; }

.temp-pass-box {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
}

.temp-pass-box div { display: flex; gap: 10px; align-items: baseline; margin: 3px 0; }
.temp-pass-box dt { width: 90px; flex-shrink: 0; font-size: 0.76rem; color: var(--text-muted); }
.temp-pass-box dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.temp-pass-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; letter-spacing: 0.03em; }
.temp-pass-warning { margin: 0 0 14px; font-size: 0.78rem; color: #b45309; }

.rp-due { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

/* ==========================================================================
   SEGUIMIENTO DE NOVEDADES
   ========================================================================== */
.btn-nav-bell { position: relative; }

.nav-badge {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px #ffffff;
}

.followup-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 5px solid #dc2626;
  border-radius: var(--radius-md);
}

.followup-alert-icon { font-size: 1.4rem; }
.followup-alert-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.followup-alert-text strong { color: #991b1b; font-size: 0.92rem; }
.followup-alert-text span { color: #7f1d1d; font-size: 0.8rem; }

@media (max-width: 560px) {
  .followup-alert { flex-wrap: wrap; }
  .followup-alert .btn { width: 100%; }
}

.followup-view { padding-bottom: 60px; }

.followup-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 720px) {
  .followup-kpis { grid-template-columns: repeat(4, 1fr); }
}

.followup-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--kpi-color, #94a3b8);
  border-radius: var(--radius-md);
}

.followup-kpi strong { font-size: 1.6rem; font-weight: 800; color: var(--kpi-color, var(--fp-dark)); line-height: 1.1; }
.followup-kpi span { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); }
.kpi-bad { --kpi-color: #dc2626; }
.kpi-warn { --kpi-color: #d97706; }
.kpi-ok { --kpi-color: #0f766e; }
.kpi-done { --kpi-color: #15803d; }

.followup-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.followup-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.followup-toolbar .input-text { max-width: 300px; }

.followup-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  border-left: 4px solid transparent;
}

.followup-row:last-child { border-bottom: none; }
.fu-vencida { border-left-color: #dc2626; background: #fffafa; }
.fu-por-vencer { border-left-color: #d97706; }
.fu-en-plazo { border-left-color: #0f766e; }
.fu-atendida { border-left-color: #15803d; background: #fbfefc; }

@media (min-width: 900px) {
  .followup-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}

.followup-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.followup-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.followup-branch { font-size: 0.74rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: #b45309; }
.followup-due { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); }
.fu-vencida .followup-due { color: #b91c1c; }
.fu-por-vencer .followup-due { color: #b45309; }
.fu-atendida .followup-due { color: #15803d; }
.followup-title { color: var(--fp-dark); font-size: 0.9rem; }
.followup-obs { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.followup-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.74rem; color: var(--text-muted); }
.followup-meta b { color: var(--fp-slate); }

.followup-resolution {
  margin: 4px 0 0;
  padding: 6px 10px;
  background: var(--pass-green-bg);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--pass-green-dark);
}

.followup-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.resolve-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.resolve-summary span:last-child:not(.followup-branch) { color: var(--text-muted); }

.an-table-wrap { width: 100%; overflow-x: auto; }

@media (max-width: 640px) {
  .an-table { font-size: 0.76rem; }
  .an-table th, .an-table td { padding: 6px 4px; }
  .an-hide-sm { display: none; }
}

.rp-sign-input {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8rem;
  background: var(--bg-card);
  color: var(--text-main);
}

.rp-sign-input:focus {
  outline: none;
  border-color: var(--fp-yellow);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* Sin señal: fotos y auditorías pendientes de envío */
.photo-thumb.photo-pending { outline: 2px dashed var(--fp-yellow); outline-offset: 1px; }
.photo-thumb.photo-pending::after {
  content: '⏳';
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  padding: 0 3px;
}

.queued-chip {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: var(--fp-yellow-badge);
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Pestañas del panel */
.dash-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin: 4px 0 16px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-subtle);
  scrollbar-width: none;
}

.dash-tabs::-webkit-scrollbar { display: none; }

.dash-tab {
  flex: 1 0 auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base);
}

.dash-tab:hover { color: var(--fp-dark); background: var(--bg-card-alt); }
.dash-tab.active { background: var(--fp-dark); color: #ffffff; }
.dash-tab:focus-visible { outline: 2px solid var(--fp-yellow); outline-offset: 2px; }

.dash-panel[hidden] { display: none; }
.dash-panel { margin-bottom: 24px; }
.dash-panel .benchmark-section,
.dash-panel .audits-panel { margin-bottom: 0; }

.benchmark-header h3 { margin: 0; }
.panel-sub { font-size: 0.8rem; color: var(--text-muted); }

.an-card.an-solo { background: var(--bg-card); padding: 20px; box-shadow: var(--shadow-card); border-radius: var(--radius-lg); }
.analytics-grid .an-card { background: var(--bg-card); box-shadow: var(--shadow-card); padding: 18px; }

.an-trend-single {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.an-trend-single strong { font-size: 2rem; color: var(--fp-dark); }
.an-trend-single span { font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }

.an-list { list-style: none; margin: 0; padding: 0; }
.an-list.an-collapsed .an-list-row:nth-child(n + 6) { display: none; }

.an-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.an-list-row:last-child { border-bottom: none; }
.an-list-main { flex: 1; min-width: 0; }
.an-list-main .an-item-title { margin-top: 0; font-size: 0.86rem; }
.an-list-main .an-item-sub { margin-top: 2px; font-size: 0.76rem; }

.an-rank {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card-alt);
  color: var(--fp-slate);
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.an-list-stat { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; }
.an-list-stat strong { font-size: 1.05rem; color: var(--fail-red-dark); }
.an-list-stat span { font-size: 0.72rem; color: var(--text-muted); }

.an-chip {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.an-chip-bad { background: var(--fail-red-bg); color: var(--fail-red-dark); }
.an-chip-good { background: var(--pass-green-bg); color: var(--pass-green-dark); }
.an-more { margin-top: 8px; }

.an-kpis { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.an-kpis > div { padding: 10px 12px; }

/* En pantallas angostas las pestañas se desplazan: el borde derecho se
   desvanece para insinuar que hay más. */
@media (max-width: 640px) {
  .dash-tabs {
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  }
  .dash-tab { padding: 9px 14px; }
}

/* Nivel de la escala: verde = bien, naranja/rojo = mal (mismos valores
   que LEVEL_COLORS en app.js). */
.lv-oro { background: #1a7f37; }
.lv-bueno { background: #86c858; }
.lv-accion { background: #e07b22; }
.lv-intervencion, .lv-critica { background: #b91c1c; }
.lv-none { background: #e2e8f0; }
.lv-bg-oro { background: #d6eedc; color: #14532d; }
.lv-bg-bueno { background: #e8f5da; color: #3f6212; }
.lv-bg-accion { background: #fde4cf; color: #9a3412; }
.lv-bg-intervencion, .lv-bg-critica { background: #fad4d4; color: #991b1b; }
.lv-bg-none { background: var(--bg-card-alt); color: var(--text-light); }

.level-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.level-legend span { display: inline-flex; align-items: center; gap: 6px; }
.level-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Botones de tipo de auditoría (Ranking y Calidad) */
.tpl-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.tpl-chips-bar { margin-bottom: 12px; }

.tpl-chip {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--fp-slate);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tpl-chip span {
  font-size: 0.72rem;
  background: var(--bg-card-alt);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 1px 7px;
}

.tpl-chip:hover:not([disabled]) { border-color: var(--fp-slate); }
.tpl-chip.active { background: var(--fp-dark); border-color: var(--fp-dark); color: #ffffff; }
.tpl-chip.active span { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
.tpl-chip[disabled] { cursor: default; }
.tpl-chips-note { font-size: 0.74rem; color: var(--text-muted); }

/* Ranking en lista */
.rk-list { list-style: none; margin: 0; padding: 0; }

.rk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border-color);
}

.rk-row:last-child { border-bottom: none; }
.rk-row.rk-risk { background: linear-gradient(90deg, var(--fail-red-bg), transparent 70%); }

.rk-pos {
  flex: 0 0 28px;
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.rk-main { flex: 1; min-width: 0; }
.rk-name { font-weight: 700; font-size: 0.9rem; color: var(--fp-dark); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rk-bar { height: 8px; background: var(--bg-card-alt); border-radius: 4px; overflow: hidden; margin: 5px 0 4px; }
.rk-bar span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.rk-meta { font-size: 0.74rem; color: var(--text-muted); }
.rk-score { flex: 0 0 auto; font-size: 1.15rem; font-weight: 800; color: var(--fp-dark); min-width: 3.2rem; text-align: right; }

/* Aviso de auditorías sin detalle */
.an-coverage {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--fp-yellow-light);
  border: 1px solid var(--fp-yellow-border);
  color: #92400e;
  font-size: 0.8rem;
  line-height: 1.45;
}

.an-coverage[hidden] { display: none; }

/* Matriz tienda × área */
.mx-wrap { width: 100%; overflow-x: auto; }
.mx-table { border-collapse: separate; border-spacing: 3px; font-size: 0.8rem; min-width: 100%; }
.mx-table th { font-weight: 700; color: var(--text-muted); font-size: 0.7rem; vertical-align: bottom; padding: 2px 4px; }
.mx-table thead th { text-align: center; max-width: 88px; }
.mx-num { display: block; font-size: 0.8rem; color: var(--fp-dark); }
.mx-area { display: block; font-weight: 600; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mx-branch {
  text-align: left !important;
  color: var(--fp-dark) !important;
  font-size: 0.8rem !important;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 1;
  padding-right: 8px !important;
}
.mx-cell { text-align: center; font-weight: 700; border-radius: 6px; padding: 7px 4px; min-width: 40px; }
.mx-total { font-weight: 800; }
td.mx-total { outline: 2px solid rgba(24, 24, 27, 0.12); outline-offset: -2px; }

@media (max-width: 640px) {
  .mx-area { display: none; }
  .mx-table thead th { max-width: none; }
}

/* En celular la matriz muestra solo el número del área: leyenda debajo. */
.mx-key { display: none; margin: 10px 0 0; font-size: 0.74rem; color: var(--text-muted); line-height: 1.5; }
.mx-key span { display: block; }
.mx-key b { display: inline-block; min-width: 1.2em; color: var(--fp-dark); }

@media (max-width: 640px) {
  .mx-key { display: block; }
}

/* Selector de fotos: Cámara / Galería */
.photo-picker { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Puntos adicionales (fuera de la plantilla) */
.extra-points-card {
  background: #ffffff;
  border: 1px dashed var(--fp-yellow-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.extra-points-head h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 800; color: var(--fp-dark); }
.extra-points-head p { margin: 0 0 12px; font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

.extra-point {
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--fp-yellow);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--fp-yellow-light);
}

.extra-point-head { display: flex; justify-content: space-between; align-items: center; }

.extra-point-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
}

.extra-point .extra-title {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  background: #ffffff;
}

.extra-point .extra-title:focus { outline: 2px solid var(--fp-yellow); border-color: transparent; }
.extra-point .item-obs-input { background: #ffffff; }
.btn-add-extra { width: 100%; justify-content: center; }

.rp-tag-extra {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--fp-yellow-badge);
  color: #92400e;
  font-size: 0.6rem;
  font-weight: 800;
  vertical-align: middle;
}

/* Tiendas sin auditoría en el período (al final de la matriz) */
.mx-unaudited .mx-branch { color: var(--text-muted) !important; font-weight: 600; }
.mx-noaudit { font-size: 0.68rem; font-weight: 700; white-space: nowrap; color: var(--text-muted); }

/* Tipos de auditoría por usuario (gestión de usuarios) */
.user-templates-group { border: none; padding: 0; margin: 0; min-width: 0; }
.user-templates-group legend { font-weight: 700; font-size: 0.85rem; color: var(--fp-dark); margin-bottom: 6px; padding: 0; }
.user-templates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.user-templates label { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-main); cursor: pointer; }
.user-templates input[disabled] + * , .user-templates label:has(input[disabled]) { color: var(--text-muted); cursor: default; }
.field-hint { display: block; margin-top: 6px; font-size: 0.74rem; color: var(--text-muted); line-height: 1.4; }
.roles-note { margin: -4px 0 16px; font-size: 0.8rem; color: var(--text-muted); }
.user-status.status-scope { background: var(--fp-yellow-badge); color: #92400e; }
