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

/* ══════════════════════════════════════════
   SISTEMA DE DISEÑO INSTITUCIONAL ADAPTABLE
   Identidad visual: Azul profundo (De la captura), Gris/Blanco, Acentos sutiles.
   ══════════════════════════════════════════ */

:root {
  /* Colores */
  --primary:           #003B7A; /* Azul institucional profundo de la captura */
  --primary-hover:     #002E62;
  --accent:            #2563EB; /* Azul de acción */
  --accent-light:      #EFF6FF; /* Fondo de acento */
  --amarillo:          #F5A800; /* Amarillo de acento */
  --bg-app:            #F4F6FA; /* Gris claro de fondo */
  --bg-card:           #FFFFFF;
  --border-color:      #E2E8F0;
  
  /* Textos */
  --text-main:         #1E293B;
  --text-body:         #475569;
  --text-muted:        #64748B;
  --text-light:        #94A3B8;

  /* Triage Semáforo */
  --critico:           #DC2626;
  --critico-bg:        #FEF2F2;
  --critico-border:    #FCA5A5;
  --alto:              #D97706;
  --alto-bg:           #FFFBEB;
  --alto-border:       #FDE68A;
  --medio:             #CA8A04;
  --medio-bg:          #FEFCE8;
  --medio-border:      #FEF08A;
  --bajo:              #16A34A;
  --bajo-bg:           #F0FDF4;
  --bajo-border:       #BBF7D0;

  /* Estados */
  --state-borrador:    #475569;
  --state-borrador-bg: #F1F5F9;
  --state-enviado:     #2563EB;
  --state-enviado-bg:  #EFF6FF;
  --state-comite:      #7C3AED;
  --state-comite-bg:   #F5F3FF;
  --state-validado:    #16A34A;
  --state-validado-bg: #F0FDF4;
  --state-devuelto:    #DC2626;
  --state-devuelto-bg: #FEF2F2;

  /* Formas y Efectos */
  --radius-sm:         6px;
  --radius-md:         8px;
  --radius-lg:         12px;
  --shadow-sm:         0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:         0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg:         0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --transition:        all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-body);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR RESPONSIVE ── */
.sidebar {
  width: 250px;
  background-color: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: #F8FAFC;
}
.sidebar-brand-sub { font-size: 11px; color: #94A3B8; margin-top: 2px; }
.sidebar-brand-badge {
  display: inline-block; margin-top: 6px;
  background-color: var(--amarillo); color: var(--primary);
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}
.sidebar-nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.sidebar-nav-label {
  font-size: 9px; font-weight: 600; color: rgba(255,255,255,0.4);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 0 12px; margin-bottom: 6px; margin-top: 18px;
}
.sidebar-nav-label:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-md);
  color: rgba(255,255,255,0.75); text-decoration: none;
  font-size: 12.5px; font-weight: 500;
  transition: var(--transition); cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background-color: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background-color: rgba(255,255,255,0.12); color: white; font-weight: 600; }
.nav-item-icon { font-size: 12px; opacity: 0.8; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 10.5px; color: rgba(255,255,255,0.4); }

/* Hamburguesa móvil */
.menu-toggle {
  display: none; background: none; border: none;
  color: var(--text-main); font-size: 20px; cursor: pointer;
  padding: 8px; margin-right: 12px;
}

/* ── CONTENIDO PRINCIPAL ── */
.main-content {
  margin-left: 250px;
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left 0.2s ease;
}

/* ── TOPBAR ── */
.topbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-main); }
.topbar-breadcrumb { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ── CUERPO DE PÁGINA ── */
.page-body { padding: 24px; flex: 1; }

/* ── TARJETAS (CARDS) ── */
.card {
  background-color: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  margin-bottom: 20px; overflow: hidden;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  background-color: #FAFBFC;
}
.card-title { font-size: 11.5px; font-weight: 600; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px; }
.card-body { padding: 20px; }

/* ── KPIs ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background-color: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-label { font-size: 9.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text-main); line-height: 1.1; margin-bottom: 4px; }
.kpi-value.azul { color: var(--accent); }
.kpi-value.rojo { color: var(--critico); }
.kpi-value.naranja { color: var(--alto); }
.kpi-value.verde { color: var(--bajo); }
.kpi-value.amarillo { color: var(--medio); }
.kpi-sub { font-size: 10.5px; color: var(--text-muted); }

/* ── FORMULARIO Y CAMPOS (DENTRO DEL MODAL) ── */
.f-section { border: 1px solid var(--border-color); border-radius: var(--radius-lg); margin-bottom: 16px; background: white; overflow: hidden; }
.f-section-head { padding: 12px 18px; background-color: #FAFBFC; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; }
.f-section-num { width: 22px; height: 22px; background-color: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.f-section-title { font-size: 11px; font-weight: 600; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px; }
.f-section-tag { margin-left: auto; font-size: 9px; font-weight: 600; color: var(--text-muted); background-color: #E2E8F0; padding: 2px 6px; border-radius: 4px; }
.f-section-body { padding: 18px; }

.fg-grid { display: grid; gap: 14px; }
.fg-2 { grid-template-columns: 1fr 1fr; }
.fg-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) { .fg-2, .fg-3 { grid-template-columns: 1fr; } }

.fg { display: flex; flex-direction: column; gap: 4px; }
.fl { font-size: 10.5px; font-weight: 600; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px; }
.fl .r { color: var(--critico); }
.fh { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }

input.fc, select.fc, textarea.fc {
  background-color: white; border: 1px solid #CBD5E1; border-radius: var(--radius-md);
  color: var(--text-main); font-family: var(--font-main); font-size: 13px;
  padding: 8px 12px; width: 100%; transition: var(--transition);
}
input.fc:focus, select.fc:focus, textarea.fc:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
textarea.fc { resize: vertical; min-height: 80px; }
input.fc:disabled, select.fc:disabled { background-color: #F8FAFC; color: var(--text-muted); cursor: not-allowed; border-color: var(--border-color); }
.fc-auto { background-color: #F0F9FF !important; border-color: #B9E6FE !important; color: #0369A1 !important; font-weight: 600; }

/* ── MODAL FORMULARIO EMERGENTE EXTREMADAMENTE SEGURO Y ADAPTABLE ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background-color: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px);
  padding: 16px; overflow-y: auto;
}
.modal-overlay.show { display: flex; align-items: flex-start; justify-content: center; }
.modal-box {
  background-color: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-width: 820px; width: 100%; margin-top: 20px; margin-bottom: 20px; overflow: hidden;
  display: flex; flex-direction: column; max-height: calc(100vh - 40px);
}
.modal-head {
  background-color: var(--primary); padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; color: white;
}
.modal-head-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.modal-close {
  background: rgba(255,255,255,0.1); border: none; color: white;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.modal-close:hover { background-color: rgba(255,255,255,0.25); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-color);
  display: flex; gap: 8px; justify-content: space-between; align-items: center;
  background-color: #FAFBFC;
}

/* Consecutivo Minimalista */
.consecutivo-badge {
  font-family: monospace; font-size: 12px; font-weight: 700;
  color: var(--accent); background-color: var(--accent-light);
  padding: 4px 10px; border-radius: 4px; border: 1px solid #BFDBFE;
}

/* ── BOTONES ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-family: var(--font-main); font-size: 12.5px; font-weight: 600;
  cursor: pointer; border: none; transition: var(--transition); text-decoration: none;
}
.btn-primary { background-color: var(--accent); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: white; color: var(--text-body); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: #F8FAFC; }
.btn-danger { background-color: var(--critico-bg); color: var(--critico); border: 1px solid var(--critico-border); }
.btn-danger:hover { background-color: var(--critico); color: white; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

/* ── CATEGORÍAS ── */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .cat-grid { grid-template-columns: 1fr; } }
.cat-card {
  border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 12px;
  cursor: pointer; transition: var(--transition); background-color: white; position: relative;
}
.cat-card input { position: absolute; opacity: 0; }
.cat-card:hover { border-color: var(--accent); background-color: #F8FAFC; }
.cat-card.sel-c { border-color: var(--critico); background-color: var(--critico-bg); }
.cat-card.sel-a { border-color: var(--alto); background-color: var(--alto-bg); }
.cat-card.sel-m { border-color: var(--medio); background-color: var(--medio-bg); }
.cat-card.sel-b { border-color: var(--bajo); background-color: var(--bajo-bg); }
.cat-name { font-size: 12.5px; font-weight: 600; color: var(--text-main); margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-c { background-color: var(--critico); }
.dot-a { background-color: var(--alto); }
.dot-m { background-color: var(--medio); }
.dot-b { background-color: var(--bajo); }
.cat-desc { font-size: 10.5px; color: var(--text-muted); line-height: 1.3; }

/* ── EVIDENCE DROPZONE ── */
.evidence-dropzone {
  border: 2px dashed #CBD5E1; border-radius: var(--radius-lg); padding: 20px;
  text-align: center; background-color: #F8FAFC; cursor: pointer; transition: var(--transition);
}
.evidence-dropzone:hover { border-color: var(--accent); background-color: #EFF6FF; }
.dz-icon { font-size: 24px; color: var(--text-light); margin-bottom: 4px; }
.dz-text { font-size: 12px; font-weight: 600; color: var(--text-body); }
.dz-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background-color: white; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 11.5px; }
.file-name { font-weight: 600; color: var(--text-body); }
.file-size { color: var(--text-muted); margin-left: 6px; }
.file-remove { color: var(--critico); cursor: pointer; font-weight: 600; }

/* ── ADAPTABILIDAD MÓVIL (MEDIA QUERIES EXTREMAS) ── */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .page-body { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .heatmap-grid { grid-template-columns: repeat(3, 1fr); }
  .modal-box { max-height: calc(100vh - 20px); margin-top: 10px; margin-bottom: 10px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .heatmap-grid { grid-template-columns: repeat(2, 1fr); }
  .tr-grid { grid-template-columns: 1fr; }
  .ft-grid { grid-template-columns: 1fr; }
  .ck-grid { grid-template-columns: 1fr; }
}

/* ── TABS NAVEGACIÓN ── */
.tab-nav { display: flex; background-color: white; border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow-x: auto; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.tab-btn { flex: 1; min-width: 100px; padding: 10px; border: none; background: transparent; color: var(--text-muted); font-family: var(--font-main); font-size: 11px; font-weight: 600; cursor: pointer; transition: var(--transition); text-transform: uppercase; letter-spacing: 0.5px; border-right: 1px solid var(--border-color); }
.tab-btn:last-child { border-right: none; }
.tab-btn:hover { background-color: #F8FAFC; color: var(--accent); }
.tab-btn.active { background-color: var(--accent); color: white; }
.tab-content { display: none; } .tab-content.active { display: block; }

/* ── PIPELINES, GRAFICOS Y MODALES COMPARTIDOS ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-wrap { height: 220px; position: relative; }
.empty-state { text-align: center; padding: 36px 16px; }
.empty-icon { font-size: 32px; color: var(--text-light); margin-bottom: 8px; }
.empty-title { font-size: 13px; font-weight: 600; color: var(--text-body); }
.empty-desc { font-size: 11px; color: var(--text-muted); }
.spinner { width: 22px; height: 22px; border: 3px solid #E2E8F0; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: none; position: fixed; inset: 0; z-index: 500; background-color: rgba(255,255,255,0.8); backdrop-filter: blur(2px); align-items: center; justify-content: center; flex-direction: column; gap: 10px; }
.loading-overlay.show { display: flex; }
.loading-text { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; }
.toast { background: white; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 10px 14px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg); font-size: 12px; min-width: 240px; animation: toastIn 0.2s ease; }
.toast.success { border-left: 3px solid var(--bajo); }
.toast.error { border-left: 3px solid var(--critico); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--amarillo); }
@keyframes toastIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.tg-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #F1F5F9; }
.tg-row:last-child { border-bottom: none; }
.tg-lbl { font-size: 12px; color: var(--text-body); }
.tg-sw { position: relative; width: 34px; height: 18px; flex-shrink: 0; }
.tg-sw input { opacity: 0; width: 0; height: 0; }
.tg-sl { position: absolute; cursor: pointer; inset: 0; background-color: #CBD5E1; border-radius: 18px; transition: var(--transition); }
.tg-sl::before { content: ''; position: absolute; height: 12px; width: 12px; left: 3px; bottom: 3px; background-color: white; border-radius: 50%; transition: var(--transition); }
.tg-sw input:checked + .tg-sl { background-color: var(--accent); }
.tg-sw input:checked + .tg-sl::before { transform: translateX(16px); }
.mn-wrap { position: relative; }
.mn-pre { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--text-muted); font-weight: 600; }
.mn-wrap input { padding-left: 22px; }
.tags-box { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px; background-color: white; border: 1px solid #CBD5E1; border-radius: var(--radius-md); min-height: 38px; cursor: text; transition: var(--transition); }
.tags-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.tag-chip { background-color: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.tag-rm { cursor: pointer; color: #93C5FD; }
.tag-rm:hover { color: var(--critico); }
.tag-in { border: none; outline: none; font-family: var(--font-main); font-size: 12.5px; color: var(--text-main); min-width: 100px; flex: 1; background: transparent; }
.divider { border: none; border-top: 1px solid var(--border-color); margin: 12px 0; }
.flow-bar { display: flex; background-color: white; border-radius: var(--radius-lg); overflow-x: auto; border: 1px solid var(--border-color); }
.flow-step { flex: 1; min-width: 90px; padding: 12px; text-align: center; border-right: 1px solid var(--border-color); background-color: white; }
.flow-step:last-child { border-right: none; }
.flow-step-num { font-size: 20px; font-weight: 700; color: var(--text-main); line-height: 1; }
.flow-step-lbl { font-size: 9px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.flow-step.active { background-color: #EFF6FF; }
.flow-step.active .flow-step-num { color: var(--accent); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: monospace; }

/* ── MAPA DE CALOR SECTORIAL (HEATMAP) ── */
.heatmap-container { padding: 10px 0; }
.heatmap-legend { display: flex; gap: 14px; margin-bottom: 16px; font-size: 11px; flex-wrap: wrap; }
.hl-item { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-body); }
.hl-box { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.heatmap-cell {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  min-height: 76px;
  box-shadow: var(--shadow-sm);
}
.heatmap-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.hc-count { font-size: 20px; font-weight: 800; color: var(--text-main); }
.hc-lbl { font-size: 8.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; letter-spacing: 0.3px; }

/* Colores de criticidad */
.h-bajo { background-color: #F0FDF4 !important; border-color: #BBF7D0 !important; color: #166534 !important; }
.h-bajo .hc-count, .h-bajo .hc-lbl { color: #15803d !important; }

.h-medio { background-color: #FFFBEB !important; border-color: #FDE68A !important; color: #B45309 !important; }
.h-medio .hc-count, .h-medio .hc-lbl { color: #b45309 !important; }

.h-alto { background-color: #FFF7ED !important; border-color: #FED7AA !important; color: #C2410C !important; }
.h-alto .hc-count, .h-alto .hc-lbl { color: #c2410c !important; }

.h-critico { background-color: #FEF2F2 !important; border-color: #FCA5A5 !important; color: #B91C1C !important; }
.h-critico .hc-count, .h-critico .hc-lbl { color: #b91c1c !important; }

/* ── REJILLAS DE OPCIONES EN EL FORMULARIO (ESCRITORIO) ── */
.ck-grid, .ft-grid, .tr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

/* ── ESTILOS PREMIUM PARA TABLAS ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

th {
  background-color: #F8FAFC;
  color: var(--text-main);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-body);
  vertical-align: middle;
}

tr {
  transition: var(--transition);
  cursor: pointer;
}

tr:hover {
  background-color: #F8FAFC;
}

tr:last-child td {
  border-bottom: none;
}

/* Badges estilizados para las tablas */
.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.2;
  white-space: nowrap;
}

/* Badges de Triage */
.badge-critico { background-color: var(--critico-bg); color: var(--critico); border: 1px solid var(--critico-border); }
.badge-alto { background-color: var(--alto-bg); color: var(--alto); border: 1px solid var(--alto-border); }
.badge-medio { background-color: var(--medio-bg); color: var(--medio); border: 1px solid var(--medio-border); }
.badge-bajo { background-color: var(--bajo-bg); color: var(--bajo); border: 1px solid var(--bajo-border); }

/* Badges de Estado */
.badge-borrador { background-color: var(--state-borrador-bg); color: var(--state-borrador); border: 1px solid #CBD5E1; }
.badge-enviado { background-color: var(--state-enviado-bg); color: var(--state-enviado); border: 1px solid #BFDBFE; }
.badge-comite { background-color: var(--state-comite-bg); color: var(--state-comite); border: 1px solid #DDD6FE; }
.badge-validado { background-color: var(--state-validado-bg); color: var(--state-validado); border: 1px solid #BBF7D0; }
.badge-devuelto { background-color: var(--state-devuelto-bg); color: var(--state-devuelto); border: 1px solid var(--critico-border); }

/* ── OPTIMIZACIONES MÓVILES EXTREMAS (MEDIA QUERIES) ── */
@media (max-width: 768px) {
  /* KPIs en una regleta horizontal ultra compacta y deslizable */
  .kpi-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
    scrollbar-width: none; /* Firefox */
    padding-bottom: 4px;
  }
  .kpi-grid::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  .kpi-card {
    flex: 0 0 115px !important;
    padding: 8px 10px !important;
    min-height: 72px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    margin-bottom: 0 !important;
  }
  .kpi-label {
    font-size: 8px !important;
    letter-spacing: 0.3px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .kpi-value {
    font-size: 16px !important;
    margin-bottom: 0 !important;
  }
  .kpi-sub {
    font-size: 8px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Ocultar elementos secundarios en la Topbar para dar espacio */
  #btnRegistrarTopbar {
    display: none !important;
  }
  #simuladorRolContainer {
    display: none !important;
  }
  .topbar-breadcrumb {
    display: none !important;
  }
  #activeUserText {
    display: none !important;
  }
  #activeUserSessionContainer {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }
  #activeUserSessionContainer button {
    background-color: var(--critico-bg) !important;
    color: var(--critico) !important;
    border: 1px solid var(--critico-border) !important;
    padding: 4px 8px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
  }
  .topbar-title {
    font-size: 13.5px !important;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Flujo de validación (Doble Check) más compacto */
  .flow-bar {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .flow-step {
    padding: 8px 4px !important;
    min-width: 75px !important;
  }
  .flow-step-num {
    font-size: 14px !important;
  }
  .flow-step-lbl {
    font-size: 8.5px !important;
  }

  /* Pestañas con scroll suave */
  .tab-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn {
    flex: 0 0 auto;
    font-size: 10px;
    padding: 8px 12px;
  }

  /* Modal de formulario compacto en móvil */
  .modal-overlay {
    padding: 8px;
  }
  .modal-box {
    max-height: calc(100vh - 16px);
    margin: 8px auto;
  }
  .modal-body {
    padding: 12px;
  }
  .f-section-body {
    padding: 12px;
  }
  .f-section-head {
    padding: 8px 12px;
  }
  .fg-grid {
    gap: 10px;
  }

  /* Topbar compacta */
  .topbar {
    padding: 0 12px;
    height: 50px;
  }
}

@media (max-width: 480px) {
  /* Optimización extrema de tabla para que quepa en pantalla pequeña */
  td, th {
    padding: 8px 10px;
    font-size: 11px;
  }
  
  /* Reducir espacio innecesario */
  .page-body {
    padding: 10px;
  }
  
  .card-body {
    padding: 10px;
  }
  
  /* Botones más amigables al tacto */
  .btn {
    padding: 6px 12px;
    font-size: 11.5px;
  }
}
