/* =========================================================================
   Admin Workbench — production redesign.
   Scoped to #admin-dashboard, #add-user-modal, #edit-user-modal.
   Vanilla CSS, no framework. OKLCH neutrals, one restrained accent.
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=Geist:wght@400;450;500;600&family=Geist+Mono:wght@400;500&display=swap");

/* -------------------------------------------------------------------------
   Tokens
   ------------------------------------------------------------------------- */
#admin-dashboard,
#add-user-modal,
#edit-user-modal {
  /* Warm tinted neutrals, hue 80 (cream). Never #000 or #fff. */
  --canvas:        oklch(98%   0.005 80);
  --canvas-2:      oklch(97%   0.006 80);
  --surface:       oklch(100%  0     0);
  --surface-sunk:  oklch(96.4% 0.005 80);
  --surface-tint:  oklch(94.8% 0.006 80);
  --border-faint:  oklch(94%   0.005 80);
  --border:        oklch(90%   0.006 80);
  --border-strong: oklch(82%   0.008 80);

  --ink:           oklch(22%   0.010 80);
  --ink-strong:    oklch(14%   0.010 80);
  --ink-muted:     oklch(48%   0.012 80);
  --ink-subtle:    oklch(64%   0.010 80);
  --ink-faint:     oklch(78%   0.008 80);

  --accent:        oklch(40%   0.14  22);
  --accent-tint:   oklch(96%   0.025 22);
  --accent-ink:    oklch(34%   0.13  22);

  --warning:       oklch(48%   0.14  70);
  --warning-tint:  oklch(96%   0.04  85);
  --warning-ink:   oklch(36%   0.12  70);

  --good:          oklch(48%   0.10 155);
  --good-tint:     oklch(96%   0.025 155);
  --good-ink:      oklch(36%   0.10 155);

  /* Spacing scale — varied, not uniform. */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  32px;
  --s-8:  40px;
  --s-9:  56px;
  --s-10: 72px;

  --r-xs: 3px;
  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;

  --font-serif: "Newsreader", "Iowan Old Style", "Georgia", "Times New Roman", serif;
  --font-sans:  "Geist", "Inter Tight", -apple-system, "Helvetica Neue", system-ui, sans-serif;
  --font-mono:  "Geist Mono", "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Strong ease-out for UI interactions (impeccable). */
  --ease-out:   cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --d-fast:     140ms;
  --d-base:     200ms;
  --d-slow:     300ms;

  --sidebar-w:  248px;
  --topbar-h:   64px;
}

/* -------------------------------------------------------------------------
   When the admin dashboard is shown, the workbench takes the whole
   viewport: hide the auth screen, the outer "Learning Space" header,
   the outer container padding, and the centered-flex body layout.
   ------------------------------------------------------------------------- */
body:has(#admin-dashboard:not(.hidden)) {
  background: var(--canvas) !important;
  display: block !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 !important;
  margin: 0 !important;
}
body:has(#admin-dashboard:not(.hidden)) > .container,
body:has(#admin-dashboard:not(.hidden)) > #app-container {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  width: 100% !important;
}
body:has(#admin-dashboard:not(.hidden)) > .container > #app-container {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
}
body:has(#admin-dashboard:not(.hidden)) #role-selection,
body:has(#admin-dashboard:not(.hidden)) #app-container > header {
  display: none !important;
}

/* -------------------------------------------------------------------------
   Root container
   ------------------------------------------------------------------------- */
#admin-dashboard {
  display: block;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv01", "cv11";
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}
#admin-dashboard *,
#admin-dashboard *::before,
#admin-dashboard *::after {
  box-sizing: border-box;
}

/* Neutralize Tailwind atomic backgrounds/shadows that leak in from leftover
   markup (modals, forms still use Tailwind classes). */
#admin-dashboard [class*="bg-gradient-"] { background-image: none !important; }
#admin-dashboard .shadow,
#admin-dashboard .shadow-sm,
#admin-dashboard .shadow-md,
#admin-dashboard .shadow-lg,
#admin-dashboard .shadow-xl { box-shadow: none !important; }

/* Hidden-by-class still hides. */
#admin-dashboard .hidden { display: none !important; }

/* -------------------------------------------------------------------------
   Shell — sidebar + main grid
   ------------------------------------------------------------------------- */
.adm-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
}

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.adm-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  background: var(--canvas-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Brand block (reuses existing #admin-topbar id) */
.adm-brand {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-5) var(--s-5) var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--canvas-2);
}
.adm-brand__avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.adm-brand__logo {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
}
.adm-brand__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.adm-brand__monogram {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.adm-brand__lines {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.adm-brand__product {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.adm-brand__school {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 1px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-brand__role {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: -0.003em;
  margin-top: 1px;
}
/* When school name is hidden (.hidden), fall back to product-only label. */
.adm-brand:has(.adm-brand__school.hidden) .adm-brand__role {
  display: none;
}

/* Nav */
.adm-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--s-4) var(--s-2) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}
.adm-nav__group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.adm-nav__eyebrow {
  display: block;
  padding: 0 var(--s-3) var(--s-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.adm-nav__item {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: 7px var(--s-3);
  text-align: left;
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 450;
  letter-spacing: -0.003em;
  cursor: pointer;
  transition:
    background-color var(--d-fast) var(--ease-out),
    color var(--d-fast) var(--ease-out),
    transform var(--d-fast) var(--ease-out);
}
.adm-nav__item:hover {
  background: var(--surface-tint);
  color: var(--ink);
}
.adm-nav__item:active {
  transform: scale(0.985);
}
.adm-nav__item.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--border);
}
.adm-nav__item.is-active .adm-nav__bullet {
  background: var(--ink);
}
.adm-nav__bullet {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: background-color var(--d-fast) var(--ease-out);
}
.adm-nav__item:hover .adm-nav__bullet {
  background: var(--ink-muted);
}
.adm-nav__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.adm-nav__count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-subtle);
  background: var(--surface-sunk);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.adm-nav__item.is-active .adm-nav__count {
  background: var(--surface-tint);
  color: var(--ink-muted);
}
.adm-nav__count--warn {
  color: var(--warning-ink);
  background: var(--warning-tint);
}

/* Identity strip */
.adm-identity {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--canvas-2);
}
.adm-identity__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--canvas);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow: hidden;
}
.adm-identity__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.adm-identity__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.adm-identity__name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.003em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-identity__role {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.adm-identity__logout {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background-color var(--d-fast) var(--ease-out),
    color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out),
    transform var(--d-fast) var(--ease-out);
}
.adm-identity__logout:hover {
  background: var(--accent-tint);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.adm-identity__logout:active { transform: scale(0.94); }
.adm-identity__logout i { font-size: 12px; }

/* =========================================================================
   MAIN
   ========================================================================= */
.adm-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--s-8) var(--s-9) var(--s-10);
  max-width: 1640px;
  width: 100%;
}

/* Hooks block is invisible */
.adm-hooks { display: none !important; }
.adm-hooks[hidden] { display: none !important; }

/* View visibility: only the matching view is displayed */
.adm-view { display: none; }
.adm-shell[data-view="people"]    .adm-view[data-adm-view="people"]    { display: block; }
.adm-shell[data-view="insights"]  .adm-view[data-adm-view="insights"]  { display: block; }
.adm-shell[data-view="settings"]  .adm-view[data-adm-view="settings"]  { display: block; }
.adm-shell[data-view="deleted"]   .adm-view[data-adm-view="deleted"]   { display: block; }

/* View animation — exponential ease-out, opacity + 4px translate. */
.adm-view {
  animation: adm-view-in 280ms var(--ease-out);
}
@keyframes adm-view-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* View header */
.adm-view__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s-6);
  padding-bottom: var(--s-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-7);
}
.adm-view__lede { min-width: 0; }
.adm-view__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: var(--s-2);
}
.adm-view__eyebrow--warn { color: var(--warning-ink); }
.adm-view__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: -0.022em;
  color: var(--ink-strong);
  margin: 0 0 6px;
}
.adm-view__sub {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 64ch;
  margin: 0;
}
.adm-view__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* Inline counter (used in deleted-view header) */
.adm-counter {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.adm-counter strong {
  font-weight: 500;
  color: var(--ink);
  margin-right: 4px;
}

/* =========================================================================
   Stats strip — density-mode, three columns separated by hairlines
   ========================================================================= */
.adm-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--s-7);
  overflow: hidden;
}
.adm-stat {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.adm-stat + .adm-stat {
  border-left: 1px solid var(--border);
}
.adm-stat__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.adm-stat__primary {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.022em;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.adm-stat__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-stat__warn { color: var(--warning-ink); font-weight: 500; }

/* =========================================================================
   Tabs
   ========================================================================= */
.adm-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-3);
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: var(--s-3) var(--s-4) var(--s-3);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink-muted);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition:
    color var(--d-fast) var(--ease-out),
    transform var(--d-fast) var(--ease-out);
}
.adm-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: transparent;
  transition: background-color var(--d-base) var(--ease-out);
}
.adm-tab:hover { color: var(--ink); }
.adm-tab.is-active {
  color: var(--ink-strong);
}
.adm-tab.is-active::after {
  background: var(--ink-strong);
}
.adm-tab:active { transform: scale(0.985); }
.adm-tab__count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-subtle);
  background: var(--surface-sunk);
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  min-width: 22px;
  text-align: center;
}
.adm-tab.is-active .adm-tab__count {
  background: var(--ink-strong);
  color: var(--canvas);
}

/* =========================================================================
   Filter row
   ========================================================================= */
.adm-filters {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(3, minmax(140px, 180px)) auto;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.adm-search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition:
    border-color var(--d-fast) var(--ease-out),
    background-color var(--d-fast) var(--ease-out);
}
.adm-search:focus-within {
  border-color: var(--ink-strong);
  background: var(--surface);
}
.adm-search > i {
  position: absolute;
  left: 12px;
  font-size: 12px;
  color: var(--ink-subtle);
  pointer-events: none;
}
.adm-search > input {
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 9px 12px 9px 32px;
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  letter-spacing: -0.003em;
}
.adm-search > input::placeholder { color: var(--ink-subtle); }

.adm-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23667' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink);
  padding: 9px 32px 9px 12px;
  cursor: pointer;
  transition:
    border-color var(--d-fast) var(--ease-out),
    background-color var(--d-fast) var(--ease-out);
}
.adm-select:hover { border-color: var(--border-strong); }
.adm-select:focus {
  outline: 0;
  border-color: var(--ink-strong);
}

/* =========================================================================
   Buttons
   ========================================================================= */
.adm-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 13px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out),
    color var(--d-fast) var(--ease-out),
    transform var(--d-fast) var(--ease-out);
  white-space: nowrap;
}
.adm-btn:hover {
  background: var(--surface-sunk);
  border-color: var(--border-strong);
}
.adm-btn:active { transform: scale(0.97); }
.adm-btn:focus-visible {
  outline: 2px solid var(--ink-strong);
  outline-offset: 2px;
}
.adm-btn > i {
  font-size: 11.5px;
  color: var(--ink-muted);
}
.adm-btn--primary {
  background: var(--ink-strong);
  color: var(--canvas);
  border-color: var(--ink-strong);
}
.adm-btn--primary:hover {
  background: oklch(8% 0.01 80);
  border-color: oklch(8% 0.01 80);
}
.adm-btn--primary > i { color: var(--canvas); opacity: 0.85; }
.adm-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
}
.adm-btn--ghost:hover {
  background: var(--surface-sunk);
  color: var(--ink);
  border-color: var(--border);
}
.adm-btn--danger {
  background: var(--surface);
  border-color: var(--border);
  color: var(--accent-ink);
}
.adm-btn--danger:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.adm-btn--danger > i { color: var(--accent-ink); }

/* Icon-only button */
.adm-iconbtn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  cursor: pointer;
  transition:
    background-color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out),
    transform var(--d-fast) var(--ease-out);
}
.adm-iconbtn:hover {
  background: var(--surface-sunk);
  border-color: var(--border-strong);
  color: var(--ink);
}
.adm-iconbtn:active { transform: scale(0.94); }

/* =========================================================================
   Generic input
   ========================================================================= */
.adm-input {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  transition:
    border-color var(--d-fast) var(--ease-out),
    background-color var(--d-fast) var(--ease-out);
  width: 100%;
}
.adm-input:focus {
  outline: 0;
  border-color: var(--ink-strong);
}
.adm-input::placeholder { color: var(--ink-subtle); }
.adm-input--file {
  padding: 7px 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.adm-check {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.4px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background-color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out);
  position: relative;
  margin: 0;
}
.adm-check:hover { border-color: var(--ink-muted); }
.adm-check:checked {
  background: var(--ink-strong);
  border-color: var(--ink-strong);
}
.adm-check:checked::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 7px;
  border: solid var(--canvas);
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* =========================================================================
   PEOPLE TABLE
   ========================================================================= */
.adm-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

/* Column template — used by both head and rows for perfect alignment.
   Columns: check | avatar | name | user# | email | role | school | actions */
.adm-table {
  --col-check:  32px;
  --col-avatar: 36px;
  --col-id:     90px;
  --col-email:  minmax(180px, 1.3fr);
  --col-role:   100px;
  --col-school: 200px;
  --col-actions: max-content;
}

.adm-table__head,
.adm-row {
  display: grid;
  grid-template-columns:
    var(--col-check)
    var(--col-avatar)
    minmax(140px, 1.4fr)
    var(--col-id)
    var(--col-email)
    var(--col-role)
    var(--col-school)
    var(--col-actions);
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-5);
}

.adm-table__head {
  height: 38px;
  background: var(--canvas-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.adm-th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  display: flex;
  align-items: center;
}
.adm-th--check { justify-content: flex-start; }
.adm-th--avatar { /* empty header above avatar column */ }
.adm-th--actions { justify-content: flex-end; }

.adm-table__body {
  background: var(--surface);
}

.adm-tabgroup { padding: 0; }
.adm-tabgroup__head {
  display: none; /* shown only in "All" tab */
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-5) 6px;
  background: var(--canvas-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border-faint);
}
.adm-tabgroup:first-child .adm-tabgroup__head { border-top: 0; }
.adm-tabgroup__label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.adm-tabgroup__count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-subtle);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* Tab filtering */
.adm-table[data-adm-active-tab="all"]      .adm-tabgroup__head { display: flex; }
.adm-table[data-adm-active-tab="all"]      .adm-tabgroup { display: block; }
.adm-table[data-adm-active-tab="admins"]   .adm-tabgroup:not([data-adm-tab-group="admins"]),
.adm-table[data-adm-active-tab="teachers"] .adm-tabgroup:not([data-adm-tab-group="teachers"]),
.adm-table[data-adm-active-tab="students"] .adm-tabgroup:not([data-adm-tab-group="students"]),
.adm-table[data-adm-active-tab="parents"]  .adm-tabgroup:not([data-adm-tab-group="parents"]) {
  display: none;
}

/* When focused on a single tab, hide that group's mini-header (the parent
   tab already labels it). */
.adm-table[data-adm-active-tab="admins"]   .adm-tabgroup__head,
.adm-table[data-adm-active-tab="teachers"] .adm-tabgroup__head,
.adm-table[data-adm-active-tab="students"] .adm-tabgroup__head,
.adm-table[data-adm-active-tab="parents"]  .adm-tabgroup__head {
  display: none;
}

/* =========================================================================
   ROW — emitted by renderUserList. 8-column grid matching the header.
   ========================================================================= */
.adm-row {
  height: 56px;
  border-top: 1px solid var(--border-faint);
  background: var(--surface);
  position: relative;
  transition: background-color var(--d-fast) var(--ease-out);
}
.adm-row:first-of-type { border-top: 0; }
.adm-tabgroup:not(:first-child) .adm-row:first-of-type { border-top: 0; }
.adm-row:hover {
  background: var(--canvas-2);
}

.adm-row__check {
  display: flex;
  align-items: center;
}
.adm-row__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  overflow: hidden;
  flex-shrink: 0;
}
.adm-row__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.adm-row__name {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-strong);
  letter-spacing: -0.005em;
}
.adm-row__name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.adm-row__id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-row__email {
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: -0.003em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.adm-row__email--empty {
  color: var(--ink-faint);
  font-style: italic;
}
.adm-row__role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--border-faint);
  width: max-content;
}
.adm-row__role[data-role="admin"]   { color: var(--ink-strong); background: var(--surface-tint); border-color: var(--border); }
.adm-row__role[data-role="teacher"] { color: oklch(38% 0.08 240); background: oklch(96% 0.018 240); border-color: oklch(90% 0.02 240); }
.adm-row__role[data-role="student"] { color: oklch(38% 0.08 155); background: var(--good-tint); border-color: oklch(90% 0.02 155); }
.adm-row__role[data-role="parent"]  { color: oklch(40% 0.08 30);  background: oklch(96% 0.018 30);  border-color: oklch(90% 0.02 30); }

.adm-row__school {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
  letter-spacing: -0.003em;
  min-width: 0;
}
.adm-row__school-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  flex-shrink: 0;
}
.adm-row__school-dot--warn {
  background: var(--warning);
}
.adm-row__school-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.adm-row__warning {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warning-ink);
  background: var(--warning-tint);
  border: 1px solid oklch(88% 0.03 70);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Actions — hidden by default, revealed on hover/focus */
.adm-row__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease-out);
}
.adm-row:hover .adm-row__actions,
.adm-row:focus-within .adm-row__actions {
  opacity: 1;
}
@media (hover: none) {
  .adm-row__actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .adm-row__actions { opacity: 1; transition: none; }
}

.adm-row__btn {
  appearance: none;
  font-family: var(--font-sans);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.003em;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out),
    color var(--d-fast) var(--ease-out),
    transform var(--d-fast) var(--ease-out);
}
.adm-row__btn:hover {
  background: var(--surface-sunk);
  border-color: var(--border-strong);
}
.adm-row__btn:active { transform: scale(0.95); }
.adm-row__btn--migrate {
  background: var(--warning-tint);
  border-color: oklch(88% 0.03 70);
  color: var(--warning-ink);
}
.adm-row__btn--migrate:hover {
  background: oklch(94% 0.04 70);
  border-color: var(--warning);
  color: var(--warning-ink);
}
.adm-row__remove,
.adm-row__btn--remove {
  color: var(--accent-ink);
}
.adm-row__remove:hover,
.adm-row__btn--remove:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Empty / loading row */
.adm-empty {
  padding: var(--s-9) var(--s-5);
  text-align: center;
  color: var(--ink-subtle);
  font-size: 13px;
  background: var(--surface);
}

/* Pagination */
.adm-pagination {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border-faint);
  background: var(--canvas-2);
}
.adm-pagination:empty { display: none; }
.adm-pagination .flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.adm-pagination .text-sm,
.adm-pagination .text-gray-600 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-muted) !important;
}
.adm-pagination button {
  appearance: none;
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 5px 10px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  background: var(--surface) !important;
  color: var(--ink) !important;
  cursor: pointer;
  transition: background-color var(--d-fast) var(--ease-out);
}
.adm-pagination button:hover:not(:disabled) {
  background: var(--surface-sunk) !important;
  border-color: var(--border-strong) !important;
}
.adm-pagination button:disabled,
.adm-pagination .opacity-50 {
  opacity: 0.4 !important;
  cursor: not-allowed;
}

/* Show more */
.adm-show-more {
  appearance: none;
  background: transparent;
  border: 0;
  width: 100%;
  padding: var(--s-3) var(--s-5);
  text-align: left;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  border-top: 1px solid var(--border-faint);
  transition: color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}
.adm-show-more:hover {
  color: var(--ink);
  background: var(--canvas-2);
}
.adm-show-more:active { transform: none; }
/* Hide show-more buttons when the rows already fit (default state — JS can show if needed) */
.adm-show-more {
  display: none; /* default hidden — original JS doesn't toggle this; only paginate */
}

/* =========================================================================
   BULK ACTION BAR — appears on selection
   ========================================================================= */
.adm-bulkbar {
  position: sticky;
  bottom: var(--s-5);
  margin-top: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--s-4);
  background: var(--ink-strong);
  color: var(--canvas);
  border: 1px solid var(--ink-strong);
  border-radius: var(--r-md);
  box-shadow:
    0 1px 0 oklch(0% 0 0 / 0.04),
    0 16px 36px oklch(0% 0 0 / 0.12);
  max-width: max-content;
  margin-left: auto;
  margin-right: 0;
  animation: adm-bulkbar-in 280ms var(--ease-out);
}
@keyframes adm-bulkbar-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.adm-bulkbar[hidden] { display: none; }
.adm-bulkbar__count {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.adm-bulkbar__count strong {
  font-weight: 600;
  color: var(--canvas);
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}
.adm-bulkbar__sep {
  width: 1px;
  height: 18px;
  background: oklch(35% 0.01 80);
}
.adm-bulkbar .adm-btn {
  background: transparent;
  border-color: oklch(35% 0.01 80);
  color: var(--canvas);
  font-size: 12.5px;
  padding: 6px 10px;
}
.adm-bulkbar .adm-btn:hover {
  background: oklch(28% 0.01 80);
  border-color: oklch(45% 0.01 80);
}
.adm-bulkbar .adm-btn--danger {
  color: oklch(82% 0.10 22);
  border-color: oklch(35% 0.05 22);
}
.adm-bulkbar .adm-btn--danger:hover {
  background: oklch(28% 0.06 22);
  border-color: oklch(48% 0.13 22);
  color: oklch(92% 0.06 22);
}
.adm-bulkbar .adm-btn > i { color: inherit; }
.adm-bulkbar__clear {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink-faint);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 6px 8px;
  margin-left: 4px;
  text-decoration: underline;
  text-decoration-color: oklch(35% 0.01 80);
  text-underline-offset: 3px;
}
.adm-bulkbar__clear:hover {
  color: var(--canvas);
  text-decoration-color: var(--ink-faint);
}

/* =========================================================================
   SETTINGS VIEW
   ========================================================================= */
.adm-settings {
  display: grid;
  grid-template-columns: minmax(0, 540px);
  gap: var(--s-7);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-7);
  max-width: 720px;
}
.adm-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-bottom: 1px solid var(--border-faint);
  padding-bottom: var(--s-7);
}
.adm-field:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.adm-field__label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-strong);
  letter-spacing: -0.005em;
  margin-bottom: 2px;
}
.adm-field__hint {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 0 0 6px;
}
.adm-field__row {
  display: flex;
  gap: var(--s-2);
  margin-top: 4px;
}
.adm-logo-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--s-5);
  align-items: flex-start;
}
.adm-logo-preview {
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-tint);
  display: grid;
  place-items: center;
  color: var(--ink-subtle);
  font-size: 22px;
  overflow: hidden;
}
.adm-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.adm-logo-row__controls {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-width: 0;
}

/* =========================================================================
   RECENTLY DELETED — deleted row markup emitted by renderDeletedUsers
   ========================================================================= */
.adm-table--deleted {
  --col-avatar: 36px;
  --col-id: 90px;
  --col-role: 100px;
  --col-time: 180px;
  --col-actions: max-content;
}
.adm-table--deleted .adm-table__head,
.adm-table--deleted .adm-row--deleted {
  display: grid;
  grid-template-columns:
    var(--col-avatar)
    minmax(140px, 1.6fr)
    var(--col-id)
    var(--col-role)
    var(--col-time)
    var(--col-actions);
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-5);
}
.adm-row--deleted {
  height: 60px;
  border-top: 1px solid var(--border-faint);
  background: var(--surface);
  transition: background-color var(--d-fast) var(--ease-out);
  position: relative;
}
.adm-row--deleted:first-of-type { border-top: 0; }
.adm-row--deleted:hover { background: var(--canvas-2); }
.adm-row--deleted .adm-row__time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--warning-ink);
  letter-spacing: 0.02em;
}
.adm-row--deleted .adm-row__actions {
  opacity: 1; /* always visible for deleted — they're destructive */
}
.adm-row--deleted .adm-row__btn--restore {
  background: var(--good-tint);
  border-color: oklch(88% 0.04 155);
  color: var(--good-ink);
}
.adm-row--deleted .adm-row__btn--restore:hover {
  background: oklch(94% 0.04 155);
  border-color: var(--good);
}

#admin-deleted-list:empty + .adm-empty,
#admin-deleted-list .adm-empty {
  padding: var(--s-9) var(--s-5);
}

/* =========================================================================
   Legacy users panel + admin-eyebrow (preserved utility classes)
   ========================================================================= */
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-6);
  margin-bottom: var(--s-7);
}
.admin-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin: 0 0 var(--s-2);
}

/* =========================================================================
   MODALS (Add User / Edit User) — kept editorial
   ========================================================================= */
#add-user-modal,
#edit-user-modal {
  background: oklch(18% 0.01 80 / 0.46) !important;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
#add-user-modal > div,
#edit-user-modal > div {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  box-shadow:
    0 1px 0 oklch(0% 0 0 / 0.02),
    0 20px 52px oklch(0% 0 0 / 0.10) !important;
}
#add-user-modal h2,
#edit-user-modal h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.018em;
  color: var(--ink-strong);
}
#add-user-modal *,
#edit-user-modal * { font-family: inherit; }
#add-user-modal input,
#add-user-modal select,
#add-user-modal textarea,
#edit-user-modal input,
#edit-user-modal select,
#edit-user-modal textarea {
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  color: var(--ink) !important;
  padding: 9px 12px !important;
  box-shadow: none !important;
}
#add-user-modal input:focus,
#add-user-modal select:focus,
#add-user-modal textarea:focus,
#edit-user-modal input:focus,
#edit-user-modal select:focus,
#edit-user-modal textarea:focus {
  outline: 0 !important;
  border-color: var(--ink-strong) !important;
}
#add-user-modal label,
#edit-user-modal label {
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: var(--ink-muted) !important;
}
#add-user-modal button[class*="bg-"],
#edit-user-modal button[class*="bg-"] {
  background: var(--surface) !important;
  background-image: none !important;
  color: var(--ink) !important;
  border: 1px solid var(--border) !important;
  padding: 8px 13px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border-radius: var(--r-sm) !important;
  box-shadow: none !important;
}
#add-user-modal button[type="submit"],
#edit-user-modal button[type="submit"] {
  background: var(--ink-strong) !important;
  color: var(--canvas) !important;
  border-color: var(--ink-strong) !important;
}
#add-user-modal button[type="submit"]:hover,
#edit-user-modal button[type="submit"]:hover {
  background: oklch(8% 0.01 80) !important;
}
#add-user-modal button:active,
#edit-user-modal button:active {
  transform: scale(0.97);
}

/* =========================================================================
   RESPONSIVE — keep names + actions readable as viewport narrows
   ========================================================================= */
@media (max-width: 1440px) {
  .adm-table {
    --col-school: 160px;
    --col-email:  minmax(160px, 1.1fr);
  }
}
@media (max-width: 1280px) {
  .adm-table {
    --col-school: 140px;
  }
  .adm-table__head .adm-th--school,
  .adm-row__school { display: none; }
  .adm-table__head,
  .adm-row {
    grid-template-columns:
      var(--col-check)
      var(--col-avatar)
      minmax(140px, 1.4fr)
      var(--col-id)
      var(--col-email)
      var(--col-role)
      var(--col-actions);
  }
  .adm-table--deleted .adm-table__head,
  .adm-table--deleted .adm-row--deleted {
    grid-template-columns:
      var(--col-avatar)
      minmax(140px, 1.6fr)
      var(--col-id)
      var(--col-role)
      var(--col-time)
      var(--col-actions);
  }
}
@media (max-width: 1024px) {
  .adm-table__head .adm-th--email,
  .adm-row__email { display: none; }
  .adm-table__head,
  .adm-row {
    grid-template-columns:
      var(--col-check)
      var(--col-avatar)
      minmax(140px, 1.6fr)
      var(--col-id)
      var(--col-role)
      var(--col-actions);
  }
  .adm-main {
    padding: var(--s-6) var(--s-6) var(--s-9);
  }
  .adm-stats { grid-template-columns: 1fr; }
  .adm-stat + .adm-stat {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}
@media (max-width: 880px) {
  .adm-shell {
    grid-template-columns: 1fr;
  }
  .adm-sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .adm-nav { padding: var(--s-3) var(--s-2); }
  .adm-nav__group { gap: 0; }
  .adm-nav__group + .adm-nav__group { margin-top: var(--s-3); }
  .adm-main {
    padding: var(--s-5) var(--s-5) var(--s-8);
  }
  .adm-filters {
    grid-template-columns: 1fr 1fr;
  }
  .adm-filters .adm-search { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .adm-view__head {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .adm-view__actions { justify-content: flex-end; }
  .adm-view__title { font-size: 26px; }
  .adm-table__head .adm-th--id,
  .adm-row__id { display: none; }
  .adm-table__head,
  .adm-row {
    grid-template-columns:
      var(--col-check)
      var(--col-avatar)
      minmax(0, 1fr)
      var(--col-role)
      var(--col-actions);
  }
  .adm-logo-row { grid-template-columns: 1fr; }
}

/* =========================================================================
   REDUCED MOTION
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  #admin-dashboard *,
  #admin-dashboard *::before,
  #admin-dashboard *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
  .adm-view { animation: none; }
  .adm-bulkbar { animation: none; }
}

/* =========================================================================
   LEGACY-PANEL COMPATIBILITY — the loadLegacyUsers() renderer still emits
   .admin-row markup. Give it a minimal horizontal layout so the legacy
   panel reads cleanly when shown.
   ========================================================================= */
#legacy-users-list .admin-row {
  display: grid;
  grid-template-columns: 0 36px 1fr auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border-faint);
  background: var(--surface);
}
#legacy-users-list .admin-row:first-of-type { border-top: 0; }
#legacy-users-list .admin-row__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: uppercase;
}
#legacy-users-list .admin-row__body { min-width: 0; }
#legacy-users-list .admin-row__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-strong);
  letter-spacing: -0.005em;
}
#legacy-users-list .admin-row__meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
#legacy-users-list .admin-row__warning {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warning-ink);
  background: var(--warning-tint);
  border: 1px solid oklch(88% 0.03 70);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
}
#legacy-users-list .admin-row__actions { display: flex; gap: 4px; }
#legacy-users-list .admin-row__btn {
  appearance: none;
  font-family: var(--font-sans);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out);
}
#legacy-users-list .admin-row__btn:hover {
  background: var(--surface-sunk);
  border-color: var(--border-strong);
}
#legacy-users-list .admin-row__btn--migrate {
  background: var(--warning-tint);
  border-color: oklch(88% 0.03 70);
  color: var(--warning-ink);
}
#legacy-users-list .admin-row__btn--migrate:hover {
  background: oklch(94% 0.04 70);
  border-color: var(--warning);
}

/* =========================================================================
   SCROLLBARS — quiet
   ========================================================================= */
#admin-dashboard *::-webkit-scrollbar { width: 10px; height: 10px; }
#admin-dashboard *::-webkit-scrollbar-track { background: transparent; }
#admin-dashboard *::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--canvas);
  border-radius: 999px;
}
#admin-dashboard *::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
}

/* =========================================================================
   INSIGHTS VIEW — live data graphs, health, activity
   ========================================================================= */

/* Live-pulse dot used in the view eyebrow + nav. */
.adm-live-dot,
.adm-nav__dot--live {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--good);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--good) 60%, transparent);
  animation: adm-pulse 1.8s var(--ease-in-out) infinite;
  vertical-align: middle;
}
.adm-live-dot { margin-right: 6px; }
.adm-nav__dot--live {
  margin-left: auto;
  align-self: center;
}
@keyframes adm-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklch, var(--good) 55%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in oklch, var(--good) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--good) 0%, transparent); }
}

/* "Live · auto-refresh" counter pill in the view header. */
#adm-insights-updated { display: inline-flex; align-items: center; gap: 6px; }
#adm-insights-updated strong { color: var(--good-ink); position: relative; padding-left: 12px; }
#adm-insights-updated strong::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--good);
  animation: adm-pulse 1.8s var(--ease-in-out) infinite;
}

/* -------------------------------------------------------------------------
   Health strip — 3-column hairline grid matching .adm-stats
   ------------------------------------------------------------------------- */
.adm-health {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--s-7);
  overflow: hidden;
}
.adm-health__cell {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  position: relative;
}
.adm-health__cell + .adm-health__cell {
  border-left: 1px solid var(--border);
}
.adm-health__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.adm-health__primary {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
}
.adm-health__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* DB status pill */
.adm-health__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--good-tint);
  color: var(--good-ink);
  border: 1px solid color-mix(in oklch, var(--good) 28%, transparent);
  align-self: flex-start;
  transition:
    background-color var(--d-base) var(--ease-out),
    border-color var(--d-base) var(--ease-out),
    color var(--d-base) var(--ease-out);
}
.adm-health__pill[data-status="error"] {
  background: var(--accent-tint);
  color: var(--accent-ink);
  border-color: color-mix(in oklch, var(--accent) 32%, transparent);
}
.adm-health__pill[data-status="warn"] {
  background: var(--warning-tint);
  color: var(--warning-ink);
  border-color: color-mix(in oklch, var(--warning) 32%, transparent);
}
.adm-health__dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.8;
  animation: adm-pulse 1.8s var(--ease-in-out) infinite;
}

/* Storage bar */
.adm-health__bar {
  position: relative;
  height: 4px;
  background: var(--surface-sunk);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.adm-health__bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    color-mix(in oklch, var(--good) 55%, var(--surface)),
    var(--good)
  );
  border-radius: 999px;
  transition: width var(--d-slow) var(--ease-out);
  display: block;
}

/* -------------------------------------------------------------------------
   Insights grid — wide growth chart + compact distribution chart
   ------------------------------------------------------------------------- */
.adm-insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: var(--s-5);
  margin-bottom: var(--s-7);
}

/* Generic card surface */
.adm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: border-color var(--d-base) var(--ease-out);
}
.adm-card:hover {
  border-color: var(--border-strong);
}
.adm-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-3);
  border-bottom: 1px solid var(--border-faint);
}
.adm-card__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: 4px;
}
.adm-card__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.014em;
  color: var(--ink-strong);
  margin: 0;
}
.adm-card__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  text-align: right;
  white-space: nowrap;
  padding-top: 2px;
}
.adm-card__body {
  padding: var(--s-4) var(--s-5) var(--s-5);
  flex: 1;
}
.adm-card__body--feed { padding-top: var(--s-3); }

/* Chart container — Chart.js needs an explicit height when
   maintainAspectRatio:false. The wider card gets a taller chart. */
.adm-chart {
  position: relative;
  width: 100%;
  height: 260px;
}
.adm-card--wide .adm-chart {
  height: 300px;
}
.adm-chart > canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* -------------------------------------------------------------------------
   Activity feed
   ------------------------------------------------------------------------- */
.adm-card--feed { margin-bottom: var(--s-7); }
.adm-feed {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-faint);
  border-radius: var(--r-sm);
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
.adm-feed:empty,
.adm-feed > .adm-feed__empty {
  background: transparent;
}
.adm-feed__empty {
  font-size: 13.5px;
  color: var(--ink-muted);
  padding: var(--s-5) var(--s-4);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  margin: 0;
}
/* Inherit reasonable defaults for rows the JS injects.
   updateActivityFeed() renders divs with Tailwind classes
   (bg-gray-50, rounded-lg, etc). We override here via higher
   specificity (#admin-dashboard scope + child combinator). */
#admin-dashboard .adm-feed > * {
  background: var(--surface);
  padding: var(--s-3) var(--s-4);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  border-radius: 0;
  transition: background-color var(--d-fast) var(--ease-out);
}
#admin-dashboard .adm-feed > *:hover { background: var(--surface-sunk); }
#admin-dashboard .adm-feed > * > .flex-1 { min-width: 0; }
#admin-dashboard .adm-feed > * > .flex-1 > p:first-child {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.003em;
}
#admin-dashboard .adm-feed > * > .flex-1 > p:last-child {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-subtle);
  margin: 4px 0 0;
}
#admin-dashboard .adm-feed i,
#admin-dashboard .adm-feed .fa,
#admin-dashboard .adm-feed .fas,
#admin-dashboard .adm-feed [class*="fa-"] {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 3px;
  flex: 0 0 auto;
}
/* Map the legacy Tailwind icon-color classes to admin tokens. */
#admin-dashboard .adm-feed .text-purple-600 { color: var(--accent-ink); }
#admin-dashboard .adm-feed .text-blue-600   { color: oklch(46% 0.12 240); }

/* Responsive: insights grid collapses on tablet */
@media (max-width: 980px) {
  .adm-insights-grid {
    grid-template-columns: 1fr;
  }
  .adm-card--wide .adm-chart { height: 260px; }
  .adm-health {
    grid-template-columns: 1fr;
  }
  .adm-health__cell + .adm-health__cell {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}
@media (max-width: 640px) {
  .adm-chart,
  .adm-card--wide .adm-chart { height: 240px; }
  .adm-card__head { flex-direction: column; gap: 4px; }
  .adm-card__meta { text-align: left; }
}

/* Style the "No recent activity" / "Error loading activity" fallback
   markup that updateActivityFeed() injects with Tailwind classes. */
#admin-dashboard .adm-feed > p.text-gray-500 {
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink-muted);
  padding: var(--s-5) var(--s-4);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  margin: 0;
  display: block;
  font-weight: 400;
}

/* Refresh button spin while reload is in flight. */
#adm-insights-refresh-btn.is-spinning > i {
  animation: adm-spin 0.7s linear infinite;
}
@keyframes adm-spin {
  to { transform: rotate(360deg); }
}

/* Reduced motion: kill the pulse */
@media (prefers-reduced-motion: reduce) {
  .adm-live-dot,
  .adm-nav__dot--live,
  .adm-health__dot,
  #adm-insights-updated strong::before,
  #adm-insights-refresh-btn.is-spinning > i {
    animation: none !important;
  }
}
