/* ==========================================================================
   SISTEMA SENA JUICIOS — Design System v2.0
   Un único archivo de estilos centralizado. Todas las vistas reutilizan
   las clases definidas aquí. No añadir CSS inline en las vistas.
   ========================================================================== */

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

/* ─── 1. TOKENS ────────────────────────────────────────────────────────────── */
:root {
  /* Colores primarios */
  --primary:        #39d900;
  --primary-dark:   #2aaf00;
  --primary-light:  #56ff12;
  --primary-glow:   rgba(57, 217, 0, 0.28);
  --primary-subtle: rgba(57, 217, 0, 0.08);

  /* Colores de acento */
  --secondary:  #00d4ff;
  --accent:     #FF6D00;
  --danger:     #ff3d57;
  --warning:    #ffb800;
  --info:       #00c8ff;
  --success:    #39d900;

  /* Superficies */
  --bg:          #0c0f17;
  --bg2:         #141926;
  --bg3:         #1e2738;
  --bg4:         #253044;
  --card:        #141926;
  --card-hover:  #1a2236;
  --card-border: rgba(57, 217, 0, 0.12);
  --divider:     rgba(255, 255, 255, 0.06);

  /* Texto */
  --text:       #f1f5f9;
  --text-muted: #8fa3bf;
  --text-dim:   #526070;
  --text-light: #ffffff;

  /* Layout */
  --sidebar-w:     260px;
  --sidebar-w-sm:  68px;   /* rail colapsado: solo iconos */
  --topbar-h:      64px;

  /* Radios */
  --radius-xs:  6px;
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Sombras */
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow:     0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg:  0 16px 48px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 8px 24px var(--primary-glow);

  /* Transición */
  --transition: all 0.2s ease;
}

/* Modo claro */
[data-theme="light"] {
  --primary:        #2d9400;
  --primary-dark:   #1f6b00;
  --primary-light:  #3cb800;
  --primary-glow:   rgba(45, 148, 0, 0.2);
  --primary-subtle: rgba(45, 148, 0, 0.06);

  --secondary:  #007eb5;
  --accent:     #e05500;
  --danger:     #d4001a;
  --warning:    #d4790a;
  --info:       #0077b5;
  --success:    #2d9400;

  --bg:          #f3f8f0;
  --bg2:         #e8f5e0;
  --bg3:         #ddf0d0;
  --bg4:         #cde8bc;
  --card:        #ffffff;
  --card-hover:  #fafff7;
  --card-border: rgba(45, 148, 0, 0.18);
  --divider:     rgba(0, 0, 0, 0.07);

  --text:       #0d1a08;
  --text-muted: #4a6340;
  --text-dim:   #7a9e6a;
  --text-light: #000000;

  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow:     0 8px 24px rgba(0, 0, 0, 0.09);
  --shadow-lg:  0 16px 48px rgba(0, 0, 0, 0.12);
}

/* ─── 2. RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-width: 320px;          /* evita colapso total en zoom extremo */
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
  line-height: 1.5;
}

/* ─── 3. LAYOUT ─────────────────────────────────────────────────────────────── */
.layout       { display: flex; min-height: 100vh; }
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-width: 0;              /* evita que flex desborde */
  overflow-x: hidden;
  transition: margin-left 0.3s ease;
}

/* ─── 4. SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  height: 100vh; width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--card-border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease, background-color 0.3s;
  box-shadow: var(--shadow-sm);
  overflow: hidden;   /* impide scroll horizontal en transición */
}
.sidebar-brand   { padding: 20px 16px 14px; border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.brand-logo      { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.brand-icon      { width: 40px; height: 40px; min-width: 40px; background: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-glow); flex-shrink: 0; }
.brand-icon svg  { width: 22px; height: 22px; color: #fff; }
.brand-text      { overflow: hidden; transition: opacity 0.2s, width 0.3s; }
.brand-text h2   { font-size: .93rem; font-weight: 700; color: var(--text); line-height: 1.2; white-space: nowrap; }
.brand-text span { font-size: .67rem; color: var(--primary); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }
.sidebar-nav     { flex: 1; padding: 12px 8px; overflow-y: auto; overflow-x: hidden; }
.nav-label       { font-size: .63rem; font-weight: 700; color: var(--text-dim); letter-spacing: 1.2px; text-transform: uppercase; padding: 10px 12px 4px; white-space: nowrap; overflow: hidden; transition: opacity 0.2s; }
.nav-item        { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; font-size: .845rem; font-weight: 500; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); margin-bottom: 2px; white-space: nowrap; overflow: hidden; position: relative; }
.nav-item:hover  { background: var(--bg2); color: var(--text); }
.nav-item.active { background: var(--primary-subtle); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); }
.nav-item svg    { width: 20px; height: 20px; min-width: 20px; flex-shrink: 0; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.nav-item span   { overflow: hidden; text-overflow: ellipsis; transition: opacity 0.2s; }
.sidebar-footer  { padding: 12px 14px; border-top: 1px solid var(--divider); font-size: .72rem; color: var(--text-dim); text-align: center; white-space: nowrap; overflow: hidden; flex-shrink: 0; }

/* ─ SIDEBAR RAIL (modo compacto: app dock style, ≥ 781px) ─── */
@media (min-width: 781px) {
  :root { --sidebar-w: 80px; } /* Slightly wider to accommodate squircle icons comfortably */

  .sidebar { width: var(--sidebar-w); overflow: visible; padding-top: 10px; }
  .brand-text  { opacity: 0; width: 0; pointer-events: none; }
  .sidebar-brand { padding: 16px; display: flex; justify-content: center; }
  .brand-icon { margin: 0 auto; width: 44px; height: 44px; border-radius: 12px; }
  
  .nav-label   { opacity: 0; height: 0; padding: 0; margin: 0; }
  
  /* App-dock icon style */
  .nav-item {
    justify-content: center;
    gap: 0;
    width: 46px; height: 46px; padding: 0; margin: 0 auto 12px auto;
    border-radius: 14px; border: none;
    background: transparent;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  .nav-item:hover { 
    transform: translateY(-4px) scale(1.1); 
    background: var(--bg2); 
    box-shadow: var(--shadow); 
    color: var(--text);
  }
  .nav-item:active { transform: scale(0.95); }
  
  .nav-item.active { 
    background: var(--primary); color: #fff; 
    box-shadow: 0 8px 16px var(--primary-glow); 
    border: none; transform: scale(1.05);
  }
  .nav-item.active svg { color: #fff; transform: scale(1.15); }
  
  .nav-item span { opacity: 0; width: 0; overflow: hidden; display: none; }
  .sidebar-footer { opacity: 0; height: 0; padding: 0; }

  /* Tooltip on hover in rail mode */
  .nav-item[title]:hover::after {
    content: attr(title);
    position: absolute; left: calc(100% + 16px); top: 50%; transform: translateY(-50%);
    background: var(--card); color: var(--text); font-size: .8rem; font-weight: 600;
    padding: 8px 14px; border-radius: 10px; white-space: nowrap;
    box-shadow: var(--shadow-lg); border: 1px solid var(--card-border);
    z-index: 200; pointer-events: none;
    opacity: 0; animation: dockTooltipFade 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: 0.1s;
  }
}

@keyframes dockTooltipFade {
  from { opacity: 0; transform: translate(-15px, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(0, -50%) scale(1); }
}

/* ─ MOBILE OVERLAY SIDEBAR (< 781px) ─── */
@media (max-width: 780px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
}

/* Botón hamburguesa - solo visible cuando sidebar está oculto */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 200;
  background: var(--primary); border: none; border-radius: var(--radius-sm);
  padding: 9px; cursor: pointer; box-shadow: var(--shadow-glow);
  align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.1s;
}
.mobile-menu-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.mobile-menu-btn svg { width: 20px; height: 20px; color: #fff; display: block; }
@media (max-width: 780px) { .mobile-menu-btn { display: flex !important; } }
@media (min-width: 781px) { .mobile-menu-btn { display: none !important; } }

.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 150; display: none; backdrop-filter: blur(2px); }
.sidebar-overlay.open { display: block; }

/* ─── 5. TOPBAR ─────────────────────────────────────────────────────────────── */
.topbar        { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.topbar h1     { font-size: 1.45rem; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.topbar-right  { display: flex; align-items: center; gap: 10px; }
.topbar-badge  { background: var(--primary-subtle); border: 1px solid rgba(57,148,0,.25); color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: .75rem; font-weight: 600; }

/* ─── 6. CARDS ──────────────────────────────────────────────────────────────── */
.card { 
  background: var(--card); border: 1px solid var(--card-border); 
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); 
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s; 
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-sm   { padding: 16px; }
.card-flat { box-shadow: none; transform: none !important; }

/* ─── 7. KPI CARDS ──────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: linear-gradient(145deg, var(--card) 0%, var(--bg2) 100%); 
  border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 22px; position: relative; overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  min-height: 120px; box-shadow: var(--shadow-sm);
}
.kpi-card::after {
  content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px;
  border-radius: 0 var(--radius) 0 50%;
}
.kpi-card.green::after  { background: rgba(57,217,0,.08); }
.kpi-card.cyan::after   { background: rgba(0,212,255,.08); }
.kpi-card.orange::after { background: rgba(255,109,0,.08); }
.kpi-card.blue::after   { background: rgba(59,130,246,.08); }
.kpi-card.purple::after { background: rgba(139,92,246,.08); }
.kpi-card.yellow::after { background: rgba(255,184,0,.08); }
.kpi-card.red::after    { background: rgba(255,61,87,.08); }
.kpi-card:hover         { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-glow); }

.kpi-icon     { width: 42px; height: 42px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.kpi-icon svg { width: 20px; height: 20px; }
.kpi-card.green  .kpi-icon  { background: rgba(57,217,0,.14);   color: var(--primary); }
.kpi-card.cyan   .kpi-icon  { background: rgba(0,212,255,.14);  color: var(--secondary); }
.kpi-card.orange .kpi-icon  { background: rgba(255,109,0,.14);  color: var(--accent); }
.kpi-card.blue   .kpi-icon  { background: rgba(59,130,246,.14); color: var(--info); }
.kpi-card.yellow .kpi-icon  { background: rgba(255,184,0,.14);  color: var(--warning); }
.kpi-card.red    .kpi-icon  { background: rgba(255,61,87,.14);  color: var(--danger); }

.kpi-value   { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 4px; color: var(--text); letter-spacing: -1px; }
.kpi-label   { font-size: .78rem; color: var(--text-muted); font-weight: 500; }
.kpi-trend   { font-size: .72rem; margin-top: 8px; }
.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* ─── 8. GRIDS DE LAYOUT ────────────────────────────────────────────────────── */
.grid-2   { display: grid; grid-template-columns: 1fr 1fr;     gap: 20px; }
.grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr;     gap: 20px; }
.grid-1-3 { display: grid; grid-template-columns: 1fr 3fr;     gap: 20px; }
@media (max-width: 1100px) { .grid-2, .grid-3, .grid-1-2, .grid-1-3 { grid-template-columns: 1fr; } }

/* ─── 9. SECTION HEADER ─────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.section-title  { font-size: 1rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.section-title svg { width: 18px; height: 18px; color: var(--primary); }

/* ─── 10. TABLAS ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--card-border); }
table { width: 100%; border-collapse: collapse; font-size: .845rem; background: var(--card); }
thead tr { background: var(--bg2); }
th { padding: 11px 16px; text-align: left; font-weight: 600; color: var(--text-dim); font-size: .72rem; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--card-border); }
td { padding: 11px 16px; border-bottom: 1px solid var(--divider); color: var(--text); vertical-align: middle; transition: color 0.2s; }
tbody tr { transition: background-color 0.2s, transform 0.2s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg2); transform: scale(1.001); box-shadow: inset 2px 0 0 var(--primary); }
.table-compact th, .table-compact td { padding: 8px 10px; font-size: .78rem; }
.col-long  { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-short { width: 90px; }

/* Resaltado de búsqueda */
.highlight { background: rgba(57,217,0,.25); border-radius: 2px; font-weight: 600; }

/* ─── 11. BADGES ─────────────────────────────────────────────────────────────── */
.badge        { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 5px; font-size: .695rem; font-weight: 600; gap: 5px; white-space: nowrap; }
.badge-green  { background: rgba(57,217,0,.12);   color: var(--primary); }
.badge-orange { background: rgba(255,109,0,.12);  color: var(--accent); }
.badge-red    { background: rgba(255,61,87,.12);  color: var(--danger); }
.badge-blue   { background: rgba(59,130,246,.12); color: var(--info); }
.badge-cyan   { background: rgba(0,212,255,.12);  color: var(--secondary); }
.badge-gray   { background: var(--bg3);            color: var(--text-muted); }
.badge-yellow { background: rgba(255,184,0,.12);  color: var(--warning); }
.badge-lg     { padding: 5px 14px; font-size: .8rem; border-radius: 6px; }

/* ─── 12. PROGRESS ──────────────────────────────────────────────────────────── */
.progress-wrap  { background: var(--bg3); border-radius: 10px; height: 8px; overflow: hidden; }
.progress-bar   { height: 100%; border-radius: 10px; transition: width 1s ease; background: var(--primary); }
.progress-label { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-muted); margin-bottom: 4px; }

/* ─── 13. CHARTS ─────────────────────────────────────────────────────────────── */
.chart-box      { position: relative; width: 100%; background: var(--bg2); border-radius: var(--radius-sm); padding: 12px; height: 320px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-box-tall { height: 440px; }
.donut-wrap     { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.donut-center   { position: absolute; text-align: center; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.donut-center span { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.donut-center small { display: block; font-size: .65rem; color: var(--text-muted); margin-top: 2px; }

/* ─── 14. FORMS ──────────────────────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
label          { display: block; font-size: .79rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

input[type=text], input[type=number], input[type=date],
input[type=email], input[type=file], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 9px 14px;
  font-size: .875rem; font-family: 'Inter', sans-serif;
  transition: border-color .2s, box-shadow .2s, background-color .3s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
select option { background: var(--bg2); color: var(--text); }
.form-row     { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

[data-theme="light"] input[type=text],
[data-theme="light"] input[type=number],
[data-theme="light"] input[type=date],
[data-theme="light"] input[type=email],
[data-theme="light"] select,
[data-theme="light"] textarea { background: #fff; border-color: #d1d5db; color: #1f2937; }
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,148,0,.1); }
[data-theme="light"] select option { background: #fff; color: #1f2937; }

/* ─── 15. FILTER BAR ─────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--bg2); border: 1px solid var(--card-border);
  padding: 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
}
.filter-bar .form-group { margin: 0; min-width: 160px; flex: 1; }
[data-theme="light"] .filter-bar { background: #f9fafb; border-color: #e5e7eb; }

/* ─── 16. SEARCH BOX ─────────────────────────────────────────────────────────── */
.search-box       { position: relative; }
.search-box input { padding-left: 38px; }
.search-box .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-dim); pointer-events: none;
}
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 2px; border-radius: 50%; display: none; align-items: center; justify-content: center;
  transition: color .2s, background .2s;
}
.search-clear:hover { color: var(--danger); background: rgba(255,61,87,.1); }
.search-clear.visible { display: flex; }
.search-clear svg { width: 14px; height: 14px; }

.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); max-height: 320px; overflow-y: auto;
  z-index: 999; display: none; box-shadow: var(--shadow);
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 11px 16px; cursor: pointer; font-size: .84rem;
  border-bottom: 1px solid var(--divider); transition: background .15s;
  display: flex; align-items: center; justify-content: space-between;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--primary-subtle); color: var(--primary); }

/* ─── 17. BUTTONS ────────────────────────────────────────────────────────────── */
.btn         { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: .845rem; font-weight: 600; cursor: pointer; border: none; transition: var(--transition); text-decoration: none; white-space: nowrap; }
.btn svg     { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 16px var(--primary-glow); }
.btn-secondary { background: var(--bg2); color: var(--text); border: 1px solid var(--card-border); }
.btn-secondary:hover { background: var(--bg3); }
.btn-danger  { background: rgba(255,61,87,.1); color: var(--danger); border: 1px solid rgba(255,61,87,.2); }
.btn-danger:hover { background: rgba(255,61,87,.18); }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg2); color: var(--text); border-color: var(--card-border); }
.btn-sm      { padding: 6px 12px; font-size: .77rem; }
.btn-xs      { padding: 4px 9px; font-size: .72rem; }
.btn-icon    { padding: 8px; border-radius: var(--radius-sm); }
.btn-success { background: var(--primary); color: #fff; }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ─── 18. DROP ZONE ──────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--card-border); border-radius: var(--radius);
  padding: 44px 24px; text-align: center; cursor: pointer;
  transition: border-color .25s, background .25s; background: var(--bg);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: var(--primary-subtle); }
.drop-zone svg { width: 44px; height: 44px; color: var(--primary); opacity: .75; margin-bottom: 12px; }
.drop-zone p   { color: var(--text-muted); font-size: .88rem; }
.drop-zone strong { color: var(--primary); }

/* ─── 19. ALERTS ─────────────────────────────────────────────────────────────── */
.alert         { padding: 11px 16px; border-radius: var(--radius-sm); font-size: .845rem; margin-bottom: 10px; display: flex; align-items: flex-start; gap: 9px; }
.alert svg     { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(57,217,0,.1);  border: 1px solid rgba(57,217,0,.28);  color: #7bdc45; }
.alert-warning { background: rgba(255,184,0,.1); border: 1px solid rgba(255,184,0,.28); color: #ffcc4d; }
.alert-error   { background: rgba(255,61,87,.1); border: 1px solid rgba(255,61,87,.28); color: #ff7a8a; }
.alert-info    { background: rgba(0,200,255,.1); border: 1px solid rgba(0,200,255,.28); color: #60d4f5; }

/* ─── 20. MODAL ──────────────────────────────────────────────────────────────── */
.modal-bg      { position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(5px); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal         { background: var(--bg3); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 28px; width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: fadeInScale .2s ease; }
.modal-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.modal-header h3 { font-size: 1.08rem; font-weight: 700; }
.modal-close   { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-xs); transition: color .2s, background .2s; }
.modal-close:hover { color: var(--text); background: var(--bg2); }
.modal-close svg { width: 20px; height: 20px; }
.modal-footer  { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

@keyframes fadeInScale { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

/* ─── 21. TABS ───────────────────────────────────────────────────────────────── */
.tabs      { display: flex; gap: 2px; border-bottom: 2px solid var(--divider); margin-bottom: 22px; flex-wrap: wrap; }
.tab-btn   { padding: 10px 20px; background: none; border: none; color: var(--text-muted); font-size: .845rem; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .2s, border-color .2s; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab-btn:hover  { color: var(--text); background: var(--bg2); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-pane       { display: none; }
.tab-pane.active { display: block; animation: fadeIn .3s ease; }

/* ─── 22. FASE TIMELINE (Dashboard Fases) ───────────────────────────────────── */
.fase-timeline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; position: relative; }
.fase-card {
  background: var(--bg2); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 20px; position: relative;
  transition: transform .2s, box-shadow .2s; cursor: default;
}
.fase-card:hover        { transform: translateY(-4px); box-shadow: var(--shadow); }
.fase-card.done         { border-color: rgba(57,217,0,.35);  background: rgba(57,217,0,.05); }
.fase-card.mid          { border-color: rgba(255,184,0,.35); background: rgba(255,184,0,.04); }
.fase-card.low          { border-color: rgba(255,109,0,.3);  background: rgba(255,109,0,.04); }
.fase-card.empty        { opacity: .65; }
.fase-num               { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 800; margin: 0 auto 12px; }
.fase-card.done  .fase-num { background: rgba(57,217,0,.2);  color: var(--primary); }
.fase-card.mid   .fase-num { background: rgba(255,184,0,.2); color: var(--warning); }
.fase-card.low   .fase-num { background: rgba(255,109,0,.2); color: var(--accent); }
.fase-card.empty .fase-num { background: var(--bg3); color: var(--text-dim); }
.fase-nombre            { font-weight: 700; font-size: .9rem; text-align: center; margin-bottom: 14px; }
.fase-progress-wrap     { background: rgba(0,0,0,.2); border-radius: 10px; height: 9px; margin-bottom: 10px; overflow: hidden; }
.fase-progress-bar      { height: 100%; border-radius: 10px; transition: width 1s ease; }
.fase-pct               { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.fase-card.done  .fase-pct { color: var(--primary); }
.fase-card.mid   .fase-pct { color: var(--warning); }
.fase-card.low   .fase-pct { color: var(--accent); }
.fase-card.empty .fase-pct { color: var(--text-dim); }
.fase-stats     { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.fase-stat      { background: rgba(0,0,0,.18); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.fase-stat-val  { font-size: .95rem; font-weight: 700; }
.fase-stat-lbl  { font-size: .67rem; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.fase-detail-row { display: flex; justify-content: space-between; font-size: .77rem; color: var(--text-muted); margin-top: 10px; border-top: 1px solid var(--divider); padding-top: 8px; }
.fase-legend     { display: flex; gap: 14px; margin-bottom: 16px; font-size: .8rem; color: var(--text-muted); flex-wrap: wrap; }
.legend-dot      { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* ─── 23. FASES CRUD (Gestión de Fases) ─────────────────────────────────────── */
.fase-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--card-border);
  margin-bottom: 8px; cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.fase-item:hover       { border-color: var(--primary); background: var(--primary-subtle); box-shadow: 0 0 0 1px var(--primary-glow); }
.fase-item.selected    { border-color: var(--primary); background: var(--primary-subtle); }
.fase-order-badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-subtle); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem; flex-shrink: 0; border: 1px solid rgba(57,217,0,.3);
}
.fase-info           { flex: 1; min-width: 0; }
.fase-info strong    { display: block; font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fase-info small     { font-size: .75rem; color: var(--text-muted); display: block; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fase-actions        { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity .2s; }
.fase-item:hover .fase-actions { opacity: 1; }

.act-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-top: 1px solid var(--divider);
  transition: background .15s;
}
.act-item:hover { background: var(--bg2); }
.act-item .act-info { flex: 1; min-width: 0; }
.act-item .act-info strong { display: block; font-size: .845rem; font-weight: 600; }
.act-item .act-info small  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; display: block; }
.act-item .act-del  { flex-shrink: 0; opacity: 0; transition: opacity .2s; }
.act-item:hover .act-del { opacity: 1; }

/* Columna de fases sin seleccionar */
.empty-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; color: var(--text-dim); text-align: center; gap: 10px;
}
.empty-panel svg   { width: 42px; height: 42px; opacity: .4; }
.empty-panel p     { font-size: .875rem; line-height: 1.5; }

/* Conteo en la cabecera de la lista */
.list-count { font-size: .72rem; color: var(--text-dim); background: var(--bg3); border-radius: 10px; padding: 2px 8px; font-weight: 600; }

/* ─── 24. PROGRAM SELECTOR BAR ──────────────────────────────────────────────── */
.prog-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; background: var(--bg2);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  margin-bottom: 22px; flex-wrap: wrap;
}
.prog-bar .prog-label { font-size: .82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.prog-bar select      { flex: 1; max-width: 480px; }
.prog-bar .prog-hint  { font-size: .76rem; color: var(--text-dim); }

/* ─── 25. PROFILE CARD ──────────────────────────────────────────────────────── */
.profile-card   { display: flex; align-items: center; gap: 18px; padding: 18px; background: var(--primary-subtle); border: 1px solid rgba(57,148,0,.25); border-radius: var(--radius); margin-bottom: 18px; }
.profile-avatar { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 800; color: #fff; flex-shrink: 0; }
.profile-info h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 3px; }
.profile-info p  { font-size: .78rem; color: var(--text-muted); }

/* ─── 26. ANIMATIONS ─────────────────────────────────────────────────────────── */
@keyframes fadeIn      { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin        { to { transform: rotate(360deg); } }
@keyframes pulse       { 0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); } 50% { box-shadow: 0 0 0 8px transparent; } }
@keyframes shimmer     { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.fade-in    { animation: fadeIn .35s ease both; }
.stagger-1  { animation-delay: .04s; }
.stagger-2  { animation-delay: .08s; }
.stagger-3  { animation-delay: .13s; }
.stagger-4  { animation-delay: .18s; }
.stagger-5  { animation-delay: .23s; }
.stagger-6  { animation-delay: .28s; }
.stagger-7  { animation-delay: .34s; }
.stagger-8  { animation-delay: .4s; }

/* Skeleton loader */
.skeleton   { background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }

/* ─── 27. LOADING & EMPTY ────────────────────────────────────────────────────── */
.loading        { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--text-muted); gap: 10px; }
.loading svg    { animation: spin 1s linear infinite; width: 24px; height: 24px; color: var(--primary); }
.empty-state    { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 44px; height: 44px; color: var(--text-dim); margin-bottom: 12px; }
.empty-state p   { font-size: .875rem; line-height: 1.6; }

/* ─── 28. MISC UTILITIES ─────────────────────────────────────────────────────── */
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.p-8   { padding: 8px; }
.p-16  { padding: 16px; }
.p-24  { padding: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap     { flex-wrap: wrap; }
.text-muted    { color: var(--text-muted) !important; }
.text-primary  { color: var(--primary) !important; }
.text-danger   { color: var(--danger) !important; }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider       { border: none; border-top: 1px solid var(--divider); margin: 16px 0; }
.tag           { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .71rem; font-weight: 600; background: var(--bg3); color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   29. RESPONSIVE — MEDIA QUERIES COMPLETOS
   Breakpoints:
     xs  →  max 479px   (móviles pequeños, ej. 360px)
     sm  →  max 639px   (móviles grandes, ej. iPhone)
     md  →  max 899px   (tablets verticales)
     lg  →  max 1199px  (tablets horizontales / laptops pequeños)
     xl  →  min 1200px  (escritorio estándar)
     2xl →  min 1400px  (pantallas anchas)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Prevent global overflow ──────────────────────────────────────────────── */
img, svg, video, canvas, iframe, table {
  max-width: 100%;
}

/* ── 2XL: pantallas anchas (≥ 1400px) ─────────────────────────────────────── */
@media (min-width: 1400px) {
  .main-content { padding: 32px 40px; }
  .kpi-grid     { grid-template-columns: repeat(6, 1fr); }
  .grid-3       { grid-template-columns: repeat(3, 1fr); }
}

/* ── LG+: sidebar en modo RAIL (1101–1399px) ──────────────────────────────── */
@media (max-width: 1399px) and (min-width: 1101px) {
  .kpi-grid          { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .grid-2            { grid-template-columns: 1fr 1fr; gap: 18px; }
  .grid-3            { grid-template-columns: 1fr 1fr; gap: 18px; }
  .grid-1-2          { grid-template-columns: 1fr 1.8fr; gap: 18px; }
  .grid-1-3          { grid-template-columns: 1fr 2.5fr; gap: 18px; }
  .fase-timeline-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
  .chart-box          { height: 290px; }
  .topbar h1          { font-size: 1.3rem; }
}

/* ── LG: sidebar RAIL activo (781–1100px) ──────────────────────────────────── */
/* El sidebar ya colapsó a var(--sidebar-w-sm). El main-content se ajusta solo
   porque --sidebar-w cambia con el @media en el bloque del sidebar. */
@media (max-width: 1100px) and (min-width: 781px) {
  .kpi-grid          { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .grid-2            { grid-template-columns: 1fr 1fr; gap: 14px; }
  .grid-3            { grid-template-columns: 1fr 1fr; gap: 14px; }
  .grid-1-2, .grid-1-3 { grid-template-columns: 1fr; gap: 14px; }
  .chart-box          { height: 260px; }
  .chart-box-tall     { height: 360px; }
  .topbar h1          { font-size: 1.2rem; }
  .topbar-badge       { display: none; }
  .main-content       { padding: 20px 20px; }
}

/* ── MD: tablet / móvil (≤ 780px) — sidebar oculto, hamburger visible ─────── */
@media (max-width: 780px) {
  /* Layout */
  .main-content {
    margin-left: 0 !important;
    padding: 56px 14px 90px;  /* 56px top = espacio para el botón hamburger */
    width: 100%;
    min-width: 0;
  }

  /* Topbar: ajustado para no tapar el botón hamburger */
  .topbar        { margin-bottom: 16px; padding-left: 48px; } /* desplaza el h1 */
  .topbar h1     { font-size: 1.1rem; }
  .topbar-badge  { display: none; }

  /* Grids */
  .grid-2, .grid-3, .grid-1-2, .grid-1-3 { grid-template-columns: 1fr; gap: 14px; }

  /* KPI */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
  .kpi-card { min-height: 100px; padding: 16px; }
  .kpi-value { font-size: 1.6rem; }

  /* Fase timeline */
  .fase-timeline-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Cards */
  .card { padding: 16px; border-radius: var(--radius-sm); }

  /* Tablas */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table       { min-width: 480px; }

  /* Prog-bar */
  .prog-bar           { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
  .prog-bar select    { max-width: 100%; }
  .prog-bar .prog-hint { display: none; }

  /* Filter-bar */
  .filter-bar { flex-direction: column; gap: 10px; padding: 12px; }
  .filter-bar .form-group { min-width: 100%; }

  /* Tabs */
  .tabs    { gap: 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-btn { flex-shrink: 0; padding: 9px 14px; font-size: .8rem; }

  /* Section-header */
  .section-header { flex-wrap: wrap; gap: 10px; }
  .section-title  { font-size: .9rem; }

  /* Modal */
  .modal        { padding: 20px; border-radius: var(--radius); width: 94%; max-height: 94vh; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Charts */
  .chart-box      { height: 240px; padding: 8px; }
  .chart-box-tall { height: 320px; }
  .donut-wrap     { width: 180px !important; height: 180px !important; }
  .donut-center span { font-size: 1.3rem; }

  /* Buttons */
  .btn    { padding: 8px 14px; font-size: .82rem; }
  .btn-sm { padding: 6px 11px; font-size: .75rem; }

  /* PDF Preview table */
  #pdfPreview .table-wrap table { min-width: 560px; }
  #accordionFases .table-wrap table { min-width: 520px; }
  .search-clear { right: 8px; }
}

/* ── SM: móviles grandes (≤ 639px) ────────────────────────────────────────── */
@media (max-width: 639px) {
  .main-content { padding: 10px 10px 80px; }

  /* Topbar */
  .topbar       { gap: 10px; margin-bottom: 14px; }
  .topbar h1    { font-size: 1rem; }
  .topbar-right { gap: 6px; }

  /* KPI grid: 2 columnas ajustadas */
  .kpi-grid  { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card  { padding: 14px; min-height: 90px; border-radius: var(--radius-sm); }
  .kpi-value { font-size: 1.4rem; }
  .kpi-label { font-size: .72rem; }
  .kpi-icon  { width: 36px; height: 36px; margin-bottom: 10px; }
  .kpi-icon svg { width: 17px; height: 17px; }

  /* Fase timeline: 1 columna */
  .fase-timeline-grid { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 14px; }

  /* Fase crud */
  .fase-item  { padding: 10px 12px; }
  .fase-info strong { font-size: .82rem; }

  /* Tabs scrollables */
  .tab-btn { padding: 8px 12px; font-size: .77rem; }

  /* Filter bar: columna completa */
  .filter-bar { gap: 8px; }

  /* Botones en sección header: apilados */
  .section-header { align-items: flex-start; }

  /* Modal */
  .modal { width: 98%; padding: 16px; max-height: 96vh; }
  .modal-header h3 { font-size: .97rem; }

  /* Chart reducido */
  .chart-box { height: 210px; }
  .donut-wrap { width: 150px !important; height: 150px !important; }

  /* PDF Preview KPI-inline */
  #pdfPreview [style*="grid-template-columns:repeat(5"] {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }

  /* Fase legend: columna */
  .fase-legend { flex-direction: column; gap: 6px; }

  /* Alert */
  .alert { font-size: .8rem; padding: 10px 12px; }

  /* Prog bar */
  .prog-bar { padding: 10px 12px; border-radius: var(--radius-sm); }

  /* tabla: min menor */
  table { min-width: 360px; }
}

/* ── XS: móviles pequeños (≤ 479px) ───────────────────────────────────────── */
@media (max-width: 479px) {
  .main-content { padding: 8px 8px 76px; }

  .topbar h1 { font-size: .93rem; }

  /* KPI: 1 columna en pantallas muy pequeñas */
  .kpi-grid { grid-template-columns: 1fr; }

  /* Fase stats: 1 columna */
  .fase-stats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .fase-stat  { padding: 6px; }
  .fase-stat-val { font-size: .85rem; }

  /* Tabla: min-width reducido al máximo */
  table { min-width: 300px; font-size: .78rem; }
  th, td { padding: 8px 10px; }

  /* Badges en tabla: sin padding lateral */
  .badge { padding: 2px 7px; font-size: .66rem; }

  /* Modal full-screen casi */
  .modal { width: 100%; border-radius: var(--radius) var(--radius) 0 0; position: fixed; bottom: 0; left: 0; max-height: 90vh; }
  .modal-bg { align-items: flex-end; }

  /* Buttons */
  .btn    { padding: 8px 12px; font-size: .8rem; }
  .btn-sm { padding: 5px 9px; font-size: .73rem; }
  .btn-xs { padding: 3px 8px; font-size: .7rem; }

  /* Search box */
  .search-box input { font-size: .82rem; }

  /* prog bar select */
  .prog-bar select { font-size: .82rem; padding: 8px 10px; }

  /* Drop zone */
  .drop-zone { padding: 28px 14px; }
  .drop-zone svg { width: 36px; height: 36px; }
  .drop-zone p { font-size: .8rem; }

  /* Charts */
  .chart-box { height: 190px; }

  /* PDF Preview: 2 columnas solo */
  #pdfPreview [style*="grid-template-columns:repeat(5"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Fase timeline: compact */
  .fase-pct        { font-size: 1.2rem; }
  .fase-card       { padding: 14px; }
  .fase-num        { width: 36px; height: 36px; font-size: 1rem; }
  .fase-nombre     { font-size: .83rem; margin-bottom: 10px; }

  /* nav label oculto */
  .nav-label { padding: 8px 10px 2px; font-size: .58rem; }
  .nav-item  { padding: 9px 10px; font-size: .82rem; gap: 8px; }

  /* Form row → 1 col */
  .form-row { grid-template-columns: 1fr; gap: 12px; }

  /* Empty state reducido */
  .empty-state { padding: 32px 12px; }
  .empty-panel { padding: 28px 12px; }
}

/* ── Landscape móvil (altura corta) ───────────────────────────────────────── */
@media (max-height: 500px) and (max-width: 899px) {
  .sidebar       { overflow-y: auto; }
  .main-content  { padding-top: 8px; }
  .topbar        { margin-bottom: 10px; }
  .modal         { max-height: 96vh; }
  .chart-box     { height: 180px; }
}

/* ── Print ─────────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .mobile-menu-btn, .topbar-right, .btn, .tabs, .modal-bg { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 12px !important; }
  .card         { box-shadow: none !important; border: 1px solid #ccc !important; }
  body          { background: #fff !important; color: #000 !important; }
  a             { text-decoration: none !important; color: inherit !important; }
}

