/* ================================================
   ERP LoRastreo — Design System v2
   Inter font · Indigo primary · Slate sidebar
   ================================================ */

/* ── Variables ─────────────────────────────────── */
:root {
  --font:           'Inter', system-ui, -apple-system, sans-serif;

  --primary:        #4f46e5;
  --primary-light:  #ede9fe;
  --primary-dark:   #4338ca;

  --sidebar-w:      252px;
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-hover:  rgba(255,255,255,0.05);
  --sidebar-active: rgba(99,102,241,0.18);
  --sidebar-accent: #818cf8;
  --sidebar-border: rgba(255,255,255,0.06);

  --topbar-h:       60px;
  --topbar-bg:      #ffffff;

  --page-bg:        #f1f5f9;
  --card-bg:        #ffffff;
  --border:         #e2e8f0;
  --muted:          #64748b;
  --body-color:     #1e293b;

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.05);
  --shadow:      0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 16px 32px rgba(0,0,0,0.05);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
}

/* ── Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--body-color);
  background: var(--page-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Layout wrapper ─────────────────────────────── */
#wrapper { min-height: 100vh; width: 100%; }

/* ══════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════ */
.sidebar-nav {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* Brand */
.sidebar-brand {
  padding: 0 1rem;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  color: #fff;
}

/* Menu */
.sidebar-menu {
  list-style: none;
  padding: 0.75rem 0.75rem 0;
  margin: 0;
  flex: 1;
}

.menu-header {
  padding: 0.875rem 0.75rem 0.375rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.22);
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 450;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
}
.menu-item a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.menu-item.active > a {
  background: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
}
.menu-item.active > a i { color: var(--sidebar-accent); }
.menu-item a i {
  font-size: 1rem;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.menu-item a:hover i, .menu-item.active > a i { opacity: 1; }

/* Footer */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}
.sidebar-footer .badge {
  font-size: 0.7rem;
  padding: 0.35em 0.7em;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Collapsed */
body.sidebar-collapsed .sidebar-nav { width: 60px; }
body.sidebar-collapsed .brand-link span,
body.sidebar-collapsed .menu-item a span,
body.sidebar-collapsed .menu-header { display: none; }
body.sidebar-collapsed .brand-link { justify-content: center; }
body.sidebar-collapsed .brand-icon { margin: 0; }
body.sidebar-collapsed .menu-item a { justify-content: center; padding: 0.6rem; gap: 0; }
body.sidebar-collapsed .menu-item a i { width: auto; }
body.sidebar-collapsed #page-content { margin-left: 60px; }
body.sidebar-collapsed .sidebar-footer { display: none; }

/* ══════════════════════════════════════════════════
   PAGE CONTENT & TOPBAR
══════════════════════════════════════════════════ */
#page-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

/* Sidebar toggle */
.sidebar-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-toggle:hover { background: #f8fafc; color: var(--body-color); }

/* Breadcrumb */
.topbar .breadcrumb { font-size: 0.78rem; }
.topbar .breadcrumb-item a { color: var(--muted); text-decoration: none; }
.topbar .breadcrumb-item a:hover { color: var(--primary); }
.topbar .breadcrumb-item.active { color: var(--body-color); font-weight: 500; }
.topbar .breadcrumb-item + .breadcrumb-item::before { color: #cbd5e1; }

/* User avatar */
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Logout button */
.btn-logout {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-logout:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ══════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════ */
.main-content { flex: 1; width: 100%; }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}
.page-header h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--body-color);
  margin-bottom: 0.125rem;
}

/* ══════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════ */
.erp-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.erp-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--body-color);
}

/* Override Bootstrap card para ERP */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow) !important;
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md) !important; }
.card-header {
  background: var(--card-bg) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 1rem 1.25rem !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  font-weight: 600;
  font-size: 0.875rem;
}
.card-body { padding: 1.25rem !important; }

/* KPI cards */
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow) !important;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-accent, #e2e8f0);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
}
.kpi-card .card-body { padding: 1.25rem !important; }
.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
}
.kpi-label { font-size: 0.73rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--body-color); line-height: 1.1; }

/* ══════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════ */
.table {
  font-size: 0.855rem;
  color: var(--body-color);
}
.table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border) !important;
  padding: 0.7rem 1rem;
  white-space: nowrap;
}
.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr { transition: background 0.1s; }
.table-hover tbody tr:hover { background: #f8faff !important; }

/* ══════════════════════════════════════════════════
   BADGES — scoped, no afecta utilities globales
══════════════════════════════════════════════════ */
.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.28em 0.62em;
  border-radius: 5px;
  letter-spacing: 0.02em;
}
/* Solo en contenido principal, no en sidebar */
.main-content .badge.bg-success,
.main-content .badge.bg-primary,
.main-content .badge.bg-danger,
.main-content .badge.bg-warning,
.main-content .badge.bg-info,
.main-content .badge.bg-secondary { border: none; }

.main-content .badge.bg-success   { background: #dcfce7 !important; color: #15803d !important; }
.main-content .badge.bg-primary   { background: #ede9fe !important; color: #6d28d9 !important; }
.main-content .badge.bg-danger    { background: #fee2e2 !important; color: #dc2626 !important; }
.main-content .badge.bg-warning   { background: #fef3c7 !important; color: #d97706 !important; }
.main-content .badge.bg-info      { background: #dbeafe !important; color: #2563eb !important; }
.main-content .badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }

/* ══════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════ */
.btn {
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.84rem;
  border-radius: var(--radius-sm) !important;
  transition: all 0.15s ease !important;
  letter-spacing: -0.01em;
}
.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 1px 2px rgba(79,70,229,0.2);
}
.btn-primary:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3) !important;
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline-primary { color: var(--primary) !important; border-color: #c7d2fe !important; }
.btn-outline-primary:hover { background: var(--primary-light) !important; color: var(--primary) !important; border-color: var(--primary) !important; }

.btn-outline-secondary { border-color: var(--border) !important; color: var(--muted) !important; }
.btn-outline-secondary:hover { background: #f8fafc !important; color: var(--body-color) !important; }

.btn-outline-danger { border-color: #fca5a5 !important; color: #dc2626 !important; }
.btn-outline-danger:hover { background: #fee2e2 !important; border-color: #dc2626 !important; }

/* Icon buttons in tables */
.btn-icon {
  width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* ══════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════ */
textarea.form-control {
  min-height: 80px;
  resize: vertical;
}
textarea.form-control.textarea-lg { min-height: 140px; }

.form-section {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.form-control, .form-select {
  font-family: var(--font);
  font-size: 0.875rem;
  border-color: var(--border);
  border-radius: var(--radius-sm) !important;
  color: var(--body-color);
  background: #f8fafc;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1) !important;
}
.form-label {
  font-weight: 500;
  font-size: 0.82rem;
  color: #374151;
  margin-bottom: 0.35rem;
}
.input-group-text {
  background: #f8fafc;
  border-color: var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  border-radius: var(--radius-sm) !important;
}

/* ══════════════════════════════════════════════════
   ALERTS
══════════════════════════════════════════════════ */
.alert {
  border: none;
  border-radius: var(--radius) !important;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-left-color: #22c55e; }
.alert-danger  { background: #fff1f2; color: #be123c; border-left-color: #f43f5e; }
.alert-warning { background: #fffbeb; color: #92400e; border-left-color: #f59e0b; }
.alert-info    { background: #eff6ff; color: #1e40af; border-left-color: #3b82f6; }

/* ══════════════════════════════════════════════════
   FILTER BAR
══════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .form-control,
.filter-bar .form-select { font-size: 0.84rem !important; height: 36px; }
.filter-bar .btn { height: 36px; }
.filter-bar .input-group { height: 36px; }
.filter-bar .input-group .form-control,
.filter-bar .input-group .input-group-text { height: 100%; }

/* ══════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-state-icon {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-lg);
  background: #f1f5f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #94a3b8;
  margin-bottom: 1.25rem;
}
.empty-state h6 { font-size: 0.9rem; font-weight: 600; color: var(--body-color); margin-bottom: 0.35rem; }
.empty-state p  { color: var(--muted); font-size: 0.83rem; margin-bottom: 1.25rem; }

/* ══════════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════════ */
.pagination { gap: 3px; }
.page-link {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.3rem 0.65rem;
}
.page-item.active .page-link { background: var(--primary) !important; border-color: var(--primary) !important; }
.page-item:not(.disabled) .page-link:hover { background: #f1f5f9 !important; color: var(--body-color); }

/* ══════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════ */
.modal-content {
  border: none !important;
  border-radius: var(--radius-xl) !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15) !important;
}
.modal-header {
  padding: 1.25rem 1.5rem !important;
  border-bottom: 1px solid var(--border) !important;
}
.modal-footer {
  padding: 1rem 1.5rem !important;
  border-top: 1px solid var(--border) !important;
}

/* ══════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════ */
.login-body { min-height: 100vh; display:flex; background:#f8fafc; }
.login-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Panel izquierdo — branding */
.login-brand {
  flex: 0 0 42%;
  background: linear-gradient(145deg, #0d2b4e 0%, #185fa5 60%, #1e40af 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(99,179,237,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(129,140,248,0.12) 0%, transparent 50%);
}
.login-brand-inner {
  position: relative;
  z-index: 1;
  color: #fff;
  max-width: 300px;
}
.login-brand-icon {
  width: 70px; height: 70px;
  border-radius: 18px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin-bottom: 1.5rem;
}
.login-brand-name {
  font-size: 2rem; font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 0.4rem;
}
.login-brand-desc {
  font-size: .9rem;
  opacity: 0.75;
  margin-bottom: 2.5rem;
}
.login-brand-features { display: flex; flex-direction: column; gap: .6rem; }
.login-feat {
  font-size: .82rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.login-feat i { color: #86efac; font-size: .85rem; }

/* Panel derecho — formulario */
.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #fff;
}
.login-form-box {
  width: 100%;
  max-width: 380px;
}
.login-form-footer {
  text-align: center;
  color: #94a3b8;
  font-size: .72rem;
  margin-top: 2.5rem;
}

/* Lockout / card genérica */
.login-container { width: 100%; max-width: 420px; padding: 1.25rem; }
.login-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 2.75rem 2.25rem;
  box-shadow: 0 24px 80px rgba(0,0,0,0.12);
}
.login-logo {
  width: 56px; height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff;
  margin: 0 auto 1.25rem;
}
.login-title {
  text-align: center; font-size: 1.4rem; font-weight: 700;
  color: var(--body-color); margin-bottom: 0.25rem; letter-spacing: -0.03em;
}
.login-subtitle {
  text-align: center; color: var(--muted); font-size: 0.875rem; margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .login-wrapper { flex-direction: column; }
  .login-brand { flex: none; padding: 2rem 1.5rem; min-height: auto; }
  .login-brand-features { display: none; }
  .login-body { background: #fff; }
}

/* ══════════════════════════════════════════════════
   INACTIVITY MODAL
══════════════════════════════════════════════════ */
.inactivity-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}
.inactivity-overlay.show { display: flex; }
.inactivity-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}
.inactivity-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fef3c7;
  color: #d97706;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
}
.inactivity-countdown {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin: 0.5rem 0 1.25rem;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ══════════════════════════════════════════════════
   QUICK ACTION BUTTONS (dashboard)
══════════════════════════════════════════════════ */
.quick-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--body-color);
  text-decoration: none;
  font-size: 0.855rem;
  font-weight: 500;
  transition: all 0.15s ease;
}
.quick-btn:hover {
  background: #f8faff;
  border-color: #c7d2fe;
  color: var(--primary);
  transform: translateX(3px);
  text-decoration: none;
}
.quick-btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════
   DARK MODE TOGGLE BUTTON
══════════════════════════════════════════════════ */
.btn-theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-theme-toggle:hover { background: #f1f5f9; color: var(--body-color); }

/* ══════════════════════════════════════════════════
   DARK MODE
══════════════════════════════════════════════════ */
[data-theme="dark"] {
  --primary:        #818cf8;
  --primary-light:  #1e1b4b;
  --primary-dark:   #a5b4fc;
  --sidebar-bg:     #080d1a;
  --sidebar-text:   #64748b;
  --sidebar-hover:  rgba(255,255,255,0.04);
  --sidebar-active: rgba(129,140,248,0.12);
  --sidebar-accent: #a5b4fc;
  --sidebar-border: rgba(255,255,255,0.04);
  --topbar-bg:      #111827;
  --page-bg:        #0f172a;
  --card-bg:        #1e293b;
  --border:         #334155;
  --muted:          #64748b;
  --body-color:     #e2e8f0;
}

[data-theme="dark"] body { background: var(--page-bg); color: var(--body-color); }

[data-theme="dark"] .topbar {
  background: var(--topbar-bg) !important;
  border-bottom-color: var(--border) !important;
}
[data-theme="dark"] .card,
[data-theme="dark"] .kpi-card {
  background: var(--card-bg) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .card-header {
  background: var(--card-bg) !important;
  border-bottom-color: var(--border) !important;
  color: var(--body-color);
}
[data-theme="dark"] .card-body { background: var(--card-bg); }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: #0f172a !important;
  border-color: var(--border) !important;
  color: var(--body-color) !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background: #0f172a !important;
  color: var(--body-color) !important;
}
[data-theme="dark"] .form-label { color: #94a3b8; }
[data-theme="dark"] .input-group-text {
  background: #1e293b !important;
  border-color: var(--border) !important;
  color: var(--muted);
}
[data-theme="dark"] .table { color: var(--body-color); }
[data-theme="dark"] .table thead th {
  background: #162032 !important;
  color: var(--muted);
  border-bottom-color: var(--border) !important;
}
[data-theme="dark"] .table tbody td {
  border-bottom-color: #1e293b;
  color: #cbd5e1;
}
[data-theme="dark"] .table-hover tbody tr:hover { background: #1a2d45 !important; }
[data-theme="dark"] .empty-state-icon { background: #1e293b; color: #475569; }
[data-theme="dark"] .quick-btn {
  background: #1e293b;
  border-color: var(--border);
  color: var(--body-color);
}
[data-theme="dark"] .quick-btn:hover {
  background: #253347;
  border-color: #4f46e5;
  color: var(--primary);
}
[data-theme="dark"] .btn-outline-secondary {
  border-color: var(--border) !important;
  color: #94a3b8 !important;
}
[data-theme="dark"] .btn-outline-secondary:hover {
  background: #1e293b !important;
  color: var(--body-color) !important;
}
[data-theme="dark"] .page-link {
  background: #1e293b !important;
  border-color: var(--border) !important;
  color: var(--muted);
}
[data-theme="dark"] .btn-theme-toggle:hover { background: #1e293b; color: var(--body-color); }
[data-theme="dark"] .btn-logout { border-color: var(--border); color: var(--muted); }
[data-theme="dark"] .inactivity-card { background: #1e293b; color: var(--body-color); }
[data-theme="dark"] .text-dark { color: var(--body-color) !important; }
[data-theme="dark"] .text-muted { color: #475569 !important; }
[data-theme="dark"] .form-section { color: #475569; border-bottom-color: var(--border); }
[data-theme="dark"] .sidebar-toggle { border-color: var(--border); color: var(--muted); }
[data-theme="dark"] .sidebar-toggle:hover { background: #1e293b; color: var(--body-color); }
[data-theme="dark"] .breadcrumb-item a { color: #64748b; }
[data-theme="dark"] .filter-bar .form-control,
[data-theme="dark"] .filter-bar .form-select { background: #1e293b !important; }
[data-theme="dark"] code { background: #1e293b; color: #a5b4fc; border-radius:4px; padding:0 4px; }
[data-theme="dark"] .alert-info { background: #1e3a5f; color: #93c5fd; border-left-color: #3b82f6; }
[data-theme="dark"] .alert-success { background: #14532d; color: #86efac; border-left-color: #22c55e; }
[data-theme="dark"] .alert-danger { background: #450a0a; color: #fca5a5; border-left-color: #ef4444; }
[data-theme="dark"] .alert-warning { background: #451a03; color: #fcd34d; border-left-color: #f59e0b; }

/* ── Dark mode: old PHP class compat ────────────── */
[data-theme="dark"] .table-wrap { background: var(--card-bg) !important; }
[data-theme="dark"] .form-group input:not([type=checkbox]):not([type=radio]),
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: #0f172a !important;
  border-color: var(--border) !important;
  color: var(--body-color) !important;
}
[data-theme="dark"] .detalle-card { background: var(--card-bg) !important; border-color: var(--border) !important; }
[data-theme="dark"] .stat-card { background: var(--card-bg) !important; }
[data-theme="dark"] .search-bar input {
  background: #0f172a !important;
  border-color: var(--border) !important;
  color: var(--body-color) !important;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
  touch-action: none;
}
.sidebar-overlay.show { display: block; }

body.sidebar-open { overflow: hidden; }

@media (max-width: 768px) {
  .sidebar-nav {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 1050;
    width: var(--sidebar-w) !important;
  }
  .sidebar-nav.show { transform: translateX(0); }
  #page-content { margin-left: 0 !important; }
  .kpi-value { font-size: 1.3rem; }
  .topbar { z-index: 1045; }

  body.sidebar-collapsed .sidebar-nav          { width: var(--sidebar-w) !important; }
  body.sidebar-collapsed .brand-link span,
  body.sidebar-collapsed .menu-item a span,
  body.sidebar-collapsed .menu-header          { display: revert !important; }
  body.sidebar-collapsed .brand-link           { justify-content: flex-start !important; }
  body.sidebar-collapsed .menu-item a          { justify-content: flex-start !important; padding: 0.5rem 0.75rem !important; gap: 0.7rem !important; }
  body.sidebar-collapsed .menu-item a i        { width: 1.1rem !important; }
  body.sidebar-collapsed .sidebar-footer       { display: block !important; }
}

/* ══════════════════════════════════════════════════
   BACKWARDS COMPAT — old PHP class aliases
   (allows module files to keep their current HTML)
══════════════════════════════════════════════════ */

/* Old badge classes */
.badge-green  { background: #dcfce7 !important; color: #15803d !important; }
.badge-blue   { background: #ede9fe !important; color: #6d28d9 !important; }
.badge-yellow { background: #fef3c7 !important; color: #d97706 !important; }
.badge-red    { background: #fee2e2 !important; color: #dc2626 !important; }
.badge-gray   { background: #f1f5f9 !important; color: #475569 !important; }

/* Role badges */
.badge-rol { font-size: .7rem; padding: .3em .6em; border-radius: 5px; font-weight: 600; }
.badge-maestro      { background: #fef3c7; color: #92400e; }
.badge-admin        { background: #dbeafe; color: #1e40af; }
.badge-ventas       { background: #dcfce7; color: #166534; }
.badge-compras      { background: #ede9fe; color: #5b21b6; }
.badge-almacen      { background: #fee2e2; color: #991b1b; }
.badge-rrhh         { background: #fce7f3; color: #9d174d; }
.badge-contabilidad { background: #e0f2fe; color: #075985; }

/* alert-error alias */
.alert-error { background: #fff1f2; color: #be123c; border-left: 3px solid #f43f5e; border-radius: var(--radius) !important; font-size: 0.875rem; padding: 0.65rem 1rem; margin-bottom: 1rem; }

/* Old .cards stat grid (dashboard) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.cards > .card { padding: 1.2rem 1rem; display: block; text-decoration: none; color: inherit; }
.card-value { font-size: 1.8rem; font-weight: 700; color: var(--body-color); }
.card-label { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.card-icon  { font-size: 1.6rem; margin-bottom: .4rem; }

/* Old form layout */
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; margin-bottom: .25rem; font-size: .82rem; font-weight: 500; color: #374151; }
.form-group input:not([type=checkbox]):not([type=radio]),
.form-group select,
.form-group textarea {
  width: 100%; padding: .45rem .7rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .875rem; color: var(--body-color);
  background: #f8fafc; font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:not([type=checkbox]):not([type=radio]):focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-row { display: grid; gap: 0 1rem; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* Old table wrap */
.table-wrap { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow-x: auto; }

/* Old search bar */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar input { flex: 1; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; font-family: var(--font); background: #f8fafc; color: var(--body-color); }
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }

/* Old pagination */
.paginacion { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }
.pag-link { display: inline-block; padding: .3rem .65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .82rem; text-decoration: none; color: var(--muted); transition: background .1s; }
.pag-link:hover { background: #f1f5f9; color: var(--body-color); }
.pag-activo { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }

/* Old stat cards */
.stat-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 1rem 1.2rem; border-left: 4px solid var(--primary); box-shadow: var(--shadow); }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--body-color); }

/* Old detalle cards */
.detalle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.detalle-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 1rem 1.2rem; border: 1px solid var(--border); box-shadow: var(--shadow); }
.detalle-card h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .65rem; }
.detalle-row { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.detalle-row:last-child { border-bottom: none; }
.detalle-row span:first-child { color: var(--muted); }
.detalle-row a { text-decoration: none; color: var(--primary); }
.detalle-row a:hover { text-decoration: underline; }

/* Old page-header headings */
.page-header h2 { font-size: 1.15rem; font-weight: 700; color: var(--body-color); margin-bottom: 0.125rem; }
.page-header h3 { font-size: 1rem; font-weight: 600; color: var(--body-color); margin-bottom: 0.1rem; }
h3 { font-size: 1rem; color: var(--body-color); margin-bottom: .75rem; }

/* Table actions (old .table-actions) */
.table-actions { display: flex; gap: .3rem; flex-wrap: wrap; }

/* Button sizes */
.btn-sm { padding: .25rem .6rem; font-size: .78rem; }

/* Misc */
.text-muted { color: var(--muted) !important; font-size: .85rem; }
.text-right { text-align: right; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.moneda::before { content: '$ '; }

/* Responsive: old form rows collapse */
@media (max-width: 768px) {
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .detalle-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); }
}
