/* ================================================================
   Sistema de Presentación de Programas · FICA — UNSL
   Design System v3  ·  Light + Dark  ·  Responsive
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --sidebar-w: 260px;

  /* Light surface tokens */
  --bg:         #f1f3fb;
  --surface:    #ffffff;
  --surface-2:  #f7f8ff;
  --border:     #e5e8f5;
  --border-2:   #cdd2ec;
  --text:       #1a1d3c;
  --text-2:     #4a527e;
  --text-muted: #8b93bc;

  /* Sidebar (fixed dark in both modes) */
  --sb-bg:     #1b2c3e;
  --sb-border: rgba(255,255,255,0.055);
  --sb-text:   rgba(255,255,255,0.58);
  --sb-text-h: #ffffff;
  --sb-item-h: rgba(255,255,255,0.065);
  --sb-active: rgba(90,160,210,0.18);
  --sb-line:   #5aa0d2;

  /* Topbar */
  --tb-bg:     #ffffff;
  --tb-border: #e5e8f5;

  /* Brand colors */
  --primary:         #1865a3;
  --primary-h:       #155793;
  --primary-rgb:     24,101,163;
  --primary-alpha:   rgba(24,101,163,0.10);
  --success:         #10b981;
  --success-alpha:   rgba(16,185,129,0.10);
  --warning:         #f59e0b;
  --warning-alpha:   rgba(245,158,11,0.10);
  --danger:          #ef4444;
  --danger-alpha:    rgba(239,68,68,0.10);
  --info:            #06b6d4;
  --info-alpha:      rgba(6,182,212,0.10);
  --purple:          #5a8fbb;
  --purple-alpha:    rgba(90,143,187,0.10);
  --orange:          #f97316;
  --orange-alpha:    rgba(249,115,22,0.10);

  /* Shadows */
  --sh-xs: 0 1px 2px rgba(0,0,0,0.05);
  --sh-sm: 0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.03);
  --sh:    0 4px 20px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.03);
  --sh-lg: 0 10px 40px rgba(0,0,0,0.12);
  --sh-xl: 0 20px 60px rgba(0,0,0,0.16);

  /* Radii */
  --r-xs: 8px;  --r-sm: 12px;  --r: 14px;  --r-lg: 18px;  --r-xl: 22px;

  /* Transitions */
  --t:  0.16s ease;
  --ts: 0.28s ease;
}

/* ── Dark Mode ──────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #0b0d1a;
  --surface:   #111327;
  --surface-2: #171a30;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.13);
  --text:      #dde4f8;
  --text-2:    #8e99c8;
  --text-muted:#454f76;

  --sb-bg:     #131e2b;
  --tb-bg:     #111327;
  --tb-border: rgba(255,255,255,0.07);

  --sh-xs: 0 1px 2px rgba(0,0,0,0.35);
  --sh-sm: 0 2px 8px rgba(0,0,0,0.40);
  --sh:    0 4px 20px rgba(0,0,0,0.50);
  --sh-lg: 0 10px 40px rgba(0,0,0,0.60);
  --sh-xl: 0 20px 60px rgba(0,0,0,0.70);
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--ts), color var(--ts);
}

a { color: var(--primary); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--primary-h); }

/* ── Layout ─────────────────────────────────────────────────── */
.sp-layout { display: flex; min-height: 100vh; }

.sp-backdrop {
  display: none; position: fixed; inset: 0; z-index: 1009;
  background: rgba(8,10,28,.60);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadeIn var(--t);
}
.sp-backdrop.active { display: block; }

@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95) } to { opacity: 1; transform: none } }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sp-sidebar {
  width: var(--sidebar-w);
  position: fixed; inset: 0 auto 0 0; z-index: 1010;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: transform var(--ts), box-shadow var(--ts);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.sp-sidebar::-webkit-scrollbar       { width: 3px; }
.sp-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* Brand */
.sb-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0; cursor: default;
}
.sb-brand-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; color: #fff;
  box-shadow: 0 4px 14px rgba(95,82,255,0.40);
  flex-shrink: 0;
}
.sb-brand-name { display: block; font-size: 0.82rem; font-weight: 700; color: #fff; line-height: 1.3; letter-spacing: -0.01em; }
.sb-brand-sub  { display: block; font-size: 0.68rem; color: rgba(255,255,255,0.38); margin-top: 1px; }

/* Nav */
.sb-nav { padding: 10px; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sb-section-label {
  font-size: 0.66rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.28); padding: 12px 8px 4px;
}
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--sb-text); font-size: 0.855rem; font-weight: 500;
  text-decoration: none; transition: all var(--t);
  position: relative;
}
.sb-link:hover { background: var(--sb-item-h); color: var(--sb-text-h); }
.sb-link.active { background: var(--sb-active); color: #fff; font-weight: 600; }
.sb-link.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 54%; background: var(--sb-line); border-radius: 0 3px 3px 0;
}
.sb-icon {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; flex-shrink: 0; opacity: .70; transition: opacity var(--t);
}
.sb-link:hover .sb-icon, .sb-link.active .sb-icon { opacity: 1; }

/* Sidebar footer */
.sb-foot { border-top: 1px solid var(--sb-border); padding: 12px 10px; flex-shrink: 0; }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  background: rgba(255,255,255,0.04);
}
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; flex-shrink: 0;
}
.sb-user-info  { flex: 1; min-width: 0; }
.sb-user-name  { font-size: 0.78rem; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role  { font-size: 0.67rem; color: rgba(255,255,255,0.38); margin-top: 1px; }

/* ── WRAPPER ────────────────────────────────────────────────── */
.sp-wrapper {
  margin-left: var(--sidebar-w); flex: 1;
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left var(--ts);
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.sp-topbar {
  position: sticky; top: 0; z-index: 900;
  height: 60px; background: var(--tb-bg); border-bottom: 1px solid var(--tb-border);
  padding: 0 24px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--sh-xs); flex-shrink: 0;
  transition: background var(--ts), border-color var(--ts);
}
.btn-sb-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: var(--r-sm); width: 36px; height: 36px;
  align-items: center; justify-content: center; cursor: pointer;
  color: var(--text-2); font-size: .9rem; transition: all var(--t); flex-shrink: 0;
}
.btn-sb-toggle:hover { background: var(--surface-2); color: var(--text); }

.topbar-breadcrumb {
  flex: 1; display: flex; align-items: center; gap: 6px;
  font-size: .82rem; color: var(--text-muted); overflow: hidden;
}
.topbar-breadcrumb .bc-sep  { font-size: .65rem; }
.topbar-breadcrumb .bc-curr {
  font-size: .875rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn-theme {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; color: var(--text-2); font-size: .85rem; transition: all var(--t);
}
.btn-theme:hover { background: var(--primary-alpha); border-color: rgba(var(--primary-rgb),.3); color: var(--primary); }

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.topbar-ava {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; flex-shrink: 0;
}
.topbar-name {
  font-size: .8rem; font-weight: 600; color: var(--text);
  white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}

.btn-logout {
  height: 36px; padding: 0 12px; display: flex; align-items: center; gap: 6px;
  background: var(--danger-alpha); border: 1px solid rgba(239,68,68,.18);
  border-radius: var(--r-sm); color: var(--danger); font-size: .8rem; font-weight: 600;
  text-decoration: none; transition: all var(--t); white-space: nowrap;
}
.btn-logout:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── MAIN & FOOTER ──────────────────────────────────────────── */
.sp-banner-wrap { flex-shrink: 0; line-height: 0; }
.sp-banner-img  { width: 100%; display: block; height: auto; }

.sp-main   { flex: 1; padding: 28px 28px 36px; }
.sp-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap; flex-shrink: 0;
  transition: background var(--ts), border-color var(--ts);
}
.sp-footer-text  { font-size: .78rem; color: var(--text-muted); }
.sp-footer-regla {
  display: flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  padding: 5px 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-xs); text-decoration: none; transition: all var(--t);
}
.sp-footer-regla:hover { color: var(--primary); border-color: rgba(var(--primary-rgb),.3); background: var(--primary-alpha); }

/* ── PAGE HEADER ────────────────────────────────────────────── */
.sp-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.sp-page-title { font-size: 1.45rem; font-weight: 800; color: var(--text); letter-spacing: -.025em; line-height: 1.25; }
.sp-page-sub   { font-size: .875rem; color: var(--text-muted); margin-top: 3px; }
.sp-page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }

/* ── CARD ───────────────────────────────────────────────────── */
.sp-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden;
  transition: background var(--ts), border-color var(--ts), box-shadow var(--t);
}
.sp-card-hover:hover { box-shadow: var(--sh); border-color: var(--border-2); }

.sp-card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); transition: background var(--ts), border-color var(--ts);
}
.sp-card-ico {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; font-size: .9rem; flex-shrink: 0;
}
.sp-card-title { font-size: .9375rem; font-weight: 700; color: var(--text); flex: 1; letter-spacing: -.01em; }
.sp-card-body  { padding: 20px; }
.sp-card-foot  { padding: 13px 20px; border-top: 1px solid var(--border); background: var(--surface-2); transition: background var(--ts); }

/* ── STAT GRID ──────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 16px 16px; display: flex; align-items: flex-start; gap: 13px;
  box-shadow: var(--sh-sm); transition: all var(--t);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--stat-c, var(--primary)); border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.stat-card:hover         { box-shadow: var(--sh); transform: translateY(-2px); border-color: var(--border-2); }
.stat-card.clickable     { cursor: pointer; }
.stat-card.clickable:hover .stat-value { color: var(--stat-c, var(--primary)); }

.stat-icon {
  width: 42px; height: 42px; border-radius: var(--r);
  background: var(--stat-bg, var(--primary-alpha));
  color: var(--stat-c, var(--primary));
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem; flex-shrink: 0;
}
.stat-value    { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -.035em; transition: color var(--t); }
.stat-label    { font-size: .775rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

.stat-primary { --stat-c: var(--primary); --stat-bg: var(--primary-alpha); }
.stat-success { --stat-c: var(--success); --stat-bg: var(--success-alpha); }
.stat-warning { --stat-c: var(--warning); --stat-bg: var(--warning-alpha); }
.stat-danger  { --stat-c: var(--danger);  --stat-bg: var(--danger-alpha);  }
.stat-info    { --stat-c: var(--info);    --stat-bg: var(--info-alpha);    }
.stat-purple  { --stat-c: var(--purple);  --stat-bg: var(--purple-alpha);  }
.stat-orange  { --stat-c: var(--orange);  --stat-bg: var(--orange-alpha);  }

/* ── TABLE ───────────────────────────────────────────────────── */
.sp-table-wrap { border: 1px solid var(--border); border-radius: var(--r-lg); overflow-x: auto; overflow-y: hidden; box-shadow: var(--sh-sm); }
.sp-table      { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--surface); }
.sp-table thead th {
  background: var(--surface-2); color: var(--text-muted); font-size: .72rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap; transition: background var(--ts);
}
.sp-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.sp-table tbody tr:last-child td { border-bottom: none; }
.sp-table tbody tr:hover td { background: var(--surface-2); }

/* ── PILLS / BADGES ─────────────────────────────────────────── */
.sp-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .715rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.4;
}
.sp-pill.sp-pill-dot::before {
  content: ''; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; flex-shrink: 0;
}
.pill-enviado           { background: rgba(99,102,241,.10); color: #6366f1; }
.pill-en_revision       { background: var(--info-alpha);    color: #0891b2; }
.pill-con_observaciones { background: var(--warning-alpha); color: #d97706; }
.pill-aprobado          { background: var(--success-alpha); color: var(--success); }
.pill-rechazado         { background: var(--danger-alpha);  color: var(--danger); }
.pill-borrador          { background: rgba(100,116,139,.1); color: #64748b; }

[data-theme="dark"] .pill-en_revision { color: var(--info); }

.pill-role-admin   { background: rgba(239,68,68,.10);  color: var(--danger); }
.pill-role-adminsp { background: rgba(245,158,11,.10); color: #b45309; }
.pill-role-eval    { background: var(--info-alpha);    color: #0891b2; }
.pill-role-docente { background: var(--success-alpha); color: var(--success); }
[data-theme="dark"] .pill-role-adminsp { color: var(--warning); }
[data-theme="dark"] .pill-role-eval    { color: var(--info); }

/* ── CARRERA BADGES (circular) ──────────────────────────────── */
.carr-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cbg, #6c757d); color: var(--ctxt, #fff);
  width: 38px; height: 38px; border-radius: 50%;
  font-size: .60rem; font-weight: 800; letter-spacing: -.03em;
  white-space: nowrap; margin: 2px 2px 2px 0; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.22); vertical-align: middle;
  cursor: default; user-select: none; line-height: 1;
}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn-sp {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--t); text-decoration: none; line-height: 1.4; white-space: nowrap;
}
.btn-sp:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(var(--primary-rgb),.28); }
.btn-primary:hover { background: var(--primary-h); color: #fff; box-shadow: 0 4px 16px rgba(var(--primary-rgb),.38); transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); box-shadow: 0 2px 8px rgba(16,185,129,.28); }
.btn-success:hover { background: #0da773; color: #fff; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 2px 8px rgba(239,68,68,.28); }
.btn-danger:hover { background: #dc2626; color: #fff; transform: translateY(-1px); }

.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-danger-soft { background: var(--danger-alpha); border-color: rgba(239,68,68,.2); color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-xs { padding: 3px 8px; font-size: .755rem; border-radius: var(--r-xs); }
.btn-lg { padding: 11px 22px; font-size: .9375rem; }
.btn-w  { width: 100%; justify-content: center; }

.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); }
.btn-icon.btn-xs { width: 28px; height: 28px; border-radius: var(--r-xs); }

/* ── FORMS ───────────────────────────────────────────────────── */
.sp-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.sp-label { font-size: .79rem; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.sp-label .req { color: var(--danger); margin-left: 2px; }

.sp-input, .sp-select, .sp-textarea {
  width: 100%; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); color: var(--text); font-size: .875rem;
  font-family: inherit; padding: 9px 12px;
  transition: border-color var(--t), box-shadow var(--t), background var(--ts);
  -webkit-appearance: none;
}
.sp-input:focus, .sp-select:focus, .sp-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.12);
}
.sp-input::placeholder { color: var(--text-muted); }
.sp-textarea { resize: vertical; min-height: 90px; }
.sp-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b93bc' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer;
}
.sp-hint      { font-size: .76rem; color: var(--text-muted); }
.sp-field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ── DROPZONE ───────────────────────────────────────────────── */
.sp-dropzone {
  position: relative; border: 2px dashed var(--border-2);
  border-radius: var(--r-lg); background: var(--surface-2);
  transition: all var(--t); cursor: pointer; overflow: hidden;
}
.sp-dropzone:hover, .sp-dropzone.drag-over { border-color: var(--primary); background: var(--primary-alpha); }
.sp-dropzone.has-file { border-style: solid; border-color: var(--success); background: var(--success-alpha); }
.sp-dropzone-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 5; width: 100%; height: 100%; }
.sp-dropzone-body  { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 36px 24px; text-align: center; pointer-events: none; }
.sp-dz-ico {
  width: 56px; height: 56px; border-radius: var(--r-lg);
  background: var(--primary-alpha); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  margin-bottom: 4px; transition: all var(--t);
}
.sp-dropzone.has-file .sp-dz-ico { background: var(--success-alpha); color: var(--success); }
.sp-dz-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.sp-dz-sub   { font-size: .78rem; color: var(--text-muted); }

/* ── ALERTS ─────────────────────────────────────────────────── */
.sp-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); font-size: .875rem; line-height: 1.55; }
.sp-alert-icon  { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.sp-alert-body  { flex: 1; }
.sp-alert-title { font-weight: 700; margin-bottom: 2px; }
.sp-alert-info    { background: var(--info-alpha);    border: 1px solid rgba(6,182,212,.2);    color: #0e7490; }
.sp-alert-success { background: var(--success-alpha); border: 1px solid rgba(16,185,129,.2);  color: #065f46; }
.sp-alert-warning { background: var(--warning-alpha); border: 1px solid rgba(245,158,11,.2);  color: #92400e; }
.sp-alert-danger  { background: var(--danger-alpha);  border: 1px solid rgba(239,68,68,.2);   color: #991b1b; }
[data-theme="dark"] .sp-alert-info    { color: #67e8f9; }
[data-theme="dark"] .sp-alert-success { color: #6ee7b7; }
[data-theme="dark"] .sp-alert-warning { color: #fbbf24; }
[data-theme="dark"] .sp-alert-danger  { color: #fca5a5; }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.sp-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 52px 24px; text-align: center; }
.sp-empty-ico {
  width: 68px; height: 68px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--text-muted); margin-bottom: 4px;
}
.sp-empty-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.sp-empty-sub   { font-size: .875rem; color: var(--text-muted); max-width: 320px; line-height: 1.55; }

/* ── PROGRAM CARD ───────────────────────────────────────────── */
.program-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-xs); transition: all var(--t);
}
.program-card:hover { box-shadow: var(--sh-sm); border-color: var(--border-2); }
.pc-ico {
  width: 44px; height: 44px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.pc-pdf  { background: rgba(239,68,68,.1);  color: var(--danger); }
.pc-doc, .pc-docx { background: rgba(37,99,235,.1); color: #2563eb; }
.pc-other { background: var(--primary-alpha); color: var(--primary); }
.pc-body  { flex: 1; min-width: 0; }
.pc-title { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: 4px; word-break: break-word; }
.pc-meta  { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .775rem; color: var(--text-muted); }
.pc-meta-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.pc-actions { display: flex; gap: 6px; align-items: flex-start; flex-shrink: 0; }

/* ── EVAL TIMELINE ──────────────────────────────────────────── */
.eval-timeline { display: flex; flex-direction: column; gap: 12px; }
.eval-item { display: flex; gap: 12px; align-items: flex-start; }
.eval-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; flex-shrink: 0; margin-top: 2px;
}
.eval-dot-ap { background: var(--success-alpha); color: var(--success); }
.eval-dot-ob { background: var(--warning-alpha); color: var(--warning); }
.eval-dot-re { background: var(--danger-alpha);  color: var(--danger);  }
.eval-bubble { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.eval-meta   { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.eval-dec    { font-size: .8rem; font-weight: 700; }
.eval-date   { font-size: .75rem; color: var(--text-muted); }
.eval-text   { font-size: .855rem; color: var(--text-2); line-height: 1.55; }

/* ── ACTIVITY FEED ──────────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 5px; }
.activity-text { flex: 1; font-size: .835rem; color: var(--text-2); }
.activity-time { font-size: .74rem; color: var(--text-muted); flex-shrink: 0; margin-top: 1px; }

/* ── QUICK ACTIONS ──────────────────────────────────────────── */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.quick-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); text-decoration: none; color: var(--text-2);
  font-size: .8rem; font-weight: 600; text-align: center;
  transition: all var(--t); box-shadow: var(--sh-xs); cursor: pointer;
}
.quick-item:hover {
  color: var(--primary); border-color: rgba(var(--primary-rgb),.3);
  background: var(--primary-alpha); transform: translateY(-2px); box-shadow: var(--sh-sm);
}
.quick-ico {
  width: 42px; height: 42px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--text-muted); transition: all var(--t);
}
.quick-item:hover .quick-ico { background: var(--primary-alpha); border-color: rgba(var(--primary-rgb),.25); color: var(--primary); }

/* ── DL ─────────────────────────────────────────────────────── */
.sp-dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; align-items: baseline; }
.sp-dt { font-size: .775rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.sp-dd { font-size: .875rem; color: var(--text); font-weight: 500; word-break: break-word; margin: 0; }

/* ── PROGRESS ───────────────────────────────────────────────── */
.sp-prog { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.sp-prog-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--purple)); transition: width .6s cubic-bezier(.25,.46,.45,.94); }
.sp-prog-bar.bar-success { background: var(--success); }
.sp-prog-bar.bar-warning { background: var(--warning); }

/* ── INLINE SEARCH ───────────────────────────────────────────── */
.sp-search { position: relative; }
.sp-search .sp-search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .78rem; pointer-events: none; }
.sp-search input { padding-left: 30px; }

.sp-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── ANIMATIONS ─────────────────────────────────────────────── */
.anim-in { animation: slideUp .22s ease both; }
.anim-in:nth-child(1) { animation-delay: .04s; }
.anim-in:nth-child(2) { animation-delay: .08s; }
.anim-in:nth-child(3) { animation-delay: .12s; }
.anim-in:nth-child(4) { animation-delay: .16s; }
.anim-in:nth-child(5) { animation-delay: .20s; }
.anim-in:nth-child(6) { animation-delay: .24s; }
.anim-in:nth-child(7) { animation-delay: .28s; }
.anim-scale { animation: scaleIn .2s ease both; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */

/* Fix selects en toolbars — la regla base pone width:100%, esto la anula en contextos de toolbar y tabla (solo desktop) */
.sp-select { min-width: 120px; }
.sp-card-header .sp-select { width: auto; }
@media (min-width: 768px) {
  .sp-table .sp-select { width: auto; }
}

/* Filter toolbar: always wraps, never clips */
.sp-filter-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}

@media (max-width: 991.98px) {
  .sp-sidebar          { transform: translateX(-100%); box-shadow: none; }
  .sp-sidebar.open     { transform: translateX(0); box-shadow: var(--sh-xl); }
  .sp-wrapper          { margin-left: 0; }
  .btn-sb-toggle       { display: flex; }
  .sp-main             { padding: 20px 16px 28px; }
  .sp-footer           { padding: 12px 16px; }
  .sp-topbar           { padding: 0 16px; }
  .sp-field-row        { grid-template-columns: 1fr; }
}

/* ── TABLE → CARDS (mobile) ─────────────────────────────────── */
@media (max-width: 767.98px) {
  /* Filter bar: full width, stacked */
  .sp-card-header                       { flex-wrap: wrap; gap: 8px; }
  .sp-card-header .sp-search            { width: 100% !important; margin-left: 0 !important; margin-right: 0 !important; }
  .sp-card-header .sp-filter-form,
  .sp-card-header form.d-flex           { width: 100%; flex-wrap: wrap; }
  .sp-card-header .sp-filter-form .sp-select,
  .sp-card-header form.d-flex .sp-select { min-width: 0; flex: 1 1 130px; width: auto !important; }
  .sp-card-header .sp-filter-form .sp-input,
  .sp-card-header form.d-flex .sp-input  { flex: 1 1 80px; width: auto !important; }

  /* Responsive table → card rows */
  .sp-table-wrap.sp-table-wrap { overflow: visible; border-radius: 0; } /* reset for card layout */
  .sp-table                         { display: block; }
  .sp-table thead                   { display: none; }
  .sp-table tbody                   { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
  .sp-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--sh-xs);
    overflow: hidden;
    transition: box-shadow var(--t), border-color var(--t);
  }
  .sp-table tbody tr:hover { box-shadow: var(--sh-sm); border-color: var(--border-2); }
  .sp-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    background: none !important; /* remove hover bg from individual cells */
    font-size: .855rem;
  }
  .sp-table tbody td:last-child { border-bottom: none; }

  /* Label from data-label */
  .sp-table tbody td::before {
    content: attr(data-label);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .055em;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 80px;
  }
  /* Cells with no label (action cells) align right and hide ::before */
  .sp-table tbody td[data-label=""]::before { display: none; }
  .sp-table tbody td[data-label=""]         { justify-content: flex-end; }

  /* Selects y forms dentro de celdas-card: ocupan todo el espacio disponible */
  .sp-table tbody td select,
  .sp-table tbody td .sp-select       { flex: 1 !important; min-width: 0 !important; width: 100% !important; box-sizing: border-box; }
  .sp-table tbody td form             { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; width: 100%; }
  .sp-table tbody td form .sp-select,
  .sp-table tbody td form select      { flex: 1 !important; min-width: 0 !important; width: 100% !important; }

  /* Celda con form (Cambiar estado): layout vertical para dar ancho completo al select */
  .sp-table tbody td:has(form) {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .sp-table tbody td:has(form)::before {
    min-width: unset;
  }
  .sp-table tbody td:has(form) form {
    width: 100%;
    display: flex;
    gap: 4px;
    align-items: center;
  }
  .sp-table tbody td:has(form) form .sp-select,
  .sp-table tbody td:has(form) form select {
    flex: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  /* State pills bar */
  .sp-pills-bar           { flex-wrap: wrap; gap: 6px; }

  /* Page header */
  .sp-page-header         { gap: 10px; }
  .sp-page-actions        { width: 100%; }
  .sp-page-actions .btn-sp { flex: 1; justify-content: center; }
}

@media (max-width: 575.98px) {
  .sp-page-title       { font-size: 1.2rem; }
  .stat-grid           { grid-template-columns: 1fr 1fr; }
  .sp-card-body        { padding: 14px; }
  .topbar-name         { display: none; }
  .topbar-user         { padding: 4px; }
  .quick-grid          { grid-template-columns: 1fr 1fr; }

  /* Topbar: tighter */
  .sp-topbar           { padding: 0 12px; gap: 8px; }
  .btn-logout span     { display: none; } /* hide logout text, keep icon */
  .btn-theme           { width: 32px; height: 32px; }
  .btn-sb-toggle       { width: 32px; height: 32px; }

  /* Cards full-width on tiny screens */
  .sp-table tbody      { padding: 8px; }
  .sp-table tbody td   { padding: 8px 12px; }
  .sp-table tbody td::before { min-width: 70px; }
}

/* ── BS OVERRIDES ───────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--surface); border-color: var(--border); color: var(--text);
  font-family: 'Inter', inherit; border-radius: var(--r-sm); font-size: .875rem;
  transition: border-color var(--t), box-shadow var(--t), background var(--ts);
}
.form-control:focus, .form-select:focus {
  background: var(--surface); border-color: var(--primary); color: var(--text);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: .79rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.table { color: var(--text); }
.card  { background: var(--surface); border-color: var(--border); border-radius: var(--r-lg); }
.alert { border-radius: var(--r); }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-xl); }
.modal-header, .modal-footer { border-color: var(--border); }
.dropdown-menu { background: var(--surface); border-color: var(--border); border-radius: var(--r); box-shadow: var(--sh-lg); }
.dropdown-item { color: var(--text-2); font-size: .875rem; }
.dropdown-item:hover  { background: var(--surface-2); color: var(--text); }
.dropdown-item:active { background: var(--primary-alpha); color: var(--primary); }

/* ── UTILS ───────────────────────────────────────────────────── */
.text-c      { color: var(--text) !important; }
.text-2-c    { color: var(--text-2) !important; }
.text-muted-c{ color: var(--text-muted) !important; }
.fw-500 { font-weight: 500; }  .fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }  .fw-800 { font-weight: 800; }
.lh-sm  { line-height: 1.3; }

/* Scrollbar */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

[data-theme="dark"] .swal2-popup {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}

/* ── CHECKBOX / RADIO LISTS (formulario envío) ───────────────── */
.sp-form-group { margin-bottom: 16px; }
.sp-req        { color: var(--danger); margin-left: 2px; }

.sp-check-list  { display: flex; flex-direction: column; gap: 5px; }

.sp-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color var(--t), background var(--t);
  font-size: .855rem; color: var(--text); line-height: 1.4; user-select: none;
}
.sp-check-item:hover {
  border-color: rgba(var(--primary-rgb), .45);
  background: var(--primary-alpha);
}
.sp-check-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-alpha);
}
.sp-check-item input[type="checkbox"],
.sp-check-item input[type="radio"]  {
  accent-color: var(--primary); width: 15px; height: 15px;
  flex-shrink: 0; cursor: pointer;
}

/* Single checkbox row (eg. "No acepta libre") */
.sp-check-label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color var(--t), background var(--t);
  font-size: .875rem; color: var(--text); line-height: 1.4; user-select: none;
}
.sp-check-label:hover { border-color: rgba(var(--primary-rgb), .45); background: var(--primary-alpha); }
.sp-check-label:has(input:checked) { border-color: var(--primary); background: var(--primary-alpha); }
.sp-check-label input[type="checkbox"] {
  accent-color: var(--primary); width: 15px; height: 15px;
  flex-shrink: 0; cursor: pointer;
}

/* Fallback for older browsers that don't support :has() */
@supports not selector(:has(*)) {
  .sp-check-item, .sp-check-label { transition: border-color var(--t); }
  .sp-check-item input:checked ~ span,
  .sp-check-label input:checked ~ span { font-weight: 600; color: var(--primary); }
}

/* Dark mode tweaks */
[data-theme="dark"] .sp-check-item,
[data-theme="dark"] .sp-check-label { background: var(--surface-2); }

