/* Helix Admin — extracted from admin/index.htm */
header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 10px;
    min-height: 62px;
    height: auto;
    min-width: 0;
  }

  .page-hero {
    background: linear-gradient(135deg, var(--surface) 0%, var(--bg2) 100%);
    border-bottom: 1px solid var(--border);
    padding: 32px 28px 0;
    max-width: 100%;
    overflow-x: clip;
  }

  .page-hero h1 {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary, var(--text));
    margin-bottom: var(--space-2, 6px);
  }

  .page-hero p {
    font-size: var(--font-size-md, .9375rem);
    color: var(--text-muted);
  }

  /* ── Admin top nav ── */
  .admin-nav {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
  }

  .admin-nav-btn {
    padding: var(--space-3, 10px) var(--space-5, 20px);
    font-size: var(--font-size-md, .9375rem);
    font-weight: var(--font-weight-semibold, 600);
    font-family: inherit;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color .15s, border-color .15s, background .15s;
  }

  .admin-nav-btn:hover { color: var(--text); background: rgba(var(--accent-rgb),.06); }

  .admin-nav-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(var(--accent-rgb),.08);
  }

  main {
    max-width: var(--layout-max-width, 1520px);
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    box-sizing: border-box;
    padding: var(--space-7, 28px) var(--page-gutter, 28px);
  }

  /* ── Section panels ── */
  .admin-section { display: none; }
  .admin-section.active { display: block; }

  #cf-policy-info {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
  }

  /* ── Toolbar ── */
  .toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
  }

  .toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

  .search-input {
    padding: var(--space-2, 8px) var(--space-4, 14px);
    font-size: var(--font-size-md, .9375rem);
    min-height: var(--control-height-md, 40px);
    border: 1px solid var(--border-strong, var(--border));
    border-radius: var(--radius-md, var(--radius-sm));
    background: var(--surface-1, var(--surface));
    color: var(--text-primary, var(--text));
    font-family: inherit;
    width: min(280px, 100%);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .search-input:focus {
    outline: none;
    border-color: var(--action, var(--accent));
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(var(--accent-rgb),.1));
  }

  .stat-pill {
    font-size: var(--font-size-sm, .875rem);
    font-weight: var(--font-weight-semibold, 600);
    padding: var(--space-1, 4px) var(--space-3, 12px);
    border-radius: 999px;
    background: var(--surface-2, var(--bg2));
    border: 1px solid var(--border-subtle, var(--border));
    color: var(--text-muted);
  }

  .admin-hint {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    margin: 0 0 var(--space-4, 14px);
  }

  /* ── Users table ── */
  .admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    min-width: 0;
  }
  @media (max-width: 768px) {
    .admin-table-wrap { overflow-x: hidden; }
  }

  .admin-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm, .875rem);
    table-layout: auto;
  }

  thead tr {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
  }

  .admin-table-wrap th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--font-size-xs, .75rem);
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    vertical-align: bottom;
  }

  .admin-table-wrap td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: normal;
  }

  tr:last-child td { border-bottom: none; }

  tr.user-row-clickable {
    cursor: pointer;
    transition: background .12s;
  }

  tr.user-row-clickable:hover td {
    background: rgba(var(--accent-rgb, 30, 90, 175), .06);
  }

  tr.user-row-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  /* Not a flex row. It was, and every inline child — each <strong>, each text node
     between them — became its own flex item with the 8px gap applied, so a sentence
     with emphasis in it rendered as spaced chunks instead of prose. The icon is
     positioned out of flow instead, leaving the text to wrap normally. */
  .users-hint {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    margin: 0 0 14px;
    position: relative;
    padding-left: 26px;
    line-height: 1.55;
  }

  .users-hint::before {
    content: 'ℹ';
    position: absolute;
    left: 0;
    /* Against the first line rather than the block, which drifts as the text wraps. */
    top: 0.1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    font-size: .7rem;
    flex-shrink: 0;
  }

  .users-group {
    margin-bottom: 28px;
  }

  .users-group:last-child {
    margin-bottom: 0;
  }

  .users-group-title {
    font-size: var(--font-size-lg, 1.0625rem);
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .users-group-count {
    font-size: var(--font-size-xs, .75rem);
    font-weight: 600;
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--bg2);
    border: 1px solid var(--border);
  }

  .user-name-cell {
    font-weight: var(--font-weight-medium, 500);
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-primary, var(--text));
    line-height: 1.35;
    min-width: 0;
  }

  .user-email-cell {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.35;
    min-width: 0;
  }

  .user-suspended-tag {
    display: inline-block;
    margin-left: 6px;
    font-size: var(--font-size-xs, .75rem);
    font-weight: 600;
    color: var(--warning, #d97706);
    vertical-align: middle;
  }

  .access-select {
    padding: 5px 8px;
    font-size: .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .access-select:focus { outline: none; border-color: var(--accent); }
  .access-select.level-none          { border-color: #888;    color: #888; }
  .access-select.level-read_only     { border-color: #6495ED; color: #6495ED; }
  .access-select.level-support       { border-color: #D57602; color: #D57602; }
  .access-select.level-prof_services { border-color: #9b5de5; color: #9b5de5; }
  .access-select.level-super_user    { border-color: #2D9B5A; color: #2D9B5A; }
  .access-select.level-development   { border-color: #0d9488; color: #0d9488; }
  .access-select.level-dba           { border-color: #0369a1; color: #0369a1; }
  .access-select.level-operations    { border-color: #c2410c; color: #c2410c; }

  .um-adhoc-list { margin-bottom: 16px; }
  .um-adhoc-form {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .um-adhoc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
  }
  .um-adhoc-table th,
  .um-adhoc-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  /* Native calendar picker for AdHoc expiry (Admin grant form + inline "Renew to date" on Admin/Approvals tables) */
  .um-adhoc-date {
    font: inherit;
    font-size: 0.8rem;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: inherit;
  }
  td .um-adhoc-date {
    font-size: 0.75rem;
    padding: 3px 6px;
    margin-right: 4px;
    width: 140px;
  }
  [data-theme="dark"] .um-adhoc-date { background: #161B22; border-color: #30363D; color-scheme: dark; }
  /* .modal-field is display:flex, which outranks the UA [hidden] rule — make the toggle work */
  #um-adhoc-date-wrap[hidden] { display: none; }

  /* AdHoc pattern autocomplete (segment-by-segment member list under the Pattern box) */
  .um-adhoc-pattern-wrap { position: relative; }
  /* Fixed, not absolute, and placed by position() in helix-adhoc-pattern-picker.js.
     The user modal scrolls in .modal-body now, and an absolutely positioned child of a
     scroll container is clipped by it — this list is up to 260px tall and sits partway
     down the AdHoc panel, so most of it disappeared. Same approach as .helix-iam-popover. */
  .um-adhoc-suggest {
    position: fixed;
    z-index: 40;
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    font-size: 0.8rem;
  }
  .um-adhoc-suggest-head,
  .um-adhoc-suggest-empty {
    padding: 6px 10px;
    color: var(--text-muted, #6b7280);
    font-size: 0.75rem;
  }
  .um-adhoc-suggest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    cursor: pointer;
    border-top: 1px solid var(--border);
  }
  .um-adhoc-suggest-item:first-child { border-top: 0; }
  .um-adhoc-suggest-item.active { background: rgba(59, 130, 246, 0.12); }
  .um-adhoc-suggest-item.is-segment .um-adhoc-suggest-text { font-weight: 600; }
  .um-adhoc-suggest-text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .um-adhoc-suggest-meta { display: flex; align-items: center; gap: 4px; flex-shrink: 0; font-size: 0.7rem; color: var(--text-muted, #6b7280); }
  .um-adhoc-suggest-dim { color: var(--text-muted, #6b7280); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .um-adhoc-src {
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.5;
    background: rgba(107, 114, 128, 0.18);
    color: #6b7280;
  }
  .um-adhoc-src-wildcard  { background: rgba(245, 158, 11, 0.18); color: #b45309; }
  .um-adhoc-src-role      { background: rgba(16, 185, 129, 0.18); color: #047857; }
  .um-adhoc-src-adhoc     { background: rgba(59, 130, 246, 0.18); color: #1d4ed8; }
  .um-adhoc-src-catalogue { background: rgba(139, 92, 246, 0.18); color: #6d28d9; }
  [data-theme="dark"] .um-adhoc-suggest { background: #161B22; border-color: #30363D; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
  [data-theme="dark"] .um-adhoc-suggest-item.active { background: rgba(59, 130, 246, 0.22); }
  [data-theme="dark"] .um-adhoc-src-role      { color: #34d399; }
  [data-theme="dark"] .um-adhoc-src-adhoc     { color: #60a5fa; }
  [data-theme="dark"] .um-adhoc-src-catalogue { color: #a78bfa; }
  [data-theme="dark"] .um-adhoc-src-wildcard  { color: #fbbf24; }
  .helix-iam-wild-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
    font-size: 10px;
    font-weight: 600;
  }

  /* ── Admin → AdHoc Grants (common/helix-adhoc-admin.js) ── */
  .adg-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
  }
  .adg-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .adg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .adg-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
  /* utils.js wraps the search box in .helix-search-wrap; size whichever is the flex item. */
  .adg-filters > .helix-search-wrap,
  .adg-filters > .search-input { flex: 1 1 280px; min-width: 220px; max-width: 440px; }
  /* .access-select is width:100% for the grantor roster; here each sizes to its options. */
  .adg-filters .access-select { width: auto; flex: 0 0 auto; min-height: var(--control-height-md, 40px); }
  .adg-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--font-size-sm, .8125rem);
    cursor: pointer;
  }
  .adg-pill:hover { border-color: var(--accent); }
  .adg-pill.is-active { border-color: var(--accent); background: rgba(59, 130, 246, 0.12); }
  .adg-pill-n { font-weight: 700; }
  .adg-pill.is-warn .adg-pill-n { color: var(--warning); }
  .adg-dup-note { font-size: var(--font-size-sm, .8125rem); color: var(--warning); }
  .adg-bulkbar[hidden],
  .adg-results[hidden],
  .adg-error[hidden] { display: none; }
  .adg-error {
    padding: 8px 12px;
    margin: 0 0 12px;
    border: 1px solid rgba(var(--danger-rgb), 0.28);
    border-left: 3px solid var(--danger);
    border-radius: 6px;
    background: rgba(var(--danger-rgb), 0.08);
    color: var(--danger);
    font-size: var(--font-size-sm, .8125rem);
  }
  .adg-bulkbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    margin: 0 0 12px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.08);
  }
  .adg-bulk-count { font-weight: 600; margin-right: 4px; }
  .adg-results {
    padding: 8px 12px;
    margin: 0 0 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    border-radius: 6px;
    font-size: var(--font-size-sm, .8125rem);
  }
  .adg-results.has-failures { border-left-color: var(--warning); }
  .adg-results ul { margin: 6px 0 0; padding-left: 18px; }
  .adg-results-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
  .adg-results-close { margin-left: auto; }
  .adg-table td { vertical-align: top; }
  .adg-col-select { width: 32px; }
  .adg-col-actions { white-space: nowrap; text-align: right; }
  .adg-row-inactive td { opacity: 0.7; }
  .adg-row-failed td { background: rgba(245, 158, 11, 0.08); }
  .adg-soon { color: var(--warning); font-weight: 600; }
  .adg-pattern { font-size: 11px; overflow-wrap: anywhere; }
  .adg-warn-text { display: block; color: var(--warning); font-size: 11px; }
  .adg-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .adg-link:hover { text-decoration: underline; }
  .adg-remind { display: inline-flex; gap: 6px; align-items: center; font-size: var(--font-size-sm, .8125rem); white-space: nowrap; }
  .adg-detail-remind { white-space: normal; margin: 12px 0; }
  .adg-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
  .adg-facts dt { color: var(--text-muted); }
  .adg-facts dd { margin: 0; word-break: break-word; }
  .adg-detail-renew { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
  .adg-subhead { font-size: var(--font-size-md, .9375rem); margin: 16px 0 8px; }
  .adg-activity { list-style: none; margin: 0; padding: 0; }
  .adg-activity li { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--border); }
  .adg-activity li:first-child { border-top: 0; }
  .adg-activity-when { color: var(--text-muted); min-width: 150px; }
  .adg-activity-what { font-weight: 600; }
  .adg-people-input { width: 100%; box-sizing: border-box; }
  .adg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .adg-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: var(--font-size-sm, .8125rem);
  }
  .adg-chip-note { color: var(--text-muted); font-size: 11px; }
  .adg-chip-note.is-warn { color: var(--warning); }
  .adg-chip-x {
    padding: 0 6px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
  }
  .adg-chip-x:hover { color: var(--danger); }
  .adg-summary-line { margin: 12px 0 0; font-weight: 600; }

  .portal-admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .75rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .portal-admin-badge.is-admin  { background: rgba(245,51,63,.1); color: #F5333F; border: 1px solid rgba(245,51,63,.3); }
  .portal-admin-badge.not-admin { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

  .toggle-active {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: .8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    white-space: normal;
  }
  .toggle-active input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

  .notes-input {
    padding: 5px 8px;
    font-size: .78rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .notes-input:focus { outline: none; border-color: var(--accent); }

  .save-btn {
    padding: 5px 14px;
    font-size: .8rem;
    font-weight: 600;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: rgba(var(--accent-rgb),.08);
    color: var(--accent);
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
  }
  .save-btn:hover    { background: rgba(var(--accent-rgb),.16); }
  .save-btn:disabled { opacity: .4; cursor: not-allowed; }
  .save-btn.success  { border-color: #2D9B5A; color: #2D9B5A; background: rgba(45,155,90,.08); }
  .save-btn.error    { border-color: #F5333F; color: #F5333F; background: rgba(245,51,63,.08); }

  .last-access   { font-size: var(--font-size-xs, .75rem); color: var(--text-muted); white-space: nowrap; }
  .access-count  { font-size: var(--font-size-sm, .875rem); color: var(--text-muted); text-align: right; }
  .updated-by {
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 168px;
  }

  /* ── Roles column (Users tables) ──────────────────────────────────────────
     Product label followed by its role pills, one group per product, groups
     wrapping. Both are buttons: clicking either applies that filter, which is
     why they carry focus styling rather than being plain text. */
  .user-roles-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: center;
    max-width: 420px;
  }

  .user-role-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
  }

  .user-role-product {
    font-size: var(--font-size-xs, .75rem);
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
  }
  .user-role-product:hover,
  .user-role-product:focus-visible { color: var(--accent); text-decoration: underline; }

  /* .access-select sets width:100% for the real <select> on the grantor roster. These
     are buttons, so unlike the inline <span> pills there it would actually apply. */
  .user-role-pill {
    width: auto;
    padding: 2px 7px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .user-role-pill:hover { background: var(--surface-2, rgba(127, 127, 127, 0.07)); }

  /* ── Users filter bar ─────────────────────────────────────────────────────
     Shared .filters / .filter-group / .toggle-chip from styles.css; only the
     per-chip tally is local. */
  .users-filters { padding: var(--space-4, 14px) var(--space-5, 18px); }

  .users-chip-count {
    display: inline-block;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--surface-2, rgba(127, 127, 127, 0.1));
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
  }
  .toggle-chip.checked .users-chip-count { color: var(--text-primary, var(--text)); }

  /* Full-width row under the chips. Product and Role are coupled, so the combination is
     spelled out — an empty list then reads as an answer rather than a fault. */
  .users-filter-summary {
    flex: 1 1 100%;
    margin: 0;
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
  }
  .users-filter-summary[hidden] { display: none; }

  /* Excluded chip. The sign carries the meaning on its own — the colour and the rule
     through the label are reinforcement, for the benefit of anyone who cannot use them. */
  .toggle-chip.excluded {
    background: rgba(245, 51, 63, .09);
    border-color: rgba(245, 51, 63, .4);
    color: var(--text-primary, var(--text));
    text-decoration: line-through;
    text-decoration-color: rgba(245, 51, 63, .7);
  }
  .toggle-chip.excluded:hover { background: rgba(245, 51, 63, .15); }

  .users-chip-sign {
    display: inline-block;
    margin-right: 5px;
    font-weight: 700;
    text-decoration: none;
  }
  .toggle-chip.checked .users-chip-sign { color: var(--accent); }
  .toggle-chip.excluded .users-chip-sign { color: #f5333f; }
  .toggle-chip.excluded .users-chip-count { text-decoration: none; }

  /* ── Sortable column headers ───────────────────────────────────────────────
     Same shape as the Migration and EDC tables: click to sort, click again to
     reverse, one column at a time. */
  #section-users th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  #section-users th[data-sort]:hover { color: var(--text-primary, var(--text)); }
  #section-users th[data-sort].is-sorted { color: var(--accent); }
  #section-users th[data-sort] .sort-ind { font-size: .7rem; }

  /* ── Bulk role selection ──────────────────────────────────────────────────── */
  .user-select-col {
    width: 34px;
    text-align: center;
    padding-right: 0;
  }
  .user-select-col input[type="checkbox"] { cursor: pointer; margin: 0; }

  tr.user-row-clickable.is-selected {
    background: rgba(var(--accent-rgb), .1);
  }

  .users-bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: var(--space-4, 14px);
    padding: 10px 14px;
    border: 1px solid rgba(var(--accent-rgb), .32);
    border-radius: var(--radius-md, 8px);
    background: rgba(var(--accent-rgb), .08);
  }
  .users-bulk-bar[hidden] { display: none; }

  .users-bulk-count {
    font-size: var(--font-size-sm, .875rem);
    font-weight: 700;
    color: var(--text-primary, var(--text));
  }

  /* Loud on purpose. Replacing roles for a selection is the one action on this page
     that cannot be walked back from the UI. */
  .bulk-warning {
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid rgba(245, 51, 63, .34);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: rgba(245, 51, 63, .08);
    font-size: var(--font-size-sm, .875rem);
    line-height: 1.5;
    color: var(--text-primary, var(--text));
  }

  .bulk-targets {
    margin: 0 0 14px;
    font-size: var(--font-size-sm, .875rem);
  }
  .bulk-targets summary {
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
  }
  .bulk-targets ul {
    margin: 8px 0 0;
    padding: 0 0 0 18px;
    max-height: 190px;
    overflow-y: auto;
  }
  .bulk-targets li { margin-bottom: 4px; }
  .bulk-target-email {
    margin-left: 8px;
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
  }

  .bulk-ack {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 14px 0 0;
    font-size: var(--font-size-sm, .875rem);
    line-height: 1.45;
    cursor: pointer;
  }
  .bulk-ack input[type="checkbox"] { margin-top: 3px; flex: 0 0 auto; cursor: pointer; }

  /* ── Role grant provenance ────────────────────────────────────────────────
     Popover anchored to a role pill (right-click), plus the report table in the
     Audit tab. */
  .grant-popover {
    position: absolute;
    z-index: 60;
    max-width: 320px;
    padding: 11px 13px;
    border: 1px solid var(--border-strong, var(--border));
    border-radius: var(--radius-md, 8px);
    background: var(--surface-1, var(--surface));
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    font-size: var(--font-size-sm, .875rem);
  }
  .grant-popover[hidden] { display: none; }
  .grant-popover .gp-title {
    margin: 0 0 5px;
    font-weight: 700;
    color: var(--text-primary, var(--text));
  }
  .grant-popover .gp-note {
    margin: 0 0 10px;
    color: var(--text-muted);
    line-height: 1.45;
  }

  .prov-sub {
    margin-left: 7px;
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
  }

  /* Revoked rows stay legible but clearly historical — they are the only record of
     access somebody used to hold, so they are not greyed into invisibility. */
  tr.prov-revoked { opacity: .62; }
  tr.prov-revoked .user-role-pill { text-decoration: line-through; }

  .user-modal-box {
    width: min(680px, calc(100vw - 32px));
    max-width: 100%;
  }
  @media (min-width: 1100px) {
    .user-modal-box { width: min(760px, calc(100vw - 48px)); }
  }
  @media (min-width: 1400px) {
    .user-modal-box { width: min(820px, calc(100vw - 64px)); }
  }

  /* Tab strip between the modal header and its scrolling body. */
  .um-tabs {
    flex: 0 0 auto;
    padding: 0 24px;
    margin-bottom: 0;
  }

  /* ── Access matrix ───────────────────────────────────────────────────────
     One row per product, one column per level, a radio in each cell. Radios
     rather than checkboxes despite the square look: a product has exactly one
     level, and a radio group is what says that to both the browser and a
     screen reader. Checkboxes would allow a state the data model cannot hold.

     Eight columns inside an 860px modal is tight, so headers wrap and the
     whole table scrolls sideways rather than squeezing below legibility. */
  .um-matrix-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }

  /* Fixed layout so the eight level columns share the space evenly and long headers
     wrap instead of widening the table. With auto layout "Prof Services" and
     "Development" each claimed ~125px on one line, pushing the total to 919px inside
     an 808px modal — Super User fell off the right edge entirely. */
  .um-matrix {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.74rem;
  }

  /* Scoped through .modal-body deliberately. `.modal-body table th` in styles.css is
     (0,1,2) and sets uppercase plus a 14px font on every th in a modal, which clipped
     "Prof Services" to "PROF SERV" and ran "Certificate Manager" across the first
     radio. A bare `.um-matrix th` is (0,1,1) and loses; this is (0,2,1) and wins.
     Overridden here rather than loosened globally — the other modal tables want it. */
  .modal-body .um-matrix th,
  .modal-body .um-matrix td {
    border-bottom: 1px solid var(--border);
    padding: 7px 2px;
    text-align: center;
    white-space: normal;
    text-transform: none;
    font-size: 0.74rem;
    letter-spacing: 0;
  }

  .modal-body .um-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2, var(--surface));
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.15;
    vertical-align: bottom;
    padding-bottom: 8px;
    cursor: default;
  }

  /* Product name column: left aligned, holds its own background so the row label
     stays readable while the table scrolls under it on a narrow viewport. */
  .modal-body .um-matrix th[scope="row"],
  .modal-body .um-matrix thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 124px;
    text-align: left;
    padding-left: 12px;
    padding-right: 8px;
    background: var(--surface);
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    cursor: default;
  }

  .modal-body .um-matrix thead th:first-child {
    z-index: 3;
    background: var(--surface-2, var(--surface));
  }

  .um-matrix tbody tr:last-child th,
  .um-matrix tbody tr:last-child td { border-bottom: none; }

  .um-matrix tbody tr:hover th[scope="row"],
  .um-matrix tbody tr:hover td { background: rgba(127, 127, 127, 0.06); }

  .um-matrix input[type="radio"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent, #3b82f6);
  }

  /* A role that holds no permissions yet. Shown rather than hidden so the matrix
     stays the same shape for every product and the gap is explained by the tooltip,
     instead of a column silently going missing. */
  .um-matrix input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.25;
  }

  .um-matrix td.is-unavailable { background: repeating-linear-gradient(
      45deg, transparent, transparent 4px,
      rgba(127, 127, 127, 0.07) 4px, rgba(127, 127, 127, 0.07) 8px); }

  /* Read Only, ticked because another role implies it. Disabled like an unavailable
     cell but not hatched and not faded — it is granted, not withheld, and reading it
     as "off" would be exactly wrong. */
  .um-matrix td.is-implied { background: rgba(56, 139, 253, 0.07); }
  .um-matrix td.is-implied input[type="checkbox"]:disabled {
    cursor: help;
    opacity: 0.6;
  }

  /* Specialty roles grant only what has been assigned to them, so the header is
     tinted to set them apart. */
  .um-matrix th.is-specialty { color: var(--accent-2, #c2410c); }

  .um-matrix-legend,
  .um-matrix-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
  }

  .um-matrix-legend { margin: 8px 0 0; }

  .um-matrix-summary {
    margin: 10px 0 0;
    padding: 9px 11px;
    background: var(--surface-2, rgba(127, 127, 127, 0.06));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }

  .um-matrix-summary strong { color: var(--text); font-weight: 600; }
  .um-matrix-summary .um-sum-none { color: var(--text-muted); }
  .um-matrix-summary .um-sum-item { white-space: nowrap; }

  /* Grants page: a grantor picks any subset of the roles they hold, so the single
     role dropdown became a checkbox group. Admin reuses it to appoint a grantor for
     several products at once. Both wrap rather than scroll. */
  .grant-role-set,
  .pg-product-set {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2, rgba(127, 127, 127, 0.04));
  }

  .grant-role-opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .grant-role-opt input { cursor: pointer; margin: 0; }

  .grant-ack {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .grant-ack label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: var(--font-size-sm);
    color: var(--text);
    cursor: pointer;
  }

  .grant-ack[hidden] { display: none; }

  /* .modal-field is display:flex, which outranks the UA [hidden] rule. */
  #grant-modal .modal-field[hidden],
  #grant-modal .admin-table-wrap[hidden],
  #grant-modal-person[hidden] { display: none; }

  /* The product picker sits inline with the user select and the Add button, and has
     thirteen options, so it takes the free width and wraps under them. */
  .pg-toolbar .toolbar-left { flex-wrap: wrap; align-items: center; }
  .pg-product-set { flex: 1 1 340px; min-width: 260px; }

  /* Anchors the suggestion list. Absolute rather than fixed, unlike the AdHoc pattern
     box: that one lives in a scrolling modal and has to be re-placed as it moves, while
     this sits in a toolbar that stays put. */
  .pg-combo { position: relative; }

  /* Sizes to its content, not to the input. The useful half of a row is the email and
     the products the person already covers, and pinning the list to a 240px box
     truncated exactly that. */
  .pg-combo-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(460px, 90vw);
    z-index: 40;
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  }

  .pg-combo-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 10px;
    cursor: pointer;
    border-top: 1px solid var(--border);
  }

  .pg-combo-item:first-child { border-top: 0; }
  .pg-combo-item.active { background: rgba(59, 130, 246, 0.12); }
  .pg-combo-name { font-size: 0.82rem; }

  .pg-combo-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pg-combo-empty {
    padding: 8px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  [data-theme="dark"] .pg-combo-list {
    background: #161B22;
    border-color: #30363D;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }

  [data-theme="dark"] .pg-combo-item.active { background: rgba(59, 130, 246, 0.22); }

  /* Authority is per product, so one person can hold several rows. Grouping under a
     product heading keeps that readable without repeating the product on every row,
     and without pretending the rows are a single record. */
  .pg-group-row th {
    background: var(--surface-2, rgba(127, 127, 127, 0.07));
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
    padding: 7px 12px;
    border-top: 1px solid var(--border);
  }

  .pg-group-count {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-1, rgba(127, 127, 127, 0.14));
    color: var(--text-muted);
    font-size: 0.68rem;
  }

  /* Several level pills per grantor now, so let them wrap instead of stretching. */
  .pg-grantable { line-height: 2; }

  .user-modal-subtitle {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    margin-top: 4px;
    word-break: break-all;
  }

  .modal-section-title {
    font-size: var(--font-size-xs, .75rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 18px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .modal-section-title:first-child { margin-top: 0; }

  .user-modal-portal-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
  }

  .user-modal-portal-row .hint {
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
    line-height: 1.45;
  }

  .modal-section-title.danger {
    color: var(--danger, #ef4444);
    border-bottom-color: rgba(var(--danger-rgb, 239, 68, 68), .35);
  }

  .user-delete-zone {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(var(--danger-rgb, 239, 68, 68), .28);
    background: rgba(var(--danger-rgb, 239, 68, 68), .06);
    margin-bottom: 4px;
  }

  .user-delete-zone .hint {
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
    line-height: 1.45;
  }

  #user-modal-error {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #ef4444;
    font-size: var(--font-size-sm, .875rem);
  }

  #fb-edit-modal-error {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #ef4444;
    font-size: var(--font-size-sm, .875rem);
  }

  .fb-edit-description {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg2, var(--surface-2));
    color: var(--text-muted);
    font-size: var(--font-size-sm, .875rem);
    line-height: 1.45;
    white-space: pre-wrap;
    max-height: 160px;
    overflow: auto;
  }

  #user-modal .modal-field textarea.notes-input,
  #fb-edit-modal .modal-field textarea.notes-input {
    min-height: 88px;
    resize: vertical;
    font-family: inherit;
    font-size: var(--font-size-sm, .875rem);
  }

  /* ── Product badge (audit log table) ── */
  .product-badge {
    font-size: var(--font-size-xs, .75rem);
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .badge-sp   { background: rgba(37,99,235,.12);  color: #2563eb; border: 1px solid rgba(37,99,235,.25); }
  .badge-hz   { background: rgba(22,163,74,.12);  color: #16a34a; border: 1px solid rgba(22,163,74,.25); }
  .badge-dd   { background: rgba(124,58,237,.12); color: #7c3aed; border: 1px solid rgba(124,58,237,.25); }
  .badge-ddqa { background: rgba(217,119,6,.12);  color: #d97706; border: 1px solid rgba(217,119,6,.25); }
  .badge-inactive { opacity: .55; }

  /* ── Audit logs table ── */
  .audit-table-wrap {
    background: var(--glass-bg, var(--surface));
    border: 1px solid var(--glass-border, var(--border));
    border-radius: var(--radius-lg, var(--radius));
    box-shadow: var(--glass-shadow, var(--shadow-sm));
    overflow: hidden;
  }

  .audit-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm, .875rem);
  }

  .audit-table-wrap th {
    padding: var(--space-3, 12px) var(--space-4, 14px);
    text-align: left;
    font-weight: var(--font-weight-bold, 600);
    color: var(--text-muted);
    font-size: var(--font-size-xs, .75rem);
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--surface-2, var(--bg2));
    border-bottom: 1px solid var(--border-subtle, var(--border));
    white-space: nowrap;
  }

  .audit-table-wrap td {
    padding: var(--space-3, 10px) var(--space-4, 14px);
    border-bottom: 1px solid var(--border-subtle, var(--border));
    color: var(--text-secondary, var(--text));
    vertical-align: middle;
    word-break: normal;
  }

  .audit-table-wrap tr:last-child td { border-bottom: none; }

  tr.audit-row-clickable {
    cursor: pointer;
    transition: background .12s;
  }

  tr.audit-row-clickable:hover td {
    background: rgba(var(--action-rgb, var(--accent-rgb)), .06);
  }

  .audit-ts {
    font-family: var(--eci-font-family-mono, monospace);
    font-size: var(--font-size-sm, .875rem);
    white-space: nowrap;
    color: var(--text-primary, var(--text));
  }

  .audit-actor {
    font-size: var(--font-size-sm, .875rem);
    word-break: break-all;
    overflow-wrap: anywhere;
    color: var(--text-primary, var(--text));
  }

  .action-badge {
    display: inline-flex;
    padding: var(--space-1, 2px) var(--space-3, 8px);
    border-radius: 999px;
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-semibold, 600);
    background: var(--surface-2, var(--bg2));
    border: 1px solid var(--border-subtle, var(--border));
    color: var(--text-primary, var(--text));
    white-space: nowrap;
  }

  .audit-status-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1, 2px) var(--space-3, 10px);
    border-radius: 999px;
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-bold, 600);
    white-space: nowrap;
    line-height: 1.3;
    text-transform: capitalize;
  }

  .audit-status-success {
    background: rgba(var(--success-rgb, 69, 201, 138), .14);
    color: var(--success, #45c98a);
    border: 1px solid rgba(var(--success-rgb, 69, 201, 138), .28);
  }

  .audit-status-failure {
    background: rgba(var(--danger-rgb, 242, 85, 95), .14);
    color: var(--danger, #f2555f);
    border: 1px solid rgba(var(--danger-rgb, 242, 85, 95), .28);
  }

  .audit-status-neutral {
    background: var(--surface-2, var(--bg2));
    color: var(--text-muted);
    border: 1px solid var(--border-subtle, var(--border));
  }

  .audit-filter-row {
    display: flex;
    gap: var(--space-4, 10px);
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: var(--space-4, 16px);
    padding: var(--space-5, 16px);
    background: var(--glass-bg, var(--surface));
    border: 1px solid var(--glass-border, var(--border));
    border-radius: var(--radius-lg, var(--radius));
    box-shadow: var(--glass-shadow, var(--shadow-sm));
  }

  .filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 4px);
  }

  .filter-group label {
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
  }

  .filter-group input,
  .filter-group select {
    padding: var(--space-2, 7px) var(--space-3, 10px);
    font-size: var(--font-size-md, .9375rem);
    min-height: var(--control-height-md, 40px);
    border: 1px solid var(--border-strong, var(--border));
    border-radius: var(--radius-md, var(--radius-sm));
    background: var(--surface-1, var(--bg));
    color: var(--text-primary, var(--text));
    font-family: inherit;
    min-width: 120px;
    box-sizing: border-box;
  }

  .filter-group input:focus,
  .filter-group select:focus {
    outline: none;
    border-color: var(--action, var(--accent));
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(var(--accent-rgb),.1));
  }

  .audit-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    margin-top: var(--space-4, 14px);
    flex-wrap: wrap;
  }

  .audit-pagination span { font-size: var(--font-size-sm, .875rem); color: var(--text-muted); }

  .audit-detail-kv {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border-subtle, var(--border));
    border: 1px solid var(--border-subtle, var(--border));
    border-radius: var(--radius-md, var(--radius-sm));
    overflow: hidden;
    margin-bottom: var(--space-4, 14px);
  }

  .audit-detail-kv .kv-item {
    background: var(--surface-1, var(--surface));
    padding: var(--space-3, 10px) var(--space-4, 14px);
  }

  .audit-detail-kv .kv-key {
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: var(--space-1, 4px);
    font-weight: var(--font-weight-semibold, 600);
  }

  .audit-detail-kv .kv-val {
    font-size: var(--font-size-md);
    color: var(--text-primary, var(--text));
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .audit-detail-kv .kv-val.mono {
    font-family: var(--eci-font-family-mono, monospace);
    font-size: var(--font-size-sm);
  }

  .audit-detail-block {
    margin-top: var(--space-4, 14px);
  }

  .audit-detail-block label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: var(--space-2, 6px);
  }

  .audit-detail-pre {
    margin: 0;
    padding: var(--space-4, 12px);
    background: var(--surface-2, var(--bg2));
    border: 1px solid var(--border-subtle, var(--border));
    border-radius: var(--radius-md, var(--radius-sm));
    font-family: var(--eci-font-family-mono, monospace);
    font-size: var(--font-size-sm);
    color: var(--text-secondary, var(--text));
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
  }

  /* ── Collapsible maintenance ── */
  .collapsible-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    padding: 14px 0 10px;
    border-top: 1px solid var(--border);
    margin-top: 32px;
  }
  .collapsible-header .chevron { transition: transform .2s; display: inline-block; }
  .collapsible-header.open .chevron { transform: rotate(90deg); }
  .collapsible-body { display: none; }
  .collapsible-body.open { display: block; }

  /* ── Modal ── */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
  }
  .modal-overlay.open { display: flex; }

  /* The box is capped and the BODY scrolls, so the footer — which holds Save — stays
     on screen however tall the content gets. Without the cap the box grew, the
     overlay scrolled instead, and Save ended up below the fold with the cursor off
     the modal. The 48px matches the overlay's 24px top/bottom padding. */
  .modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: min(860px, 100%);
    max-width: 100%;
    margin: auto;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
  }

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

  .modal-header h2 { font-size: var(--font-size-xl); font-weight: 700; color: var(--text); }

  .modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    padding: 0 4px;
  }
  .modal-close:hover { color: var(--text); }

  .modal-body {
    padding: 20px 24px;
    font-size: var(--font-size-md);
    line-height: var(--line-height-normal);
    /* min-height:0 is what actually lets a flex child scroll rather than stretch. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  @media (max-width: 600px) {
    .audit-detail-kv { grid-template-columns: 1fr; }
  }

  .modal-field input:focus,
  .modal-field select:focus,
  .modal-field textarea:focus { outline: none; border-color: var(--accent); }

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

  /* Admin buttons inherit styles.css; local overrides only where needed */
  #user-modal .btn-primary {
    background: var(--action, var(--accent));
    color: var(--action-text, #fff);
  }

  .btn-sm {
    padding: var(--space-2, 6px) var(--space-3, 12px);
    font-size: var(--font-size-sm, .875rem);
    min-height: var(--control-height-sm, 34px);
  }

  /* ── Common ── */
  .empty-state, .loading-state {
    padding: 60px 28px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-md, .9375rem);
  }

  .loading-state .loading-inline {
    justify-content: center;
  }

  .loading-state:not(:has(.spinner)):not(:has(.kv-loading))::before {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    margin: 0 auto 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
  }

  .section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }

  .access-denied {
    max-width: 520px;
    margin: 80px auto;
    text-align: center;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .access-denied h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 8px; }
  .access-denied p  { font-size: .88rem; color: var(--text-muted); }

  /* ── Dark mode ── */
  [data-theme="dark"] .page-hero { background: linear-gradient(135deg, #161B22 0%, #0D1117 100%); border-bottom-color: #21262D; }
  [data-theme="dark"] thead tr  { background: #0D1117; border-bottom-color: #21262D; }
  [data-theme="dark"] td        { border-bottom-color: #21262D; }
  [data-theme="dark"] .admin-table-wrap { border-color: #30363D; }
  [data-theme="dark"] .audit-table-wrap { border-color: #30363D; }
  [data-theme="dark"] .access-select { background: #161B22; border-color: #30363D; }
  [data-theme="dark"] .notes-input   { background: #161B22; border-color: #30363D; }
  [data-theme="dark"] .search-input  { background: #161B22; border-color: #30363D; color: #E6EDF3; }
  [data-theme="dark"] .modal-box     { background: #161B22; border-color: #30363D; }
  [data-theme="dark"] .modal-field input,
  [data-theme="dark"] .modal-field select,
  [data-theme="dark"] .modal-field textarea { background: #0D1117; border-color: #30363D; color: #E6EDF3; }
  [data-theme="dark"] .filter-group input,
  [data-theme="dark"] .filter-group select  { background: #0D1117; border-color: #30363D; color: #E6EDF3; }
  [data-theme="dark"] .access-denied { background: #161B22; border-color: #30363D; }

  footer { text-align: center; padding: 32px 28px; color: var(--text-muted); font-size: .82rem; border-top: 1px solid var(--border); margin-top: 48px; }
  [data-theme="dark"] footer { border-top-color: #21262D; color: #6E7681; }

  /* ── Usage Dashboard ── */
  .usage-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3, 10px);
    margin-bottom: var(--space-5, 20px);
  }

  .usage-toolbar-title {
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary, var(--text));
  }

  .usage-toolbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3, 10px);
    flex-wrap: wrap;
  }

  .usage-toolbar-actions select {
    padding: var(--space-2, 7px) var(--space-3, 10px);
    font-size: var(--font-size-md, .9375rem);
    min-height: var(--control-height-md, 40px);
    border: 1px solid var(--border-strong, var(--border));
    border-radius: var(--radius-md, var(--radius-sm));
    background: var(--surface-1, var(--surface));
    color: var(--text-primary, var(--text));
    font-family: inherit;
  }

  .usage-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4, 14px);
    margin-bottom: var(--space-6, 28px);
  }

  .usage-stat-card {
    background: var(--glass-bg, var(--surface));
    border: 1px solid var(--glass-border, var(--border));
    border-radius: var(--radius-lg, var(--radius));
    box-shadow: var(--glass-shadow, var(--shadow-sm));
    padding: var(--space-5, 16px) var(--space-5, 18px);
    display: flex;
    flex-direction: column;
    gap: var(--space-1, 4px);
  }

  .usage-stat-label {
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
  }

  .usage-stat-value {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary, var(--text));
    line-height: 1.2;
  }

  .usage-stat-sub {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
  }

  .usage-section-title {
    font-size: var(--font-size-md, .9375rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary, var(--text));
    margin: 0 0 var(--space-3, 12px);
    padding-bottom: var(--space-2, 8px);
    border-bottom: 1px solid var(--border-subtle, var(--border));
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
  }

  .usage-panel {
    background: var(--glass-bg, var(--surface));
    border: 1px solid var(--glass-border, var(--border));
    border-radius: var(--radius-lg, var(--radius));
    box-shadow: var(--glass-shadow, var(--shadow-sm));
    padding: var(--space-5, 16px);
    margin-bottom: var(--space-5, 20px);
  }

  .usage-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5, 20px);
    margin-bottom: var(--space-5, 24px);
  }

  @media (max-width: 860px) { .usage-grid-2 { grid-template-columns: 1fr; } }

  .usage-grid-2 > .usage-panel { display: flex; flex-direction: column; margin-bottom: 0; }
  .usage-grid-2 > .usage-panel > .usage-donut-host { flex: 1; display: flex; align-items: center; }
  .usage-donut-host > .usage-donut-wrap { width: 100%; }

  .usage-donut-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-6, 24px);
    flex-wrap: wrap;
  }

  .usage-donut {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
  }

  .usage-donut-hole {
    position: absolute;
    inset: 30%;
    border-radius: 50%;
    background: var(--surface-1, var(--surface));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
    padding: 4px;
  }

  .usage-donut-legend {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
  }

  .usage-legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-secondary, var(--text));
  }

  .usage-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
  }

  .usage-legend-count {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: var(--font-size-sm, .875rem);
  }

  .usage-ranked-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 6px);
  }

  .usage-ranked-list li {
    display: flex;
    align-items: center;
    gap: var(--space-3, 10px);
    padding: var(--space-2, 8px) var(--space-3, 10px);
    background: var(--surface-2, var(--bg2));
    border: 1px solid var(--border-subtle, var(--border));
    border-radius: var(--radius-md, var(--radius-sm));
    font-size: var(--font-size-sm, .875rem);
  }

  .usage-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-1, var(--surface));
    border: 1px solid var(--border-subtle, var(--border));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .usage-rank-label {
    flex: 1;
    min-width: 0;
    color: var(--text-primary, var(--text));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .usage-rank-val {
    font-weight: var(--font-weight-semibold, 600);
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .usage-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm, .875rem);
  }

  .usage-mini-table th {
    text-align: left;
    padding: var(--space-2, 8px) var(--space-3, 10px);
    font-size: var(--font-size-xs, .75rem);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle, var(--border));
  }

  .usage-mini-table td {
    padding: var(--space-2, 8px) var(--space-3, 10px);
    border-bottom: 1px solid var(--border-subtle, var(--border));
    color: var(--text-secondary, var(--text));
    vertical-align: middle;
  }

  .usage-mini-table tr:last-child td { border-bottom: none; }

  .usage-mini-table .usage-user-cell {
    word-break: break-all;
    overflow-wrap: anywhere;
    color: var(--text-primary, var(--text));
  }

  .usage-perm-badge {
    font-size: var(--font-size-xs, .75rem);
    font-weight: var(--font-weight-bold, 700);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .perm-super_user    { background: rgba(45,155,90,.12);  color: #2D9B5A; border: 1px solid rgba(45,155,90,.25); }
  .perm-prof_services { background: rgba(124,58,237,.12); color: #7c3aed; border: 1px solid rgba(124,58,237,.25); }
  .perm-support       { background: rgba(217,119,6,.12);  color: #d97706; border: 1px solid rgba(217,119,6,.25); }
  .perm-read_only     { background: rgba(100,149,237,.12);color: #6495ED; border: 1px solid rgba(100,149,237,.25); }
  .perm-none          { background: var(--bg2); color: var(--text-muted); border: 1px solid var(--border); }

  .usage-trend-wrap { overflow-x: hidden; max-width: 100%; }
  .usage-trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding: var(--space-2, 4px) 0;
    min-width: 0;
    width: 100%;
  }

  .usage-trend-bar {
    flex: 1 1 0;
    min-width: 3px;
    width: auto;
    border-radius: 4px 4px 0 0;
    background: var(--action, var(--accent));
    opacity: .82;
    cursor: default;
    transition: opacity .15s, transform .15s;
  }

  .usage-trend-bar:hover { opacity: 1; transform: translateY(-2px); }

  .usage-trend-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
    margin-top: var(--space-2, 4px);
  }

  .usage-empty {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    padding: var(--space-3, 10px) 0;
  }

  .usage-note {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    margin: 0 0 var(--space-4, 14px);
  }

  .usage-section-heading {
    font-size: var(--font-size-lg, 1.1rem);
    font-weight: 600;
    color: var(--text-primary, var(--text));
    margin: var(--space-6, 28px) 0 var(--space-4, 14px);
    padding-bottom: var(--space-2, 8px);
    border-bottom: 1px solid var(--border-subtle, var(--border));
  }

  .usage-mini-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .usage-mini-table .usage-sub {
    display: block;
    font-size: var(--font-size-xs, .75rem);
    color: var(--text-muted);
  }

  .usage-mini-table .usage-bad { color: var(--danger, #dc2626); }

  .usage-adopt-bar {
    position: relative;
    height: 8px;
    min-width: 120px;
    border-radius: 4px;
    background: var(--border-subtle, var(--border));
    overflow: hidden;
  }

  .usage-adopt-bar span {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 4px;
  }

  .usage-adopt-bar .acted { background: var(--accent, #6495ED); }

  .usage-scroll { max-height: 420px; overflow-y: auto; }

  /* ── Reports ── */
  .reports-builder {
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-5, 20px);
    margin-bottom: var(--space-5, 20px);
  }

  .reports-builder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4, 16px);
    align-items: end;
  }

  .reports-desc {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
    margin: var(--space-3, 10px) 0 var(--space-4, 16px);
    line-height: 1.5;
  }

  .reports-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3, 10px);
    margin-top: var(--space-4, 16px);
    padding-top: var(--space-4, 16px);
    border-top: 1px solid var(--border-subtle);
  }

  .reports-preview-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 10px);
    margin-bottom: var(--space-3, 10px);
  }

  .reports-preview-title {
    font-size: var(--font-size-md, .9375rem);
    font-weight: var(--font-weight-semibold, 600);
  }

  .reports-preview-meta {
    font-size: var(--font-size-sm, .875rem);
    color: var(--text-muted);
  }

  .reports-export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2, 8px);
  }

  .reports-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    max-height: 480px;
    overflow-y: auto;
  }
  @media (max-width: 768px) {
    .reports-table-wrap { overflow-x: hidden; }
  }

  .reports-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm, .875rem);
  }

  .reports-table-wrap th,
  .reports-table-wrap td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
  }

  .reports-table-wrap th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    font-size: var(--font-size-xs, .75rem);
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    z-index: 1;
  }

  .reports-table-wrap tr:last-child td { border-bottom: none; }

  .reports-truncated-warn {
    margin-top: var(--space-3, 10px);
    font-size: var(--font-size-sm, .875rem);
    color: var(--warning, #d97706);
  }

/* ── Role policy grid ─────────────────────────────────────────────────────────
   A role's permissions as component (rows) by action (columns). The grid shape is
   the point: a role is legible as an area rather than as a list of names, and the
   gaps are as informative as the ticks. */

/* Fixed layout, not auto. The component gloss is a sentence, and an auto-layout table
   treats max-width on a cell as a suggestion — the column took the width of the longest
   gloss and the text ran across the action columns instead of wrapping under itself. */
.rp-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.rp-grid th[scope="col"] {
  text-align: left;
  font-size: var(--font-size-xs, .75rem);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}

.rp-grid col.rp-col-component { width: 30%; }
.rp-grid col.rp-col-action { width: 23.33%; }

/* Column headers get `text-transform: uppercase; letter-spacing: .05em; white-space:
   nowrap` from `.admin-table-wrap th`, which is right for a heading and wrong for a row
   label: it rendered every component name and gloss as spaced-out grey capitals that
   could not wrap, so the sentence ran across the action columns instead of under itself.
   Selector is `.rp-grid .rp-component` rather than `.rp-component` because the grid sits
   inside `.admin-table-wrap` and needs to out-specify that rule. */
.rp-grid .rp-component {
  text-align: left;
  vertical-align: top;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  font-weight: 400;
  color: var(--text);
  font-size: var(--font-size-sm, .875rem);
  padding: var(--space-3, 10px) var(--space-4, 14px);
}

.rp-component-name {
  display: block;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 600;
  color: var(--text);
}

/* The component list is closed and its members are abbreviations, so the gloss is
   not decoration — without it "d1" and "link" are guesses. */
.rp-component-gloss {
  display: block;
  margin-top: 2px;
  font-size: var(--font-size-xs, .75rem);
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-muted);
  white-space: normal;
  overflow-wrap: anywhere;
}

.rp-cell {
  vertical-align: top;
  border-left: 1px solid var(--border);
  padding: var(--space-3, 10px) var(--space-4, 14px);
}

/* A component this product does not touch. Muted rather than absent, so the grid
   keeps its shape and an empty cell reads as "nothing here" rather than "not
   loaded yet". */
.rp-cell-empty {
  color: var(--text-muted);
  text-align: center;
}

.rp-cell.is-all { background: var(--accent-soft, rgba(59, 130, 246, .10)); }
.rp-cell.is-partial { background: var(--surface-2, rgba(127, 127, 127, .05)); }

/* Every box ticked, one by one. Grants what `is-all` grants today and stops covering it
   the moment the component gains a permission, so it must not wear the same tint. The
   dashed count is the tell: a list that ends where it is, rather than a rule that keeps
   going. */
.rp-cell.is-complete { background: var(--surface-2, rgba(127, 127, 127, .05)); }
.rp-cell.is-complete .rp-toggle {
  border-style: dashed;
  border-color: var(--border-strong, var(--border));
  color: var(--text);
}

.rp-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm, .875rem);
}

/* Same "hover me" convention as .rp-pick-known below. What separates a ticked cell from
   a full one is entirely in the future, and no checkbox has ever conveyed that. */
.rp-all-known {
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 3px;
  cursor: help;
}

.rp-all:hover .rp-all-known { text-decoration-color: var(--accent, var(--text)); }

.rp-toggle {
  margin-top: 4px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-xs, .75rem);
  cursor: pointer;
}

.rp-toggle:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.rp-toggle:disabled { opacity: .45; cursor: default; }

.rp-picks {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
}

.rp-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs, .75rem);
  font-family: var(--font-mono, ui-monospace, monospace);
}

.rp-pick input:disabled + span { opacity: .5; }

/* A tooltip nobody knows is there explains nothing. The dotted underline is the one
   convention people already read as "hover me"; permissions the catalogue cannot
   describe deliberately do not get it, so the absence is information too. */
.rp-pick-known {
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 3px;
  cursor: help;
}

.rp-pick:hover .rp-pick-known { text-decoration-color: var(--accent, var(--text)); }

.rp-stray {
  margin-top: var(--space-4, 14px);
  padding: var(--space-3, 10px) var(--space-4, 14px);
  border: 1px solid var(--warning, #d97706);
  border-radius: var(--radius-sm);
}

.rp-stray h4 { margin: 0 0 4px; font-size: var(--font-size-sm, .875rem); }

/* Review filters share the page width. The old toolbar spread each 280px field
   with space-between, so the last control on a row landed on the far edge. */
#review-section .review-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

#review-section .review-filters > .search-input,
#review-section .review-filters > .helix-search-wrap {
  width: 100%;
  max-width: none;
  min-width: 0;
}

#review-section .review-filters .btn {
  justify-self: start;
}

#review-section .review-ask {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 16px;
}

/* utils.js wraps the question in a 280px box. That box is the flex item, so it
   has to grow or Ask stays beside a short field. */
#review-section .review-ask > .helix-search-wrap,
#review-section .review-ask > .search-input {
  flex: 1 1 16rem;
  width: auto;
  max-width: none;
  min-width: 0;
}

/* Fixed columns so a long requestor or target wraps, and Open stays inside the
   table border. Auto layout let that last column fall past the frame. */
#review-section .review-table {
  table-layout: fixed;
  width: 100%;
}

#review-section .review-table th,
#review-section .review-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

#review-section .review-table th:nth-child(1) { width: 14%; }
#review-section .review-table th:nth-child(2) { width: 22%; }
#review-section .review-table th:nth-child(3) { width: 20%; }
#review-section .review-table th:nth-child(4) { width: 18%; }
#review-section .review-table th:nth-child(5) { width: 12%; }
#review-section .review-table th:nth-child(6) { width: 14%; }

#review-section .review-table tbody tr[data-review-id] {
  cursor: pointer;
}

#review-section .review-table tbody tr[data-review-id]:hover td {
  background: rgba(var(--accent-rgb, 30, 90, 175), .06);
}

#review-section .review-table tbody tr[data-review-id]:focus-visible {
  outline: 2px solid var(--accent, var(--action));
  outline-offset: -2px;
}

header.approvals-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

.approvals-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-left: auto;
}

.approvals-section-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--font-size-sm, .875rem);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm, 6px);
}

.approvals-section-nav a:hover,
.approvals-section-nav a[aria-current="true"] {
  color: var(--text-primary, var(--text));
  background: rgba(var(--accent-rgb, 30, 90, 175), .12);
}

.approvals-section-nav a[hidden] { display: none; }

.approvals-anchor { scroll-margin-top: 5.5rem; }

/* Approvals: a row's buttons share one size and one line, at the right of the row. */
.approval-row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2, 8px);
  white-space: nowrap;
}

.approval-row-actions .btn-sm,
.approval-row-actions a.btn-sm:visited {
  display: inline-flex;
  align-items: center;
  color: var(--text-primary);
  text-decoration: none;
}

.approval-row-actions .btn-cancel {
  color: var(--danger);
  border-color: rgba(var(--danger-rgb), 0.45);
}

.approval-row-actions .btn-cancel:hover {
  color: var(--danger);
  background: rgba(var(--danger-rgb), 0.12);
  border-color: var(--danger);
}

/* Admin → Nexus (helix-nexus-admin.js) */
.nexus-admin-h {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
}

.nexus-admin-error { color: var(--danger); }

.nexus-admin-notes {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-4);
  font-size: var(--font-size-sm);
}

/* Admin → Integrations (helix-integrations-admin.js) */
.integ-views {
  display: flex;
  gap: var(--space-2, 8px);
  margin-bottom: var(--space-3, 12px);
}

.integ-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
  align-items: end;
  margin-bottom: var(--space-3, 12px);
}

.integ-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--font-size-sm, .875rem);
  color: var(--text-muted);
}

.integ-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
}

.integ-toggle {
  display: grid;
  grid-template-columns: minmax(10rem, 16rem) auto auto 1fr;
  gap: var(--space-2, 8px);
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.integ-toggle:hover { background: rgba(var(--accent-rgb, 30, 90, 175), .06); }

.integ-name { font-weight: var(--font-weight-semibold, 600); }

.integ-summary {
  color: var(--text-muted);
  font-size: var(--font-size-sm, .875rem);
}

.integ-pill {
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  text-transform: lowercase;
}

.integ-pill-planned,
.integ-pill-partial { color: var(--text-muted); }

.integ-detail {
  padding: 4px 12px 12px 12px;
}

.integ-h {
  margin: var(--space-3, 12px) 0 var(--space-2, 8px);
  font-size: var(--font-size-md, 1rem);
}

.integ-features {
  margin: 0 0 var(--space-2, 8px);
  padding-left: var(--space-4, 16px);
}

.integ-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-2, 8px) var(--space-4, 16px);
  margin: var(--space-3, 12px) 0;
}

.integ-meta dt {
  color: var(--text-muted);
  font-size: var(--font-size-sm, .875rem);
}

.integ-meta dd { margin: 0; }

@media (max-width: 768px) {
  .integ-toggle { grid-template-columns: 1fr; }
}