/* ╔══════════════════════════════════════════════════════════════════╗
   ║  NexusM2 OS · Comisiones · stylesheet                            ║
   ║  Sin trampas. Cada clase tiene un porqué.                        ║
   ╚══════════════════════════════════════════════════════════════════╝ */

:root {
  --nm2-500: #0294CE;
  --nm2-600: #0277A5;
  --nm2-700: #015A7C;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body { font-family: 'Inter', system-ui, sans-serif; }

/* Sidebar tab buttons */
.tab-btn {
  color: #4B5563;        /* ink-600 */
}
.dark .tab-btn { color: #CBD0D6; }  /* ink-300 */
.tab-btn:hover { background: #F1F3F5; color: #111827; }
.dark .tab-btn:hover { background: #1F2937; color: #FFFFFF; }
.tab-btn.active {
  background: linear-gradient(135deg, #E6F4FA 0%, #CCE9F5 100%);
  color: #015A7C;
  font-weight: 600;
}
.dark .tab-btn.active {
  background: linear-gradient(135deg, #013D52 0%, #015A7C 100%);
  color: #99D3EB;
}

/* KPI cards */
.kpi-card {
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px -8px rgba(2,148,206,0.20);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 90px; height: 90px;
  background: radial-gradient(circle, rgba(2,148,206,0.10), transparent 70%);
  pointer-events: none;
}

/* Number tickers */
.kpi-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Data tables */
.dt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.dt thead th {
  position: sticky;
  top: 56px;     /* under header */
  z-index: 5;
  background: #F8FAFB;
  color: #6B7280;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #E4E7EB;
  box-shadow: inset 0 -1px 0 #E4E7EB;
  user-select: none;
}
.dark .dt thead th {
  background: #1F2937;
  color: #9BA3AD;
  border-bottom-color: #374151;
  box-shadow: inset 0 -1px 0 #374151;
}
/* Cuando la tabla está dentro de un scroll horizontal (card-body.overflow-x-auto),
   desactivamos el sticky vertical para evitar overlap con la primera fila. */
.card-body.overflow-x-auto .dt thead th {
  position: static;
  top: auto;
}
/* Columna pegada izquierda en tablas anchas (histórico, líneas, etc.) */
.dt .sticky-col {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #FFFFFF;
  box-shadow: 1px 0 0 #F1F3F5;
}
.dark .dt .sticky-col {
  background: #111827;
  box-shadow: 1px 0 0 #374151;
}
.dt thead th.sticky-col {
  background: #F8FAFB;
  z-index: 6;
}
.dark .dt thead th.sticky-col {
  background: #1F2937;
}
.dt tbody tr:hover .sticky-col {
  background: #F8FAFB;
}
.dark .dt tbody tr:hover .sticky-col {
  background: #1F2937;
}
.dt tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #F1F3F5;
  vertical-align: middle;
}
.dark .dt tbody td { border-bottom-color: #374151; }
.dt tbody tr {
  transition: background-color 0.14s ease;
}
.dt tbody tr:hover { background: #F8FAFB; cursor: pointer; }
.dark .dt tbody tr:hover { background: #1F2937; }
.dt .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-feature-settings: 'tnum';
}
.dt .mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.pill-draft     { background:#F1F3F5; color:#6B7280; }
.pill-computed  { background:#E6F4FA; color:#015A7C; }
.pill-approved  { background:#DCFCE7; color:#15803D; }
.pill-locked    { background:#FEF3C7; color:#92400E; }
.pill-paid      { background:#DBEAFE; color:#1E40AF; }
.dark .pill-draft    { background:#374151; color:#CBD0D6; }
.dark .pill-computed { background:#013D52; color:#99D3EB; }
.dark .pill-approved { background:#14532D; color:#86EFAC; }
.dark .pill-locked   { background:#78350F; color:#FCD34D; }
.dark .pill-paid     { background:#1E3A8A; color:#BFDBFE; }

/* Progress bar — barra Cobrado con contraste reforzado */
.progress {
  background: #E2E8F0;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}
.dark .progress {
  background: #1F2937;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #047857 0%, #10B981 60%, #34D399 100%);
  box-shadow: 0 0 0 1px rgba(4, 120, 87, 0.15), 0 1px 2px rgba(4, 120, 87, 0.2);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
}
.dark .progress-bar {
  background: linear-gradient(90deg, #10B981 0%, #34D399 60%, #6EE7B7 100%);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25), 0 1px 3px rgba(16, 185, 129, 0.35);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #0294CE 0%, #0277A5 100%);
  color: white;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(2,148,206,0.20);
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(2,148,206,0.30);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  color: #6B7280;
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #E4E7EB;
  transition: all 0.14s ease;
}
.dark .btn-ghost { color: #CBD0D6; border-color: #374151; }
.btn-ghost:hover { background: #F8FAFB; border-color: #CBD0D6; }
.dark .btn-ghost:hover { background: #1F2937; border-color: #4B5563; }

.btn-danger {
  background: #FEE2E2;
  color: #B91C1C;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}
.btn-danger:hover { background: #FECACA; }

/* Inputs */
.field {
  display: block;
  width: 100%;
  padding: 8px 11px;
  font-size: 13px;
  background: #F8FAFB;
  border: 1px solid #E4E7EB;
  border-radius: 8px;
  transition: all 0.14s ease;
}
.dark .field { background: #111827; border-color: #374151; color: #F1F3F5; }
.field:focus {
  outline: none;
  border-color: #0294CE;
  box-shadow: 0 0 0 3px rgba(2,148,206,0.15);
  background: white;
}
.dark .field:focus { background: #1F2937; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}
.dark .field-label { color: #9BA3AD; }

/* Drawer transition */
#drawer { transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1); }
#drawer.hidden { transform: translateX(100%); display: block !important; pointer-events: none; }

/* Toast */
#toast.success { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
#toast.error   { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
#toast.info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* Skeleton loader */
@keyframes pulse-bg {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.skel {
  background: linear-gradient(90deg, #F1F3F5 0%, #E4E7EB 50%, #F1F3F5 100%);
  background-size: 200% 100%;
  animation: pulse-bg 1.4s ease-in-out infinite;
  border-radius: 6px;
}
.dark .skel { background: linear-gradient(90deg, #1F2937 0%, #374151 50%, #1F2937 100%); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fade in */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 0.22s ease-out both; }

/* Drilldown row */
.drilldown {
  background: #F8FAFB;
  border-left: 3px solid #0294CE;
}
.dark .drilldown { background: #111827; border-left-color: #33A6D6; }

/* Section cards */
.card {
  background: white;
  border: 1px solid #E4E7EB;
  border-radius: 12px;
  overflow: hidden;
}
.dark .card { background: #1F2937; border-color: #374151; }

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid #E4E7EB;
  display: flex;
  align-items: center;
  gap: 12px;
}
.dark .card-header { border-bottom-color: #374151; }
.card-title { font-size: 14px; font-weight: 700; color: #111827; }
.dark .card-title { color: #F1F3F5; }
.card-body { padding: 18px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: #6B7280;
}
.empty .empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #E6F4FA, #CCE9F5);
  display: flex; align-items: center; justify-content: center;
  color: #0294CE;
}
.dark .empty .empty-icon { background: linear-gradient(135deg, #013D52, #015A7C); }

/* Money emphasis */
.money-big {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.money-small {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Compute button special */
.btn-compute {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: white;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(245,158,11,0.30);
  transition: all 0.18s ease;
}
.btn-compute:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(245,158,11,0.40);
}
.btn-compute:disabled { opacity: 0.6; cursor: wait; }

/* Mobile */
@media (max-width: 768px) {
  aside.w-60 { display: none; }
  .dt thead th { font-size: 10px; padding: 8px; }
  .dt tbody td { padding: 9px 8px; font-size: 12px; }
  .money-big { font-size: 22px; }
}
