/* layout */
/* Hide shell until auth session is confirmed (avoids guest flash). */
body:not(.has-auth) .app-layout,
body:not(.has-auth) .sidebar-backdrop {
  visibility: hidden;
  pointer-events: none;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-backdrop {
  display: none;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.sidebar-close-btn {
  display: none;
}

.brand-icon {
  font-size: 28px;
}

.brand-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.badge-server {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-soft-md);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 2px;
}

.nav-menu {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--surface-tint);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary-soft-md);
  color: var(--primary);
  font-weight: 600;
}

body:not(.is-admin) .nav-item[data-admin-only="true"] {
  display: none !important;
}

body:not(.is-admin) .nav-group:not(:has(.nav-item:not([data-admin-only="true"]))) {
  display: none;
}

.brand-mark svg,
.preloader-brand .brand-mark svg,
.btn-icon.icon-svg,
.btn .icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 var(--primary-soft-hot); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px transparent; }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 transparent; }
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--topbar-bg);
  backdrop-filter: blur(10px);
  gap: 12px 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 100%;
}

.menu-toggle-btn {
  display: none;
}

.topbar h1 {
  font-size: 1.4rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-container {
  padding: 32px;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Stacked cards in a tab (audit + logs, players sections, settings…) */
.tab-pane > .card + .card {
  margin-top: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  align-items: stretch;
}

.stats-grid.finance-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  min-width: 0;
  height: 100%;
  min-height: 96px;
}

.stat-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.stat-card-clickable:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.stat-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.icon-users { background: rgba(59, 130, 246, 0.15); }
.icon-logs { background: rgba(107, 155, 209, 0.15); }
.icon-money { background: var(--primary-soft-md); }
.icon-items { background: rgba(245, 158, 11, 0.15); }

.stat-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.25;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  line-height: 1.2;
  word-break: break-word;
}

.stat-card-tx {
  align-items: flex-start;
}

.stat-card-tx .stat-icon {
  margin-top: 2px;
}

.stat-tx-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.stat-tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.stat-tx-row .tx-badge-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-tx-row .tx-val {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.stat-tx-row .tx-bought-val {
  color: var(--primary);
}

.stat-tx-row .tx-sold-val {
  color: var(--accent-amber);
}

.stat-tx-row.tx-sum-row {
  margin-top: 2px;
  padding-top: 3px;
  border-top: 1px dashed var(--border-strong);
}

.stat-tx-row .tx-sum-val {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.dashboard-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 4px;
  align-items: stretch;
  justify-items: stretch;
}

.dashboard-panels > .card {
  min-width: 0;
  min-height: 300px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.dashboard-panels > .card > .card-header {
  flex: 0 0 auto;
}

.dashboard-panels > .card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.dashboard-panels .series-chart {
  flex: 1 1 auto;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.dashboard-panels .series-chart-inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-panels .series-bars-row {
  flex: 1 1 auto;
  align-items: flex-end !important;
  min-height: 140px;
}

.dashboard-panels .recent-list,
.dashboard-panels #topItemsList,
.dashboard-panels #topPlayersList {
  flex: 1 1 auto;
  min-height: 180px;
  overflow: auto;
}

.dashboard-panels-secondary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1200px) {
  .dashboard-panels-secondary {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .stats-grid,
  .stats-grid.finance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .dashboard-panels {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .dashboard-panels > .card {
    min-height: 240px;
  }
}

@media (max-width: 560px) {
  .stats-grid,
  .stats-grid.finance-grid {
    grid-template-columns: 1fr;
  }
}

