#dashboard-view {
  min-height: 100vh;
  background: var(--bg);
}
#dashboard-view.d-none {
  display: none;
}

#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  transition: left 0.3s ease;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-toggle {
  color: var(--text) !important;
  font-size: 1.2rem;
  padding: 4px 8px;
  text-decoration: none;
}
.topbar-toggle:hover {
  background: var(--primary-light);
  border-radius: 8px;
}
.topbar-brand-icon {
  font-size: 1.5rem;
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon-glow);
}
.topbar-brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-user-info {
  text-align: right;
  line-height: 1.3;
}
.topbar-greeting {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}
.topbar-user {
  font-size: 0.9rem;
}
.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--neon);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--neon-glow-border);
}
.btn-topbar-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-topbar-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-light);
  transform: translateY(-1px);
}
.btn-topbar-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-topbar-icon:hover {
  color: var(--neon);
  border-color: var(--neon);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 0 10px var(--neon-glow-subtle);
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(0, 255, 65, 0.1);
  min-height: var(--topbar-h);
}
.sidebar-brand-icon {
  font-size: 1.8rem;
  color: var(--neon);
  text-shadow: 0 0 15px var(--neon-glow);
}
.sidebar-brand-text {
  line-height: 1.3;
}
.sidebar-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
  text-shadow: 0 0 10px var(--neon-glow-subtle);
}
.sidebar-sub {
  font-size: 0.75rem;
  color: var(--sidebar-text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}
.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-menu li {
  list-style: none;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 450;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}
.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: var(--neon);
  border-left-color: var(--neon);
}
.sidebar-item.active {
  background: rgba(0, 255, 65, 0.1);
  color: var(--neon);
  border-left-color: var(--neon);
  font-weight: 500;
}
.sidebar-item-icon {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.sidebar-item-arrow {
  width: 16px;
  font-size: 0.7rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
  text-align: center;
}
.sidebar-sub-toggle.open .sidebar-item-arrow {
  transform: rotate(90deg);
}

.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: rgba(0, 0, 0, 0.3);
}
.sidebar-submenu.open {
  max-height: 300px;
}
.sidebar-sub-item {
  padding-left: 3.2rem !important;
  font-size: 0.82rem !important;
  border-left-color: transparent !important;
}
.sidebar-sub-item:hover {
  border-left-color: var(--neon) !important;
}
.sidebar-sub-item.active {
  border-left-color: var(--neon) !important;
}
.sidebar-sub-item .sidebar-item-icon {
  font-size: 0.8rem;
  width: 18px;
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(0, 255, 65, 0.1);
  text-align: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
}

#main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: 1.5rem;
  transition: margin-left 0.3s ease;
}

.welcome-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--topbar-h) - 3rem);
}
.welcome-card {
  max-width: 480px;
  width: 100%;
}
.welcome-icon {
  font-size: 4rem;
  color: var(--neon);
  opacity: 0.4;
  text-shadow: 0 0 40px var(--neon-glow);
}
.welcome-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
}
.welcome-text {
  color: var(--text-secondary);
}

@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
  }
  .sidebar-overlay.active {
    display: block;
  }
  #topbar {
    left: 0;
  }
  #main-content {
    margin-left: 0;
  }
}

@media (max-width: 575.98px) {
  #topbar {
    padding: 0 1rem;
  }
  .topbar-user-info {
    display: none;
  }
  #main-content {
    padding: 1rem;
  }
}

.page-content {
  animation: fadeInUp 0.35s ease;
}

/* ─── Tree View ─── */
.productos-tree {
  overflow-x: auto;
}
.productos-tree-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: rgba(17, 24, 39, 0.5);
}
.productos-tree-header .th-toggle { width: 28px; flex-shrink: 0; }
.productos-tree-header .th-img { width: 40px; flex-shrink: 0; }
.productos-tree-header .th-sku { width: 130px; flex-shrink: 0; }
.productos-tree-header .th-nombre { flex: 1; min-width: 0; }
.productos-tree-header .th-stock { width: 80px; flex-shrink: 0; text-align: right; }
.productos-tree-header .th-precio { width: 90px; flex-shrink: 0; text-align: right; }
.productos-tree-header .th-tipo { width: 100px; flex-shrink: 0; text-align: center; }
.productos-tree-header .th-estado { width: 80px; flex-shrink: 0; text-align: center; }
.productos-tree-header .th-acciones { width: 100px; flex-shrink: 0; }

.producto-tree-root {
  list-style: none;
  margin: 0;
  padding: 8px;
}
.producto-node {
  margin-bottom: 6px;
}
.producto-node.empty-tree {
  margin: 0;
}
.producto-node.inactive {
  opacity: 0.6;
}

.producto-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: all 0.12s ease;
}
.producto-row:hover {
  background: var(--primary-light);
  border-color: var(--neon-glow-border);
}
.producto-row.inactive {
  opacity: 0.6;
}

.producto-node.expanded > .producto-row,
.cuenta-node.expanded > .producto-row {
  border-color: var(--neon);
  box-shadow: 0 0 10px var(--neon-glow-subtle);
}

.producto-toggle-wrapper {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.producto-toggle {
  width: 28px; height: 28px;
  border: none; background: none;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.producto-toggle:hover {
  background: var(--border-light);
  color: var(--primary);
}
.producto-toggle i {
  transition: transform 0.2s ease;
  font-size: 0.8rem;
}
.producto-toggle i.rotated {
  transform: rotate(90deg);
}
.producto-spacer {
  width: 28px; height: 28px;
  display: block;
}

.producto-img {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}
.producto-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.producto-img .no-img {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--text-muted);
  font-size: 1rem;
  border-radius: 6px;
}
.producto-img.clickable {
  cursor: pointer;
}

.producto-sku {
  width: 130px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.producto-nombre {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.producto-stock {
  width: 80px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.88rem;
}
.producto-precio {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.88rem;
}
.producto-node .badge {
  width: 100px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.7rem;
}
.producto-node .badge-status {
  width: 80px;
  flex-shrink: 0;
  text-align: center;
}

.producto-actions {
  width: 100px;
  flex-shrink: 0;
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.producto-children {
  list-style: none;
  margin: 6px 0 4px 32px;
  padding-left: 12px;
  border-left: 1px dashed var(--border);
}

/* ─── POS Layout ─── */
.pos-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - var(--topbar-h) - 40px);
  overflow: hidden;
}
.pos-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.pos-right {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-h) - 40px);
}
.pos-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.pos-panel:hover {
  border-color: rgba(0, 255, 65, 0.15);
  box-shadow: var(--shadow-sm), 0 0 15px var(--neon-glow-subtle);
}
.pos-panel-cart {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.pos-panel-totals {
  flex-shrink: 0;
}
.pos-panel-saldo {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--surface));
}
.pos-product-results {
  position: absolute;
  z-index: 1050;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 250px;
  overflow-y: auto;
  width: calc(100% - 50px);
}
.pos-product-result-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.12s ease;
  border-bottom: 1px solid var(--border-light);
}
.pos-product-result-item:hover {
  background: var(--primary-light);
}
.pos-product-result-item:last-child {
  border-bottom: none;
}
.pos-cart-qty-btn {
  width: 26px; height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s;
}
.pos-cart-qty-minus {
  background: var(--danger-light);
  color: var(--danger);
}
.pos-cart-qty-plus {
  background: var(--success-light);
  color: var(--success);
}
.pos-cart-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
}
.pos-cart-remove:hover {
  color: var(--danger);
}
#posProductSearch {
  position: relative;
}
.pos-panel-product-search {
  position: relative;
}

.pos-panel-espera {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.pos-panel-espera .badge {
  font-size: 0.65rem;
}

@media (max-width: 992px) {
  .pos-layout {
    flex-direction: column;
    height: auto;
  }
  .pos-right {
    width: 100%;
  }
}
