* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #1a202c;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: 80px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 3px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  color: #ffffff;
  border-radius: 12px;
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
  transform: scale(1);
  transition: transform 0.3s;
}

.brand-icon:hover {
  transform: scale(1.05);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand span {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}

.update-info {
  text-align: right;
}

.update-info span {
  display: block;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}

.update-info strong {
  font-size: 14px;
  color: #3b82f6;
  font-weight: 700;
}

/* MENÚ */
.menu {
  background: linear-gradient(90deg, #ffffff 0%, #f1f5f9 100%);
  border-bottom: 2px solid #e2e8f0;
  padding: 0 40px;
  display: flex;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.menu-btn {
  border: none;
  background: transparent;
  padding: 14px 28px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: #64748b;
  border-bottom: 4px solid transparent;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.menu-btn:hover {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
}

.menu-btn.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

/* CONTENEDOR */
.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 40px 50px;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 40px;
}

.kpi-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.kpi-card:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.kpi-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 15px 40px rgba(59, 130, 246, 0.2);
  transform: translateY(-5px);
}

.kpi-card:hover:before {
  transform: scaleX(1);
}

.kpi-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.kpi-label {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  margin-top: 10px;
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kpi-card.highlight {
  border-color: #ef4444;
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

.kpi-card.highlight:hover {
  border-color: #ef4444;
  box-shadow: 0 15px 40px rgba(239, 68, 68, 0.2);
}

.kpi-card.highlight .kpi-value {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* SECCIONES */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.section-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  color: #ffffff;
}

.section-header p {
  margin: 8px 0 0;
  color: #cbd5e1;
  font-size: 14px;
}

/* FILTROS */
.filters {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.filter-group label {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
  height: 42px;
  border: 2px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  color: #e2e8f0;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  transition: all 0.3s;
  font-weight: 500;
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #0f172a;
}

.filter-group select option {
  background: #1e293b;
  color: #e2e8f0;
}

.search-group {
  flex: 1;
  min-width: 280px;
}
/* TABLAS */
.table-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.table-title {
  min-height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-bottom: 2px solid #e2e8f0;
}

.table-title strong {
  font-size: 16px;
  color: #1e293b;
  font-weight: 700;
}

.table-title span {
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: #f8fafc;
}

th {
  padding: 14px 16px;
  text-align: left;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

td {
  padding: 14px 16px;
  border-top: 1px solid #f1f5f9;
  color: #334155;
  font-weight: 500;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr:hover td {
  color: #1e293b;
}

.summary-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.summary-title {
  min-height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-bottom: 2px solid #e2e8f0;
}

.summary-title strong {
  color: #1e293b;
  font-size: 16px;
}

.summary-title span {
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.summary-total td {
  background: #e2e8f0;
  border-top: 2px solid #94a3b8;
  color: #0f172a;
}

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: #64748b;
  font-style: italic;
}

tbody tr:has(.empty-state):hover {
  background: transparent;
}

/* NÚMEROS PENDIENTES */
.pending-number {
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  display: inline-block;
}

.pending-number.zero {
  color: #94a3b8;
  background: #f1f5f9;
}

.pending-number.has-pending {
  color: #ffffff;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ESTRUCTURA */
.structure-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.mini-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  transition: all 0.3s;
}

.mini-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.2);
  transform: translateY(-3px);
}

.mini-card span {
  display: block;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
}

.mini-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mini-card.pending {
  border-color: #ef4444;
  background: linear-gradient(135deg, #7f1d1d 0%, #4c0519 100%);
}

.mini-card.pending strong {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* AGENTE */
.agent-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.agent-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.agent-card:hover {
  border-color: #3b82f6;
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(59, 130, 246, 0.2);
}

.agent-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.agent-name {
  font-weight: 700;
  font-size: 16px;
  color: #1e293b;
}

.agent-dni {
  margin-top: 4px;
  color: #94a3b8;
  font-size: 12px;
}

.agent-info {
  margin-bottom: 16px;
  color: #64748b;
  font-size: 13px;
  padding: 10px 12px;
  background: #f1f5f9;
  border-radius: 8px;
}

.agent-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.agent-metric {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid #cbd5e1;
  transition: all 0.3s;
}

.agent-metric:hover {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #3b82f6;
}

.agent-metric span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
}

.agent-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  color: #3b82f6;
}

/* LOADING */
.loading {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #334155;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ERROR */
.error-box {
  background: linear-gradient(135deg, #fef2f2 0%, #ffe4e6 100%);
  border: 2px solid #ef4444;
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.1);
}

.error-box h3 {
  margin-top: 0;
  font-size: 20px;
  color: #dc2626;
}

.error-box p {
  color: #991b1b;
}

.error-box button {
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s;
  margin-top: 16px;
}

.error-box button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

/* UTILIDADES */
.hidden {
  display: none !important;
}

.view {
  animation: fadeIn 0.3s ease-in;
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-in;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid #e5e7eb;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.modal-header h3 {
  margin: 0;
  color: #1a202c;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.3s;
}

.modal-close:hover {
  background: #e5e7eb;
  color: #1a202c;
}

.modal-body {
  padding: 20px;
  color: #374151;
}

.modal-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.modal-section h4 {
  color: #3b82f6;
  font-size: 16px;
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-dates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.date-table-wrapper {
  overflow-x: auto;
  border: 1px solid #cbd5e1;
}

.date-table {
  min-width: 360px;
  font-size: 12px;
}

.date-table th,
.date-table td {
  width: 50%;
  padding: 4px 10px;
  text-align: center;
  border: 1px solid #cbd5e1;
}

.date-table th {
  color: #ffffff;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

.date-table th:nth-child(1) { background: #475569; }
.date-table th:nth-child(2) { background: #64748b; }

.date-table td {
  height: 24px;
  color: #1e293b;
  background: #ffffff;
}

.date-badge {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.date-badge.fl {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}

.date-badge.pf {
  border-color: #8b5cf6;
  background: #faf5ff;
  color: #6d28d9;
}

.date-badge.pn {
  border-color: #10b981;
  background: #f0fdf4;
  color: #065f46;
}

.modal-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.modal-info-label {
  color: #6b7280;
  font-size: 14px;
}

.modal-info-value {
  color: #1a202c;
  font-weight: 600;
  font-size: 16px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* RESPONSIVE */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .structure-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .agent-results {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 20px;
    height: auto;
    flex-direction: column;
    gap: 12px;
  }

  .menu {
    padding: 0 20px;
    gap: 4px;
    overflow-x: auto;
  }

  .menu-btn {
    padding: 12px 16px;
    font-size: 12px;
  }

  .container {
    padding: 20px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .structure-summary {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group {
    min-width: unset;
  }

  .update-info {
    display: none;
  }

  .agent-results {
    grid-template-columns: 1fr;
  }
}
