:root {
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --gradient-card: linear-gradient(145deg, #ffffff, #f8fafc);
  --gradient-accent: linear-gradient(135deg, #3b82f6, #06b6d4);
  --gradient-success: linear-gradient(135deg, #10b981, #059669);
  --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 12px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item i {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  box-shadow: inset 3px 0 0 var(--accent-blue);
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-color);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.content-wrapper {
  padding: 28px 32px;
  flex: 1;
}

/* CARDS */
.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-lg);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

.card-header i {
  color: var(--accent-blue);
}

/* STAT CARDS */
.stat-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 24px;
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 48px;
  opacity: 0.08;
  transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
  opacity: 0.15;
  transform: scale(1.1);
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.stat-card .stat-change {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
}

.stat-card.accent-blue { border-left: 3px solid var(--accent-blue); }
.stat-card.accent-green { border-left: 3px solid var(--accent-green); }
.stat-card.accent-red { border-left: 3px solid var(--accent-red); }
.stat-card.accent-amber { border-left: 3px solid var(--accent-amber); }
.stat-card.accent-cyan { border-left: 3px solid var(--accent-cyan); }
.stat-card.accent-purple { border-left: 3px solid var(--accent-purple); }

.stat-card.accent-blue .stat-value { color: var(--accent-blue); }
.stat-card.accent-green .stat-value { color: var(--accent-green); }
.stat-card.accent-red .stat-value { color: var(--accent-red); }
.stat-card.accent-amber .stat-value { color: var(--accent-amber); }
.stat-card.accent-cyan .stat-value { color: var(--accent-cyan); }
.stat-card.accent-purple .stat-value { color: var(--accent-purple); }

/* TABLES */
.table-container {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--gradient-card);
}

.table {
  margin-bottom: 0;
  color: var(--text-primary);
  --bs-table-bg: transparent;
  --bs-table-hover-bg: rgba(59, 130, 246, 0.04);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
}

.table > thead {
  background: rgba(10, 14, 23, 0.6);
}

.table > thead > tr > th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(30, 45, 74, 0.5);
  vertical-align: middle;
}

.table > tbody > tr:hover {
  background: var(--bs-table-hover-bg);
}

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

/* BADGES */
.badge {
  font-weight: 500;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}

.badge-al-dia {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-atrasado {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-pendiente {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-inactivo {
  background: rgba(90, 101, 119, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(90, 101, 119, 0.2);
}

/* BUTTONS */
.btn {
  font-weight: 500;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-warning {
  background: var(--accent-amber);
  border: none;
  color: #000;
  font-weight: 600;
}

.btn-warning:hover {
  background: #d97706;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-success {
  background: var(--accent-green);
  border: none;
  color: white;
  font-weight: 600;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary {
  background: var(--accent-blue);
  border: none;
  font-weight: 600;
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-outline-secondary {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

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

.btn-outline-info {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-outline-info:hover {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.btn-outline-danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
}

/* FORMS */
.form-control, .form-select {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 14px;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  background: var(--bg-primary);
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  color: var(--text-primary);
}

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

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group-text {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
}

.form-text {
  color: var(--text-muted);
  font-size: 12px;
}

.form-check-input {
  background-color: var(--bg-primary);
  border-color: var(--border-light);
}

.form-check-input:checked {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* NAV PILLS */
.nav-pills .nav-link {
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
}

.nav-pills .nav-link:hover {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.06);
}

.nav-pills .nav-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

/* LINKS */
a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #60a5fa;
}

/* PROGRESS */
.progress {
  background: var(--bg-primary);
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar {
  font-weight: 600;
  font-size: 11px;
}

/* CHART CONTAINER */
.chart-container {
  position: relative;
  min-height: 250px;
}

/* ALERTS */
.alert {
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}

/* EMPTY STATE */
.empty-state {
  padding: 60px 20px;
  text-align: center;
}

.empty-state i {
  font-size: 56px;
  color: var(--text-muted);
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state h5 {
  color: var(--text-secondary);
  font-weight: 500;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
}

/* PAGE HEADER */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0;
}

/* DETAIL INFO */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item .detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.detail-item .detail-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

/* TOOLBAR */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

/* ANIMATIONS */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-card, .card {
  animation: fadeInUp 0.4s ease forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

/* MOBILE SIDEBAR */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: 1050;
    height: 100vh;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .sidebar .sidebar-close {
    display: block;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1049;
    background: rgba(0, 0, 0, 0.5);
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .content-wrapper {
    padding: 20px 16px;
  }
  .topbar {
    padding: 0 16px;
  }
}

@media (min-width: 992px) {
  .sidebar .sidebar-close {
    display: none !important;
  }
  .sidebar-backdrop {
    display: none !important;
  }
}

/* MODAL */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.modal-header {
  border-bottom-color: var(--border-color);
}

.modal-footer {
  border-top-color: var(--border-color);
}

.btn-close {
  filter: invert(0.7);
}

/* TOOLTIP CUSTOM */
[data-bs-toggle="tooltip"] {
  cursor: pointer;
}
