/* Permissions owns its layout; other admin surfaces keep their existing styles. */
.ap-permissions { min-width: 0; }
.ap-permissions *, .ap-dialog * { box-sizing: border-box; }
.ap-tabs { display: flex; gap: 22px; margin: -2px 0 20px; border-bottom: 1px solid var(--line); }
.ap-tabs .button { min-height: 44px; margin-bottom: -1px; padding: 0 2px; border-radius: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; }
.ap-tabs .button.is-active { color: var(--green-dark); border-bottom-color: var(--green); }
.ap-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.ap-toolbar input { width: min(300px, 65%); }
.ap-account-table { table-layout: fixed; }
.ap-account-table th:nth-child(1) { width: 20%; }
.ap-account-table th:nth-child(2) { width: 18%; }
.ap-account-table th:nth-child(3) { width: 31%; }
.ap-account-table th:nth-child(4) { width: 11%; }
.ap-account-table th:nth-child(5) { width: 20%; }
.ap-account-table td { overflow-wrap: anywhere; line-height: 1.65; }
.ap-account-name { font-weight: 650; }
.ap-row-actions { display: flex; justify-content: flex-start; align-items: center; gap: 4px; flex-wrap: wrap; }
.ap-row-actions > .button { padding-inline: 4px; color: var(--green-dark); }
.ap-status { display: inline-flex; align-items: center; gap: 6px; color: #34745a; font-size: 12px; white-space: nowrap; }
.ap-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ap-status.is-disabled { color: var(--subtle); }
.ap-more { position: relative; }
.ap-more summary { padding: 5px 7px; color: var(--muted); cursor: pointer; font-size: 12px; list-style: none; border-radius: 6px; white-space: nowrap; }
.ap-more summary::-webkit-details-marker { display: none; }
.ap-more summary::after { content: '⌄'; margin-left: 5px; }
.ap-more[open] summary, .ap-more summary:hover { background: #edf3fb; color: var(--ink); }
.ap-more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 8; display: grid; min-width: 130px; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.ap-more-menu .button { text-align: left; font-size: 12px; }
.ap-permissions .ap-danger { color: var(--red); }
.ap-hint { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.65; }
.ap-empty { padding: 40px 16px; color: var(--muted); text-align: center; }
.ap-empty-scope { color: var(--amber); font-size: 12px; line-height: 1.65; }
.ap-unmatched-scope { display: block; margin-top: 3px; color: var(--amber); font-size: 11px; font-weight: 400; }
.ap-role-workspace { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 480px; }
.ap-role-list { min-width: 0; padding: 18px 12px; border-right: 1px solid var(--line); }
.ap-role-list > .button-secondary { width: 100%; margin-bottom: 14px; }
.ap-role-item { display: grid; gap: 3px; width: 100%; min-height: 62px; padding: 11px 12px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.ap-role-item.is-active { color: var(--green-dark); background: var(--green-soft); }
.ap-role-item.is-active small { color: #5b79a8; }
.ap-role-form { display: grid; align-content: start; gap: 22px; min-width: 0; max-width: 760px; padding: 25px 30px; }
.ap-role-heading { display: grid; gap: 6px; }
.ap-role-heading h3 { font-size: 17px; }
.ap-field { display: grid; gap: 8px; min-width: 0; }
.ap-field > span { font-size: 13px; font-weight: 650; }
.ap-field input, .ap-field select { min-width: 0; }
.ap-field input[readonly] { color: var(--muted); background: #f6f8fc; }
.ap-menu-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 20px; min-width: 0; margin: 0; padding: 10px 0 0; border: 0; border-top: 1px solid var(--line-soft); }
.ap-menu-group legend { padding: 0 12px 0 0; color: var(--muted); font-size: 12px; font-weight: 650; }
.ap-menu-option { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 34px; cursor: pointer; }
.ap-menu-option > span { min-width: 0; overflow-wrap: anywhere; }
.ap-menu-option:has(input:disabled) { cursor: default; }
.ap-permissions input[type=checkbox], .ap-dialog input[type=checkbox] { flex: 0 0 auto; width: 16px; height: 16px; padding: 0; margin: 0; border-radius: 4px; accent-color: var(--green); box-shadow: none; }
.ap-role-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 4px; }
.ap-role-footer > small { flex: 1 0 100%; }
.ap-form-error { min-height: 0; color: var(--red); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.ap-form-error:empty { display: none; }
.ap-role-refresh-error:empty { display: none; }
.ap-role-refresh-error .button { padding-inline: 0; color: var(--green-dark); }
.ap-dialog { padding: 0; border: 0; color: var(--ink); background: var(--surface); box-shadow: 0 28px 90px rgba(10, 25, 55, .25); }
.ap-dialog::backdrop { background: rgba(10, 22, 42, .42); }
.ap-account-dialog { position: fixed; inset: 0 0 0 auto; width: min(600px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 16px 0 0 16px; overflow: hidden; }
.ap-dialog-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ap-dialog-header { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 25px 28px 22px; border-bottom: 1px solid var(--line); }
.ap-dialog-header h3 { font-size: 19px; line-height: 1.4; }
.ap-dialog-header .ap-hint { margin-top: 7px; }
.ap-dialog-header > .button { min-width: 32px; min-height: 32px; padding: 0 8px; margin: -3px -10px 0 0; font-size: 24px; font-weight: 400; }
.ap-dialog-body { display: grid; flex: 1 1 auto; align-content: start; gap: 23px; min-height: 0; padding: 25px 28px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.ap-dialog-footer { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 18px 28px; border-top: 1px solid var(--line); background: var(--surface); }
.ap-dialog-footer > .ap-form-error { flex: 1 0 100%; margin: 0 0 3px; }
.ap-dialog-footer > .button { min-width: 82px; }
.ap-scope { display: grid; align-content: start; gap: 13px; padding-top: 22px; border-top: 1px solid var(--line); min-width: 0; }
.ap-scope h4 { margin: 0; font-size: 14px; }
.ap-scope-all { color: var(--green-dark); font-weight: 650; line-height: 1.7; }
.ap-scope-tabs { display: flex; align-items: center; gap: 4px; width: fit-content; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f5f8fd; }
.ap-scope-tabs .button { min-height: 30px; padding: 0 14px; }
.ap-scope-tabs .is-active { color: var(--green-dark); background: white; box-shadow: 0 1px 4px rgba(16, 42, 90, .1); }
.ap-selection-label { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.ap-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ap-chip { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; padding: 3px 4px 3px 10px; border: 1px solid #dce7fb; border-radius: 7px; color: #375a91; background: #f1f6ff; font-size: 12px; }
.ap-chip > span { overflow-wrap: anywhere; min-width: 0; }
.ap-chip .button { flex: 0 0 auto; min-height: 24px; width: 24px; padding: 0; color: #5d789f; font-size: 17px; font-weight: 400; }
.ap-chip.is-unlisted { color: var(--amber); border-color: #f1dfbc; background: #fff9ef; }
.ap-selected > .ap-empty-scope, .ap-inactive-scopes > .ap-empty-scope { margin-top: 8px; }
.ap-candidates { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; padding: 5px; min-width: 0; }
.ap-candidates > p { padding: 12px 8px; }
.ap-candidates > .button { align-self: flex-start; margin: 0 8px 8px; }
.ap-candidate { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; min-width: 0; min-height: 39px; height: auto; padding: 8px 9px; border-radius: 6px; line-height: 1.5; cursor: pointer; }
.ap-candidate:hover { background: #f4f7fc; }
.ap-candidate > span { display: block; flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.ap-candidate small { display: block; font-size: 11px; }
.ap-scope-pager { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.ap-scope-pager > span { margin-right: auto; }
.ap-inactive-scopes, .ap-login-details { padding-top: 15px; border-top: 1px solid var(--line-soft); }
.ap-inactive-scopes summary, .ap-login-details summary { color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1.8; }
.ap-role-features summary { color: var(--green-dark); cursor: pointer; font-size: 12px; font-weight: 400; line-height: 1.8; }
.ap-role-features[open] summary { margin-bottom: 5px; }
.ap-inactive-scopes[open] summary, .ap-login-details[open] summary { margin-bottom: 12px; }
.ap-inactive-scopes .ap-selection-label:not(:first-of-type) { margin-top: 14px; }
.ap-login-details p + p { margin-top: 6px; }
.ap-password-dialog { width: min(440px, calc(100vw - 32px)); max-height: 90dvh; border-radius: 14px; }
.ap-password-dialog .ap-dialog-body { gap: 18px; }
.ap-password-account { font-weight: 650; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .ap-account-table th, .ap-account-table td { padding-inline: 12px; }
  .ap-role-workspace { grid-template-columns: 180px minmax(0, 1fr); }
  .ap-role-form { padding-inline: 22px; }
}
@media (max-width: 680px) {
  .ap-toolbar { padding: 14px; }
  .ap-account-table, .ap-account-table tbody, .ap-account-table tr, .ap-account-table td { display: block; width: 100%; }
  .ap-account-table thead { display: none; }
  .ap-account-table tr { padding: 14px; border-bottom: 1px solid var(--line); }
  .ap-account-table tr:last-child { border-bottom: 0; }
  .ap-account-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: start; min-height: 0; padding: 5px 0; border: 0; font-size: 13px; }
  .ap-account-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 400; }
  .ap-account-table .ap-empty { display: block; padding-block: 20px; text-align: center; }
  .ap-account-table .ap-empty::before { display: none; }
  .ap-row-actions { gap: 8px; }
  .ap-role-workspace { display: block; }
  .ap-role-list { display: flex; gap: 7px; align-items: stretch; padding: 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .ap-role-list > .button-secondary { flex: 0 0 auto; width: auto; margin: 0; padding-inline: 12px; }
  .ap-role-item { flex: 0 0 auto; width: auto; min-width: 112px; min-height: 58px; }
  .ap-role-form { padding: 22px 18px; gap: 20px; }
  .ap-account-dialog { width: 100vw; border-radius: 0; }
  .ap-dialog-header { padding: 22px 20px 18px; }
  .ap-dialog-body { padding: 22px 20px; }
  .ap-dialog-footer { padding: 16px 20px max(16px, env(safe-area-inset-bottom)); }
}
@media (max-width: 440px) {
  .ap-menu-group { grid-template-columns: minmax(0, 1fr); }
}
