/* =============================================================================
   style.css — Sistema de Diseño SaaS Gestión Documental
   Adaptado y expandido del FormularioWeb.html existente.
   Incluye: glassmorphism, dark mode, responsive, animaciones, toasts.
   ============================================================================= */

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

/* ── TOKENS DE DISEÑO ────────────────────────────────────────────────────────── */
:root {
  --bg-main:             #f1f5f9;
  --bg-card:             #ffffff;
  --bg-sidebar:          #ffffff;
  --surface-glass:       rgba(15,23,42,0.02);
  --surface-glass-hover: rgba(15,23,42,0.05);
  --border-glass:        rgba(15,23,42,0.08);
  --border-glass-active: rgba(15,23,42,0.18);
  --primary:             #4f46e5;
  --primary-hover:       #3730a3;
  --primary-soft:        rgba(79,70,229,0.08);
  --primary-glow:        rgba(79,70,229,0.25);
  --success:             #027a48;
  --success-soft:        #ecfdf3;
  --danger:              #b42318;
  --danger-soft:         #fef3f2;
  --warning:             #b54708;
  --warning-soft:        #fffaeb;
  --text-main:           #0f172a;
  --text-muted:          #475569;
  --text-faint:          #94a3b8;
  --border:              rgba(15,23,42,0.12);
  --input-bg:            #ffffff;
  --shadow-sm:           0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:           0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:           0 10px 30px rgba(0,0,0,0.10);
  --shadow-xl:           0 20px 50px rgba(0,0,0,0.15);
  --radius-sm:           6px;
  --radius-md:           10px;
  --radius-lg:           16px;
  --radius-xl:           24px;
  --font:                'Outfit','Poppins',sans-serif;
  --transition:          all 0.3s cubic-bezier(0.4,0,0.2,1);
  --blur:                12px;
  --sidebar-w:           270px;
}

/* ── DARK MODE ───────────────────────────────────────────────────────────────── */
body.dark {
  --bg-main:             #08090e;
  --bg-card:             rgba(15,23,42,0.60);
  --bg-sidebar:          #0d1117;
  --surface-glass:       rgba(255,255,255,0.03);
  --surface-glass-hover: rgba(255,255,255,0.07);
  --border-glass:        rgba(255,255,255,0.06);
  --border-glass-active: rgba(255,255,255,0.14);
  --primary:             #6366f1;
  --primary-hover:       #4f46e5;
  --primary-soft:        rgba(99,102,241,0.12);
  --primary-glow:        rgba(99,102,241,0.35);
  --text-main:           #f1f5f9;
  --text-muted:          #94a3b8;
  --text-faint:          #64748b;
  --border:              rgba(255,255,255,0.07);
  --input-bg:            #111520;
  --shadow-sm:           0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:           0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:           0 10px 30px rgba(0,0,0,0.5);
  --shadow-xl:           0 20px 50px rgba(0,0,0,0.6);
}

@media (prefers-color-scheme:dark) {
  body:not(.light) { /* mismos tokens que body.dark */ }
}

/* ── RESET Y BASE ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  transition: background 0.4s, color 0.3s;
  line-height: 1.6;
  background-image:
    radial-gradient(at 15% 25%, rgba(99,102,241,0.05) 0, transparent 55%),
    radial-gradient(at 85% 75%, rgba(6,182,212,0.04) 0, transparent 55%);
}
body.dark {
  background-image:
    radial-gradient(at 15% 25%, rgba(99,102,241,0.10) 0, transparent 55%),
    radial-gradient(at 85% 75%, rgba(6,182,212,0.07) 0, transparent 55%);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PANTALLA DE LOGIN
   ═══════════════════════════════════════════════════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 2.8rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  animation: fadeSlideUp 0.5s ease both;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2rem;
  justify-content: center;
}

.login-logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--primary-glow);
  font-size: 1.6rem;
}

.login-brand h1 {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-brand p { font-size: 0.78rem; color: var(--text-muted); }

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}
.login-sub {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   APP SHELL (post-login)
   ═══════════════════════════════════════════════════════════════════════════════ */
#app {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}
#app.visible { display: flex; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.4rem 1rem;
  transition: var(--transition);
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.4rem 0.6rem 1.8rem;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 1.2rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
}

.brand-text h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}
.brand-text span {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── MENÚ LATERAL ─────────────────────────────────────────────────────────────── */
.nav-group { margin-bottom: 1.4rem; }
.nav-group-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 0.8rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.nav-item:hover {
  background: var(--surface-glass-hover);
  color: var(--text-main);
}
.nav-item.active {
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  color: var(--primary);
  border-color: rgba(99,102,241,0.18);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
  transition: var(--transition);
}
.nav-item.active .nav-icon { opacity: 1; filter: drop-shadow(0 0 4px var(--primary)); }

/* ── BADGE DE CONTEO EN MENÚ ──────────────────────────────────────────────────── */
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

/* ── FOOTER SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  cursor: default;
  transition: var(--transition);
}
.user-card:hover { background: var(--surface-glass-hover); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-info-text .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.user-info-text .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: var(--surface-glass);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  width: 100%;
}
.btn-logout:hover { background: rgba(180,35,24,0.08); border-color: var(--danger); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════════════
   ÁREA PRINCIPAL
   ═══════════════════════════════════════════════════════════════════════════════ */
.main-area {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
}

/* ── HEADER TOPBAR ───────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-glass);
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 12px;
}

.topbar-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}
.topbar-title p { font-size: 0.78rem; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── TOGGLE DARK MODE ─────────────────────────────────────────────────────────── */
.btn-theme {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--surface-glass);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
  color: var(--text-muted);
}
.btn-theme:hover { background: var(--primary-soft); color: var(--primary); }

/* ── CONTENIDO DE PÁGINAS ─────────────────────────────────────────────────────── */
.page-content {
  padding: 2rem;
  flex: 1;
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}
.page-content.active { display: flex; }

/* ── CARDS ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-glass);
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header h3 span.card-icon { color: var(--primary); font-size: 1.1rem; }

/* ── STAT CARDS (dashboard) ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon-wrap.blue   { background: rgba(79,70,229,0.1); }
.stat-icon-wrap.green  { background: rgba(2,122,72,0.1);  }
.stat-icon-wrap.orange { background: rgba(181,71,8,0.1);  }
.stat-icon-wrap.purple { background: rgba(126,34,206,0.1);}
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text-main); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════════════════════
   FORMULARIOS
   ═══════════════════════════════════════════════════════════════════════════════ */
.form-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 6px;
  margin: 1.6rem 0 1rem;
}
.form-section-title:first-child { margin-top: 0; }

.input-block { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 5px;
}
label .req { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
input:focus,select:focus,textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { resize: vertical; min-height: 100px; }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input.invalid, select.invalid, textarea.invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(180,35,24,0.12) !important;
  animation: shake 0.3s ease;
}
.field-error { font-size: 0.75rem; color: var(--danger); margin-top: 3px; display: block; }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── CAMPO BLOQUEADO (encargado automático) ──────────────────────────────────── */
.field-locked {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  background: var(--primary-soft);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  cursor: not-allowed;
}

/* ── QUILL EDITOR ─────────────────────────────────────────────────────────────── */
.ql-toolbar {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  border-color: var(--border) !important;
  background: var(--surface-glass) !important;
}
.ql-container {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
  border-color: var(--border) !important;
  background: var(--input-bg) !important;
  min-height: 160px;
  font-family: var(--font) !important;
}
.ql-editor { color: var(--text-main) !important; font-size: 0.9rem; }
.ql-snow .ql-stroke { stroke: var(--text-muted) !important; }
.ql-snow .ql-fill  { fill:   var(--text-muted) !important; }
.ql-snow .ql-picker { color:  var(--text-muted) !important; }
.ql-container:focus-within { border-color: var(--primary) !important; box-shadow: 0 0 0 3px var(--primary-soft); }

/* ═══════════════════════════════════════════════════════════════════════════════
   BOTONES
   ═══════════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-1px); }

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(2,122,72,0.25);
}
.btn-success:hover { background: #025a34; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8c1a11; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-glass-hover); color: var(--text-main); border-color: var(--border-glass-active); }

.btn-outline-primary {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 0.95rem; }
.btn-full { width: 100%; }

/* ── BOTONES IA ───────────────────────────────────────────────────────────────── */
.btn-ia {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
}
.btn-ia:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(99,102,241,0.45); }

.ia-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABLAS
   ═══════════════════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-glass); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead {
  background: var(--surface-glass);
  border-bottom: 1px solid var(--border-glass);
}
th {
  padding: 10px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}
td { padding: 11px 14px; color: var(--text-main); border-bottom: 1px solid var(--border-glass); vertical-align: middle; }
tbody tr:hover { background: var(--surface-glass); }
tbody tr:last-child td { border-bottom: none; }

.td-nomen {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-soft);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── BADGES / CHIPS ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(2,122,72,0.12); color: var(--success); }
.badge-danger  { background: rgba(180,35,24,0.10); color: var(--danger); }
.badge-warning { background: rgba(181,71,8,0.10);  color: var(--warning);}
.badge-primary { background: var(--primary-soft);  color: var(--primary); }
.badge-gray    { background: var(--surface-glass-hover); color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST / NOTIFICACIONES
   ═══════════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 300px;
  max-width: 500px;
  padding: 16px 22px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: all;
  animation: toastIn 0.35s cubic-bezier(.34,1.56,.64,1) both;
  box-shadow: var(--shadow-xl);
  border-bottom: 3px solid rgba(255,255,255,0.25);
  line-height: 1.4;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--primary); color: #fff; }
.toast-warning { background: #b54708;        color: #fff; }
.toast-icon    { font-size: 1.2rem; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  animation: fadeSlideUp 0.3s ease both;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-glass);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-main); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; transition: var(--transition); }
.modal-close:hover { background: var(--surface-glass-hover); color: var(--text-main); }

/* ═══════════════════════════════════════════════════════════════════════════════
   BARRA DE PROGRESO
   ═══════════════════════════════════════════════════════════════════════════════ */
.progress-wrap {
  background: var(--border-glass);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 20px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BUSCADOR DE HISTORIAL
   ═══════════════════════════════════════════════════════════════════════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--text-main);
  padding: 0;
}
.search-bar .search-icon { color: var(--text-faint); font-size: 1rem; }

/* ═══════════════════════════════════════════════════════════════════════════════
   UPLOAD DE ARCHIVOS (zona de arrastre)
   ═══════════════════════════════════════════════════════════════════════════════ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface-glass);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.drop-zone .drop-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.6; }
.drop-zone p { font-size: 0.85rem; color: var(--text-muted); }
.drop-zone strong { color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════════════════════
   SECCIÓN VACÍA (empty state)
   ═══════════════════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h4 { font-size: 1rem; color: var(--text-main); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.85rem; }

/* ═══════════════════════════════════════════════════════════════════════════════
   TABS (pestañas dentro de página)
   ═══════════════════════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
}
.tab-btn {
  padding: 7px 18px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: var(--transition);
  font-family: var(--font);
}
.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ANIMACIONES
   ═══════════════════════════════════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes toastIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}
@keyframes pulse {
  0%,100% { opacity: 0.6; } 50% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .split-2, .split-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; left: -280px; top: 0; height: 100%; width: 280px; z-index: 200; transition: left 0.3s ease; }
  .sidebar.open { left: 0; }
  .topbar { padding: 0.8rem 1rem; }
  .page-content { padding: 1rem; }
  .modal { padding: 1.4rem; }
  .stats-grid { grid-template-columns: 1fr; }
}
