/* Users & Students (app/owner/users): the compact administration workspace shared by the redesigned finance and training pages.
   4px spacing scale, brand tokens only, neutral elevation, sentence-case labels. Teal marks the primary action and the student role; gold marks
   administrators. Replaces the page's old inline <style>. Scoped to this page (.us-page, body[data-nav="users"]): nothing here reaches another admin page. */

/* ---------------------------------------------------------------- page shell */
body.has-topbar[data-nav="users"] .admin-header { display: none; }

/* .us-page is also .admin-content, which grows to fill the viewport: a top-aligned flex column cannot stretch its rows into gaps. */
.us-page { display: flex; flex-direction: column; align-content: flex-start; gap: 12px; width: 100%; max-width: 1440px; padding-top: 16px; padding-bottom: 32px; caret-color: var(--c-primary); }
.us-page .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.us-page ::selection { background: #cde6ec; color: var(--c-text); }
.us-page > #adminAlert { position: fixed; top: calc(var(--adm-topbar-h, 56px) + 12px); right: 24px; z-index: 200; width: min(420px, calc(100vw - 32px)); margin: 0; box-shadow: var(--e-2); }
.us-page :where(button, select, input):focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

/* ---------------------------------------------------------------- header: title and subtitle, a compact search, and the primary action on one row */
.us-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.us-title { flex: 1 0 auto; min-width: 0; }
.us-title h1 { margin: 0; color: var(--c-text); font-family: var(--font-sans); font-size: 1.5rem; font-weight: 650; line-height: 1.2; letter-spacing: -.02em; white-space: nowrap; }
.us-title p { margin: 2px 0 0; color: var(--c-text-muted); font-size: .8125rem; }
.us-search { position: relative; flex: 1 1 180px; max-width: 280px; min-width: 140px; margin: 0; }
.us-search i { position: absolute; top: 50%; left: 11px; color: var(--c-text-muted); font-size: .75rem; pointer-events: none; transform: translateY(-50%); }
.us-search input { width: 100%; height: 36px; padding: 0 10px 0 32px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; color: var(--c-text); font: inherit; font-size: .8125rem; }
.us-search input::placeholder { color: var(--c-text-muted); }
.us-search input:hover { border-color: #aab6c2; }
.us-search input:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus-ring); }
.us-head .btn-primary { flex: none; min-height: 36px; padding: 0 16px; border-radius: 8px; background: var(--c-primary); font-size: .875rem; font-weight: 600; white-space: nowrap; }
.us-head .btn-primary:hover { background: var(--c-primary-hover); }

/* ---------------------------------------------------------------- toolbar: the two filters, and how many accounts match */
.us-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); }
.us-control { flex: 0 1 180px; height: 36px; min-width: 132px; max-width: 100%; padding: 0 24px 0 10px; border: 1px solid var(--c-border-strong); border-radius: 8px; background-color: #fff; color: var(--c-text); font: inherit; font-size: .8125rem; }
.us-control:hover { border-color: #aab6c2; }
.us-control:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus-ring); }
.us-count { margin-left: auto; color: var(--c-text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------------- table */
.us-panel { container: us / inline-size; min-width: 0; margin: 0; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); overflow: clip; }
.us-loader { min-height: 0; padding: 16px; }
.us-panel .us-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: .8125rem; }   /* beats admin.css's .table-container table { min-width: 560px } */
.us-table th { padding: 9px 12px; border-bottom: 1px solid var(--c-border); background: #f8fafb; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; letter-spacing: 0; text-align: left; text-transform: none; white-space: nowrap; }
.us-table td { padding: 10px 12px; border-bottom: 1px solid #eef1f4; color: var(--c-text-secondary); vertical-align: middle; }
.us-table th:first-child, .us-table td:first-child { padding-left: 16px; }
.us-table th:last-child, .us-table td:last-child { padding-right: 16px; }
.us-table tbody tr:last-child td { border-bottom: 0; }
.us-table tbody tr:hover td { background: #f9fbfc; }
.us-user { min-width: 200px; }
.us-name { display: block; color: var(--c-text); font-weight: 600; }
.us-sub { display: block; margin-top: 1px; overflow: hidden; color: var(--c-text-muted); font-size: .75rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.us-phone, .us-date { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* role and status: a small dot and a name; colors are the brand's (teal student, gold admin, green doctor, navy developer) */
.us-table .role-badge, .us-table .status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; letter-spacing: 0; line-height: 1.4; text-transform: capitalize; white-space: nowrap; }
.us-table .role-badge::before, .us-table .status-badge::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.us-table .role-student { background: var(--c-primary-soft); color: var(--c-primary); }
.us-table .role-admin { background: #fff1d6; color: #7a4d00; }
.us-table .role-admin::before { background: var(--c-accent); }
.us-table .role-doctor { background: var(--c-success-bg); color: var(--c-success); }
.us-table .role-developer_admin { background: #e1e8ee; color: var(--c-secondary); }
.us-table .status-active { background: var(--c-success-bg); color: var(--c-success); }
.us-table .status-disabled { background: var(--c-danger-bg); color: var(--c-danger); }

/* Manage: one compact outlined button on every row */
.us-table td.us-actions { display: table-cell; width: 1%; white-space: nowrap; }
.us-table .edit-user-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; color: var(--c-text-secondary); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.us-table .edit-user-btn i { color: var(--c-text-muted); font-size: .75rem; }
.us-table .edit-user-btn:hover { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary); }
.us-table .edit-user-btn:hover i { color: var(--c-primary); }
.us-empty { padding: 32px 16px !important; color: var(--c-text-muted); font-size: .8125rem; text-align: center; }
.us-empty i { display: block; margin-bottom: 8px; color: #b4bec8; font-size: 1.25rem; }

/* the dialogs' titles are h2 now (the page title is the h1, so no level is skipped): same size, weight and rhythm as before */
body[data-nav="users"] .modal-header h2 { margin: 0; color: var(--c-text); font-family: var(--font-sans); font-size: var(--fs-h3); font-weight: 600; line-height: var(--lh-h3); letter-spacing: -.01em; }

/* ---------------------------------------------------------------- responsive: the panel's own width decides when rows become cards */
@container us (max-width: 820px) {
  .us-table, .us-table tbody { display: block; width: 100%; }
  .us-table thead { position: absolute; left: -9999px; }
  .us-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 12px; border-bottom: 1px solid #eef1f4; }
  .us-table tbody tr:last-child { border-bottom: 0; }
  .us-table td, .us-table td:first-child, .us-table td:last-child { display: block; padding: 0; border: 0; }
  .us-table tbody tr:hover td { background: transparent; }
  .us-table td.us-user { order: 1; flex: 1 1 calc(100% - 112px); min-width: 0; }
  .us-table td.us-actions { order: 2; width: auto; }
  .us-table td.us-role { order: 3; }
  .us-table td.us-status { order: 4; }
  .us-table td.us-phone { order: 5; margin-left: auto; font-size: .75rem; }
  .us-table td.us-date { order: 6; font-size: .75rem; }
  .us-table td.us-phone::before, .us-table td.us-date::before { content: attr(data-label) " "; color: var(--c-text-muted); font-weight: 600; }
  .us-empty { flex: 1 1 100%; }
}
@media (max-width: 768px) {
  .us-control, .us-search input, .us-head .btn-primary { min-height: 44px; height: 44px; }
  .us-table .edit-user-btn { min-height: 44px; }
}
@media (max-width: 680px) {
  .us-page { gap: 8px; padding-top: 8px; }
  .us-page > #adminAlert { right: 16px; }
  .us-title h1 { font-size: 1.25rem; white-space: normal; }
  .us-title { flex: 1 1 calc(100% - 160px); }
  .us-search { order: 3; flex: 1 1 100%; max-width: none; }
  .us-toolbar { padding: 8px; }
  .us-control { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .us-count { flex-basis: 100%; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .us-table .edit-user-btn { transition: none; } }
