/* css/admin.css */

:root {
  /* Legacy names kept for existing rules; values come from css/tokens.css */
  --primary: var(--c-primary);
  --secondary: var(--c-primary-hover);
  --accent: #94d2bd;
  --bg-light: var(--c-bg);
  --sidebar-bg: var(--shell-admin-bg);
  --text-dark: var(--c-text);
  --text-muted: var(--c-text-muted);
  --white: var(--c-surface);
  --danger: var(--c-danger);
  --success: var(--c-success);
  --warning: var(--c-warning);
  --border: var(--c-border);
  --font-main: var(--font-sans);
  --transition: all var(--t-base) var(--ease);
  --shadow: var(--e-1);
  --radius: var(--r-md);
  --adm-topbar-h: 56px;
  --adm-sidebar-w: 250px;
  --adm-rail-w: 72px;
  --nav-teal: #5eead4;   /* small teal text on the deep navy sidebar (AA on --shell-admin-bg) */
  --nav-active: #0f766e; /* the active navigation row: teal, white text (5.5:1) */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-light);
  color: var(--text-dark);
  display: flex;
  min-height: 100vh;
}

/* Typography (scale from css/typography.css) */
h1, h2, h3, h4 { font-family: var(--font-main); color: var(--text-dark); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 700; }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
body { font-size: var(--fs-body); line-height: var(--lh-body); -webkit-font-smoothing: antialiased; }

/* Placeholders: the <aside> is empty in the HTML and the top bar is built by script, so both are painted with the first frame: the column, the shape of the
   navigation and a bar with the brand are there before any script runs (js/core/admin-shell.js, then js/admin-core.js, fill them in). */
.admin-sidebar:empty:not([data-nav-state])::before { content: ""; display: block; height: 8px; }
.admin-sidebar:empty:not([data-nav-state])::after {
  content: ""; display: block; height: 380px; margin: var(--s-4) var(--s-4); border-radius: var(--r-sm);
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.09) 0 16px, transparent 16px 42px);
  animation: dsp-sidebar-pulse 1.3s ease-in-out infinite alternate;
}
@keyframes dsp-sidebar-pulse { from { opacity: .45; } to { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .admin-sidebar:empty:not([data-nav-state])::after { animation: none; } }
/* The top bar's row is reserved until script draws it (no layout shift); an access-denied screen has none */
.admin-main:not(:has(> .admin-topbar))::before { content: ""; display: block; flex: none; height: var(--adm-topbar-h); background: var(--white); border-bottom: 1px solid var(--border); }
body:has(.admin-sidebar[data-nav-state="denied"]) .admin-main::before { display: none; }

/* ---------------------------------------------------------------- Top bar (js/core/topbar.js): menu button, where you are, notification bell, account menu */
.admin-topbar {
  position: sticky; top: 0; z-index: 95; flex: none; height: var(--adm-topbar-h); display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-5) 0 var(--s-2); background: var(--white); border-bottom: 1px solid var(--border);
}
.topbar-toggle { flex: none; width: 44px; height: 44px; margin: 0; display: inline-grid; place-items: center; border-radius: var(--r-md); font-size: 1.15rem; color: var(--text-dark); background: none; border: 0; cursor: pointer; }
.topbar-toggle:hover { background: var(--bg-light); }
.topbar-crumb { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--s-2); color: var(--text-muted); font-size: 0.875rem; }
.crumb-group { flex: none; white-space: nowrap; }
.crumb-sep { flex: none; font-size: 0.6rem; }
.crumb-page { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dark); font-weight: 600; font-size: 1rem; }
.topbar-actions { flex: none; display: flex; align-items: center; gap: var(--s-1); margin-left: auto; }
.topbar-menuwrap { position: relative; }
.topbar-icon { position: relative; width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-md); background: none; color: var(--text-muted); text-decoration: none; font-size: 1.05rem; cursor: pointer; }
.topbar-icon:hover, .topbar-icon[aria-expanded="true"] { background: var(--bg-light); color: var(--primary); }
.topbar-bell[data-alert="1"]::after { content: ""; position: absolute; top: 9px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: #dc2626; border: 2px solid var(--white); }
.topbar-user { display: flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 4px var(--s-2); border: 0; border-radius: var(--r-md); background: none; color: var(--text-dark); font: inherit; cursor: pointer; }
.topbar-user:hover, .topbar-user[aria-expanded="true"] { background: var(--bg-light); }
.topbar-avatar { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--c-primary-soft); color: var(--primary); font-size: 0.9rem; }
.topbar-user-short { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; font-weight: 600; }
.topbar-user-caret { font-size: 0.65rem; color: var(--text-muted); }
.topbar-menu[hidden], .tm-preview[hidden], .tm-empty[hidden] { display: none; }
.topbar-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(300px, calc(100vw - 24px)); padding: var(--s-2);
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e-2), 0 12px 32px rgba(15, 27, 42, 0.12);
}
.tm-title { padding: var(--s-2) var(--s-3); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.tm-list { list-style: none; margin: 0; padding: 0; }
.tm-empty { margin: 0; padding: var(--s-2) var(--s-3) var(--s-3); color: var(--text-muted); font-size: 0.875rem; }
.tm-id { display: grid; gap: 2px; padding: var(--s-2) var(--s-3) var(--s-3); margin-bottom: var(--s-2); border-bottom: 1px solid var(--border); }
.tm-name { font-weight: 700; overflow-wrap: anywhere; }
.tm-role { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--primary); }
.tm-preview { display: grid; gap: var(--s-1); padding: var(--s-2) var(--s-3) var(--s-3); }
.tm-caption { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.topbar-select { width: 100%; min-height: 40px; padding: 6px var(--s-2); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); background: var(--white); color: var(--text-dark); font: inherit; font-size: 0.875rem; text-overflow: ellipsis; }
.tm-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-sm); background: none; color: var(--text-dark); text-decoration: none; text-align: left; font: inherit; font-size: 0.9rem; cursor: pointer; }
.tm-item:hover { background: var(--bg-light); }
.tm-item i { width: 18px; text-align: center; color: var(--text-muted); }
.tm-danger, .tm-danger i { color: #b42318; }
.admin-topbar[data-state="pending"] .topbar-actions { visibility: hidden; } /* no layout shift while the navigation is being established */
.admin-topbar :is(a, button, select):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- Sidebar: a full-height deep navy column (js/core/sidebar.js) */
.admin-sidebar {
  width: var(--adm-sidebar-w);
  background-color: var(--sidebar-bg);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.06);
  transition: var(--transition);
}
/* Lucide icons from vendor/lucide/sprite.svg: one size, the colour of the text */
.lu { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sb-brand { flex: none; display: flex; align-items: center; gap: 10px; height: var(--adm-topbar-h); padding: 0 var(--s-4); border-bottom: 1px solid rgba(255,255,255,0.08); }
.sb-logo { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--nav-active); color: #fff; font-size: 1rem; }
.sb-brand-text { display: grid; min-width: 0; line-height: 1.15; }
.sb-brand-text strong { color: #fff; font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.sb-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; font-size: 0.68rem; font-weight: 600; color: var(--nav-teal); }
.admin-sidebar .sb-close { display: none; margin: 0; width: 44px; height: 44px; place-items: center; border: 0; border-radius: var(--r-md); background: none; color: rgba(255,255,255,0.8); cursor: pointer; }
.admin-sidebar .sb-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sb-close.has-alert::after { display: none; }

.sidebar-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-2) 0 var(--s-4);
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sidebar-group + .sidebar-group { margin-top: 2px; }
.sidebar-group-toggle {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 32px; padding: 10px var(--s-4) 4px; border: 0; background: none; cursor: pointer; text-align: left;
  color: rgba(255,255,255,0.58); font: 700 0.6875rem/1.2 var(--font-main); letter-spacing: 0.09em; text-transform: uppercase;
}
.sidebar-group-toggle:hover { color: #fff; }
.sidebar-group-chevron { margin-left: auto; width: 14px; height: 14px; transition: transform var(--t-base) var(--ease); }
.sidebar-group.is-closed .sidebar-group-chevron { transform: rotate(-90deg); }
.sidebar-group-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--t-base) var(--ease); }
.sidebar-group.is-closed .sidebar-group-body { grid-template-rows: 0fr; }
.sidebar-group.is-closed .sidebar-menu { visibility: hidden; transition: visibility 0s linear var(--t-base); }

.sidebar-menu { list-style: none; min-height: 0; overflow: hidden; margin: 0; padding: 0 var(--s-3) var(--s-1); }
.sidebar-menu li a {
  position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 38px; padding: 7px var(--s-3); border-radius: 8px;
  color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar-menu li a:hover { background-color: rgba(255,255,255,0.07); color: var(--white); }
.sidebar-menu li a.active { background-color: var(--nav-active); color: #fff; font-weight: 600; }
.sidebar-menu li a:focus-visible, .sb-gear:focus-visible, .sidebar-group-toggle:focus-visible { outline: 2px solid var(--nav-teal); outline-offset: -2px; }
.sidebar-menu li a .nav-badge { margin: 0 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; font-size: 0.7rem; }

/* Settings: a plain gear at the right end of the brand header (it moves to the foot of the icon rail) */
.sb-gear { flex: none; margin-left: auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: rgba(255,255,255,0.6); transition: background-color 0.15s ease, color 0.15s ease; }
.sb-gear:hover { background-color: rgba(255,255,255,0.08); color: #fff; }
.sb-gear.active { color: var(--nav-teal); }

/* the fixed bottom line: DSP Dental Training and the build */
.sb-foot { flex: none; padding: var(--s-3) var(--s-4); border-top: 1px solid rgba(255,255,255,0.08); }
.sb-foot-brand { display: grid; gap: 1px; font-size: 0.7rem; line-height: 1.3; color: rgba(255,255,255,0.55); }
.sb-foot-brand strong { color: rgba(255,255,255,0.88); font-size: 0.75rem; font-weight: 600; }

/* the icon rail's tooltip (js/core/sidebar.js places it beside the hovered or focused icon) */
.sidebar-tip { position: fixed; z-index: 1100; transform: translateY(-50%); padding: 6px 10px; border-radius: 6px; background: #07141d; color: #fff; font-size: 0.8rem; font-weight: 600; white-space: nowrap; pointer-events: none; box-shadow: var(--e-2); }
.sidebar-tip[hidden] { display: none; }

/* Main Content */
.admin-main {
  flex-grow: 1;
  min-width: 0; /* a flex child never shrinks below its content unless told: this stops wide tables stretching the page */
  margin-left: var(--adm-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  background-color: var(--white);
  padding: 20px 30px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: var(--adm-topbar-h);
  z-index: 90;
}

/* The page's own header stays only when it holds real page controls (a search box, a button, a link, a select): its title and its menu button moved to the top bar.
   The dashboard's "System Online" badge keeps its bar on wide screens. */
body.has-topbar .admin-header h3 { display: none; }
.admin-header:not(:has(input, select, button, a)) { display: none; }
@media (min-width: 769px) { .admin-header:has(.status-badge) { display: flex; justify-content: flex-end; } .admin-header:has(.status-badge):not(:has(input, select, button, a)) { padding-top: var(--s-2); padding-bottom: var(--s-2); } }

.admin-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.admin-user img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.admin-content {
  padding: var(--s-6) var(--gutter);
  flex-grow: 1;
}

.page-title {
  margin-bottom: 20px;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--white);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--white);
}

.stat-icon.students { background-color: var(--primary); }
.stat-icon.batches { background-color: var(--secondary); }
.stat-icon.payments { background-color: var(--warning); }
.stat-icon.certificates { background-color: var(--success); }

.stat-details h3 {
  font-size: 1.8rem;
  margin-bottom: 5px;
  color: var(--text-dark);
}

.stat-details p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Tables */
.table-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto; /* wide tables scroll inside their card, never the page */
  overflow-y: hidden;
  margin-bottom: 30px;
}

.table-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-light);
  border-radius: 20px;
  padding: 5px 15px;
  width: 300px;
  max-width: 100%;
  min-width: 0;
}

.search-bar input {
  border: none;
  background: transparent;
  padding: 8px;
  width: 100%;
  outline: none;
}

.search-bar i {
  color: var(--text-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 15px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background-color: #f8f9fa;
  color: var(--c-text-secondary);
  font-weight: 600;
  font-size: var(--fs-label);
  white-space: nowrap;
}

tr:hover {
  background-color: rgba(0,0,0,0.02);
}

.action-btns {
  display: flex;
  gap: 10px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--white);
}

.btn-view { background-color: var(--secondary); }
.btn-edit { background-color: var(--warning); }
.btn-delete { background-color: var(--danger); }
.btn-approve { background-color: var(--success); }

.btn-icon:hover {
  opacity: 0.8;
}

/* Badges */
.badge {
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-active { background-color: #d4edda; color: #155724; }
.badge-pending { background-color: #fff3cd; color: #856404; }
.badge-inactive { background-color: #f8d7da; color: #721c24; }
.badge-completed { background-color: #e2e3e5; color: #383d41; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background-color: var(--secondary);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--white);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  animation: slideDown 0.3s ease;
  max-height: 92vh;   /* a tall form (the batch form) scrolls inside the modal instead of pushing Save off the screen */
  overflow-y: auto;
}

@keyframes slideDown {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-modal {
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Alerts */
.alert {
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
  display: none;
}

.alert.active {
  display: block;
}

.alert-success { background-color: #d4edda; color: #155724; }
.alert-error { background-color: #f8d7da; color: #721c24; }

/* Loader */
.loader-container {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.loader {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Menu button: a drawer on phones, collapse / expand of the sidebar on wide screens */
.mobile-admin-toggle {
  display: block;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--primary);
  cursor: pointer;
  margin-right: 15px;
}

/* Minimized sidebar (wide screens): an icon rail, never hidden. Labels stay in the DOM for screen readers; a floating tooltip names each icon. */
@media (min-width: 769px) {
  .admin-sidebar.collapsed { width: var(--adm-rail-w); }
  .admin-sidebar.collapsed + .admin-main { margin-left: var(--adm-rail-w); }
  .admin-sidebar.collapsed .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .admin-sidebar.collapsed .sb-brand { justify-content: center; padding: 0; }
  .admin-sidebar.collapsed .sb-foot-brand { padding: 0; }
  .admin-sidebar.collapsed .sb-gear { position: absolute; left: 50%; bottom: var(--s-3); margin: 0; transform: translateX(-50%); }
  .admin-sidebar.collapsed .sb-foot { padding: var(--s-6) 0; }
  .admin-sidebar.collapsed .sidebar-group-toggle { display: none; }
  .admin-sidebar.collapsed .sidebar-group + .sidebar-group { margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px solid rgba(255,255,255,0.08); }
  .admin-sidebar.collapsed .sidebar-group.is-closed .sidebar-group-body { grid-template-rows: 1fr; }
  .admin-sidebar.collapsed .sidebar-group.is-closed .sidebar-menu { visibility: visible; }
  .admin-sidebar.collapsed .sidebar-menu li a { justify-content: center; gap: 0; padding: 10px 0; }
  .admin-sidebar.collapsed .nav-badge { position: absolute; top: 2px; right: 6px; margin: 0; min-width: 16px; height: 16px; padding: 0 4px; font-size: 0.62rem; }
  .topbar-toggle.has-alert::after { display: none; }
}
.admin-sidebar { overflow-x: hidden; transition: width 0.2s ease; }
.admin-main { transition: margin-left 0.2s ease; }
@media (prefers-reduced-motion: reduce) { .admin-main, .admin-sidebar { transition: none; } }

@media (max-width: 768px) {
  .admin-sidebar {
    z-index: 1000;
    left: calc(-1 * var(--adm-sidebar-w) - 16px);
    max-width: 86vw;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
  }
  .admin-sidebar .sb-close { display: inline-grid; width: 36px; height: 36px; }
  .sb-brand { gap: var(--s-2); padding: 0 var(--s-3); }
  
  .admin-sidebar.active {
    left: 0;
  }
  
  .admin-main {
    margin-left: 0;
  }
  
  .mobile-admin-toggle {
    display: block;
  }
  
  .dashboard-cards {
    grid-template-columns: minmax(0, 1fr);
  }
  
  .admin-header {
    padding: 12px var(--gutter);
    gap: var(--s-3);
  }

  .admin-header > div:first-child { flex: 1 1 auto; min-width: 0; }
  .admin-header .search-bar { flex: 1 1 0; width: auto !important; /* beats inline width on pages */ }
  .admin-header .status-badge { display: none; }
  .admin-header .admin-user { min-width: 0; }
  .admin-header .admin-user span { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-title { flex-wrap: wrap; gap: var(--s-3); }
  .page-title > div { flex-wrap: wrap; min-width: 0; }
  .table-header { flex-wrap: wrap; gap: var(--s-3); padding: var(--s-4); }
  .table-container table { min-width: 560px; }
}

/* Page header: the title sits above its one-line description (it used to share a row and squeeze the title), on every staff page. */
.page-title { flex-wrap: wrap; align-items: baseline; row-gap: var(--s-1); column-gap: var(--s-4); }
.page-title > h2, .page-title > h1 { flex: 1 1 100%; margin: 0; }
.page-title > p { flex: 1 1 100%; max-width: 70ch; line-height: 1.5; }
.page-title > :is(button, .btn, .actions, .page-actions) { flex: 0 0 auto; }

/* Touch comfort (phones, tablets and any touchscreen): tap targets at least 44px; compact sizes stay for mouse users on wide screens. */
@media (pointer: coarse), (max-width: 768px) {
  .mobile-admin-toggle { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; }
  .btn, .btn-sm { min-height: 44px; }
  .btn-icon { width: 44px; height: 44px; }
  .admin-header input, .table-header input, .filter-group input, .filter-group select, .roster-search input, input[type="search"], input[type="text"], input[type="date"], input[type="number"], input[type="email"], select { min-height: 44px; }
  .admin-user { min-height: 44px; }
}

/* Top bar on narrower screens: the page title and the controls keep their room */
@media (max-width: 900px) { .topbar-user-short, .topbar-user-caret { display: none; } .crumb-group, .crumb-sep { display: none; } }
@media (max-width: 640px) { .admin-topbar { gap: var(--s-1); padding-right: var(--s-2); } }
@media (prefers-reduced-motion: reduce) { .sidebar-group-body, .sidebar-group-chevron, .sidebar-menu li a, .sidebar-group.is-closed .sidebar-menu { transition: none; } }
