.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 26px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header .brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  color: var(--text);
}

.sidebar-header .brand-tag {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--primary);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}

.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.nav-item:not(.active):not(.disabled):hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.disabled {
  cursor: default;
  opacity: 0.55;
}

.nav-item .soon-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--border);
  color: var(--muted);
  padding: 3px 7px;
  border-radius: 999px;
}

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

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}

.logout-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke-width: 2;
  transition: transform var(--transition);
}

.logout-btn:hover:not(:disabled) {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(214, 51, 90, 0.12);
}

.logout-btn:hover:not(:disabled) svg { transform: translateX(2px); }

.logout-btn:active:not(:disabled) { transform: scale(0.98); }

.logout-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Main area ---------- */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-header h1 {
  font-size: 18px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 8px;
  color: var(--text);
}

.menu-toggle:hover { background: var(--surface); }

.account-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.account-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.account-role {
  font-size: 13px;
  font-weight: 700;
}

.account-email {
  font-size: 12px;
  color: var(--muted);
}

.admin-content {
  flex: 1;
  padding: 32px 28px 48px;
}

.content-loading,
.content-body { display: none; }
.content-body.visible { display: block; }

.content-loading.visible {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  padding-top: 40px;
  justify-content: center;
}

.welcome-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-soft);
  max-width: 640px;
}

.welcome-card h2 { font-size: 22px; margin-bottom: 8px; }
.welcome-card p { color: var(--muted); font-size: 14.5px; margin-bottom: 4px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--success);
  background: #E9F8F1;
  padding: 6px 12px;
  border-radius: 999px;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

/* ---------- Overlay for mobile drawer ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23, 21, 31, 0.4);
  z-index: 30;
}

.sidebar-overlay.visible { display: block; }

/* ---------- Auth gate (flash-of-content prevention) ---------- */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  z-index: 100;
  color: var(--muted);
  font-size: 14px;
}

.auth-gate.hidden { display: none; }

/* ==========================================================
   PHASE 2 — Dashboard overview
   ========================================================== */

.dashboard-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.greeting { font-size: 22px; margin-bottom: 4px; }
.greeting-sub { color: var(--muted); font-size: 14.5px; }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ---- Stat cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  opacity: 0.85;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-icon svg { width: 19px; height: 19px; }

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.stat-context {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.stat-context-muted {
  color: #A79FBE;
  font-style: italic;
}

/* ---- Skeleton loading ---- */
.stats-skeleton-grid { display: none; }
.stats-skeleton-grid.visible { display: grid; }

.skeleton-card { display: flex; flex-direction: column; gap: 10px; }

.sk-line {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, #F3F0FA 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.sk-icon { width: 38px; height: 38px; border-radius: 10px; }
.sk-label { width: 60%; height: 12px; }
.sk-value { width: 40%; height: 26px; margin-top: 4px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Dashboard error state ---- */
.dashboard-error {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 500;
  flex-wrap: wrap;
}

.dashboard-error.visible { display: flex; }
.dashboard-error .btn { margin-left: auto; padding: 9px 16px; font-size: 13.5px; }

/* ---- Lower grid: quick actions, status, activity ---- */
.dashboard-lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.panel-wide { grid-column: 1 / -1; }

.panel-title {
  font-size: 15px;
  margin-bottom: 16px;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}

.quick-action svg { width: 17px; height: 17px; color: var(--primary); flex-shrink: 0; }

.quick-action:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.status-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-row-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.status-dot-up { background: var(--success); }
.status-dot-down { background: var(--danger); }

.activity-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 0 8px;
  color: var(--muted);
  font-size: 13.5px;
}

.activity-empty svg { color: var(--border); }

.activity-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  list-style: none;
}

.activity-item {
  font-size: 13.5px;
  color: var(--text);
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-hover);
  }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .account-text { display: none; }
  .dashboard-lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .stats-grid { grid-template-columns: 1fr; }
  .dashboard-topline { flex-direction: column; align-items: stretch; }
  .dashboard-topline .btn { align-self: flex-start; }
}

@media (max-width: 520px) {
  .admin-header { padding: 0 16px; }
  .admin-content { padding: 22px 16px 40px; }
  .welcome-card { padding: 24px; }
  .panel { padding: 18px; }
}