/* ==========================================================================
   SISTEMA DE CONTROL DE CALIDAD TEXTIL V13 - ESTILOS PRO INDUSTRIAL SLIM v1.4
   Plataforma: Planta de Tejido de Punto Circular
   Optimizado para: Tablet Android, Celular (390px) y Computadora (1366px+)
   ========================================================================== */

:root {
  --primary: #0f172a;        /* Azul pizarra oscuro industrial */
  --primary-light: #1e293b;
  --accent: #2563eb;         /* Azul técnico */
  --accent-hover: #1d4ed8;
  --bg-main: #f8fafc;        /* Fondo gris limpio */
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #94a3b8;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  /* Estados de calidad y acentos corporativos T&F */
  --brand-emerald: #10b981;
  --brand-emerald-dark: #059669;
  --brand-emerald-bg: #ecfdf5;
  --brand-emerald-border: #a7f3d0;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-border: #bbf7d0;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-border: #fde68a;

  --sidebar-width: 240px;
  --header-height: 56px;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  position: relative;
  overflow-x: hidden;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   BARRA LATERAL (SIDEBAR)
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  height: 34px;
  min-width: 76px;
  padding: 5px 8px;
  background-color: #ffffff;
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.sidebar-logo-img {
  height: 22px;
  width: auto;
  max-width: 78px;
  object-fit: contain;
  display: block;
}

.sidebar-title h1 {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sidebar-title p {
  font-size: 0.68rem;
  color: var(--text-light);
  line-height: 1.2;
}

.sidebar-menu {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.menu-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
}

.nav-link:hover {
  background-color: var(--primary-light);
  color: #ffffff;
}

.nav-link.active {
  background-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  color: var(--text-light);
  line-height: 1.3;
}

.sidebar-footer-badge {
  display: inline-block;
  background-color: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.25);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.62rem;
  font-weight: 700;
  margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   CONTENEDOR PRINCIPAL Y TOPBAR
   -------------------------------------------------------------------------- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  min-width: 0;
  overflow-x: hidden;
  transition: margin-left 0.25s ease, width 0.25s ease;
}

.topbar {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 90;
  width: 100%;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.menu-toggle-btn {
  display: none;
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 6px 8px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1;
  color: var(--primary);
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-logo {
  max-height: 38px;
  max-width: 130px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.topbar-app-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.topbar-divider {
  color: #cbd5e1;
  font-size: 0.95rem;
  font-weight: 300;
  user-select: none;
}

.current-module-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.badge-cloud-online {
  background-color: var(--brand-emerald-bg);
  color: var(--brand-emerald-dark);
  border: 1px solid var(--brand-emerald-border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.cloud-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-emerald);
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}

.badge-cloud-online.is-syncing {
  background-color: #d1fae5;
  border-color: var(--brand-emerald);
  color: #065f46;
}

.badge-cloud-online.is-syncing .cloud-sync-dot {
  background-color: var(--brand-emerald-dark);
  animation: cloudSyncPulse 1.1s ease-in-out infinite;
}

.badge-cloud-online.is-offline {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
  color: #92400e;
}

.badge-cloud-online.is-offline .cloud-sync-dot {
  background-color: var(--warning);
  box-shadow: none;
}

@keyframes cloudSyncPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);
  }
}

.badge-demo {
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 4px 9px;
  border-radius: 14px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: var(--radius);
  background-color: #f8fafc;
  border: 1px solid var(--border);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.1;
}

.user-role {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.1;
}

/* --------------------------------------------------------------------------
   ÁREA DE CONTENIDO
   -------------------------------------------------------------------------- */
.content-area {
  padding: 18px 20px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* --------------------------------------------------------------------------
   FORMULARIOS Y CONTROLES BASE
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-label.required::after {
  content: " *";
  color: var(--danger);
}

.form-control, .form-select {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-main);
  background-color: #ffffff;
  outline: none;
  display: block;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="date"].form-control,
#filterFecha {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  display: block !important;
  padding: 5px 8px;
  margin: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  margin: 0;
  padding: 0 2px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

/* --------------------------------------------------------------------------
   VISTA 1: DASHBOARD
   -------------------------------------------------------------------------- */
.filter-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

.filter-card.filters-collapsed .filter-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.filter-card.filters-collapsed .filter-grid {
  display: none;
}

.filter-toggle-btn {
  min-height: 44px;
  padding: 6px 12px;
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.filter-toggle-btn:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.filter-toggle-arrow {
  font-size: 0.85rem;
  line-height: 1;
}

.filter-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filter-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) 100px;
  gap: 12px;
  align-items: flex-end;
  width: 100%;
  box-sizing: border-box;
}

.filter-btn-group {
  justify-content: flex-end;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  border-left: 4px solid transparent;
}

.kpi-ops { border-left-color: #2563eb; }
.kpi-rollos { border-left-color: #2563eb; }
.kpi-kilos { border-left-color: #4f46e5; }
.kpi-defectuosos { border-left-color: #dc2626; }
.kpi-conformidad { border-left-color: #d97706; }
.kpi-defectos { border-left-color: #dc2626; }

.kpi-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kpi-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-blue { background-color: #eff6ff; color: #2563eb; }
.kpi-icon-indigo { background-color: #eef2ff; color: #4f46e5; }
.kpi-icon-amber { background-color: #fffbeb; color: #d97706; }
.kpi-icon-red { background-color: #fef2f2; color: #dc2626; }

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.kpi-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
  width: 100%;
}

.chart-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.chart-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.chart-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
}

.chart-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

.chart-container {
  position: relative;
  height: 230px;
  width: 100%;
}

.card-table {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  width: 100%;
}

.card-table-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafafa;
}

.card-table-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
}

.card-table-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.data-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

/* --------------------------------------------------------------------------
   VISTA 2: FORMULARIO DE INSPECCIÓN (REDISEÑO SLIM EN 3 ZONAS)
   -------------------------------------------------------------------------- */
.form-container-clean {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 100%;
}

.section-clean {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.section-clean-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.section-clean-tag {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background-color: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-clean-title h2 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.2px;
}

/* Selector Jersey vs RIB compacto */
.structure-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.structure-toggle {
  display: inline-flex;
  background-color: #f1f5f9;
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.structure-btn {
  border: none;
  background: transparent;
  padding: 6px 18px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.structure-btn.active {
  background-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.structure-caption {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

/* Barra de Especificaciones de Datos Maestros (Solo Lectura) */
.readonly-specs-bar {
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.spec-chip strong {
  color: var(--primary);
  font-weight: 600;
}

.form-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.form-grid-peso-obs {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
}

/* ZONA C: DEFECTOS (ACCESO RÁPIDO + CATÁLOGO COLAPSABLE) */
.quick-access-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quick-access-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.catalogo-collapsible-wrapper {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.catalogo-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.catalogo-toggle-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.defect-header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.defect-badge-summary {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  background-color: #f1f5f9;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 12px;
}

.defect-badge-summary.has-defects {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.defects-container-collapsible {
  transition: max-height 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
}

.defects-container-collapsible.collapsed {
  display: none;
}

.defects-compact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.defect-compact-item {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
  min-width: 0;
}

.defect-compact-item:hover {
  border-color: #cbd5e1;
}

.defect-compact-item.has-value {
  background-color: #fffafa;
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.14);
}

.defect-compact-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.defect-pos-pill {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #64748b;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 2px 7px;
  border-radius: 5px;
  flex-shrink: 0;
  line-height: 1.35;
}

.defect-compact-item.has-value .defect-pos-pill {
  background-color: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

.defect-compact-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.32;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

.defect-compact-item.has-value .defect-compact-name {
  color: #7f1d1d;
}

.defect-compact-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.defect-compact-item.has-value .defect-compact-controls {
  border-top-color: #fee2e2;
}

.btn-ctrl {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.btn-ctrl:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.btn-ctrl:active {
  background-color: #e2e8f0;
}

.defect-input-compact {
  width: 60px;
  height: 44px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  background-color: #ffffff;
  color: #0f172a;
  padding: 0;
}

.defect-compact-item.has-value .defect-input-compact {
  border-color: #fca5a5;
  color: #b91c1c;
}

.defect-input-compact:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

/* BARRA DE ACCIÓN INFERIOR */
.bottom-action-bar {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.bottom-summary-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.summary-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
}

.bottom-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   VISTA 3: HISTORIAL DE ROLLOS
   -------------------------------------------------------------------------- */
.historial-filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.historial-search-wrap {
  flex: 1;
  min-width: 250px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  padding-left: 32px !important;
}

.historial-selects-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.historial-selects-wrap .form-select {
  width: 150px !important;
}

.historial-actions-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.historial-counter-badge {
  background-color: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

/* BADGES */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.badge-conforme {
  background-color: var(--brand-emerald-bg);
  color: var(--brand-emerald-dark);
  border: 1px solid var(--brand-emerald-border);
}

.badge-defectos {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-en-proceso {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-tela {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-tela-jersey {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-tela-rib {
  background-color: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-tela-interlock {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* --------------------------------------------------------------------------
   MODALES (DETALLE Y DUPLICIDAD)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

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

.modal-card {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-card-sm {
  max-width: 480px;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background-color: #fafafa;
}

.modal-header-warning {
  background-color: #fffbeb;
  border-bottom-color: #fef3c7;
}

.modal-badge-sup {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent);
  text-transform: uppercase;
}

.modal-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  background-color: #fafafa;
}

.duplicate-warning-box {
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.84rem;
  color: #92400e;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   TOAST
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: auto;
  bottom: 76px;
  right: 20px;
  left: auto;
  z-index: 350;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: 340px;
  width: auto;
}

.toast {
  background-color: var(--primary);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: auto;
}

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

.toast-success {
  border-left: 4px solid var(--brand-emerald);
}

.toast-error {
  background-color: #7f1d1d;
  border-left: 4px solid #ef4444;
}

.toast-warning {
  background-color: #78350f;
  border-left: 4px solid #f59e0b;
}

/* ==========================================================================
   RESPONSIVE DESIGN (TABLET 768px, CELULAR 390px, ESCRITORIO)
   ========================================================================== */

/* TABLETS Y PANTALLAS MEDIANAS (<= 992px) */
@media (max-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .form-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }

  .defects-compact-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* TABLETS COMPACTAS Y CELULARES (<= 768px) */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }

  .menu-toggle-btn {
    display: flex;
    min-width: 44px;
    min-height: 44px;
  }

  .topbar {
    padding: 0 12px;
    height: 52px;
  }

  .topbar-left,
  .topbar-right {
    gap: 8px;
  }

  .topbar-logo {
    max-height: 30px;
    max-width: 96px;
  }

  .current-module-title {
    font-size: 0.9rem;
  }

  .topbar-right .user-meta {
    display: none;
  }

  .content-area {
    padding: 12px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filter-grid .form-group,
  .filter-grid #filterFecha,
  .filter-grid #historialFiltroFecha {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .filter-btn-group {
    justify-content: stretch;
  }

  .filter-btn-group .btn {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .form-grid-3,
  .form-grid-5 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-grid-peso-obs {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .structure-toggle-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .quick-access-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .catalogo-toggle-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .catalogo-toggle-bar .btn {
    width: 100%;
  }

  .defects-compact-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bottom-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .bottom-summary-info {
    justify-content: space-between;
  }

  .bottom-action-buttons {
    flex-direction: column;
  }

  .bottom-action-buttons .btn {
    width: 100%;
  }

  .historial-filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .historial-search-wrap {
    min-width: 100%;
  }

  .historial-selects-wrap {
    flex-direction: column;
    width: 100%;
  }

  .historial-selects-wrap .form-select {
    width: 100% !important;
  }

  .historial-actions-cluster {
    width: 100%;
    justify-content: space-between;
  }

  .historial-actions-cluster .btn {
    flex: 1;
  }

  .toast-container {
    top: auto;
    bottom: 76px;
    right: 20px;
    left: auto;
    max-width: min(340px, calc(100vw - 40px));
    width: auto;
  }
}

/* TABLET (561px..1024px): filtros del dashboard desplegados en 2 columnas */
@media (min-width: 561px) and (max-width: 1024px) {
  #dashboardFilterGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #dashboardFilterGrid .filter-btn-group {
    justify-content: flex-end;
  }
}

/* SMARTPHONES PEQUEÑOS (<= 480px, ej: 390px) */
@media (max-width: 480px) {
  .current-module-title {
    font-size: 0.84rem;
  }

  .badge-demo {
    padding: 2px 5px;
    font-size: 0.62rem;
  }

  .section-clean {
    padding: 12px;
  }

  .readonly-specs-bar {
    flex-direction: column;
    gap: 4px;
  }

  .chart-container {
    height: 190px;
  }
}

/* ========================================================================== */
/* FORM GRID 4 & MÓDULO DE ÓRDENES DE PRODUCCIÓN (OP)                         */
/* ========================================================================== */

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 1024px) {
  .form-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar-app-name,
  .topbar-divider {
    display: none;
  }

  .topbar-logo {
    max-height: 30px;
    max-width: 90px;
  }

  .form-grid-4 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* Contenedor del módulo OP */
.op-module-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Banner de Contexto Demostrativo */
.op-banner-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  color: #166534;
}

.op-banner-notice strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 3px;
  color: #14532d;
}

.op-banner-notice p {
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0;
  color: #166534;
}

/* Pestañas del Módulo OP */
.op-tabs-bar {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 2px;
  overflow-x: auto;
}

.op-tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.op-tab-btn:hover {
  color: var(--primary);
}

.op-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.op-tab-panel {
  display: none;
}

.op-tab-panel.active {
  display: block;
}

/* Zona de Carga (Dropzone) */
.op-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  background-color: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}

.op-dropzone:hover,
.op-dropzone.dragover {
  border-color: var(--primary);
  background-color: #eff6ff;
}

.op-dropzone-icon {
  color: var(--primary);
  margin-bottom: 8px;
}

/* Metadatos de Archivo */
.op-meta-result {
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.op-meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.op-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.op-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.op-meta-lbl {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.op-sha256-code {
  font-family: monospace;
  font-size: 0.75rem;
  background-color: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
  color: #0f172a;
}

/* Tarjeta Encabezado de Revisión */
.op-header-card {
  background-color: #ffffff;
}

.op-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.op-code-display {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.op-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 8px;
}

.badge-borrador {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-pendiente {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-aprobada {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-origen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  vertical-align: middle;
}

.badge-origen-excel {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-origen-manual {
  background-color: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.badge-origen-pendiente {
  background-color: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.op-header-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  font-size: 0.85rem;
}

/* Caja de Diagnóstico / Alertas */
.op-diagnosis-box {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.op-alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.4;
}

.op-alert-warning {
  background-color: #fffbeb;
  border: 1px solid #fef3c7;
  color: #92400e;
}

.op-alert-success {
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

/* Tabla de Partidas */
.op-partidas-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.op-partidas-table th {
  background-color: #f8fafc;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  text-align: left;
}

.op-partidas-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.op-partidas-table tr:hover {
  background-color: #f8fafc;
}

/* Tags de Máquinas */
.machine-tag-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.machine-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 600;
}

.machine-tag-remove {
  cursor: pointer;
  color: #93c5fd;
  font-weight: bold;
}

.machine-tag-remove:hover {
  color: #dc2626;
}

.machine-tag-empty {
  display: inline-block;
  padding: 2px 8px;
  background-color: #fef2f2;
  border: 1px dashed #fca5a5;
  color: #dc2626;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* RIB Config Box */
.op-rib-config-box {
  background-color: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: var(--radius);
  padding: 14px;
}

.op-rib-machines-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: center;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 6px 10px;
}

/* Footer de Acciones */
.op-actions-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  background-color: #ffffff;
  border-top: 2px solid var(--border);
}

.op-actions-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.op-actions-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Grid de Checkboxes en Modal */
.machines-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}

.machine-chk-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  background-color: #f8fafc;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.machine-chk-item:hover {
  background-color: #eff6ff;
  border-color: #bfdbfe;
}

/* ========================================================================== */
/* SUPERVISIÓN, AUDITORÍA, KPIS AMPLIADOS Y ANÁLISIS MULTIDIMENSIONAL         */
/* ========================================================================== */

.badge-rechazada {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge-anulado {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #f87171;
  font-weight: 700;
}

.modal-header-danger {
  background-color: #fef2f2;
  border-bottom-color: #fee2e2;
}

.role-selector-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.role-selector-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
}

.role-select {
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  cursor: pointer;
  color: var(--text-main);
}

.btn-reset-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
  padding: 6px 10px;
  font-size: 0.74rem;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset-demo:hover {
  background-color: #fee2e2;
  border-color: #f87171;
  color: #991b1b;
}

.dimension-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-dim-tab {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-dim-tab:hover {
  background: #eff6ff;
  color: var(--primary);
}

.btn-dim-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.audit-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.audit-timeline-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.78rem;
}

.audit-timeline-item.anulacion {
  border-left-color: #dc2626;
  background: #fff5f5;
}

.audit-timeline-item.correccion {
  border-left-color: #2563eb;
  background: #f0f7ff;
}

/* Adaptabilidad para las 6 tarjetas de KPI */
@media (min-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px;
  }
  .kpi-card {
    padding: 18px 20px;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }
  .kpi-card {
    padding: 16px;
  }
}

@media (max-width: 767px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
}

.personal-module-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}


/* ==========================================================================
   FASE 2: ESTILOS DE INSPECCIÓN GUIADA (A -> B -> C), TARJETAS Y CONTROLES XL
   ========================================================================== */

/* Selector táctil de Rol (JEFATURA / AUDITOR) en barra superior */
.role-toggle {
  display: inline-flex;
  background: #e2e8f0;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.role-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.role-btn:hover {
  color: var(--primary);
}

.role-btn.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Barra de pasos A -> B -> C */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  gap: 8px;
}

.wizard-step {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wizard-step:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.wizard-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #0f172a;
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wizard-step.active {
  background: #eff6ff;
  border-color: var(--accent);
  color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.wizard-step.active .wizard-step-num {
  background: var(--accent);
  color: #ffffff;
}

.wizard-step.done {
  background: var(--brand-emerald-bg);
  border-color: var(--brand-emerald-border);
  color: var(--brand-emerald-dark);
}

.wizard-step.done .wizard-step-num {
  background: var(--brand-emerald);
  color: #ffffff;
}

.wizard-step-sep {
  width: 22px;
  height: 2px;
  background: #cbd5e1;
  flex-shrink: 0;
}

/* Paneles A, B y C */
.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: block;
  animation: fadeIn 0.18s ease-out;
}

/* Selector Jersey / INTERLOCK / RIB mediante tarjetas grandes */
.tela-choice {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 10px;
}

.tela-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 16px 20px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  min-height: 76px;
}

.tela-card strong {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tela-card span {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.tela-card:hover {
  border-color: #94a3b8;
  background: #ffffff;
}

.tela-card.active {
  background: #eff6ff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tela-card.active strong {
  color: #1d4ed8;
}

.tela-card.active span {
  color: #1e40af;
}

.wizard-caption {
  display: block;
  margin-bottom: 14px;
  font-size: 0.84rem;
  color: #475569;
  font-weight: 600;
}

.wizard-subtitle {
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #334155;
  margin: 6px 0 10px 0;
}

/* Bloques de OP y tarjetas de Partida (patrón visual de Jefatura) */
.op-blocks {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.op-block {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
}

.op-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: #0f172a;
  color: #ffffff;
}

.op-block-code {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-right: 10px;
  color: #ffffff;
}

.op-block-sub {
  font-size: 0.84rem;
  color: #cbd5e1;
  font-weight: 500;
}

.op-block-progress {
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: 999px;
}

.partida-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 14px;
}

.partida-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 118px;
}

.partida-card:hover {
  border-color: #64748b;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.partida-card.selected {
  border-color: var(--accent);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.partida-card.completada {
  border-color: var(--brand-emerald-border);
  background: var(--brand-emerald-bg);
}

.partida-card.completada.selected {
  border-color: var(--accent);
  background: #eff6ff;
}

.partida-card.sin-meta {
  border-style: dashed;
  border-color: #f59e0b;
}

.partida-card.sin-meta-bloqueada {
  border-style: dashed;
  border-color: #ef4444;
  background: #fef2f2;
  opacity: 0.85;
  cursor: not-allowed;
}

.partida-card.sin-meta-bloqueada .partida-card-name {
  color: #991b1b;
}

/* Selector de número de rollo mediante botones consecutivos (001 .. Meta) */
.rollo-selector-group {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.rollo-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.rollo-selector-legend {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-disponible .legend-dot {
  background: #0284c7;
}

.legend-registrado {
  background: var(--brand-emerald-bg);
  border-color: var(--brand-emerald-border);
  color: var(--brand-emerald-dark);
}

.legend-registrado .legend-dot {
  background: var(--brand-emerald);
}

.legend-seleccionado {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

.legend-seleccionado .legend-dot {
  background: #2563eb;
}

.rollo-botones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  margin-bottom: 6px;
}

.rollo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 8px 6px;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  user-select: none;
}

.rollo-btn-num {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.rollo-btn-tag {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 999px;
}

.rollo-btn.disponible {
  border-color: #94a3b8;
  background: #ffffff;
}

.rollo-btn.disponible .rollo-btn-tag {
  background: #e0f2fe;
  color: #0369a1;
}

.rollo-btn.disponible:hover {
  border-color: var(--accent);
  background: #f8fafc;
  transform: translateY(-1px);
}

.rollo-btn.registrado {
  border-color: var(--brand-emerald-border);
  background: var(--brand-emerald-bg);
  color: #065f46;
}

.rollo-btn.registrado .rollo-btn-num {
  color: var(--brand-emerald-dark);
}

.rollo-btn.registrado .rollo-btn-tag {
  background: #d1fae5;
  color: var(--brand-emerald-dark);
  border: 1px solid var(--brand-emerald-border);
}

.rollo-btn.registrado:hover {
  border-color: var(--brand-emerald);
  background: #d1fae5;
}

.rollo-btn.selected {
  border-color: var(--accent);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.24);
  transform: translateY(-1px);
}

/* Compatibilidad histórica: registros fuera de secuencia (solo lectura, no seleccionables) */
.rollo-legacy-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1.5px dashed #f59e0b;
  color: #78350f;
}

.rollo-legacy-header {
  font-size: 0.76rem;
  font-weight: 800;
  color: #92400e;
  margin-bottom: 6px;
}

.rollo-legacy-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.rollo-legacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #78350f;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: default;
  user-select: text;
}

.rollo-legacy-note {
  font-size: 0.71rem;
  color: #92400e;
  line-height: 1.35;
}

.badge-fuera-secuencia {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  vertical-align: middle;
}

.rollo-btn.selected .rollo-btn-num {
  color: #1d4ed8;
}

.rollo-btn.registrado.selected {
  border-color: #d97706;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.24);
}

.rollo-btn.registrado.selected .rollo-btn-num {
  color: #b45309;
}

.rollo-btn.registrado.selected .rollo-btn-tag {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.partida-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.partida-card-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

.partida-card.selected .partida-card-name {
  color: #1d4ed8;
}

.partida-card-art {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  line-height: 1.25;
}

.partida-card-lote {
  font-size: 0.76rem;
  font-weight: 700;
  color: #64748b;
}

.partida-progress-text {
  font-size: 0.82rem;
  color: #1e293b;
  margin-top: 2px;
}

.partida-progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.partida-progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.partida-card.completada .partida-progress-bar span {
  background: linear-gradient(90deg, var(--brand-emerald), var(--brand-emerald-dark));
}

.op-block-empty {
  grid-column: 1 / -1;
  padding: 16px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

/* Insignias de estado de meta (COMPLETADA / SIN META DEFINIDA / EN CURSO) */
.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.meta-badge-completada {
  background: var(--brand-emerald-bg);
  color: var(--brand-emerald-dark);
  border: 1px solid var(--brand-emerald-border);
}

.meta-badge-sinmeta {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.meta-badge-encurso {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}

/* --------------------------------------------------------------------------
   V11 POKA-YOKE STYLES (MÁQUINA, FECHA FIJA, TURNO AUTOMÁTICO, PESO MODAL)
   -------------------------------------------------------------------------- */
.maquina-poka-yoke-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.maquina-poka-yoke-wrapper .form-control-xl {
  flex: 1;
}

.badge-maquina-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 48px;
  background-color: #eff6ff;
  border: 2px solid var(--accent);
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.12rem;
  color: #1d4ed8;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-maquina-preview .preview-arrow {
  color: #3b82f6;
  font-size: 1.2rem;
}

.badge-maquina-preview .preview-tag {
  color: #1e40af;
}

.fixed-date-wrapper {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 12px;
  gap: 10px;
}

.fixed-date-icon {
  color: #64748b;
  display: flex;
  align-items: center;
}

.fixed-date-input {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  box-shadow: none !important;
  cursor: default !important;
  min-height: 44px !important;
  width: 100%;
}

.fixed-date-badge {
  display: inline-block;
  padding: 3px 8px;
  background-color: #e2e8f0;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #475569;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.choice-group.locked-for-auditor .choice-btn:disabled {
  opacity: 0.9;
  cursor: not-allowed;
}

/* Barra de navegación del asistente (Continuar / Atrás) */
#wizardPanelA .wizard-nav {
  display: none;
}

.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
}

.wizard-nav-hint {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

/* Resumen superior en pantallas B y C */
.wizard-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  align-items: center;
}

.wizard-chip {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
}

.wizard-chip strong {
  color: #93c5fd;
  margin-right: 4px;
}

.wizard-chip-main {
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.03em;
}

/* Barra horizontal compacta de Fecha y Turno del sistema (Pantalla B) */
.system-context-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 14px;
  min-height: 40px;
  margin-bottom: 12px;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--primary);
}

.system-context-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.system-context-sep {
  color: #cbd5e1;
  font-weight: 400;
  user-select: none;
}

/* Controles táctiles grandes en Pantalla B */
.wizard-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.form-control-xl {
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 14px;
  border-width: 2px;
  border-radius: 8px;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.choice-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 4px;
  margin-bottom: 10px;
}

.choice-group-2 {
  grid-template-columns: repeat(2, 1fr);
}

.choice-btn {
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.choice-btn:hover {
  border-color: #64748b;
  background: #ffffff;
}

.choice-btn.selected,
.choice-btn.active {
  background: #eff6ff;
  border-color: var(--accent);
  color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-xl {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 0.96rem;
  font-weight: 800;
  border-radius: 8px;
}

.btn-xl:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Controles táctiles limpios y responsivos en Pantalla C (25 defectos) */
.defects-xl-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1100px) {
  .defects-xl-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .defects-xl-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}

/* Trazabilidad de metas completadas manualmente */
.btn-meta-fill {
  padding: 2px 8px;
  font-size: 0.72rem;
  margin-left: 6px;
}

.meta-audit-box {
  margin-top: 12px;
}

.meta-audit-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}

.meta-audit-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.meta-readonly-value {
  padding: 8px 10px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

@media (max-width: 768px) {
  .wizard-steps {
    padding: 8px;
  }
  .wizard-step {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
  .tela-choice,
  .choice-group-2 {
    grid-template-columns: 1fr;
  }
  .partida-cards {
    grid-template-columns: 1fr;
  }
  .wizard-nav {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 560px) {
  .wizard-grid-2 {
    grid-template-columns: 1fr;
  }
}


/* ============================================================================ */
/* V10: PANTALLA DE ACCESO TÁCTIL, CERRAR SESIÓN Y CONFIRMACIÓN A -> B          */
/* ============================================================================ */

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 44px;
  min-width: 44px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #1e293b;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
  white-space: nowrap;
}

.btn-logout:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-overlay.active {
  display: flex;
}

.auth-shell {
  width: 100%;
  max-width: 980px;
  background: #f8fafc;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.auth-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.auth-logo-img {
  max-height: 48px;
  max-width: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.auth-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.20rem;
  font-weight: 800;
  color: #0f172a;
}

.auth-brand p {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: #475569;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.auth-grid:has(> .auth-panel:only-child) {
  grid-template-columns: minmax(0, 1fr);
}

.auth-shell:has(.auth-grid > .auth-panel:only-child) {
  max-width: 560px;
}

.auth-panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-panel-header h2 {
  margin: 8px 0 4px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

.auth-panel-header p {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.35;
}

.auth-role-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.auth-role-auditor {
  background: #dbeafe;
  color: #1d4ed8;
}

.auth-role-jefatura {
  background: #fef3c7;
  color: #b45309;
}

.auth-auditor-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-auditor-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.96rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.auth-auditor-btn:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.auth-auditor-btn:active {
  transform: scale(0.99);
}

.auth-auditor-sub {
  font-size: 0.76rem;
  font-weight: 700;
  color: #2563eb;
  white-space: nowrap;
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #94a3b8;
  background: #ffffff;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: transparent;
  user-select: none;
}

.pin-dot.filled {
  background: #2563eb;
  border-color: #2563eb;
  color: #2563eb;
}

.auth-pin-error {
  min-height: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #dc2626;
  text-align: center;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pin-key {
  min-height: 52px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.1s ease;
}

.pin-key:hover {
  background: #e2e8f0;
}

.pin-key:active {
  background: #cbd5e1;
}

.pin-key-action {
  font-size: 0.88rem;
  color: #475569;
  background: #f1f5f9;
}

.auth-pin-submit {
  width: 100%;
  min-height: 52px;
  font-size: 0.98rem;
}

.auth-pin-hint {
  text-align: center;
  font-size: 0.76rem;
  color: #64748b;
}

/* Modal Confirmación A -> B */
.confirm-stepb-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-stepb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.confirm-stepb-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.confirm-stepb-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.confirm-stepb-value {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  text-align: right;
}

#modalConfirmarPasoB .modal-card {
  max-width: 580px;
}

.confirm-stepb-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.confirm-stepb-footer .btn {
  min-height: 52px;
  width: 100%;
  justify-content: center;
  padding: 12px 14px;
  font-size: 0.94rem;
  text-align: center;
}

@media (max-width: 768px) {
  .auth-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .confirm-stepb-footer {
    grid-template-columns: minmax(0, 1fr);
  }
  .btn-logout span {
    display: none;
  }
  .btn-logout {
    min-height: 48px;
    min-width: 48px;
    padding: 10px;
  }
}

/* TABLETS HORIZONTALES (769px..1140px): compactar topbar cuando el sidebar (240px) es visible */
@media (min-width: 769px) and (max-width: 1140px) {
  .topbar {
    padding: 0 14px;
  }

  .topbar-left,
  .topbar-right {
    gap: 8px;
  }

  .topbar-logo {
    max-height: 30px;
    max-width: 96px;
  }

  .current-module-title {
    font-size: 0.92rem;
  }

  .badge-cloud-online {
    padding: 4px 10px;
    font-size: 0.72rem;
    gap: 5px;
  }

  .topbar-right .user-meta,
  .btn-logout span {
    display: none;
  }

  .user-badge {
    padding: 3px;
  }

  .btn-logout {
    min-height: 44px;
    min-width: 44px;
    padding: 8px;
  }
}

@media (min-width: 769px) and (max-width: 860px) {
  .topbar-brand,
  .topbar-divider {
    display: none;
  }
}

/* ============================================================================
 * V13 TABLET RELEASE STYLES — FILTRO TÁCTIL TEJEDORES, CLIENTES, MB KNITS & GESTIÓN JEFATURA
 * ============================================================================ */

/* Barra de filtros alfabéticos para tejedores */
.choice-group-alphabar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn-tejedor-filter {
  min-height: 44px;
  min-width: 68px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-main, #1e293b);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-tejedor-filter:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-tejedor-filter.active {
  background: #1e3a8a !important;
  color: #ffffff !important;
  border-color: #1e3a8a !important;
  box-shadow: 0 2px 4px rgba(30, 58, 138, 0.25);
}

.btn-tejedor-filter span {
  font-size: 0.85em;
  opacity: 0.9;
}

/* Buscador instantáneo de tejedores */
.tejedor-search-input {
  min-height: 46px;
  font-size: 0.95rem;
  padding: 10px 14px;
  padding-right: 36px;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
}

.tejedor-search-input:focus {
  border-color: #1e3a8a;
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.btn-clear-search {
  transition: opacity 0.15s ease;
}
.btn-clear-search:hover {
  color: #0f172a !important;
}

/* Grilla de tarjetas de tejedores */
.tejedor-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
  margin-top: 8px;
  padding: 2px;
}

.tejedor-selected-badge {
  background: #10b981;
  color: #ffffff;
  font-weight: 700;
  border-radius: 6px;
}

/* Tablas de gestión en Jefatura */
#tablaGestionAuditores th,
#tablaGestionAuditores td,
#tablaGestionTejedores th,
#tablaGestionTejedores td {
  padding: 10px 14px;
  font-size: 0.9rem;
  vertical-align: middle;
}

.btn-toggle-auditor,
.btn-toggle-tejedor {
  min-height: 36px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.84rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.badge-estado-activo {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
}

.badge-estado-inactivo {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
}

/* V13 R2: Badge MB KNITS y Botón Táctil + Rollo Adicional (sin clase .rollo-btn) */
.meta-badge-mb-extra {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.rollo-btn-extra-mb {
  min-height: 58px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px dashed #d97706;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.15s ease;
  grid-column: span 2;
}

.rollo-btn-extra-mb:hover {
  background: #fef3c7;
  border-color: #b45309;
  transform: translateY(-1px);
}

/* V13 R5: Barra Táctil de Filtro por Clientes en Módulo A */
.cliente-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.btn-cliente-filter {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-main, #1e293b);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-cliente-filter:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-cliente-filter.active {
  background: #1e3a8a !important;
  color: #ffffff !important;
  border-color: #1e3a8a !important;
  box-shadow: 0 2px 4px rgba(30, 58, 138, 0.25);
}


/* === MERMA POR OP (BOTÓN TÁCTIL Y MODAL) === */
.op-block-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-op-merma {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #f59e0b;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.btn-op-merma:hover, .btn-op-merma:active {
  background: #fde68a;
  border-color: #d97706;
}
.modal-merma-box {
  max-width: 780px;
  width: 96%;
  background-color: #ffffff !important;
  opacity: 1 !important;
  border-radius: 14px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.35);
  border: 1px solid #cbd5e1;
  overflow: hidden;
}
#modalRegistrarMerma .modal-card,
#modalRegistrarMerma .modal-box,
#modalRegistrarMerma .modal-header,
#modalRegistrarMerma .modal-body,
#modalRegistrarMerma .modal-footer {
  background-color: #ffffff !important;
  opacity: 1 !important;
}
#modalRegistrarMerma .modal-body {
  max-height: 75vh !important;
  overflow-y: auto !important;
  padding: 20px !important;
}
.merma-section-block {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.merma-section-title,
.merma-block-label {
  display: block;
  color: #0f172a !important;
  font-weight: 700 !important;
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.merma-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
}
.merma-meta-item {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: #0f172a;
}
.merma-meta-item strong {
  color: #0f172a;
  font-weight: 700;
}
.merma-meta-lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #475569;
  font-weight: 700;
  margin-bottom: 2px;
}
.merma-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.merma-chip {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid #94a3b8;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
}
.merma-chip.active {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1e40af;
}
.merma-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.merma-toggle-btn {
  min-height: 46px;
  border-radius: 8px;
  border: 2px solid #94a3b8;
  background: #ffffff;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  color: #0f172a;
}
.merma-toggle-btn.active {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}
.merma-alpha-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.merma-alpha-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1.5px solid #94a3b8;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
}
.merma-alpha-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}
.merma-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}
.merma-choice-btn {
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
  color: #0f172a;
}
.merma-choice-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}
.merma-defect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}
.merma-defect-btn {
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
  color: #0f172a;
}
.merma-defect-btn.active {
  background: #b45309;
  color: #ffffff;
  border-color: #92400e;
}
