:root {
  --bg-body: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #0284c7;
  --accent: #f59e0b;
}

[data-theme="dark"] {
  --bg-body: #0b1120;
  --card-bg: #131c31;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --primary: #38bdf8;
  --accent: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ============================================================================
   BARRA SUPERIOR GLOBAL BLINDADA CONTRA DESBORDAMIENTOS
   ============================================================================ */
.topbar-erp {
  min-height: 48px;
  background: linear-gradient(90deg, #070b14 0%, #0f172a 50%, #070b14 100%);
  border-bottom: 2px solid #f59e0b;
  padding: 4px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-left { flex: 1 1 auto; }
.topbar-right { flex: 0 1 auto; justify-content: flex-end; }

.titulo-barra-erp {
  color: #f59e0b;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid #334155;
  padding: 4px 11px;
  border-radius: 20px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-sem {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #ffffff;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 9.5px;
  font-weight: 900;
}

.user-badge-topbar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 6px 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  white-space: nowrap;
  max-width: 310px;
  flex-shrink: 1;
}

.user-name-truncate {
  color: #facc15;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 175px;
  display: inline-block;
}

.user-role-pill {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.status-realtime-pill {
  font-size: 10.5px;
  font-weight: 900;
  color: #4ade80;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 1220px) {
  .topbar-pill { display: none !important; }
  .user-name-truncate { max-width: 125px; }
}

@media (max-width: 880px) {
  .status-realtime-pill { display: none !important; }
  .user-name-truncate { max-width: 95px; }
}

/* ============================================================================
   DOCK LATERAL AUTO-OCULTABLE (APARECE AL ACERCAR EL CURSOR A LA IZQUIERDA)
   ============================================================================ */
.vr-dock-sensor {
  position: fixed;
  top: 48px;
  left: 0;
  width: 14px;
  height: calc(100vh - 48px);
  z-index: 9990;
  background: transparent;
}

.vr-dock-drawer {
  position: fixed;
  top: 48px;
  left: 0;
  width: 265px;
  height: calc(100vh - 48px);
  background: rgba(11, 17, 32, 0.97);
  border-right: 2px solid #f59e0b;
  box-shadow: 12px 0 38px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(12px);
  z-index: 9995;
  transform: translateX(-265px);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.vr-dock-drawer.abierto {
  transform: translateX(0);
}

/* Pestaña vertical discreta en el filo izquierdo */
.vr-dock-tab {
  position: absolute;
  top: 50%;
  right: -28px;
  transform: translateY(-50%);
  width: 28px;
  padding: 14px 4px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border: 1.5px solid #f59e0b;
  border-left: none;
  border-radius: 0 12px 12px 0;
  color: #f59e0b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 4px 0 14px rgba(0, 0, 0, 0.32);
  transition: opacity 0.2s, background 0.2s;
}

.vr-dock-drawer.abierto .vr-dock-tab {
  opacity: 0;
  pointer-events: none;
}

.vr-dock-tab-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.4px;
}

.vr-dock-header {
  padding: 14px 14px 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.vr-dock-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vr-dock-item {
  width: 100%;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #e2e8f0 !important;
  padding: 8px 11px !important;
  border-radius: 10px !important;
  font-size: 11.5px !important;
  font-weight: 800 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  box-shadow: none !important;
}

.vr-dock-item:hover {
  background: rgba(245, 158, 11, 0.16) !important;
  border-color: #f59e0b !important;
  color: #facc15 !important;
  transform: translateX(4px) !important;
}

.vr-dock-item.activo {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.25), rgba(245, 158, 11, 0.08)) !important;
  border-color: #f59e0b !important;
  color: #fde047 !important;
}

.vr-dock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  flex-shrink: 0;
}

/* ============================================================================
   SISTEMA UNIVERSAL DE BOTONES REALISTAS 3D Y ANIMACIÓN DE DESTELLO
   ============================================================================ */
button {
  font-family: inherit;
  letter-spacing: 0.35px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border-radius: 10px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28),
              0 3px 0 rgba(15, 23, 42, 0.22),
              0 5px 12px rgba(15, 23, 42, 0.16);
  transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.15s ease,
              filter 0.18s ease,
              background 0.18s ease !important;
}

button::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 65%;
  height: 100%;
  background: linear-gradient(
    110deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-20deg);
  pointer-events: none;
  transition: left 0.55s ease;
}

button:hover:not(:disabled)::after { left: 145%; }

button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38),
              0 5px 0 rgba(15, 23, 42, 0.24),
              0 9px 18px rgba(15, 23, 42, 0.24);
}

button:active:not(:disabled) {
  transform: translateY(2px) scale(0.985);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25),
              0 1px 0 rgba(15, 23, 42, 0.2),
              0 2px 5px rgba(15, 23, 42, 0.15);
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-topbar {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 5px 12px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 0 #090d16, 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-topbar-home {
  background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%);
  border-color: #7dd3fc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 0 #075985, 0 4px 10px rgba(2, 132, 199, 0.45);
}

.btn-topbar-salir {
  background: linear-gradient(180deg, #451a22 0%, #2a1015 100%);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.5);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 0 #18080b;
}
.btn-topbar-salir:hover {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
}

.btn-vr {
  padding: 8px 16px !important;
  font-size: 11.5px !important;
  font-weight: 900 !important;
  color: #ffffff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.btn-vr-emerald {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%) !important;
  border: 1px solid #34d399 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), 0 3px 0 #065f46, 0 6px 14px rgba(16, 185, 129, 0.35) !important;
}

.btn-vr-indigo {
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%) !important;
  border: 1px solid #818cf8 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), 0 3px 0 #3730a3, 0 6px 14px rgba(99, 102, 241, 0.35) !important;
}

.btn-vr-primary {
  background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%) !important;
  border: 1px solid #38bdf8 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), 0 3px 0 #075985, 0 6px 14px rgba(2, 132, 199, 0.35) !important;
}

.btn-vr-amber {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%) !important;
  border: 1px solid #fbbf24 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 3px 0 #92400e, 0 6px 14px rgba(245, 158, 11, 0.38) !important;
}

.btn-vr-danger {
  background: linear-gradient(180deg, #f43f5e 0%, #e11d48 100%) !important;
  border: 1px solid #fb7185 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 0 #9f1239, 0 6px 14px rgba(225, 29, 72, 0.35) !important;
}

.btn-vr-slate {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%) !important;
  border: 1px solid #64748b !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 3px 0 #0f172a, 0 6px 14px rgba(15, 23, 42, 0.3) !important;
}

.btn-vr-ghost {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%) !important;
  color: #334155 !important;
  border: 1.5px solid #cbd5e1 !important;
  text-shadow: none !important;
  box-shadow: inset 0 1px 0 #ffffff, 0 3px 0 #cbd5e1, 0 4px 10px rgba(15, 23, 42, 0.08) !important;
}

[data-theme="dark"] .btn-vr-ghost {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  color: #e2e8f0 !important;
  border: 1.5px solid #334155 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 3px 0 #020617 !important;
}

.btn-vr-icon { padding: 8px 11px !important; }