/* Cyber HQ shell — sidebar + header + main + right rail + footer */

.ttm-hq {
  overflow-x: hidden;
}

.hq-shell {
  display: grid;
  grid-template-columns: min(236px, 22vw) minmax(0, 1fr);
  min-height: 100dvh;
}

/* Minimal pages (e.g. admin login) — no sidebar; use full width */
.ttm-hq--minimal .hq-shell {
  grid-template-columns: minmax(0, 1fr);
}

.hq-main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}

/* ── Sidebar ── */
.hq-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--s2) var(--s1);
  padding-top: max(var(--s2), env(safe-area-inset-top));
  padding-left: max(var(--s1), env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(17, 14, 28, 0.98) 0%, rgba(11, 11, 26, 0.99) 100%);
  border-right: 1px solid var(--ttm-border);
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.35);
  z-index: 120;
  overflow: hidden;
}

.hq-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: var(--s1) var(--s2);
  margin-bottom: var(--s2);
  text-decoration: none;
  color: var(--ttm-text);
}

.hq-sidebar__brand-name {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.hq-sidebar__brand-tag {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--ttm-cyan);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hq-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.hq-sidebar__section {
  margin-bottom: var(--s2);
}

.hq-sidebar__section-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ttm-text-tertiary);
  padding: var(--s1) var(--s2) 6px;
}

.hq-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--ttm-radius);
  font-size: var(--font-body-size, 0.9375rem);
  font-weight: 500;
  color: var(--ttm-text-secondary);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  min-height: 42px;
}

.hq-sidebar__link i {
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.85;
}

.hq-sidebar__link:hover {
  color: var(--ttm-text);
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--ttm-border-subtle);
}

.hq-sidebar__link.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(99, 102, 241, 0.15));
  border-color: var(--ttm-border);
  box-shadow: var(--ttm-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hq-sidebar__link--danger {
  color: #fca5a5 !important;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.2);
}

.hq-sidebar__status {
  padding: var(--s2);
  border-radius: var(--ttm-radius);
  border: 1px solid var(--ttm-border-subtle);
  background: var(--ttm-surface-2);
  font-size: var(--font-caption-size, 0.8125rem);
}

.hq-sidebar__footer {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding-top: var(--s1);
  border-top: 1px solid var(--ttm-border-subtle);
}

.hq-sidebar__status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s1);
  padding: 4px 0;
  color: var(--ttm-text-tertiary);
}

.hq-sidebar__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ttm-success);
  box-shadow: 0 0 8px var(--ttm-success);
}

.hq-sidebar-toggle {
  display: none;
}

.hq-sidebar-backdrop {
  display: none;
}

/* ── Header ── */
.hq-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.hq-header__title-block {
  min-width: 0;
}

.hq-header__title {
  font-size: var(--font-display-size, 1.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ttm-text);
  line-height: 1.25;
}

.hq-header {
  position: sticky;
  top: 0;
  z-index: 110;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  padding-top: max(var(--s2), env(safe-area-inset-top));
  background: rgba(11, 11, 26, 0.92);
  border-bottom: 1px solid var(--ttm-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hq-header__subtitle {
  font-size: var(--font-caption-size, 0.8125rem);
  color: var(--ttm-text-tertiary);
  margin-top: 2px;
}

.hq-header__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1);
}

.hq-stat {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: var(--s1) var(--s2);
  border: 1px solid var(--ttm-border-subtle);
  border-radius: var(--ttm-radius);
  background: var(--ttm-surface-2);
  font-size: var(--font-caption);
}

.hq-stat__label {
  color: var(--ttm-text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}

.hq-stat__value {
  color: var(--ttm-text);
  font-weight: 700;
}

.hq-stat--cyan .hq-stat__value {
  color: var(--ttm-cyan);
}

.hq-stat--gold {
  border-color: var(--ttm-gold-border);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(139, 92, 246, 0.08));
}

.hq-stat--gold .hq-stat__value {
  color: var(--ttm-gold);
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.35);
}

.hq-stat--online .hq-stat__value {
  color: var(--ttm-success);
}

/* ── Body grid ── */
.hq-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-height: 0;
}

.hq-body--with-rail {
  grid-template-columns: minmax(0, 1fr) min(320px, 30vw);
}

.hq-content {
  padding: clamp(14px, 2.5vw, 24px) clamp(12px, 2.5vw, 24px) clamp(20px, 3vw, 32px);
  padding-left: max(clamp(12px, 2.5vw, 24px), env(safe-area-inset-left));
  padding-right: max(clamp(12px, 2.5vw, 24px), env(safe-area-inset-right));
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.hq-right-rail {
  padding: var(--s3) var(--s2);
  border-left: 1px solid var(--ttm-border-subtle);
  background: rgba(17, 14, 28, 0.5);
  overflow-y: auto;
}

/* ── Footer ── */
.hq-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  padding-bottom: max(var(--s1), env(safe-area-inset-bottom));
  border-top: 1px solid var(--ttm-border-subtle);
  background: rgba(6, 4, 12, 0.95);
  font-size: var(--font-caption);
  color: var(--ttm-text-tertiary);
}

.hq-footer__ticker {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.hq-footer__ticker-inner {
  display: inline-block;
  animation: hq-ticker 40s linear infinite;
}

.hq-footer__ticker-inner span {
  padding-right: 48px;
}

@keyframes hq-ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.hq-footer__clock,
.hq-footer__countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--ttm-border-subtle);
  background: var(--ttm-surface-2);
  white-space: nowrap;
}

.hq-footer__countdown strong {
  color: var(--ttm-cyan);
}

/* ── Mobile drawer ── */
@media (max-width: 1023px) {
  .hq-shell {
    grid-template-columns: 1fr;
  }

  .hq-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 92vw);
    transform: translate3d(-110%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
  }

  .ttm-hq.nav-open .hq-sidebar {
    transform: translate3d(0, 0, 0);
  }

  .hq-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s, visibility 0.25s;
  }

  .ttm-hq.nav-open .hq-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .hq-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--ttm-border-subtle);
    border-radius: var(--ttm-radius);
    background: var(--ttm-surface-2);
    color: var(--ttm-text);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .hq-body--with-rail {
    grid-template-columns: 1fr;
  }

  .hq-right-rail {
    border-left: none;
    border-top: 1px solid var(--ttm-border-subtle);
  }

  .ttm-hq.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .hq-header__stats {
    width: 100%;
  }

  .hq-stat {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .hq-footer {
    flex-direction: column;
    align-items: stretch;
  }
}
