/* Scoped permission editor: reuse the platform palette without affecting business forms. */
#modalContent:has(.permission-settings) { max-width: 1040px; width: calc(100vw - 32px); max-height: calc(100dvh - 32px); }
.permission-settings { color: var(--platform-text, #17211f); }
.permission-settings h3 { margin-bottom: 16px; }
.permission-role-group { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
.permission-role-group legend { width: 100%; padding: 8px 0; margin-bottom: 4px; border-bottom: 1px solid var(--platform-border, #dfe4df); font-size: 13px; font-weight: 700; }
.permission-role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.permission-role-option { display: flex; align-items: flex-start; gap: 10px; min-height: 64px; margin: 0; padding: 10px 12px; border: 1px solid var(--platform-border, #dfe4df); border-radius: 6px; background: var(--platform-surface, #fff); cursor: pointer; }
.permission-role-option:hover { border-color: var(--platform-accent, #0a7a43); }
.permission-role-option:has(input:checked) { border-color: var(--platform-accent, #0a7a43); background: var(--platform-surface-soft, #f3f7f4); }
.permission-role-option input, .permission-check-cell input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--platform-accent, #0a7a43); }
.permission-role-option span { min-width: 0; }
.permission-role-option strong { display: block; font-size: 13px; font-weight: 600; line-height: 20px; overflow-wrap: anywhere; }
.permission-role-option small { display: block; margin-top: 2px; font-size: 12px; line-height: 18px; color: var(--platform-muted, #66706d); overflow-wrap: anywhere; }
.permission-role-option.is-inactive { border-style: dashed; }
.permission-role-option:focus-within, .permission-check-cell:focus-within { outline: 2px solid var(--platform-accent, #0a7a43); outline-offset: 2px; }
.permission-note { color: var(--platform-muted, #66706d); font-size: 13px; }
.permission-matrix-scroll { max-height: 52dvh; overflow: auto; border: 1px solid var(--platform-border, #dfe4df); border-radius: 6px; isolation: isolate; }
.permission-settings .permission-matrix { table-layout: fixed; border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; font-size: 13px; }
.permission-settings .permission-matrix th, .permission-settings .permission-matrix td { box-sizing: border-box; padding: 0; height: 40px; text-align: center; border: 0; border-bottom: 1px solid var(--platform-border, #dfe4df); white-space: normal; vertical-align: middle; }
.permission-settings .permission-matrix thead { position: sticky; top: 0; z-index: 3; }
.permission-settings .permission-matrix thead th { background: var(--platform-surface-soft, #f3f7f4); font-weight: 600; }
.permission-settings .permission-matrix tr > :first-child:not([colspan]) { position: sticky; left: 0; z-index: 1; width: 230px; padding: 8px 12px; text-align: left; background: var(--platform-surface, #fff); box-shadow: 1px 0 0 var(--platform-border, #dfe4df); }
.permission-settings .permission-matrix thead tr > :first-child { z-index: 4; background: var(--platform-surface-soft, #f3f7f4); }
.permission-settings .permission-matrix .permission-matrix-group th { height: 32px; padding: 6px 12px; text-align: left; color: var(--platform-primary, #0b332f); background: var(--platform-surface-soft, #f3f7f4); font-size: 12px; }
.permission-check-cell { display: flex; min-height: 40px; align-items: center; justify-content: center; cursor: pointer; }
.permission-check-cell input { margin: 0; }
.permission-check-cell:has(input:disabled) { cursor: not-allowed; }
.account-password-status { display: inline-block; margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: var(--platform-surface-soft, #f3f7f4); color: var(--platform-muted, #66706d); font-size: 11px; line-height: 18px; white-space: nowrap; }
.account-password-status.is-pending { color: var(--platform-primary, #0b332f); box-shadow: inset 0 0 0 1px var(--platform-border, #dfe4df); font-weight: 600; }
/* Employee provisioning reuses the compact system table and permission dialog. */
.system-tabs > button { flex-shrink: 0; white-space: nowrap; }
.employee-directory { color: var(--platform-text, #17211f); }
.employee-directory-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.employee-directory-heading h3 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.employee-directory-heading p, .employee-directory-footnote { margin: 0; color: var(--platform-muted, #66706d); font-size: 12px; line-height: 20px; }
.employee-directory-heading > button { flex: none; }
.employee-directory-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.employee-directory-filters label { display: block; min-width: 160px; color: var(--platform-muted, #66706d); font-size: 12px; line-height: 20px; }
.employee-directory-filters label:first-child { flex: 0 1 320px; }
.employee-directory-filters .input-field { display: block; height: 36px; margin-top: 4px; background: var(--platform-surface-soft, #f3f7f4); border-color: var(--platform-border, #dfe4df); color: var(--platform-text, #17211f); }
.employee-directory-count { margin: 0 0 8px auto; color: var(--platform-muted, #66706d); font-size: 12px; font-variant-numeric: tabular-nums; }
.employee-directory-message { margin: 0 0 12px; color: var(--platform-muted, #66706d); font-size: 13px; }
.employee-directory-message:empty { display: none; }
.employee-directory-table-wrap { overflow-x: auto; }
.employee-directory-table { width: 100%; min-width: 720px; table-layout: fixed; border-collapse: collapse; }
.employee-directory-table :is(th, td) { padding: 12px 10px; border-bottom: 1px solid var(--platform-border, #dfe4df); text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.employee-directory-table th:first-child { width: 110px; }
.employee-directory-table th:nth-child(2) { width: 100px; }
.employee-directory-table th:last-child { width: 112px; }
.employee-directory-table th { color: var(--platform-muted, #66706d); background: var(--platform-surface-soft, #f3f7f4); font-size: 12px; font-weight: 600; }
.employee-directory-table td { font-size: 13px; }
.employee-directory-table tr:hover td { background: var(--platform-surface-soft, #f3f7f4); }
.employee-directory-table .employee-directory-empty { padding: 32px 16px; text-align: center; color: var(--platform-muted, #66706d); }
.employee-directory-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.employee-directory-status { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--platform-surface-soft, #f3f7f4); color: var(--platform-primary, #0b332f); font-size: 12px; white-space: nowrap; }
.employee-directory-status.is-review { color: var(--platform-danger, #a52929); box-shadow: inset 0 0 0 1px var(--platform-border, #dfe4df); }
.employee-directory-reason { display: block; max-width: 240px; margin-top: 4px; color: var(--platform-muted, #66706d); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.employee-directory-muted { color: var(--platform-muted, #66706d); font-size: 12px; white-space: nowrap; }
.employee-directory-open.btn { min-height: 32px; padding: 6px 12px; border: 0; border-radius: 4px; background: var(--platform-primary, #0b332f); color: var(--platform-surface, #fff); font-size: 12px; white-space: nowrap; }
.employee-directory-open.btn:hover { background: var(--platform-accent, #0a7a43); }
.employee-directory-footnote { margin-top: 16px; }
.employee-directory-source-note { margin-bottom: 16px; padding: 12px; border: 1px solid var(--platform-border, #dfe4df); border-radius: 6px; background: var(--platform-surface-soft, #f3f7f4); font-size: 12px; line-height: 20px; }
.employee-directory-source-note strong { font-weight: 600; }
.employee-directory-source-note p { margin: 4px 0 0; color: var(--platform-muted, #66706d); }
.employee-directory :is(button, input, select):focus-visible { outline: 2px solid var(--platform-accent, #0a7a43); outline-offset: 2px; }
@media (max-width: 560px) {
  .employee-directory-heading { gap: 12px; margin-bottom: 16px; }
  .employee-directory-filters { align-items: stretch; }
  .employee-directory-filters label, .employee-directory-filters label:first-child { flex: 1 1 100%; min-width: 0; }
  .employee-directory-count { margin: 0 0 4px; }
}
/* The native top-layer dialog keeps the employee at the required security step. */
body.password-setup-active { overflow: hidden; }
.password-setup-dialog { box-sizing: border-box; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto; border: 1px solid var(--platform-border, #dfe4df); border-radius: 12px; color: var(--platform-text, #17211f); background: var(--platform-surface, #fff); box-shadow: 0 16px 48px rgb(11 51 47 / 12%); }
.password-setup-dialog:not([open]) { display: none; }
.password-setup-dialog::backdrop { background: rgb(11 27 24 / 48%); }
.password-setup-form { padding: 32px; }
.password-setup-eyebrow { margin: 0 0 8px; color: var(--platform-primary, #0b332f); font-size: 12px; font-weight: 700; }
.password-setup-form h2 { margin: 0 0 12px; font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -.02em; }
#passwordSetupDescription { margin: 0; color: var(--platform-muted, #66706d); font-size: 14px; line-height: 1.6; }
.password-setup-account { margin: 16px 0 24px; padding: 10px 12px; border-radius: 6px; background: var(--platform-surface-soft, #f3f7f4); color: var(--platform-text, #17211f); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.password-setup-field { margin-bottom: 16px; }
.password-setup-field label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.password-setup-dialog .input-field { box-sizing: border-box; width: 100%; height: 44px; padding: 10px 12px; border: 1px solid var(--platform-border, #dfe4df); border-radius: 6px; color: var(--platform-text, #17211f); background: var(--platform-surface-soft, #f3f7f4); font: inherit; font-size: 16px; }
.password-setup-rule { margin: -4px 0 20px; color: var(--platform-muted, #66706d); font-size: 12px; line-height: 20px; }
.password-setup-error { margin: 0 0 16px; padding: 10px 12px; border-radius: 6px; color: var(--platform-danger, #a52929); background: var(--platform-danger-soft, #fff4f2); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.password-setup-submit.btn { display: block; width: 100%; min-height: 44px; padding: 12px 16px; border: 0; border-radius: 6px; background: var(--platform-primary, #0b332f); color: var(--platform-surface, #fff); font-size: 14px; font-weight: 600; cursor: pointer; }
.password-setup-submit.btn:hover { background: var(--platform-accent, #0a7a43); }
.password-setup-submit.btn:disabled { opacity: .65; cursor: wait; }
.password-setup-exit { display: block; min-height: 44px; margin: 8px auto -8px; padding: 8px 16px; border: 0; border-radius: 6px; background: transparent; color: var(--platform-muted, #66706d); font: inherit; font-size: 13px; cursor: pointer; }
.password-setup-exit:hover { color: var(--platform-text, #17211f); background: var(--platform-surface-soft, #f3f7f4); }
.password-setup-dialog :is(input, button):focus-visible { outline: 2px solid var(--platform-accent, #0a7a43); outline-offset: 3px; }
@media (max-width: 560px) { .password-setup-form { padding: 24px; } }
@media (max-width: 850px) { .permission-role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  #modalContent:has(.permission-settings) { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .permission-settings { padding: 16px !important; }
  .permission-settings > .grid { grid-template-columns: minmax(0, 1fr); }
  .permission-settings > .grid > .col-span-2 { grid-column: auto; }
  .permission-role-grid { grid-template-columns: minmax(0, 1fr); }
  .permission-role-option { min-height: 56px; }
  .permission-settings .permission-matrix tr > :first-child:not([colspan]) { width: 180px; }
}

/* Let role descriptions and permission summaries fit the visible table width. */
#sysRolesPanel th:nth-child(2), #sysRolesPanel th:nth-child(3),
#sysRolesPanel td:nth-child(2), #sysRolesPanel td:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

/* Keep account identity and every assigned role readable inside the account table. */
#sysUsersPanel table { width: 100%; table-layout: fixed; }
#sysUsersPanel th:nth-child(1) { width: 14%; }
#sysUsersPanel th:nth-child(2) { width: 11%; }
#sysUsersPanel th:nth-child(3) { width: 15%; }
#sysUsersPanel th:nth-child(4) { width: 31%; }
#sysUsersPanel th:nth-child(5) { width: 7%; }
#sysUsersPanel th:nth-child(6) { width: 22%; }
#sysUsersPanel th, #sysUsersPanel td {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.6;
  vertical-align: top;
}
#sysUsersPanel .account-password-status { white-space: normal; }
#sysUsersPanel td:nth-child(5) { white-space: nowrap; }
#sysUsersPanel td:nth-child(6) button {
  display: inline-block;
  margin: 0 6px 6px 0;
  white-space: nowrap;
}
@media (max-width: 640px) {
  #sysUsersPanel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #sysUsersPanel table { min-width: 640px; }
}
