/* ============================================================
   ALP Layout — layout.css
   App shell: sidebar, header, content area, mobile responsiveness
   ============================================================ */

/* ── App Layout Grid ──────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar collapsed — desktop rail: icon-only, hide labels
   All rules use element hiding (display:none) on named children — no font-size:0
   hack, no !important chain. Requires the sidebar template to render only element
   children (never bare text nodes) inside .sidebar-nav-item. */
body.sidebar-collapsed .app-layout { grid-template-columns: var(--sidebar-collapsed, 72px) 1fr; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed, 72px); }
body.sidebar-collapsed .sidebar-logo-text-wrap,
body.sidebar-collapsed .sidebar-nav-label,
body.sidebar-collapsed .sidebar-nav-item .nav-label,
body.sidebar-collapsed .sidebar-nav-item .pulse-dot,
body.sidebar-collapsed .sidebar-nav-item .nav-god-star-wrap { display: none; }
body.sidebar-collapsed .sidebar-nav-item {
  justify-content: center;
  padding-left: 0; padding-right: 0;
  gap: 0;
  position: relative;
  overflow: visible;
}
/* Icon: bump to 22px in the rail, above the active ::before/::after overlays. */
body.sidebar-collapsed .sidebar-nav-item .nav-icon {
  width: 22px; height: 22px;
  min-width: 22px; min-height: 22px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  opacity: 0.85;
}
body.sidebar-collapsed .sidebar-nav-item:hover .nav-icon,
body.sidebar-collapsed .sidebar-nav-item.active .nav-icon { opacity: 1; }
body.sidebar-collapsed .sidebar-nav-item.active::before,
body.sidebar-collapsed .sidebar-nav-item.active::after { z-index: 1; }
body.sidebar-collapsed .sidebar-nav-item .nav-badge {
  position: absolute; top: 6px; right: 8px; margin: 0; min-width: 16px;
  font-size: 10px;
}

/* JS-managed floating tooltip (rendered at <body> to escape sidebar overflow) */
.alp-nav-tooltip {
  position: fixed;
  transform: translateY(-50%) translateX(-6px);
  background: var(--bg-elevated, #0e0e0e);
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.3px; white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(212,175,55,0.15);
}
.alp-nav-tooltip.visible {
  opacity: 1; transform: translateY(-50%) translateX(0);
}
.alp-nav-tooltip::before {
  content: '';
  position: absolute;
  left: -7px; top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--border-gold);
}
[data-theme='light'] .alp-nav-tooltip {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border-primary);
}
@media (max-width: 768px) {
  .alp-nav-tooltip { display: none !important; }
}
body.sidebar-collapsed .sidebar-role-pill-name,
body.sidebar-collapsed .sidebar-role-pill-label { display: none; }
body.sidebar-collapsed .sidebar-role-pill { justify-content: center; padding: 8px 0; }
body.sidebar-collapsed .sidebar-footer a { justify-content: center; }
body.sidebar-collapsed .sidebar-telegram-body { display: none; }
body.sidebar-collapsed .sidebar-logo {
  justify-content: center;
  padding: 12px 0;
  flex-direction: column;
  gap: 10px;
  height: auto;
  min-height: var(--header-height);
}
body.sidebar-collapsed .sidebar-logo-icon {
  width: 40px; height: 40px;
  font-size: 20px;
}

/* Collapse toggle button in the sidebar logo bar */
.sidebar-collapse-btn {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  color: var(--text-tertiary);
  cursor: pointer; padding: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.sidebar-collapse-btn:hover {
  background: var(--accent-primary-muted);
  color: var(--accent-primary);
  border-color: var(--accent-primary-ring);
}
body.sidebar-collapsed .sidebar-collapse-btn {
  position: static;
  transform: none;
  margin: 0 auto;
  width: 44px; height: 28px;
  border-radius: 8px;
  background: var(--accent-primary-muted);
  border: 1px solid var(--accent-primary-ring);
  color: var(--accent-primary);
}
body.sidebar-collapsed .sidebar-collapse-btn:hover {
  background: var(--accent-primary-ring);
  border-color: var(--accent-primary);
}
body.sidebar-collapsed .sidebar-collapse-btn svg { width: 14px; height: 14px; }
@media (max-width: 768px) {
  /* Hide desktop collapse button on phones — the slide-in drawer handles it */
  .sidebar-collapse-btn { display: none; }
  /* Force full sidebar on phones even if body.sidebar-collapsed was set */
  body.sidebar-collapsed .app-layout { grid-template-columns: 1fr; }
  body.sidebar-collapsed .sidebar { width: 260px; }
  body.sidebar-collapsed .sidebar-logo-text-wrap,
  body.sidebar-collapsed .sidebar-nav-label,
  body.sidebar-collapsed .sidebar-nav-item > *:not(.nav-icon):not(.nav-badge),
  body.sidebar-collapsed .sidebar-role-pill > span:not(:first-child),
  body.sidebar-collapsed .sidebar-footer a > *:not(svg) { display: initial; }
  body.sidebar-collapsed .sidebar-nav-item {
    justify-content: flex-start;
    padding-left: 16px; padding-right: 16px;
    gap: 12px;
  }
}
[data-theme='light'] .sidebar-collapse-btn {
  background: var(--bg-tertiary);
  border-color: var(--border-primary);
  color: var(--text-secondary);
}
[data-theme='light'] .sidebar-collapse-btn:hover {
  background: rgba(184,148,46,0.10);
  color: var(--accent-primary-hover);
  border-color: rgba(184,148,46,0.35);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg, #000000);
  border-right: 1px solid var(--border-primary);
  z-index: var(--z-sidebar);
  transition: transform var(--duration-slow) var(--ease-out);
  overflow: hidden;
  box-shadow: var(--sidebar-shadow, 4px 0 24px rgba(0, 0, 0, 0.4));
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.02) 0%, transparent 30%, transparent 70%, rgba(212, 175, 55, 0.01) 100%);
  pointer-events: none;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, rgba(212, 175, 55, 0.15), transparent);
  pointer-events: none;
}

/* ── Sidebar Logo ─────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
  position: relative;
  height: var(--header-height);
}

.sidebar-logo::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.3), transparent);
}

/* Dark tile + glowing gold "$" — brand mark, kept identical across themes. */
.sidebar-logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #261f0a, #120f04);
  border: 1px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 0 15px var(--accent-primary-ring),
    inset 0 0 10px var(--accent-primary-muted);
  position: relative;
}
.sidebar-logo-symbol {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
  line-height: 1;
}

.sidebar-logo {
  justify-content: flex-start;
  gap: 12px;
}
.sidebar-logo-text-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}
.sidebar-logo-text {
  font-size: 16px;
  letter-spacing: 1px;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-logo-badge {
  font-size: 10px;
  font-weight: var(--font-semibold);
  color: var(--cyber-green);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.2);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.15);
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% {
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.25);
  }
}

/* ── Sidebar Navigation ───────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-nav-section {
  margin-top: var(--space-4);
}

.sidebar-nav-section:first-child {
  margin-top: 0;
}

.sidebar-nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-primary, #D4AF37);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.55;
}
.sidebar-nav-label::before {
  content: '';
  width: 12px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent-primary, #D4AF37), transparent);
  flex-shrink: 0;
}
.sidebar-nav-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-primary-ring, rgba(212,175,55,0.12)), transparent);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition:
    background var(--transition-base),
    color var(--transition-base),
    transform var(--transition-base),
    box-shadow var(--transition-base);
  position: relative;
  -webkit-user-select: none;
  user-select: none;
}

.sidebar-nav-item:hover {
  background: var(--accent-primary-muted);
  color: var(--text-primary);
  transform: translateX(2px);
}

.sidebar-nav-item .nav-label {
  letter-spacing: 0.02em;
  transition: text-shadow var(--transition-base);
}
.sidebar-nav-item:hover .nav-label {
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.15);
}
.sidebar-nav-item.active {
  background: linear-gradient(90deg, var(--accent-primary-ring), var(--accent-primary-muted));
  color: var(--accent-primary);
  box-shadow: inset 0 1px 2px var(--accent-primary-muted);
}
.sidebar-nav-item.active .nav-label {
  background: linear-gradient(135deg, var(--accent-primary, #D4AF37) 0%, #f5d76e 50%, var(--accent-primary, #D4AF37) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  font-weight: var(--font-semibold);
}
[data-theme='light'] .sidebar-nav-item.active .nav-label {
  background: linear-gradient(135deg, #7a6318 0%, #a8862a 50%, #7a6318 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* Accent bar is ALWAYS in the DOM; it scales in on .active so the state
   change reads as motion, not a hard pop. */
.sidebar-nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 20px;
  background: linear-gradient(180deg, var(--accent-primary), var(--accent-primary-hover));
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  box-shadow: 0 0 12px var(--accent-primary-ring);
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  opacity: 0;
  transition:
    transform 260ms var(--ease-spring),
    opacity 180ms var(--ease-out);
  pointer-events: none;
}
.sidebar-nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
  opacity: 1;
}

/* Halo border on active — fades in with the accent bar */
.sidebar-nav-item::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  pointer-events: none;
  transition: border-color var(--transition-base);
}
.sidebar-nav-item.active::after {
  border-color: var(--accent-primary-ring);
}

.sidebar-nav-item i,
.sidebar-nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  flex-shrink: 0;
  opacity: 0.7;
  transition:
    opacity var(--transition-fast),
    transform 220ms var(--ease-spring);
}

.sidebar-nav-item:hover i,
.sidebar-nav-item:hover .nav-icon {
  opacity: 1;
  transform: scale(1.08);
}
.sidebar-nav-item.active i,
.sidebar-nav-item.active .nav-icon {
  opacity: 1;
  transform: scale(1.04);
}
.sidebar-nav-item:active .nav-icon {
  transform: scale(0.94);
  transition-duration: 80ms;
}

.sidebar-nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: var(--font-semibold);
  background: var(--color-danger);
  color: #fff;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  padding: 0 6px;
}

.sidebar-nav-sub {
  padding-left: 34px;
  font-size: 12.5px;
  opacity: 0.85;
}
.sidebar-nav-sub .nav-icon {
  width: 16px;
  height: 16px;
}
.sidebar-nav-sub.active {
  opacity: 1;
}

/* ── Sidebar Motion ───────────────────────────────────────────
   Small, one-shot polish on mount + state-change micro-interactions.
   Skipped entirely under prefers-reduced-motion.
   ─────────────────────────────────────────────────────────── */

/* Entrance — items fade + slide in with a light stagger.
   `.sidebar-nav > *` covers both nav items and group labels. */
@keyframes alpNavIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0);    }
}
.sidebar-nav > * {
  animation: alpNavIn 320ms var(--ease-out) both;
}
.sidebar-nav > *:nth-child(1)  { animation-delay:  20ms; }
.sidebar-nav > *:nth-child(2)  { animation-delay:  40ms; }
.sidebar-nav > *:nth-child(3)  { animation-delay:  60ms; }
.sidebar-nav > *:nth-child(4)  { animation-delay:  80ms; }
.sidebar-nav > *:nth-child(5)  { animation-delay: 100ms; }
.sidebar-nav > *:nth-child(6)  { animation-delay: 120ms; }
.sidebar-nav > *:nth-child(7)  { animation-delay: 140ms; }
.sidebar-nav > *:nth-child(8)  { animation-delay: 160ms; }
.sidebar-nav > *:nth-child(9)  { animation-delay: 180ms; }
.sidebar-nav > *:nth-child(10) { animation-delay: 200ms; }
.sidebar-nav > *:nth-child(11) { animation-delay: 220ms; }
.sidebar-nav > *:nth-child(12) { animation-delay: 240ms; }
.sidebar-nav > *:nth-child(13) { animation-delay: 260ms; }
.sidebar-nav > *:nth-child(14) { animation-delay: 280ms; }
.sidebar-nav > *:nth-child(15) { animation-delay: 300ms; }
.sidebar-nav > *:nth-child(n+16) { animation-delay: 320ms; }

/* Logo mark: gentle fade on mount too, so the header doesn't pop before nav. */
.sidebar-logo {
  animation: alpNavIn 380ms var(--ease-out) both;
}

/* Collapse chevron: single icon rotates 180° instead of dual-polyline swap. */
.sidebar-collapse-btn svg {
  transition: transform 260ms var(--ease-spring);
}
body.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

/* Notification badge pop — JS adds .just-appeared when count enters from 0. */
@keyframes alpBadgePop {
  0%   { transform: scale(0.5); opacity: 0; }
  55%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.sidebar-nav-item .nav-badge.just-appeared,
.notif-count-badge.just-appeared {
  animation: alpBadgePop 340ms var(--ease-spring);
}

/* God-star: subtle idle twinkle — one 4s cycle every so often, not distracting. */
@keyframes alpStarTwinkle {
  0%, 92%, 100% { opacity: 1;   transform: scale(1);    filter: drop-shadow(0 0 2px transparent); }
  95%           { opacity: 0.75; transform: scale(1.15); filter: drop-shadow(0 0 4px var(--accent-primary-ring)); }
}
.nav-god-star-wrap {
  animation: alpStarTwinkle 5s ease-in-out infinite;
}

/* Reduced-motion: strip animations + transitions on the nav.
   Kept scoped to nav so global motion elsewhere is unaffected. */
@media (prefers-reduced-motion: reduce) {
  .sidebar-nav > *,
  .sidebar-logo,
  .sidebar-collapse-btn svg,
  .sidebar-nav-item,
  .sidebar-nav-item .nav-icon,
  .sidebar-nav-item::before,
  .sidebar-nav-item::after,
  .sidebar-nav-item .nav-badge,
  .nav-god-star-wrap,
  .notif-count-badge {
    animation: none;
    transition: none;
  }
  .sidebar-nav-item:hover { transform: none; }
  .sidebar-nav-item:hover .nav-icon,
  .sidebar-nav-item.active .nav-icon { transform: none; }
}

/* ── Sidebar Footer ───────────────────────────────────────── */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-primary);
  background: var(--bg-elevated);
  flex-shrink: 0;
  position: relative;
}

/* Role pill inner spans — replaces the old inline font-size / opacity styles */
.sidebar-role-pill-icon {
  display: inline-flex;
  align-items: center;
  color: currentColor;
  line-height: 1;
}
.sidebar-role-pill-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-role-pill-label {
  opacity: 0.72;
  font-size: 10px;
  margin-left: auto;
  letter-spacing: 0.2px;
}

/* Footer Telegram CTA — uses info tokens so it re-tints per theme */
.sidebar-telegram-card {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--color-info-muted);
  border: 1px solid rgba(37, 99, 235, 0.30);
  color: var(--color-info);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.sidebar-telegram-card:hover {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.45);
}
.sidebar-telegram-card > svg { flex-shrink: 0; color: var(--color-info); }
.sidebar-telegram-body { min-width: 0; }
.sidebar-telegram-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-info);
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-telegram-sub {
  font-size: 9.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* God-star badge wrap — was inline margin-left/flex-shrink */
.nav-god-star-wrap {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  color: var(--accent-primary);
  line-height: 1;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-base);
}

.sidebar-user:hover {
  background: var(--bg-hover);
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: #ffffff;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.sidebar-user-menu-btn {
  color: var(--text-muted);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.sidebar-user-menu-btn:hover {
  color: var(--text-primary);
}

/* ── Main Content Area ────────────────────────────────────── */
.main-content {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--header-height);
  padding: 0 var(--space-6);
  background: var(--header-bg, rgba(0, 0, 0, 0.90));
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border-primary);
  transition: all var(--transition-slow);
  box-shadow: var(--header-shadow, 0 1px 3px rgba(0, 0, 0, 0.12));
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.25), transparent);
  pointer-events: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
}

.header-title {
  --ht-gold:  var(--accent-primary, #D4AF37);
  --ht-shine: #f5d76e;
  font-size: var(--text-lg);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.04em;
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg, var(--ht-gold) 0%, var(--ht-shine) 40%, var(--ht-gold) 60%, var(--ht-shine) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: alpTitleShimmer 4s ease-in-out infinite;
}
[data-theme='light'] .header-title {
  --ht-gold:  #7a6318;
  --ht-shine: #a8862a;
}

/* ── Gold bloom flash behind text on entrance ──────────────── */
.header-title::before {
  content: '';
  position: absolute;
  inset: -8px -16px;
  background: radial-gradient(ellipse at center, var(--ht-gold), transparent 70%);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
.header-title.alp-title-enter::before {
  animation: alpTitleBloom 600ms ease-out forwards;
}

/* ── Underline draw ────────────────────────────────────────── */
.header-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, var(--ht-gold), var(--ht-shine), transparent 90%);
  border-radius: 1px;
  opacity: 0.5;
  transform: scaleX(1);
  transform-origin: left;
}
.header-title.alp-title-enter::after {
  transform: scaleX(0);
  animation: alpUnderDraw 450ms 300ms var(--ease-out, ease-out) forwards;
}

/* ── Main entrance: glitch flash ───────────────────────────── */
.header-title.alp-title-enter {
  animation: alpTitleFlash 500ms ease-out forwards, alpTitleShimmer 4s ease-in-out 500ms infinite;
}

@keyframes alpTitleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes alpTitleFlash {
  0%   { opacity: 0;   filter: blur(6px) brightness(3); transform: scaleX(1.08) translateX(-4px); }
  15%  { opacity: 0.7; filter: blur(0)   brightness(2.5); transform: scaleX(0.98) translateX(3px); }
  30%  { opacity: 0.5; filter: blur(1px) brightness(2); transform: scaleX(1.02) translateX(-2px); }
  50%  { opacity: 1;   filter: blur(0)   brightness(1.8); transform: scaleX(1) translateX(0); }
  75%  { filter: brightness(1.2); }
  100% { opacity: 1;   filter: brightness(1); transform: scaleX(1) translateX(0); }
}
@keyframes alpTitleBloom {
  0%   { opacity: 0.6; transform: scale(0.5); }
  30%  { opacity: 0.35; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.8); }
}
@keyframes alpUnderDraw {
  to { transform: scaleX(1); opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .header-title { animation: none !important; }
  .header-title.alp-title-enter { animation: none !important; opacity: 1; filter: none; transform: none; }
  .header-title.alp-title-enter::before { animation: none; }
  .header-title.alp-title-enter::after { animation: none; transform: scaleX(1); }
}

.header-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-left: var(--space-2);
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Header Search ────────────────────────────────────────── */
.header-search {
  position: relative;
  width: 280px;
  margin-left: auto;
}

.header-search-input {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-4) 0 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: all var(--transition-base);
}

.header-search-input::placeholder {
  color: var(--text-muted);
}

.header-search-input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-input);
  box-shadow: 0 0 0 3px var(--accent-primary-ring);
}

.header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
}

.header-search-shortcut {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 1px solid var(--border-primary);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  pointer-events: none;
  font-family: var(--font-mono);
}

/* ── Global Search Dropdown ──────────────────────────────── */
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: rgba(12, 12, 22, 0.98);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 10px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(212, 175, 55, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  z-index: var(--z-max);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overscroll-behavior: contain;
}

.global-search-dropdown::-webkit-scrollbar { width: 3px; }
.global-search-dropdown::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.2);
  border-radius: 2px;
}

.gsd-section-label {
  padding: 10px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(212, 175, 55, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.gsd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s ease;
  border-radius: 0;
  min-height: 36px;
}

.gsd-item:hover,
.gsd-item.active {
  background: rgba(212, 175, 55, 0.07);
}

.gsd-item-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.gsd-item-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.gsd-item-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.gsd-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.gsd-item-badge {
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gsd-item-shortcut {
  font-size: 10px;
  font-weight: 600;
  color: rgba(212, 175, 55, 0.4);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gsd-highlight {
  background: rgba(212, 175, 55, 0.2);
  color: #E8C547;
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}

.gsd-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.gsd-empty strong { color: var(--text-secondary); }

.gsd-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.gsd-spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 175, 55, 0.2);
  border-top-color: #D4AF37;
  animation: alpSpin 0.55s linear infinite;
  flex-shrink: 0;
}

.gsd-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.04);
  margin: 4px 0;
}

/* Light theme */
[data-theme='light'] .global-search-dropdown {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(212, 175, 55, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(212, 175, 55, 0.1);
}

[data-theme='light'] .gsd-item:hover,
[data-theme='light'] .gsd-item.active {
  background: rgba(212, 175, 55, 0.06);
}

/* ── Header Action Buttons ────────────────────────────────── */
.header-action {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-base);
  cursor: pointer;
}

.header-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-action .notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--color-danger);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-secondary);
}

/* ── Danger Bell ──────────────────────────────────────────── */
.header-danger-wrap { position: relative; }

.header-action-danger { color: var(--color-danger); }
.header-action-danger:hover { background: rgba(239, 68, 68, 0.12); color: var(--color-danger-hover); }

.header-action-danger.has-danger {
  color: #fff;
  background: var(--color-danger);
  animation: dangerPulse 1.6s ease-in-out infinite;
  transform-origin: center;
  will-change: transform, box-shadow;
}
.header-action-danger.has-danger:hover { background: var(--color-danger-hover); }

/* Two-part pulse so it reads on both themes:
   1. A scale bump on the button itself — visible against ANY background.
   2. A red ring that expands + fades — carries the "alert" language.
   3. A soft warm glow at peak — brightens the red edge so it doesn't
      disappear into a dark header. */
@keyframes dangerPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 0 0   rgba(239, 68, 68, 0.65),
      0 0 0 0   rgba(255, 170, 170, 0);
  }
  50% {
    transform: scale(1.07);
    box-shadow:
      0 0 0 8px rgba(239, 68, 68, 0),
      0 0 14px 3px rgba(255, 170, 170, 0.42);
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-action-danger.has-danger {
    animation: none;
    transform: none;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5);
  }
}

/* ─── Notification bell dropdown ─────────────────────────────────────────── */
.notif-count-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-primary);
  line-height: 1;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-height: 460px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 0 0 3px rgba(56, 189, 248, 0.06);
  z-index: 1000;
  padding: 8px 0;
}
.notif-dd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border-color);
}
.notif-dd-title {
  font-size: 12px; font-weight: 800; color: var(--text-primary);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.notif-dd-mark-all {
  background: transparent; border: none; cursor: pointer;
  font-size: 11px; color: var(--accent-primary);
  padding: 4px 8px; border-radius: 6px; font-family: inherit;
}
.notif-dd-mark-all:hover { background: rgba(212,175,55,.10); color: var(--accent-primary-hover); }
.notif-dd-list { padding: 4px 0; }
.notif-dd-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px;
  border-left: 3px solid transparent;
  transition: background .12s;
  cursor: pointer;
  position: relative;
}
.notif-dd-item:hover { background: rgba(255,255,255,.03); }
.notif-dd-item-read { opacity: 0.55; }
.notif-dd-item-read:hover { opacity: 0.85; }
.notif-dd-icon {
  flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.notif-dd-body { flex: 1; min-width: 0; }
.notif-dd-title-row {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.notif-dd-msg-title { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.notif-dd-time { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.notif-dd-msg {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 2px; line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.notif-dd-dismiss {
  align-self: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1;
  padding: 4px 8px; border-radius: 6px; font-family: inherit;
}
.notif-dd-dismiss:hover { color: var(--color-danger); background: rgba(239,68,68,.10); }
.notif-dd-empty {
  padding: 32px 20px; text-align: center;
  color: var(--text-tertiary); font-size: 13px;
}
.notif-dd-empty-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(34,197,94,.12); color: #22c55e;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 10px;
}

/* Light-mode variant */
[data-theme='light'] .notif-dropdown {
  background: var(--bg-elevated);
  border-color: var(--border-primary);
  box-shadow: var(--shadow-lg);
}
[data-theme='light'] .notif-dd-item:hover { background: var(--bg-hover); }

.danger-count-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--color-danger);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-danger);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.danger-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 0 0 3px rgba(239, 68, 68, 0.06);
  z-index: 1000;
  padding: 8px 0;
}

.danger-dd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border-color);
}
.danger-dd-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--color-danger);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.danger-dd-viewall {
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
}
.danger-dd-viewall:hover { color: var(--text-primary); }

.danger-dd-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px 6px;
}

.danger-dd-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 14px;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-base);
}
.danger-dd-item:hover { background: rgba(239, 68, 68, 0.08); }

.danger-dd-remove-btn {
  flex: 0 0 auto;
  align-self: center;
  padding: 4px 9px;
  background: rgba(239, 68, 68, 0.14);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
  white-space: nowrap;
}
.danger-dd-remove-btn:hover  { background: var(--color-danger); color: #fff; }
.danger-dd-remove-btn:active { transform: scale(0.96); }
.danger-dd-remove-btn:disabled { opacity: 0.5; cursor: wait; }

.danger-dd-item-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  background: var(--color-danger);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}
.danger-dd-item-body { min-width: 0; flex: 1; }
.danger-dd-item-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.danger-dd-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-dd-more {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px 14px 4px;
  font-style: italic;
}

.danger-dd-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}
.danger-dd-empty-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.14);
  color: #10b981;
  font-size: 18px;
  font-weight: 800;
}

/* ── Notification / Threat dropdowns — mobile ─────────────── */
@media (max-width: 640px) {
  .notif-dropdown,
  .danger-dropdown {
    position: fixed;
    top: calc(var(--header-height, 64px) + 6px);
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - var(--header-height, 64px) - 20px);
  }
  .danger-dd-item-title,
  .danger-dd-item-meta {
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: clip;
  }
  .danger-dd-remove-btn { align-self: flex-start; margin-top: 2px; }
  .notif-dd-msg-title  { word-break: break-word; }
  .notif-dd-msg        { -webkit-line-clamp: 3; }
}

/* ── Theme Toggle ─────────────────────────────────────────── */
.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-base);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--color-warning);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  transition: transform var(--duration-normal) var(--ease-spring), opacity var(--duration-fast);
}

[data-theme='light'] .theme-toggle .icon-moon { display: none; }
[data-theme='light'] .theme-toggle .icon-sun  { display: block; }
:root .theme-toggle .icon-sun  { display: none; }
:root .theme-toggle .icon-moon { display: block; }

/* ── Header User Profile ─────────────────────────────────── */
.header-user {
  position: relative;              /* anchor the profile dropdown */
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-base);
  border-left: 1px solid var(--border-primary);
  padding-left: var(--space-4);
  margin-left: var(--space-2);
}

.header-user:hover {
  background: var(--bg-hover);
}

.header-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: #ffffff;
  flex-shrink: 0;
  transition: box-shadow var(--transition-base);
}

.header-user:hover .header-user-avatar {
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--accent-primary);
}

.header-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.header-user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
  line-height: 1.2;
  margin-top: 2px;
}

/* ── Role Badges ──────────────────────────────────────────── */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  line-height: 1.6;
  white-space: nowrap;
  flex-shrink: 0;
}

.role-badge-god {
  background: linear-gradient(135deg, rgba(212,175,55,0.18), rgba(212,175,55,0.08));
  color: #D4AF37;
  border: 1px solid rgba(212,175,55,0.45);
  box-shadow: 0 0 8px rgba(212,175,55,0.25), inset 0 0 6px rgba(212,175,55,0.08);
  text-shadow: 0 0 6px rgba(212,175,55,0.6);
}

.role-badge-super-admin {
  background: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(139,92,246,0.08));
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,0.4);
  box-shadow: 0 0 6px rgba(139,92,246,0.18);
}

.sidebar-role-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.sidebar-role-pill-god {
  background: linear-gradient(135deg, var(--accent-primary-muted), var(--accent-primary-ring));
  border: 1px solid var(--accent-primary-ring);
  color: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-primary-muted);
}

.sidebar-role-pill-super-admin {
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(139,92,246,0.05));
  border: 1px solid rgba(139,92,246,0.3);
  color: #a78bfa;
}
[data-theme='light'] .sidebar-role-pill-super-admin { color: #6d28d9; }

.sidebar-role-pill-admin {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
}

/* ── Header Profile Menu ──────────────────────────────────── */
.header-profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  max-width: 92vw;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(212, 175, 55, 0.06);
  z-index: 1200;
  padding: 6px 0;
  overflow: hidden;
}
.header-profile-menu-inner { display: flex; flex-direction: column; }
.hpm-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: 4px;
}
.hpm-header-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.hpm-username {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hpm-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hpm-scope { color: var(--accent-primary); font-weight: 600; }
.hpm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  width: 100%;
}
.hpm-item:hover { background: var(--bg-hover); }
.hpm-item svg { flex-shrink: 0; color: var(--text-secondary); }
.hpm-item:hover svg { color: var(--accent-primary); }
.hpm-item-danger { color: var(--color-danger); }
.hpm-item-danger svg { color: var(--color-danger); }
.hpm-item-danger:hover { background: var(--color-danger-muted); }
.hpm-item-danger:hover svg { color: var(--color-danger); }
.hpm-divider {
  height: 1px;
  background: var(--border-primary);
  margin: 4px 0;
}

.header-logout-btn {
  color: var(--text-muted);
  transition: color var(--transition-fast), background var(--transition-base);
}

.header-logout-btn:hover {
  color: var(--color-danger);
  background: var(--color-danger-muted);
}

/* ── Page Content ─────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: var(--page-padding);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ── Page Header (inside page-content) ────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page-header-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.page-header-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Mobile Menu Icon Button ────────────────────────── */
.mobile-menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.3);
  color: #D4AF37;
  transform: scale(1.04);
}

.mobile-menu-btn.active {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ── Mobile Overlay ───────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  opacity: 1;
}

/* ── Responsive: Fluid sidebar + header ───────────────────── */

/* Slightly narrower sidebar between ~1180–1400px so the content column
   doesn't feel squeezed as the window shrinks. Pure width change — no
   layout mode switch, so labels stay visible. */
@media (max-width: 1400px) and (min-width: 1181px) {
  :root { --sidebar-width: 232px; }
}

/* Intermediate widths: collapse the sidebar into a 72px icon rail.
   Kicks in below 1180px (where labels start to eat too much space) and
   stays until the off-canvas breakpoint at 768px. */
@media (max-width: 1180px) and (min-width: 769px) {
  :root { --sidebar-width: 72px; }

  /* Sidebar shows icons only. Hide every text label by zeroing the
     font-size on the item container, then restore it on the icon and
     badge children so their sizing rules still apply. */
  .sidebar-nav-item {
    justify-content: center;
    font-size: 0;
    padding: 10px 0;
    gap: 0;
  }
  .sidebar-nav-item:hover { transform: none; }
  .sidebar-nav-item i,
  .sidebar-nav-item .nav-icon {
    font-size: var(--text-md);
    margin: 0;
  }
  .sidebar-nav-item .nav-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
  }
  .sidebar-nav-item.active::before { height: 16px; }

  /* Sub-items lose their indent so the icon lines up with parents. */
  .sidebar-nav-sub { padding-left: 0; }
  .sidebar-nav-sub .nav-icon { width: 16px; height: 16px; }

  /* Hide section labels + logo text + wordmark link. */
  .sidebar-nav-label,
  .sidebar-logo-text,
  .sidebar-logo a { display: none !important; }
  .sidebar-logo {
    justify-content: center !important;
    padding: 0 !important;
    gap: 0 !important;
  }
  .sidebar-logo > div:last-child { display: none; }

  /* User row → avatar only, centered. */
  .sidebar-user-info,
  .sidebar-user-menu-btn { display: none; }
  .sidebar-user {
    justify-content: center;
    padding: 6px;
    gap: 0;
  }

  /* Role pill collapses to just its icon slot. */
  .sidebar-role-pill {
    justify-content: center;
    padding: 6px;
    font-size: 0;
  }
  .sidebar-role-pill > svg,
  .sidebar-role-pill > i { font-size: var(--text-md); }

  .sidebar-footer { padding: var(--space-2); }
}

/* Header progressively drops space-hungry pieces before it can overflow. */
@media (max-width: 1300px) {
  .header-search { width: 220px; }
  .header-search-shortcut { display: none; }
}
@media (max-width: 1180px) {
  .header-subtitle,
  .connection-indicator { display: none; }
  .header-search { width: 180px; }
  .header-user-info { display: none; }        /* avatar-only earlier than before */
  .header-user {
    padding-left: var(--space-2);
    margin-left: 0;
    border-left: none;
  }
}
@media (max-width: 960px) {
  .header-search { width: 140px; }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 260px;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    grid-column: 1;
    width: 100%;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .mobile-overlay {
    display: block;
    pointer-events: none;
  }

  .mobile-overlay.active {
    pointer-events: auto;
  }

  /* Hide the standalone logout icon on phones — sign-out lives in the
     profile menu (with confirm) so this rail button is redundant here. */
  .header-logout-btn {
    display: none !important;
  }

  /* Hide the standalone settings gear on phones — the profile menu already
     surfaces "Account settings", so the rail icon is redundant on mobile
     where header space is tight. */
  #header-settings-btn {
    display: none !important;
  }

  .header {
    padding: 0 12px;
    gap: 8px;
  }

  .header-left {
    gap: 8px;
  }

  .header-title {
    font-size: 15px;
  }

  .header-search {
    display: none;
  }

  .header-subtitle {
    display: none;
  }

  .header-user-info {
    display: none;
  }

  .connection-indicator {
    display: none;
  }

  .page-content {
    padding: var(--page-padding-mobile);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .header-telegram-badge {
    display: none !important;
  }

  .page-header-title {
    font-size: var(--text-xl);
  }

  .header-user-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
}

