/* ============================================================
   SISTEMA DE GESTIÓN JUDICIAL — DESIGN SYSTEM GLOBAL
   Archivo: main.css
   Descripción: Variables de diseño, resets, componentes base,
                animaciones y estilos de página de login/header.
   ============================================================ */

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

/* ============================================================
   CSS CUSTOM PROPERTIES — TOKENS DE DISEÑO
   ============================================================ */
:root {
  /* Fondos */
  --bg-primary:       #0A1628;
  --bg-secondary:     #0F1F3D;
  --bg-card:          #1A2D42;
  --bg-card-hover:    #1E3550;
  --bg-glass:         rgba(26, 45, 66, 0.85);

  /* Acento */
  --accent:           #00B4D8;
  --accent-hover:     #00D4FF;
  --accent-glow:      rgba(0, 180, 216, 0.3);

  /* Tipografía */
  --text-primary:     #E8F4FD;
  --text-secondary:   #94A3B8;
  --text-muted:       #64748B;

  /* Bordes */
  --border:           rgba(0, 180, 216, 0.15);
  --border-hover:     rgba(0, 180, 216, 0.4);

  /* Colores semánticos */
  --success:          #10B981;
  --warning:          #F59E0B;
  --danger:           #EF4444;
  --info:             #3B82F6;
  --purple:           #8B5CF6;

  /* Sombras */
  --shadow-card:      0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow:      0 0 20px rgba(0, 180, 216, 0.2);

  /* Radios de borde */
  --radius:           12px;
  --radius-lg:        16px;
  --radius-sm:        8px;

  /* Transición estándar */
  --transition:       all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Tipografía base */
  --font-family:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-base:   16px;
}

/* ============================================================
   RESET GLOBAL
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

img,
video {
  max-width: 100%;
  display: block;
}

ul,
ol {
  list-style: none;
}

button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  background: none;
}

input,
select,
textarea {
  font-family: var(--font-family);
}

/* ============================================================
   SCROLLBAR PERSONALIZADA
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-card-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-card-hover) var(--bg-secondary);
}

/* ============================================================
   UTILIDADES DE TEXTO
   ============================================================ */
.text-muted     { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.text-danger    { color: var(--danger) !important; }
.text-info      { color: var(--info) !important; }
.text-accent    { color: var(--accent) !important; }
.text-purple    { color: var(--purple) !important; }

.text-center    { text-align: center !important; }
.text-left      { text-align: left !important; }
.text-right     { text-align: right !important; }

.font-bold      { font-weight: 700 !important; }
.font-semibold  { font-weight: 600 !important; }
.font-medium    { font-weight: 500 !important; }
.font-mono      { font-family: 'JetBrains Mono', 'Fira Code', monospace !important; }

.w-full         { width: 100% !important; }
.d-flex         { display: flex !important; }
.d-none         { display: none !important; }
.align-center   { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.gap-2          { gap: 8px !important; }
.gap-3          { gap: 12px !important; }
.gap-4          { gap: 16px !important; }
.mt-2           { margin-top: 8px !important; }
.mt-4           { margin-top: 16px !important; }
.mb-4           { margin-bottom: 16px !important; }

/* ============================================================
   BADGES — ESTADO EXPEDIENTE
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

/* ACTIVO */
.badge-activo {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border-color: rgba(16, 185, 129, 0.3);
}

/* INACTIVO */
.badge-inactivo {
  background: rgba(245, 158, 11, 0.15);
  color: #FBD04A;
  border-color: rgba(245, 158, 11, 0.3);
}

/* FINALIZADO */
.badge-finalizado {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* SUSTITUIDO */
.badge-sustituido {
  background: rgba(100, 116, 139, 0.15);
  color: #94A3B8;
  border-color: rgba(100, 116, 139, 0.3);
}

/* PPL — Privado de libertad */
.badge-ppl {
  background: rgba(153, 27, 27, 0.2);
  color: #FCA5A5;
  border-color: rgba(153, 27, 27, 0.4);
}

/* LIBERTAD */
.badge-libertad {
  background: rgba(20, 184, 166, 0.15);
  color: #2DD4BF;
  border-color: rgba(20, 184, 166, 0.3);
}

/* ============================================================
   BADGES — ESTADO AUDIENCIA
   ============================================================ */

/* PROGRAMADA */
.badge-programada {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border-color: rgba(59, 130, 246, 0.3);
}

/* REPROGRAMADA */
.badge-reprogramada {
  background: rgba(249, 115, 22, 0.15);
  color: #FB923C;
  border-color: rgba(249, 115, 22, 0.3);
}

/* CONCLUIDA */
.badge-concluida {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border-color: rgba(16, 185, 129, 0.3);
}

/* FRACASADA */
.badge-fracasada {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* SIN FECHA / PENDIENTE */
.badge-pendiente {
  background: rgba(100, 116, 139, 0.12);
  color: #64748B;
  border-color: rgba(100, 116, 139, 0.25);
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-family);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.05);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn:active::after {
  opacity: 1;
}

/* Primario */
.btn-primary {
  background: var(--accent);
  color: #0A1628;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 18px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secundario */
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-hover);
}

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

/* Peligro */
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: #EF4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.25);
}

/* Fantasma */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Tamaños */
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  gap: 5px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius);
}

/* Ícono solo */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.btn-icon.btn-lg {
  width: 44px;
  height: 44px;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 3px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-family);
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-card);
}

.form-control:hover:not(:focus) {
  border-color: var(--border-hover);
}

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

textarea.form-control {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

/* Select */
.form-select {
  width: 100%;
  padding: 10px 36px 10px 14px;
  background-color: var(--bg-secondary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-family);
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background-color: var(--bg-card);
}

.form-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-check input[type='checkbox'],
.form-check input[type='radio'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-check-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 2px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
  overflow-y: auto;
}

.modal {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideInModal 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.modal.modal-sm  { max-width: 460px; }
.modal.modal-lg  { max-width: 860px; }
.modal.modal-xl  { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title .modal-icon {
  color: var(--accent);
  font-size: 1.2rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ============================================================
   POPUP (observaciones / bottom sheet)
   ============================================================ */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 900;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 20px;
  animation: fadeIn 0.2s ease;
}

.popup {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-handle {
  width: 40px;
  height: 4px;
  background: var(--border-hover);
  border-radius: 2px;
  margin: 12px auto 0;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.popup-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.popup-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* ============================================================
   SPINNER DE CARGA
   ============================================================ */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3.5px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
}

.loading-overlay .spinner {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

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

@keyframes shimmer {
  from { background-position: 200% center; }
  to   { background-position: -200% center; }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 48px);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-card);
  pointer-events: all;
  animation: slideInRight 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.toast-success::before { background: var(--success); }
.toast-danger::before  { background: var(--danger);  }
.toast-warning::before { background: var(--warning); }
.toast-info::before    { background: var(--info);    }

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-danger  .toast-icon { color: var(--danger);  }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info);    }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
}

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

.toast.toast-hiding {
  animation: fadeOutRight 0.3s ease forwards;
}

/* ============================================================
   ALERTAS EN PÁGINA
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.9rem;
  line-height: 1.5;
}

.alert-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: #6EE7B7;
}
.alert-success .alert-icon { color: var(--success); }

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: #FCA5A5;
}
.alert-danger .alert-icon { color: var(--danger); }

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
  color: #FDE68A;
}
.alert-warning .alert-icon { color: var(--warning); }

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.25);
  color: #BFDBFE;
}
.alert-info .alert-icon { color: var(--info); }

/* ============================================================
   PAGINACIÓN
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 0 8px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
}

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

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0A1628;
  font-weight: 700;
  box-shadow: 0 0 12px var(--accent-glow);
}

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

.page-ellipsis {
  color: var(--text-muted);
  padding: 0 4px;
  font-size: 0.9rem;
}

/* ============================================================
   PÁGINA DE LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0, 180, 216, 0.12) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 180, 216, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -10%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), 0 0 60px rgba(0, 180, 216, 0.08);
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent) 0%, #0082A8 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  margin-top: -4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-btn {
  width: 100%;
  padding: 13px;
  margin-top: 4px;
}

.login-footer-text {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 20px;
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; }
}

/* ============================================================
   ENCABEZADO DE LA APLICACIÓN
   ============================================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(10, 22, 40, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  gap: 16px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.app-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent) 0%, #0082A8 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
}

.app-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-logo-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.app-logo-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Navegación central del header */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.header-nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  font-family: var(--font-family);
  text-decoration: none;
}

.header-nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.header-nav-link.active {
  color: var(--accent);
  background: rgba(0, 180, 216, 0.1);
  border-color: var(--border);
}

/* Menú de usuario */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  position: relative;
  flex-shrink: 0;
}

.user-menu:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px var(--accent-glow);
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.user-menu-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: var(--transition);
}

.user-menu.open .user-menu-arrow {
  transform: rotate(180deg);
  color: var(--accent);
}

/* Dropdown del usuario */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  animation: fadeInUp 0.2s ease;
  z-index: 200;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-family);
  text-align: left;
}

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

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 768px) {
  .app-logo-text   { display: none; }
  .header-nav      { display: none; }
  .user-info       { display: none; }
  .user-menu-arrow { display: none; }
}

/* ============================================================
   NAVEGACIÓN POR TABS
   ============================================================ */
.tabs-nav {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: rgba(0, 180, 216, 0.05);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--bg-card);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: var(--transition);
}

.tab-btn.active .tab-count {
  background: var(--accent);
  color: #0A1628;
}

.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
  animation: fadeInUp 0.3s ease;
}

.tab-pane.active {
  display: block;
}

/* ============================================================
   KEYFRAMES — ANIMACIONES
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInModal {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

@keyframes pulse {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.5; }
}

/* Clase de animación base */
.animate-fade-in {
  animation: fadeInUp 0.4s ease both;
}

/* Retardos escalonados para grids de tarjetas */
.animate-stagger > *:nth-child(1)   { animation: fadeInUp 0.4s ease 0.05s both; }
.animate-stagger > *:nth-child(2)   { animation: fadeInUp 0.4s ease 0.10s both; }
.animate-stagger > *:nth-child(3)   { animation: fadeInUp 0.4s ease 0.15s both; }
.animate-stagger > *:nth-child(4)   { animation: fadeInUp 0.4s ease 0.20s both; }
.animate-stagger > *:nth-child(5)   { animation: fadeInUp 0.4s ease 0.25s both; }
.animate-stagger > *:nth-child(6)   { animation: fadeInUp 0.4s ease 0.30s both; }
.animate-stagger > *:nth-child(7)   { animation: fadeInUp 0.4s ease 0.35s both; }
.animate-stagger > *:nth-child(8)   { animation: fadeInUp 0.4s ease 0.40s both; }
.animate-stagger > *:nth-child(n+9) { animation: fadeInUp 0.4s ease 0.45s both; }

/* Indicador de estado vivo */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

/* ============================================================
   DIVISORES
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 20px 0;
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   TARJETAS GENÉRICAS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: var(--transition);
  border-bottom: 1px solid rgba(0, 180, 216, 0.06);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ============================================================
   ESTADO VACÍO (empty state)
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.25;
  margin-bottom: 4px;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.5;
}

/* ============================================================
   RESPONSIVE — AJUSTES MÓVIL
   ============================================================ */
@media (max-width: 480px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 95vh;
    animation: slideInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .toast-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    padding: 0 12px 12px;
  }
}
