/* ========== DESIGN SYSTEM: CSS VARIABLES ========== */

:root {
  /* Primary Colors */
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;

  /* Accent & Status */
  --accent: #0f766e;
  --accent-light: #14b8a6;
  --success: #059669;
  --success-light: #10b981;
  --warning: #dc2626;
  --warning-light: #ef4444;
  --info: #3b82f6;

  /* Neutrals - Light Mode */
  --bg-light: #ffffff;
  --bg-surface-light: #f8fafc;
  --bg-secondary-light: #f1f5f9;
  --text-primary-light: #0f172a;
  --text-secondary-light: #475569;
  --border-light: #e2e8f0;

  /* Neutrals - Dark Mode */
  --bg-dark: #0f172a;
  --bg-surface-dark: #1e293b;
  --bg-secondary-dark: #334155;
  --text-primary-dark: #f1f5f9;
  --text-secondary-dark: #cbd5e1;
  --border-dark: #475569;

  /* Current Mode (default light) */
  --bg: var(--bg-light);
  --bg-surface: var(--bg-surface-light);
  --bg-secondary: var(--bg-secondary-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --border: var(--border-light);

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;
  --sp-3xl: 40px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --trans-fast: 150ms ease-out;
  --trans-base: 200ms ease-out;
  --trans-slow: 300ms ease-out;
}

/* ========== BASE & RESET ========== */

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

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
  color: var(--text-primary);
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  max-width: 100%;
  overflow-x: hidden;
}

/* Evita mostrar el dashboard mientras se valida la sesión de Supabase. */
body.auth-pending {
  visibility: hidden;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

/* ========== SIDEBAR NAVIGATION ========== */

.sidebar {
  width: 250px;
  height: 100vh;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
}

.sidebar-brand {
  padding: var(--sp-xl) var(--sp-lg);
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--primary);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-sm) 0;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 0 var(--sp-lg);
  height: 48px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans-base);
  position: relative;
}

.nav-item:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--bg-secondary);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--sp-lg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.user-info {
  padding: var(--sp-md) 0;
  border-bottom: 1px solid var(--border);
}

.user-email {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans-base);
}

.btn-logout:hover {
  background-color: var(--warning);
  color: white;
  border-color: var(--warning);
}

.btn-logout svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ========== MAIN CONTENT AREA ========== */

.main-content {
  flex: 1;
  margin-left: 250px;
  background-color: var(--bg);
  min-height: 100vh;
  overflow-y: auto;
}

.view-section {
  display: none;
}

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

/* ========== SECTION HEADER ========== */

.section-header {
  padding: var(--sp-3xl) var(--sp-3xl) var(--sp-xl);
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
}

.section-header button {
  flex-shrink: 0;
}

.section-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.section-header p {
  margin: var(--sp-sm) 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.btn-back {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--trans-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-back:hover {
  background-color: var(--bg-secondary);
}

.btn-back svg {
  width: 24px;
  height: 24px;
}

/* ========== QUICK ACTIONS ========== */

.quick-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
  padding: var(--sp-xl) var(--sp-3xl);
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans-base);
  white-space: nowrap;
}

.action-btn.primary {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.action-btn.primary:hover {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.action-btn.secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border);
}

.action-btn.secondary:hover {
  background-color: var(--border);
}

.action-btn.icon {
  padding: var(--sp-md) var(--sp-md);
}

.action-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.more-options {
  position: relative;
  margin-left: auto;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 1800;
  margin-top: var(--sp-sm);
}

.dropdown-menu.hidden {
  display: none;
}

.menu-item {
  display: block;
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  background: none;
  border: none;
  text-align: left;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.menu-item:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* ========== COMPLIANCE PANEL ========== */

.compliance-panel {
  margin: var(--sp-xl) var(--sp-3xl);
  padding: var(--sp-xl);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-xl);
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.panel-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.btn-refresh {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--primary);
  transition: all var(--trans-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-refresh:hover {
  background-color: var(--bg-secondary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-refresh svg {
  width: 20px;
  height: 20px;
}

.compliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-lg);
}

.compliance-pill {
  padding: var(--sp-md) var(--sp-lg);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text-secondary);
}

/* Traffic Light Cards */
.traffic-light-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-md);
  transition: all var(--trans-base);
  box-shadow: var(--shadow-sm);
}

.traffic-light-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.traffic-light-card.traffic-verde,
.traffic-light-card.traffic-green {
  border-left-color: #059669;
  background: linear-gradient(to right, rgba(5, 150, 105, 0.02), transparent);
}

.traffic-light-card.traffic-amarillo,
.traffic-light-card.traffic-yellow {
  border-left-color: #d97706;
  background: linear-gradient(to right, rgba(217, 119, 6, 0.02), transparent);
}

.traffic-light-card.traffic-rojo,
.traffic-light-card.traffic-red {
  border-left-color: #dc2626;
  background: linear-gradient(to right, rgba(220, 38, 38, 0.02), transparent);
}

.traffic-light-header {
  display: flex;
  gap: var(--sp-md);
  align-items: flex-start;
}

.traffic-light-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  display: inline-block;
}

.traffic-light-dot.traffic-verde,
.traffic-light-dot.traffic-green {
  background-color: #059669;
  box-shadow: 0 0 8px rgba(5, 150, 105, 0.6);
}

.traffic-light-dot.traffic-amarillo,
.traffic-light-dot.traffic-yellow {
  background-color: #d97706;
  box-shadow: 0 0 8px rgba(217, 119, 6, 0.6);
}

.traffic-light-dot.traffic-rojo,
.traffic-light-dot.traffic-red {
  background-color: #dc2626;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
}

.traffic-light-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--sp-xs) 0;
}

.traffic-light-header p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.traffic-light-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
  padding-top: var(--sp-md);
  border-top: 1px dashed var(--border);
}

.traffic-light-metrics span {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.02);
}

.traffic-light-metrics strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ========== ONBOARDING STEPPER ========== */

.onboarding-stepper {
  margin: var(--sp-xl) var(--sp-3xl);
  padding: var(--sp-xl);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
}

.stepper-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  opacity: 0.5;
  transition: opacity var(--trans-base);
}

.stepper-step.completed,
.stepper-step.active {
  opacity: 1;
}

.stepper-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.stepper-step.completed .stepper-circle {
  background-color: var(--success);
  border-color: var(--success);
  color: white;
}

.stepper-step.active .stepper-circle {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.stepper-content h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.stepper-content p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.stepper-line {
  width: 40px;
  height: 2px;
  background-color: var(--border);
  flex-shrink: 0;
}

/* ========== MACROPROCESS GRID ========== */

.macroprocess-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--sp-xl);
  padding: var(--sp-xl) var(--sp-3xl);
  background-color: var(--bg);
}

.macro-card {
  display: flex;
  flex-direction: column;
  padding: var(--sp-xl);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--trans-base);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.macro-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.macro-card.featured {
  border: 2px solid var(--primary);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(15, 118, 110, 0.05) 100%);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-lg);
  margin-bottom: var(--sp-md);
}

.card-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.status-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge.in-process {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.status-badge.completed {
  background: #ccfbf1;
  color: #0f766e;
  border: 1px solid #99f6e4;
}

.alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  white-space: nowrap;
}

.alert-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.alert-badge--alta {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.alert-badge--alta::before {
  background: #dc2626;
}

.alert-badge--media {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.alert-badge--media::before {
  background: #f59e0b;
}

.alert-badge--ok {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.alert-badge--ok::before {
  background: #16a34a;
}

.card-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 var(--sp-xl);
  flex: 1;
  line-height: 1.6;
}

.macro-card .btn {
  align-self: flex-start;
}

/* ========== BUTTONS ========== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans-base);
  white-space: nowrap;
  text-decoration: none;
}

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

.btn.btn-primary {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn.btn-secondary:hover {
  background-color: var(--border);
}

.btn.btn-success {
  background-color: var(--success);
  color: white;
  border-color: var(--success);
}

.btn.btn-success:hover {
  background-color: var(--success-light);
}

.btn.btn-warning {
  background-color: var(--warning);
  color: white;
  border-color: var(--warning);
}

.btn.btn-warning:hover {
  background-color: var(--warning-light);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ========== SECTION ACTIONS ========== */

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
  padding: var(--sp-lg) var(--sp-3xl);
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ========== FORM PANELS ========== */

.form-panel {
  margin: var(--sp-xl) var(--sp-3xl);
  padding: var(--sp-xl);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.form-panel h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 var(--sp-lg);
}

.form-panel h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 var(--sp-lg);
}

.panel-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin: var(--sp-sm) 0 var(--sp-lg);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
  justify-content: space-between;
  align-items: center;
}

/* ========== FILTERS ========== */

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.input-field,
.select-field,
.textarea-field {
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: inherit;
  transition: all var(--trans-base);
}

.input-field:focus,
.select-field:focus,
.textarea-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.select-field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-lg) center;
  padding-right: 32px;
}

.textarea-field {
  resize: vertical;
  min-height: 100px;
}

/* ========== FORM GROUPS ========== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.required {
  color: var(--warning);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-lg);
  margin-bottom: var(--sp-lg);
}

/* ========== KPI CARDS ========== */

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.kpi-card {
  padding: var(--sp-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  transition: all var(--trans-base);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  min-height: 100px;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background-color: var(--border);
  transition: background-color var(--trans-base);
}

.kpi-card.success::before {
  background-color: var(--success);
}

.kpi-card.warning::before {
  background-color: var(--warning);
}

.kpi-card.accent::before {
  background-color: var(--accent);
}

.kpi-card.primary::before {
  background-color: var(--primary);
}

.kpi-card.success .kpi-value {
  color: var(--success);
}

.kpi-card.warning .kpi-value {
  color: var(--warning);
}

.kpi-card.accent .kpi-value {
  color: var(--accent);
}

.kpi-card.primary .kpi-value {
  color: var(--primary);
}

.kpi-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.75px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
  font-family: 'Outfit', 'Inter', sans-serif;
  letter-spacing: -0.5px;
}

/* ========== EVIDENCE GRID ========== */

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-lg);
  margin-top: var(--sp-lg);
}

/* ========== TABLES ========== */

.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg);
}

thead {
  background-color: var(--bg-secondary);
}

th {
  padding: var(--sp-lg);
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: var(--sp-lg);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

tbody tr:hover {
  background-color: var(--bg-secondary);
}

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

/* ========== PAGINATION ========== */

.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  background-color: var(--bg);
}

/* ========== FILE UPLOAD ========== */

.file-upload-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  background-color: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-lg);
}

.file-upload-wrapper {
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
}

.file-upload-section small {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ========== MODALS ========== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal.modal-front {
  z-index: 5000;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  cursor: pointer;
  z-index: 4000;
}

.modal-content {
  position: relative;
  z-index: 4001;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: var(--sp-xl);
  animation: modalFadeIn 200ms ease-out, modalScale 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content.modal-lg {
  max-width: 700px;
}

.modal-content.modal-xl {
  max-width: 900px;
}

#modalHistorialEvidencia .modal-content {
  max-width: 860px;
  width: min(92vw, 860px);
  max-height: 88vh;
}

.modal-content.modal-confirmation {
  max-width: 460px;
  width: min(92vw, 460px);
}

.confirmation-message {
  margin: var(--sp-lg) 0 0;
  color: var(--text-primary);
  line-height: 1.6;
}

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

@keyframes modalScale {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

.modal-header {
  position: sticky;
  top: -24px;
  background-color: var(--bg-surface);
  z-index: 100;
  margin-top: -24px;
  margin-left: -24px;
  margin-right: -24px;
  padding-top: 24px;
  padding-left: 24px;
  padding-right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-lg);
  margin-bottom: var(--sp-xl);
  padding-bottom: var(--sp-lg);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.modal-close {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--trans-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-close:hover {
  background-color: var(--warning-light);
  color: white;
  border-color: var(--warning-light);
  transform: rotate(90deg) scale(1.05);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-actions {
  display: flex;
  gap: var(--sp-md);
  justify-content: flex-end;
  margin-top: var(--sp-xl);
  padding-top: var(--sp-lg);
  border-top: 1px solid var(--border);
}

/* ========== CARDS GRID ========== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--sp-lg);
}

.dashboard-grid,
.evidence-grid,
.macro-evidence-grid,
.acciones-grid,
.metrics-grid,
.metrics-summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.main-content,
.page-content,
.section-content,
.dashboard-content,
.view-section,
.form-panel {
  min-width: 0;
  width: 100%;
}

.evidence-grid,
.macro-evidence-grid {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  align-items: stretch;
}

.evidence-card,
.macro-evidence-card {
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  overflow: visible;
  overflow-wrap: anywhere;
}

.evidence-card.priority-alta,
.macro-evidence-card.priority-alta {
  border-left: 5px solid #dc2626;
}

.evidence-card.priority-media,
.macro-evidence-card.priority-media {
  border-left: 5px solid #f59e0b;
}

.evidence-card.priority-baja,
.macro-evidence-card.priority-baja {
  border-left: 5px solid #16a34a;
}

.evidence-card-header,
.evidence-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.evidence-title-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.evidence-code {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 800;
  font-size: 12px;
}

.evidence-title-group h3,
.evidence-title {
  margin: 0;
  color: #0f172a;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.evidence-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.evidence-card-body,
.evidence-meta {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.evidence-card-body p,
.evidence-meta-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
  font-size: 14px;
  color: #334155;
}

.evidence-card-body span,
.evidence-meta-label {
  font-weight: 800;
  color: #475569;
}

.evidence-progress,
.progress-block {
  display: grid;
  gap: 6px;
}

.evidence-progress .progress-meta,
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
  font-size: 14px;
}

.evidence-progress .progress-bar,
.progress-bar {
  height: 9px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.evidence-progress .progress-bar span,
.progress-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #16a34a);
}

.evidence-actions,
.primary-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.evidence-actions button {
  white-space: nowrap;
}

.metric-card,
.metrics-summary-card,
.interpretation-card {
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  min-width: 0;
  overflow-wrap: anywhere;
}

.metric-card-enhanced {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  align-items: start;
}

.metric-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #e0f2fe;
  color: #075985;
  font-weight: 900;
  font-size: 12px;
}

.metric-value {
  font-size: 20px;
  color: #0f172a;
  line-height: 1.1;
}

.metric-label {
  display: block;
  grid-column: 2;
  font-weight: 800;
  color: #0f172a;
}

.metric-description {
  grid-column: 2;
  margin: 0;
  color: #475569;
  line-height: 1.45;
  font-size: 14px;
}

/* ========== INFO BOX ========== */

.info-box {
  padding: var(--sp-xl);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========== TABS ========== */

.tabs-row {
  display: flex;
  gap: var(--sp-sm);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-lg);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-lg) var(--sp-md);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--trans-base);
}

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

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

.tab-btn svg {
  width: 18px;
  height: 18px;
}

.metrics-panel {
  display: none;
}

.metrics-panel.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-lg);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }

  .main-content {
    margin-left: 200px;
  }

  .section-header {
    padding: var(--sp-2xl) var(--sp-xl);
  }

  .section-header h1 {
    font-size: 24px;
  }

  .quick-actions-group,
  .section-actions {
    padding: var(--sp-lg) var(--sp-xl);
  }

  .macroprocess-grid,
  .form-panel {
    margin: var(--sp-lg) var(--sp-xl);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    padding: var(--sp-sm) 0;
  }

  .sidebar-brand {
    padding: var(--sp-lg) var(--sp-sm);
    text-align: center;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .nav-item {
    padding: 0 var(--sp-md);
    justify-content: center;
  }

  .nav-item span {
    display: none;
  }

  .main-content {
    margin-left: 60px;
  }

  .section-header,
  .quick-actions-group,
  .section-actions,
  .compliance-panel,
  .onboarding-stepper,
  .macroprocess-grid,
  .form-panel {
    margin: var(--sp-sm);
    padding: var(--sp-lg);
  }

  .section-header h1 {
    font-size: 20px;
  }

  .quick-actions-group {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
    justify-content: center;
  }

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

  .filter-row {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

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

  .onboarding-stepper {
    flex-direction: column;
    gap: var(--sp-md);
  }

  .stepper-line {
    width: 2px;
    height: 40px;
  }
}

@media (max-width: 375px) {
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: relative;
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: var(--sp-sm);
  }

  .nav-item {
    height: auto;
    padding: var(--sp-sm);
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    margin-left: 0;
    margin-top: 60px;
  }

  .section-header {
    padding: var(--sp-lg) var(--sp-md);
    flex-direction: column;
    gap: var(--sp-md);
  }

  .section-header h1 {
    font-size: 18px;
  }

  .quick-actions-group,
  .compliance-panel,
  .onboarding-stepper,
  .macroprocess-grid,
  .form-panel {
    margin: var(--sp-md);
    padding: var(--sp-md);
  }

  .modal-content {
    width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: var(--sp-sm);
  }
}

/* ========== UTILITIES ========== */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.gap-md {
  gap: var(--sp-md);
}

.mt-lg {
  margin-top: var(--sp-lg);
}

/* ========== AUTHENTICATION / LOGIN ========== */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, rgba(15, 118, 110, 0.05) 90%), var(--bg-surface);
  padding: var(--sp-xl);
}

.auth-container {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: modalFadeIn 300ms ease-out;
}

.auth-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2xl);
  box-shadow: var(--shadow-xl);
  transition: transform var(--trans-base);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--sp-xl);
}

.auth-brand h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  margin-bottom: var(--sp-xs);
}

.auth-brand p {
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--sp-xl);
  gap: var(--sp-md);
}

.auth-tabs button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--sp-md) 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans-base);
  margin-bottom: -2px;
}

.auth-tabs button:hover {
  color: var(--text-primary);
}

.auth-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-message {
  padding: var(--sp-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: var(--sp-lg);
  display: none;
  font-weight: 500;
  text-align: center;
}

.auth-message.success {
  display: block;
  background-color: rgba(5, 150, 105, 0.1);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.auth-message.error {
  display: block;
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--warning);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.form-control {
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  transition: all var(--trans-base);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-auth-submit {
  width: 100%;
  justify-content: center;
  padding: var(--sp-md);
  font-size: 15px;
  font-weight: 600;
  margin-top: var(--sp-sm);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  margin: var(--sp-xl) 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider:not(:empty)::before {
  margin-right: var(--sp-md);
}

.auth-divider:not(:empty)::after {
  margin-left: var(--sp-md);
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  width: 100%;
  padding: var(--sp-md);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans-base);
}

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

/* ========== TOAST NOTIFICATIONS ========== */

#toastContainer {
  position: fixed;
  top: var(--sp-lg);
  right: var(--sp-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  pointer-events: none;
  max-width: 350px;
  width: calc(100% - 2 * var(--sp-lg));
}

.toast {
  pointer-events: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--sp-md) var(--sp-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
}

.toast-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--sp-md);
}

.toast-message {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.45;
}

.toast-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  opacity: 0.6;
  cursor: pointer;
  padding: 0 var(--sp-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all var(--trans-base);
}

.toast-close-btn:hover {
  opacity: 1;
  color: var(--text-primary);
}

/* Toast Color Variations */
.toast.toast-info {
  border-left-color: var(--primary);
  background: linear-gradient(to right, rgba(37, 99, 235, 0.02), var(--bg-surface));
}

.toast.toast-success {
  border-left-color: #059669;
  background: linear-gradient(to right, rgba(5, 150, 105, 0.02), var(--bg-surface));
}

.toast.toast-warning {
  border-left-color: #d97706;
  background: linear-gradient(to right, rgba(217, 119, 6, 0.02), var(--bg-surface));
}

.toast.toast-error {
  border-left-color: #dc2626;
  background: linear-gradient(to right, rgba(220, 38, 38, 0.02), var(--bg-surface));
}

/* Animations */
.toast.fade-in {
  animation: toastSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.toast.fade-out {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
}

/* ========== ACCION CARDS (Collapsible) ========== */

#contenidoAccionesMejora {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.accion-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  transition: all var(--trans-base);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  min-width: 0;
  overflow: visible;
  overflow-wrap: anywhere;
}

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

.accion-quick-info {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--sp-xs);
  overflow-wrap: anywhere;
}

.accion-quick-info strong {
  color: var(--text-primary);
}

.accion-preview {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.btn-toggle-details {
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: var(--sp-xs) 0;
  align-self: flex-start;
  transition: color var(--trans-base);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-toggle-details:hover {
  color: var(--accent);
}

.accion-details {
  margin-top: var(--sp-xs);
  padding-top: var(--sp-md);
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  animation: fadeIn 0.2s ease;
}

.accion-detail-group h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 4px 0;
}

.accion-detail-group p {
  font-size: 13px;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.45;
}

.highlight-recommendation {
  background-color: rgba(37, 99, 235, 0.03);
  border-left: 3px solid var(--primary);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
}

.accion-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-sm);
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  padding: var(--sp-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.accion-details-grid div {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.accion-details-grid strong {
  color: var(--text-primary);
}

.accion-detail-footer {
  display: flex;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-xs);
}

.accion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.accion-actions .btn {
  flex: 1 1 auto;
  min-width: 110px;
}

.accion-actions .btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.btn-accion-proceso {
  background: #eef4fb;
  color: #1f4e79;
  border: 1px solid #c8d7e6;
}

.btn-accion-proceso:hover {
  background: #dbe8f4;
  border-color: #a9bfd6;
}

.btn-accion-atendida {
  background: #e8f3f0;
  color: #155e63;
  border: 1px solid #b9d8d2;
}

.btn-accion-atendida:hover {
  background: #d6e8e4;
  border-color: #9cc6be;
}

.btn-accion-descartar {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-accion-descartar:hover {
  background: #e5e7eb;
  border-color: #b6bcc6;
}

.btn-accion-detalle,
.btn-toggle-details {
  color: #2563eb;
}

.badge-estado-pendiente {
  background: #f6f7f9;
  color: #4b5563;
  border: 1px solid #d7dce2;
}

.badge-estado-en_proceso {
  background: #eef4fb;
  color: #1f4e79;
  border: 1px solid #c8d7e6;
}

.badge-estado-atendida {
  background: #e8f3f0;
  color: #155e63;
  border: 1px solid #b9d8d2;
}

.badge-estado-descartada {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}

@media (max-width: 640px) {
  #contenidoAccionesMejora {
    grid-template-columns: 1fr;
  }

  .accion-details-grid {
    grid-template-columns: 1fr;
  }

  .accion-actions .btn {
    width: 100%;
  }
}

/* ========== EVIDENCE DETAILS (Collapsible) ========== */

.evidence-details {
  margin-top: var(--sp-xs);
  padding-top: var(--sp-md);
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  animation: fadeIn 200ms ease-out;
}

.evidence-detail-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.evidence-detail-group h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.evidence-detail-group p {
  font-size: 13px;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.45;
}

.evidence-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  padding: var(--sp-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.evidence-details-grid div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.evidence-details-grid strong {
  color: var(--text-primary);
}

.evidence-details-grid a.file-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--trans-base);
}

.evidence-details-grid a.file-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ========== TRACE & BRECHA CARDS (Trazabilidad y Brechas) ========== */

.trace-card, .brecha-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  transition: all var(--trans-base);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.trace-card:hover, .brecha-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.trace-header, .brecha-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-md);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--sp-sm);
}

.trace-card h3, .brecha-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.trace-card p, .brecha-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.45;
}

.trace-card p strong, .brecha-card p strong {
  color: var(--text-primary);
}

/* Custom border colors on top based on coherence/priority to look premium, not raw side colors */
.trace-card.trace-alto {
  border-top: 3px solid var(--success);
}
.trace-card.trace-medio {
  border-top: 3px solid var(--primary);
}
.trace-card.trace-bajo {
  border-top: 3px solid var(--warning);
}

.brecha-card.brecha-alta {
  border-top: 3px solid var(--warning);
}
.brecha-card.brecha-media {
  border-top: 3px solid var(--primary);
}
.brecha-card.brecha-baja {
  border-top: 3px solid var(--accent);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== DROPDOWNS DE ACCIONES (E.g. en evidencias y sílabos) ========== */

.acciones-dropdown {
  position: relative;
  display: inline-block;
}

.acciones-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.14);
  min-width: 240px;
  max-width: min(320px, calc(100vw - 32px));
  z-index: 1800;
  display: flex;
  flex-direction: column;
  padding: var(--sp-xs) 0;
  overflow: visible;
  animation: dropdownFadeIn 150ms ease-out;
}

.acciones-menu.open-up {
  margin: 0;
}

.acciones-menu:not(.open-up) {
  margin: 0;
}

.acciones-menu.hidden {
  display: none !important;
}

.acciones-menu .menu-section {
  display: flex;
  flex-direction: column;
}

.acciones-menu .menu-divider {
  height: 1px;
  background-color: var(--border);
  margin: var(--sp-xs) 0;
}

.acciones-menu .menu-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: var(--sp-xs) var(--sp-md);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-xs);
  letter-spacing: 0.5px;
}

.acciones-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans-base);
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
}

.acciones-menu .menu-item:hover {
  background-color: var(--bg-secondary);
  color: var(--primary);
  padding-left: calc(var(--sp-md) + 2px);
}

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

.action-card,
.action-card *,
.accion-card,
.accion-card *,
.evidence-card,
.evidence-card *,
.weekly-history-card,
.weekly-history-card *,
.planificacion-action-card,
.planificacion-action-card * {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.action-card p,
.accion-card p,
.accion-details-grid div,
.evidence-details-grid div,
.evidence-card p,
.weekly-history-card p,
.planificacion-action-card p,
.accion-detail-group,
.accion-detail-meta,
.evidence-details {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.acciones-dropdown,
.evidence-card,
.accion-card,
.action-card {
  overflow: visible;
}

.history-list {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.history-card {
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #ffffff;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  overflow-wrap: anywhere;
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.history-field {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-date {
  margin: 6px 0 0;
  font-size: 13px;
  color: #64748b;
}

.history-badge {
  padding: 4px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.history-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}

.history-value-box {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
  min-width: 0;
}

.history-label {
  display: block;
  font-size: 11px;
  color: #64748b;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.history-value-box strong,
.history-value-box span,
.history-value-box p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.history-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-weight: 900;
}

.history-observation {
  margin-top: 12px;
  border-left: 4px solid #2563eb;
  background: #eff6ff;
  padding: 10px 12px;
  border-radius: 10px;
}

.history-observation span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: #1e3a8a;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.history-observation p {
  margin: 0;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.history-file-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  font-size: 13px;
}

.history-file-link:hover {
  background: #1d4ed8;
}

.syllabus-history-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  border-radius: 14px;
  margin-bottom: 12px;
}

.syllabus-history-summary span {
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.syllabus-history-summary strong {
  color: #0f172a;
}

.syllabus-history-list {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.syllabus-history-card {
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #ffffff;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.syllabus-history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.syllabus-history-type {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.syllabus-history-date {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.syllabus-history-change {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.history-old-value,
.history-new-value {
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.history-old-value {
  background: #f1f5f9;
  color: #334155;
}

.history-new-value {
  background: #dcfce7;
  color: #166534;
}

.syllabus-history-detail {
  margin: 8px 0 0;
  color: #334155;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.syllabus-analysis {
  display: grid;
  gap: 16px;
}

.syllabus-analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  border-radius: 14px;
}

.risk-badge,
.model-badge,
.date-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.risk-bajo,
.risk-low {
  background: #dcfce7;
  color: #166534;
}

.risk-medio,
.risk-medium {
  background: #fef3c7;
  color: #92400e;
}

.risk-alto,
.risk-high {
  background: #fee2e2;
  color: #991b1b;
}

.risk-sin-dato {
  background: #f1f5f9;
  color: #475569;
}

.model-badge {
  background: #e0f2fe;
  color: #075985;
}

.date-badge {
  background: #f1f5f9;
  color: #334155;
}

.analysis-section {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
}

.analysis-section-highlight {
  background: #f8fafc;
  border-left: 4px solid #2563eb;
}

.analysis-section h4 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
}

.analysis-section p,
.analysis-section li {
  color: #334155;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.analysis-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-chip {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.analysis-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.ai-validation-modal {
  display: grid;
  gap: 16px;
  max-width: 100%;
  overflow-x: hidden;
}

.ai-validation-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  border-radius: 14px;
}

.ai-validation-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
}

.ai-validation-high {
  background: #dcfce7;
  color: #166534;
}

.ai-validation-medium {
  background: #fef3c7;
  color: #92400e;
}

.ai-validation-low {
  background: #fee2e2;
  color: #991b1b;
}

.ai-validation-neutral {
  background: #f1f5f9;
  color: #475569;
}

.ai-validation-ok {
  background: #ccfbf1;
  color: #0f766e;
}

.ai-validation-date {
  color: #475569;
  font-size: 14px;
  font-weight: 700;
}

.ai-validation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.ai-validation-section {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
  min-width: 0;
}

.ai-validation-section h4 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
}

.ai-validation-section p,
.ai-validation-section li {
  color: #334155;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.ai-validation-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.ai-validation-meta {
  background: #f8fafc;
}

.weekly-history-list {
  display: grid;
  gap: 14px;
}

.weekly-history-card {
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #ffffff;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.weekly-history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #eef2f7;
}

.weekly-history-title {
  font-weight: 800;
  color: #0f172a;
}

.weekly-history-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

.weekly-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.weekly-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.weekly-badge.progress {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.weekly-badge.ok {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.weekly-badge.warning {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.weekly-badge.support {
  color: #075985;
  background: #f0f9ff;
  border-color: #bae6fd;
}

.weekly-badge.danger {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.weekly-history-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 7px 12px;
  font-size: 14px;
}

.weekly-history-label {
  font-weight: 800;
  color: #334155;
}

.weekly-history-value {
  min-width: 0;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.weekly-history-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 720px) {
  .acciones-menu {
    left: auto;
    right: auto;
    min-width: 220px;
  }

  .history-values {
    grid-template-columns: 1fr;
  }

  .history-arrow {
    display: none;
  }

  .history-card {
    padding: 12px;
  }

  .ai-validation-summary {
    align-items: stretch;
  }

  .ai-validation-badge,
  .ai-validation-date {
    width: 100%;
    justify-content: center;
  }

  .syllabus-analysis-meta {
    display: grid;
    grid-template-columns: 1fr;
  }

  .risk-badge,
  .model-badge,
  .date-badge {
    justify-content: center;
    width: 100%;
  }

  .syllabus-history-change {
    align-items: stretch;
  }

  .weekly-history-grid {
    grid-template-columns: 1fr;
  }

  .weekly-history-label {
    margin-top: 6px;
  }

  .weekly-history-actions button {
    width: 100%;
  }
}

/* ========== LOADING OVERLAY ========== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--trans-base);
}

.loading-overlay.hidden {
  display: none !important;
}

.loading-spinner-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  padding: var(--sp-xl) calc(var(--sp-xl) * 1.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  max-width: 350px;
  text-align: center;
  animation: fadeIn 200ms ease-out;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.5;
}

/* ========== DASHBOARD SUMMARY CARDS (Macroprocesos) ========== */
.cards-grid .card {
  padding: var(--sp-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  transition: all var(--trans-base);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  text-align: center;
  min-height: 100px;
}

.cards-grid .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.cards-grid .card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background-color: var(--primary);
}

.cards-grid .card.danger::before {
  background-color: var(--warning);
}

.cards-grid .card.warning::before {
  background-color: var(--warning-light);
}

.cards-grid .card.success::before {
  background-color: var(--success);
}

.cards-grid .card h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin: 0;
}

.cards-grid .card p {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  font-family: 'Outfit', 'Inter', sans-serif;
  letter-spacing: -0.5px;
}

.cards-grid .card.danger p {
  color: var(--warning);
}

.cards-grid .card.warning p {
  color: var(--warning-light);
}

.cards-grid .card.success p {
  color: var(--success);
}

@media (max-width: 768px) {
  .dashboard-grid,
  .evidence-grid,
  .macro-evidence-grid,
  .acciones-grid,
  .cards-grid,
  .metrics-grid,
  .metrics-summary-grid {
    grid-template-columns: 1fr;
  }

  .filter-row,
  .filters-row,
  .evidence-filters,
  .metrics-filters,
  .actions-filters {
    grid-template-columns: 1fr;
  }

  .section-actions,
  .panel-actions,
  .evidence-actions,
  .accion-actions,
  .card-actions {
    align-items: stretch;
  }

  .section-actions .btn,
  .panel-actions .btn,
  .evidence-actions > .btn,
  .evidence-actions .acciones-dropdown,
  .evidence-actions .acciones-dropdown > .btn,
  .accion-actions .btn {
    width: 100%;
  }

  .evidence-card-header,
  .evidence-card-top {
    flex-direction: column;
  }

  .evidence-badges {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .modal-content,
  .modal-panel,
  .custom-modal-content {
    width: 96vw;
    max-height: 92vh;
    padding: 14px;
    border-radius: 14px;
  }

  .modal-actions,
  .form-actions {
    flex-direction: column;
  }

  .modal-actions button,
  .form-actions button {
    width: 100%;
  }

  .evidence-card,
  .accion-card,
  .metric-card,
  .metrics-summary-card,
  .interpretation-card {
    padding: 14px;
  }

  .evidence-details-grid {
    grid-template-columns: 1fr;
  }

  .evidence-details-grid div {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .metric-card-enhanced {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .metric-card,
  .metrics-summary-card,
  .interpretation-card {
    padding: 12px;
  }
}

/* ========== RESPONSIVE MODULE LAYOUT ========== */

.main-content {
  width: calc(100% - 250px);
  max-width: calc(100% - 250px);
  min-width: 0;
}

.view-section,
.form-panel {
  min-width: 0;
}

.view-section {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.form-panel {
  width: auto;
  max-width: none;
}

#dashboardPlanificacion,
#dashboardGestionAcademica,
#macroGestionSilabos > .kpi-cards {
  margin: var(--sp-xl) var(--sp-3xl);
}

.cards-grid,
.kpi-cards,
.filter-row {
  min-width: 0;
}

.cards-grid > *,
.kpi-cards > *,
.filter-row > * {
  min-width: 0;
  max-width: 100%;
}

.panel-header {
  gap: var(--sp-lg);
  flex-wrap: wrap;
}

.panel-header > :first-child,
.panel-header > div:first-child {
  min-width: 0;
}

.panel-actions,
.section-actions {
  min-width: 0;
}

@media (max-width: 1200px) {
  .cards-grid,
  .kpi-cards {
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  }

  .filter-row {
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  }
}

@media (max-width: 1024px) {
  .main-content {
    width: calc(100% - 200px);
    max-width: calc(100% - 200px);
  }

  #dashboardPlanificacion,
  #dashboardGestionAcademica,
  #macroGestionSilabos > .kpi-cards {
    margin: var(--sp-lg) var(--sp-xl);
  }
}

@media (max-width: 768px) {
  .main-content {
    width: calc(100% - 60px);
    max-width: calc(100% - 60px);
  }

  #dashboardPlanificacion,
  #dashboardGestionAcademica,
  #macroGestionSilabos > .kpi-cards {
    margin: var(--sp-sm);
  }

  .panel-header,
  .section-header {
    align-items: flex-start;
  }

  .panel-actions,
  .section-actions {
    width: 100%;
  }
}

@media (max-width: 375px) {
  .main-content {
    width: 100%;
    max-width: 100%;
  }
}

/* ========== CONTINUOUS IMPROVEMENT DIAGNOSTIC ========== */

.diagnostic-modal-content {
  width: min(94vw, 1080px);
  max-width: 1080px !important;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
}

.diagnostic-modal-content .modal-header {
  position: relative;
  top: auto;
  margin: 0;
  padding: 22px 24px 18px;
}

.diagnostic-content {
  display: grid;
  gap: 16px;
  max-height: calc(90vh - 150px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  background: #f8fafc;
}

.diagnostic-modal-content > .modal-actions {
  margin: 0;
  padding: 14px 24px;
  background: #ffffff;
}

.diagnostic-hero {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(130px, 0.5fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: stretch;
  border: 1px solid #bfdbfe;
  border-left: 5px solid #2563eb;
  border-radius: 18px;
  padding: 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 75%);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
}

.diagnostic-hero.risk-bajo { border-left-color: #16a34a; }
.diagnostic-hero.risk-medio { border-left-color: #f59e0b; }
.diagnostic-hero.risk-alto { border-left-color: #dc2626; }

.diagnostic-hero > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
}

.diagnostic-hero > div + div {
  padding-left: 16px;
  border-left: 1px solid #dbeafe;
}

.diagnostic-hero .section-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.diagnostic-hero-main .general-risk-badge {
  align-self: flex-start;
  min-width: 150px;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid currentColor;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.08);
}

.diagnostic-hero-stat strong {
  color: #0f172a;
  font-size: 28px;
  line-height: 1;
}

.diagnostic-hero-model p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.diagnostic-section {
  min-width: 0;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.diagnostic-section h3 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 16px;
}

.diagnostic-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.diagnostic-section-heading .diagnostic-section-icon {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 900;
}

.diagnostic-section-heading h3 {
  margin-bottom: 2px;
}

.diagnostic-section-heading p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
}

.diagnostic-section p,
.diagnostic-section li {
  color: #334155;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.diagnostic-section ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.diagnostic-summary-section {
  border-left: 5px solid #2563eb;
  background: linear-gradient(135deg, #ffffff, #f8fbff);
}

.diagnostic-summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.diagnostic-summary-list li {
  position: relative;
  padding: 10px 12px 10px 36px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.diagnostic-summary-list li::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 16px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #2563eb;
  box-shadow: 0 0 0 4px #dbeafe;
}

.diagnostic-critical-term {
  color: #b91c1c;
  font-weight: 800;
}

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

.ai-analysis-indicator-groups {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diagnostic-indicator-group {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
}

.diagnostic-indicator-group h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.diagnostic-indicator-group h4 span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #2563eb;
}

.diagnostic-group-danger h4 span { background: #dc2626; }
.diagnostic-group-success h4 span { background: #16a34a; }

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

.diagnostic-group-info .diagnostic-metrics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.diagnostic-metric-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #ffffff;
}

.diagnostic-metric-card span {
  display: block;
  min-height: 30px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  text-transform: uppercase;
}

.diagnostic-metric-card strong {
  display: block;
  margin-top: 5px;
  color: #0f172a;
  font-size: 26px;
  line-height: 1;
}

.diagnostic-stat-danger strong { color: #dc2626; }
.diagnostic-stat-warning strong { color: #d97706; }
.diagnostic-stat-success strong { color: #15803d; }

.macroprocess-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 12px;
}

.diagnostic-status-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid #e2e8f0;
  border-left: 5px solid #64748b;
  border-radius: 13px;
  background: #ffffff;
}

.diagnostic-status-card.risk-bajo {
  border-left-color: #16a34a;
  background: linear-gradient(135deg, #f0fdf4, #ffffff 55%);
}

.diagnostic-status-card.risk-medio {
  border-left-color: #f59e0b;
  background: linear-gradient(135deg, #fffbeb, #ffffff 55%);
}

.diagnostic-status-card.risk-alto {
  border-left-color: #dc2626;
  background: linear-gradient(135deg, #fef2f2, #ffffff 55%);
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.09);
}

.diagnostic-status-header,
.diagnostic-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diagnostic-status-header h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.diagnostic-risk-badge {
  flex-shrink: 0;
  padding: 6px 10px;
  border: 1px solid currentColor;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.diagnostic-progress-row {
  margin: 14px 0 7px;
  color: #64748b;
  font-size: 12px;
}

.diagnostic-progress-row strong { color: #0f172a; }

.diagnostic-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.diagnostic-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
}

.diagnostic-status-card.risk-alto .diagnostic-progress span {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.diagnostic-status-card.risk-medio .diagnostic-progress span {
  background: linear-gradient(90deg, #fbbf24, #d97706);
}

.diagnostic-status-card.risk-bajo .diagnostic-progress span {
  background: linear-gradient(90deg, #22c55e, #15803d);
}

.diagnostic-status-card ul {
  margin-top: 14px;
  padding-left: 18px;
}

.diagnostic-findings {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}

.diagnostic-findings-label {
  display: block;
  margin-bottom: 8px;
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.diagnostic-findings li {
  font-size: 13px;
  line-height: 1.45;
}

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

.diagnostic-alert-section {
  border-top: 3px solid #f59e0b;
}

.priority-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 12px;
}

.priority-action-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #f59e0b;
  border-radius: 13px;
  background: #f8fafc;
}

.priority-action-card.priority-alta { border-left-color: #dc2626; }
.priority-action-card.priority-baja { border-left-color: #16a34a; }

.diagnostic-decision {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.ai-analysis-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 14px;
}

.ai-analysis-detail-grid .diagnostic-section {
  height: 100%;
}

.ai-analysis-alert-card {
  border-top: 4px solid #ef4444;
  background: linear-gradient(180deg, #fff7f7, #ffffff 42%);
}

.ai-analysis-recommendation-card {
  border-top: 4px solid #2563eb;
  background: linear-gradient(180deg, #eff6ff, #ffffff 42%);
}

.planificacion-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 12px;
}

.planificacion-action-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #f59e0b;
  border-radius: 13px;
  background: #f8fafc;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.04);
}

.planificacion-action-card.priority-alta { border-left-color: #dc2626; }
.planificacion-action-card.priority-baja { border-left-color: #16a34a; }

.planificacion-action-card h3 {
  margin: 12px 0 8px;
}

.planificacion-action-card p {
  margin: 6px 0 0;
  font-size: 13px;
}

@media (max-width: 760px) {
  .diagnostic-modal-content {
    width: min(96vw, 1080px);
    max-height: 94vh;
  }

  .diagnostic-content {
    max-height: calc(94vh - 145px);
    padding: 14px;
  }

  .diagnostic-hero,
  .diagnostic-columns,
  .diagnostic-indicator-groups,
  .ai-analysis-indicator-groups {
    grid-template-columns: 1fr;
  }

  .diagnostic-hero > div + div {
    padding-top: 12px;
    padding-left: 0;
    border-top: 1px solid #dbeafe;
    border-left: 0;
  }

  .diagnostic-group-info .diagnostic-metrics-grid,
  .diagnostic-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .diagnostic-modal-content .modal-header {
    padding: 18px 16px 14px;
  }

  .diagnostic-modal-content .modal-header h3 {
    font-size: 18px;
  }

  .diagnostic-content {
    padding: 12px;
  }

  .diagnostic-section,
  .diagnostic-hero {
    padding: 14px;
  }

  .diagnostic-group-info .diagnostic-metrics-grid,
  .diagnostic-metrics-grid {
    grid-template-columns: 1fr;
  }

  .diagnostic-status-header {
    align-items: flex-start;
  }
}
