/* ------------------------------------------------------------------------
   Generic cards / layouts
   ------------------------------------------------------------------------ */

.card, .panel, .role-card, .stat-card, .toolbar-card, .table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.card { border-radius: var(--radius-lg); padding: var(--space-6); display: grid; gap: var(--space-3); }
.card span { color: var(--muted); line-height: 1.6; }
.card-header, .panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.panel { border-radius: var(--radius-lg); padding: var(--space-6); }
.panel-header { margin-bottom: var(--space-5); }
.panel-header h2 { margin: 5px 0 0; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.list { display: grid; gap: var(--space-3); }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }

/* ------------------------------------------------------------------------
   Admin shell
   ------------------------------------------------------------------------ */

.admin-body { background: var(--bg); color: var(--text); }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.admin-main { min-width: 0; min-height: 100vh; background: var(--bg); }

/* Sidebar foundation — navigation grouping/toggle behavior is UI-2. */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: 20px 14px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  color: #fff;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; border-bottom: 1px solid var(--sidebar-line); }
.sidebar-brand strong { display: block; color: #fff; font-size: 14px; }
.sidebar-brand small { display: block; margin-top: 3px; color: #8e9aae; font-size: 12px; }
.brand-mark { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; background: #fff; color: #0e1626; font-weight: 900; }
.tenant-logo { object-fit: contain; background: #fff; border-radius: 8px; }
.tenant-logo-small { width: 34px; height: 34px; }
.tenant-logo-auth { width: 64px; height: 64px; margin: 0 auto 12px; display: block; }
.tenant-logo-sidebar { width: 36px; height: 36px; flex: 0 0 36px; }
.sidebar-nav, .sidebar-bottom { display: grid; gap: 4px; }
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sidebar-line); }
.sidebar-link {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.sidebar-link:hover { background: var(--sidebar-surface); color: #fff; border-left-color: #33415a; }
.sidebar-link.active { background: var(--sidebar-surface); color: var(--sidebar-text-active); border-left-color: var(--tenant-secondary, #60a5fa); }
.nav-icon { width: 20px; flex: 0 0 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; opacity: .75; }
.sidebar-link:hover .nav-icon, .sidebar-link.active .nav-icon { opacity: 1; }
.sidebar-button { font-weight: 600; }
.sidebar-button[data-logout] { color: #fca5a5; }
.sidebar-button[data-logout]:hover { background: #3a1717; color: #fecaca; }

/* ------------------------------------------------------------------------
   Topbar / page header
   ------------------------------------------------------------------------ */

.admin-topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: 20px 32px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left h1 { margin: 4px 0 0; font-size: 28px; letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.avatar-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--tenant-primary, #2563eb); color: #fff; font-weight: 800; cursor: pointer; }
.mobile-menu { display: none; }
.notification-bell { position: relative; min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--text); text-decoration: none; }
.notification-bell:hover { background: var(--surface-2); }
.notification-bell span { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; }
.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  padding: 24px 32px 22px;
}
.page-intro .muted { max-width: 760px; margin: 0; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); padding: 24px 32px; }
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); margin-bottom: 24px; }
.admin-header h1 { margin: 5px 0; }

/* ------------------------------------------------------------------------
   Dashboard / stats
   ------------------------------------------------------------------------ */

.stat-grid, .stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 0 32px 24px; }
.stat-card {
  min-width: 0;
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(16,24,40,.09); border-color: var(--line-strong); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-card strong { display: block; color: var(--text-strong); font-size: 24px; line-height: 1.1; letter-spacing: -.03em; }
.stat-icon { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 11px; background: var(--info-bg); color: var(--primary-2); font-weight: 800; }
.stat-grid .stat-card:nth-child(8n+1) .stat-icon { background: #e9effa; color: #2457a5; }
.stat-grid .stat-card:nth-child(8n+2) .stat-icon { background: #e8f7ef; color: #087443; }
.stat-grid .stat-card:nth-child(8n+3) .stat-icon { background: #fff6dc; color: #9a6700; }
.stat-grid .stat-card:nth-child(8n+4) .stat-icon { background: #f3e8fd; color: #7c3aed; }
.stat-grid .stat-card:nth-child(8n+5) .stat-icon { background: #feeceb; color: #b42318; }
.stat-grid .stat-card:nth-child(8n+6) .stat-icon { background: #e0f6fb; color: #0e7490; }
.stat-grid .stat-card:nth-child(8n+7) .stat-icon { background: #eef4ff; color: #1d4ed8; }
.stat-grid .stat-card:nth-child(8n+8) .stat-icon { background: #fdf0f8; color: #a3175f; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 16px; padding: 0 32px 32px; }
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick-card { min-height: 118px; display: grid; align-content: start; gap: 7px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none; transition: border-color var(--transition), transform var(--transition), background var(--transition); }
.quick-card:hover { border-color: #9eb6db; background: var(--surface); transform: translateY(-1px); }
.quick-card strong { color: var(--text-strong); }
.quick-card span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.feature-list { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.9; }
.feature-list code { color: var(--text); font-size: 12px; }

/* ------------------------------------------------------------------------
