:root {
  --qg-gold: #f59e0b;
  --qg-dark: #1e293b;
  --qg-sidebar-w: 250px;
  --qg-sidebar-collapsed: 60px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.navbar-vertical {
  width: var(--qg-sidebar-w) !important;
  min-width: var(--qg-sidebar-w) !important;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  transition: width .2s, min-width .2s;
}

body.sidebar-collapsed .navbar-vertical {
  width: var(--qg-sidebar-collapsed) !important;
  min-width: var(--qg-sidebar-collapsed) !important;
}

body.sidebar-collapsed .brand-sub,
body.sidebar-collapsed .nav-link-title,
body.sidebar-collapsed .badge-alerta {
  display: none !important;
}

body.sidebar-collapsed .navbar-brand {
  text-align: center;
}

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.navbar-brand .brand-name {
  color: var(--qg-gold);
  font-weight: 700;
  font-size: 1.1rem;
}

.navbar-brand .brand-sub {
  color: #94a3b8;
  font-size: .7rem;
  display: block;
  line-height: 1;
}

.nav-link.active {
  background: rgba(245, 158, 11, .12) !important;
  color: var(--qg-gold) !important;
  border-radius: 6px;
}

.nav-link.active .nav-link-icon {
  color: var(--qg-gold) !important;
}

/* ── Sidebar dropdown submenu ────────────────────────────────────────────── */
.nav-item.dropdown .dropdown-toggle::after {
  margin-left: auto;
  opacity: .5;
  transition: opacity .15s;
}

.nav-item.dropdown.show .dropdown-toggle::after {
  opacity: 1;
}

.nav-item.dropdown .dropdown-menu {
  display: none;
  background: #16202e;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: .5rem 0;
  min-width: 220px;
  margin-left: .5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.nav-item.dropdown.show .dropdown-menu {
  display: block;
}

.nav-item.dropdown .dropdown-item {
  color: #94a3b8;
  padding: .45rem 1rem;
  font-size: .85rem;
  border-radius: 0;
  display: flex;
  align-items: center;
  transition: color .1s, background .1s;
}

.nav-item.dropdown .dropdown-item:hover {
  color: #e2e8f0;
  background: rgba(245, 158, 11, .1);
}

.nav-item.dropdown .dropdown-item.active {
  color: var(--qg-gold);
  background: rgba(245, 158, 11, .12);
}

.nav-item.dropdown .dropdown-divider {
  border-color: rgba(255,255,255,.08);
  margin: .35rem .75rem;
}

body.sidebar-collapsed .dropdown-toggle::after {
  display: none !important;
}

/* ── Page wrapper ────────────────────────────────────────────────────────── */
.navbar-expand-lg.navbar-vertical ~ .page-wrapper {
  margin-left: var(--qg-sidebar-w) !important;
  transition: margin-left .2s;
}

body.sidebar-collapsed .navbar-expand-lg.navbar-vertical ~ .page-wrapper {
  margin-left: var(--qg-sidebar-collapsed) !important;
}

body.sidebar-collapsed .page-wrapper .container-xl {
  max-width: none;
}

/* ── Sidebar toggle button ──────────────────────────────────────────────── */
.sidebar-toggle {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 6px;
  transition: background .15s;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.page-header .row {
  flex-wrap: wrap;
}

.store-select {
  max-width: 200px;
  border-radius: 8px;
  font-size: .85rem;
}

/* ── KPI cards ───────────────────────────────────────────────────────────── */
.kpi-card {
  border-left: 4px solid transparent;
  transition: box-shadow .2s;
}

.kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}

.kpi-card .h2 {
  font-size: 1.5rem;
  white-space: nowrap;
}

.kpi-green { border-color: #22c55e; }
.kpi-red   { border-color: #ef4444; }
.kpi-amber { border-color: #f59e0b; }
.kpi-blue  { border-color: #3b82f6; }

.stock-card-lingotes {
  border: 2px solid #b45309 !important;
}

/* ── Stock cards ──────────────────────────────────────────────────────────── */
.stock-card {
  font-size: .65rem;
  line-height: 1.15;
}

.stock-card .card-body {
  min-height: 2rem;
  padding: 2px 4px !important;
}

.stock-card-label {
  font-size: .5rem;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: #64748b;
  margin-bottom: 0;
}

.stock-card .fw-bold {
  font-size: .7rem;
}

.stock-card-num {
  font-size: .68rem;
  font-weight: 700;
}

.stock-card-sub {
  font-size: .55rem;
  color: #94a3b8;
  line-height: 1;
}

.stock-card-total {
  border: 2px solid #16a34a !important;
  background: #f0fdf4 !important;
}

.stock-card-total .stock-card-label {
  color: #16a34a;
  font-weight: 700;
}

.badge-alerta {
  font-size: .65rem;
  padding: 2px 6px;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.alert-row td {
  vertical-align: middle;
}

/* ── Expandible rows ─────────────────────────────────────────────────────── */
.row-expandible { cursor: pointer; }
.row-expandible:hover td { background: rgba(245, 158, 11, .04); }
.row-detail td { padding: 0 !important; }
.row-detail-inner {
  border-top: 2px solid #3b82f6;
  background: #eff6ff;
  padding: .75rem 1.25rem;
}

/* ── Misc ────────────────────────────────────────────────────────────────── */
.badge-live {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
