/* Access control UI: form tabs, the Permissions tab of the user form, the Activity Log. Tokens from admin.css only; logical properties for RTL. */

/* a tall drawer (the permissions grid) scrolls inside its body: without this the grid row grows with the content and pushes the footer off screen */
.backdrop-drawer { grid-template-rows: minmax(0, 1fr); }
.backdrop-drawer > .drawer { min-height: 0; }

/* ------------------------------------------------------------ tabs inside a record drawer */
.form-tabbed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.form-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.form-tabs::-webkit-scrollbar { display: none; }
.form-tabs .tab { background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; min-height: 44px; font: inherit; font-weight: 700; color: var(--muted); white-space: nowrap; cursor: pointer; }
.form-tabs .tab:hover { color: var(--ink); }
.form-tabs .tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.form-tabs .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }

/* ------------------------------------------------------------ permissions tab */
.acc-perm, .acc-body { display: grid; gap: 22px; min-width: 0; }
.acc-sec { display: grid; gap: 10px; min-width: 0; }
.acc-sec .form-section { margin: 0; }
.acc-body > .acc-sec:first-child .form-section, .acc-detail-sec:first-child .form-section { border-top: 0; padding-top: 0; }
.acc-admin { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid color-mix(in srgb, var(--info) 35%, var(--line)); border-radius: var(--r-sm); background: var(--info-soft); }
.acc-admin .ico { color: var(--info-ink); flex: 0 0 auto; margin-top: 1px; }
.acc-admin p { margin: 4px 0 0; font-size: 13px; }

.acc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-chip { position: relative; display: inline-flex; }
.acc-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.acc-chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-weight: 650; pointer-events: none; transition: background .15s, border-color .15s; }
.acc-chip:hover span { border-color: var(--muted); }
.acc-chip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
:root[data-theme="dark"] .acc-chip input:checked + span { color: #1a120c; }
.acc-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.acc-tpl-desc { margin: 0; min-height: 1.4em; }

.acc-block { border-bottom: 1px solid var(--line-2); min-width: 0; }
.acc-block:last-child { border-bottom: 0; }

/* the permission matrix: a row per app with a checkbox per operation (Read / Create / Edit / Delete) and an "all" checkbox; the header row ticks a whole column */
.acc-matrix { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: clip; background: var(--panel); min-width: 0; }
.acc-mrow { display: grid; grid-template-columns: minmax(120px, 1fr) repeat(4, 76px) 60px; gap: 0 4px; align-items: center; padding: 4px 12px; min-width: 0; }
.acc-mhead { position: sticky; top: 0; z-index: 2; background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.acc-mgroup-t { padding: 8px 12px; background: var(--panel-2); border-block: 1px solid var(--line-2); font-size: 12px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.acc-op { position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 44px; min-height: 44px; border-radius: var(--r-sm); cursor: pointer; }
.acc-op:hover { background: var(--panel-3); }
.acc-op input { width: 22px; height: 22px; margin: 0; cursor: pointer; accent-color: var(--brand); }
.acc-op input:disabled { cursor: not-allowed; opacity: .6; }
.acc-op:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-op-t { display: none; font-size: 12px; font-weight: 650; color: var(--muted); text-align: center; }
.acc-mhead .acc-op-t { display: block; order: -1; font-size: 12.5px; font-weight: 750; }
.op-read input { accent-color: var(--info); }
.op-create input { accent-color: var(--ok); }
.op-edit input { accent-color: var(--warn); }
.op-delete input { accent-color: var(--danger); }
.op-all input { accent-color: var(--brand); }
.acc-app { display: grid; gap: 3px; min-width: 0; align-content: center; }
.acc-matrix-note { margin: 0; }

/* an app's Actions and Pages expanders sit side by side; an open one takes the full row */
.acc-exps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 12px 10px; min-width: 0; }
.acc-exps[hidden] { display: none; }
.acc-exps > details { flex: 1 1 240px; min-width: 0; }
.acc-exps > details[open] { flex-basis: 100%; }

/* pages of an app (menu items) the person can open */
.acc-pages { margin: 0; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel-2); min-width: 0; }
.acc-pages[hidden] { display: none; }
.acc-pages-sum { display: flex; align-items: center; min-height: 44px; padding: 0 12px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.acc-pages-sum.limited { color: var(--warn-ink); }
.acc-pages-sum:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }
.acc-pages-body { display: grid; gap: 12px; padding: 4px 12px 12px; }
.acc-pages-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
.acc-pages-head > span { flex: 1 1 220px; min-width: 0; }
.acc-pages-all { min-height: 44px; }
.acc-pagegroup { display: grid; gap: 4px; }
.acc-pagegroup-t { font-size: 12px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.acc-pagelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 8px; }
.acc-page { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 6px; border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px; }
.acc-page:hover { background: var(--panel-3); }
.acc-page input { width: 20px; height: 20px; flex: 0 0 auto; margin: 0; accent-color: var(--brand); }
.acc-page:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

.acc-hint { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.acc-hint .ico { margin-top: 1px; flex: 0 0 auto; }
.acc-hint > span:not(.ico) { flex: 1 1 160px; min-width: 0; }
.acc-hint.warn { color: var(--warn-ink); }
.acc-hint-btn { min-height: 34px; padding: 0 12px; font-size: 12.5px; }

.acc-rights { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel); }
.acc-right { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.acc-right:last-child { border-bottom: 0; }
.acc-right-txt { display: grid; gap: 2px; flex: 1; min-width: 0; cursor: pointer; }

/* ------------------------------------------------------------ activity (detail drawer, compact list, log) */
.acc-detail { display: grid; gap: 18px; min-width: 0; }
.acc-detail-sec { display: grid; gap: 8px; min-width: 0; }
.acc-detail-sec .form-section { margin: 0; }
.acc-summary { margin: 0; overflow-wrap: anywhere; font-size: 13.5px; }
.acc-path { overflow-wrap: anywhere; font-size: 12.5px; }
.acc-kv dd { overflow-wrap: anywhere; }
.acc-val { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; }
.acc-diff td { vertical-align: top; overflow-wrap: anywhere; }
.acc-diff td:first-child { width: 28%; }
.acc-before { background: var(--danger-soft); }
.acc-after { background: var(--ok-soft); }
.acc-json { margin: 0; padding: 10px 12px; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.acc-sum { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; max-width: 560px; }

.acc-act { display: grid; gap: 10px; min-width: 0; }
.acc-act-list { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel); }
.acc-act-row { display: grid; grid-template-columns: 84px auto minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; min-height: 44px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line-2); background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.acc-act-row:last-child { border-bottom: 0; }
.acc-act-row:hover { background: var(--panel-2); }
.acc-act-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-act-sum { min-width: 0; overflow-wrap: anywhere; font-size: 13.5px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.acc-act-all { justify-self: start; min-height: 40px; }

/* ------------------------------------------------------------ phone */
@media (max-width: 600px) {
  .acc-matrix { border: 0; gap: 10px; overflow: visible; background: transparent; }
  .acc-mgroup { display: grid; gap: 10px; }
  .acc-mgroup-t { border: 0; border-radius: var(--r-sm); }
  .acc-block, .acc-mhead { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
  .acc-block:last-child { border-bottom: 1px solid var(--line); }
  .acc-mhead { position: static; background: var(--panel-2); }
  /* each app is a card: its name and "All" on the first line, the four operations as large toggles below */
  .acc-mrow { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 6px; padding: 10px 12px; }
  .acc-mrow > .acc-app { grid-column: 1 / 4; grid-row: 1; }
  .acc-mrow > .op-all { grid-column: 4; grid-row: 1; }
  .acc-mhead > .acc-app { grid-column: 1 / -1; }
  .acc-op { min-height: 64px; padding: 6px 2px; border: 1px solid var(--line-2); background: var(--panel-2); }
  .acc-op input { width: 26px; height: 26px; }
  .acc-op-t { display: block; }
  .acc-mhead .acc-op-t { order: 0; font-size: 12px; font-weight: 650; }
  .acc-op.op-all { min-height: 44px; border: 0; background: transparent; }
  .acc-op:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); }
  .acc-op.op-all:has(input:checked) { background: transparent; }
  .acc-exps { margin: 0 8px 8px; }
  .acc-pagelist { grid-template-columns: minmax(0, 1fr); }
  .acc-hint-btn { min-height: 40px; }
  .acc-right { padding-block: 12px; }
  .acc-act-row { grid-template-columns: auto minmax(0, 1fr); }
  .acc-act-sum { grid-column: 1 / -1; }
  .acc-chip span { padding: 0 14px; }
}

/* user form: show / generate / copy under the password and PIN fields */
.secret-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.secret-tools .btn { min-height: 44px; }
.no-access .empty { padding-block: 48px; }

/* the Import icon next to Export on a list: icon only, 44 px target; the dialog hosts the shared wizard (public/shared/import.css) */
:root .import-icon-btn { min-width: 44px; min-height: 44px; padding: 0; }
.modal-body > .imp { min-width: 0; }
.imp-what { margin: 0; }
.modal .imp-radio input[type=radio], .modal .imp-check input[type=checkbox] { display: inline-block; width: 18px; min-width: 18px; height: 18px; min-height: 0; padding: 0; border: 0; box-shadow: none; flex: 0 0 auto; accent-color: var(--accent); }

/* "Created by <name> · <time>": under the header of a record page and at the top of a record drawer; the "Created by" list column */
.created-by { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-block: 2px 10px; padding-inline: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.5; min-width: 0; }
.created-by[hidden] { display: none; }
.created-by .ico { flex: none; opacity: .8; }
.created-by .cb-name { color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }
.created-by .cb-none { cursor: help; border-radius: 4px; }
@media (pointer: coarse) { .created-by .cb-none { padding: 13px 14px; margin: -13px -8px; touch-action: manipulation; } }   /* a tap explains the dash (no hover on a phone): 44 px hit area */
.created-by .cb-none:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.created-by.cb-drawer { margin-block: 0 12px; }
.data-table td.cb-col { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* page history: "Activity on this page" / "History" at the bottom of every list and record */
.ph-host { margin-block-start: 18px; padding: 0; overflow: hidden; }
.ph-host.ph-drawer { margin-block-start: 14px; box-shadow: none; }
.ph-host[hidden] { display: none; }
.ph-det > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 16px; }
.ph-det > summary::-webkit-details-marker { display: none; }
.ph-det > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }
.ph-sum-row h3 { font-size: 15px; margin: 0; }
.ph-count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--panel-3); color: var(--muted); font-size: 12px; font-weight: 700; }
.ph-chev { transition: transform .15s; }
.ph-det[open] .ph-chev { transform: rotate(180deg); }
.ph-body { display: grid; gap: 10px; padding: 0 16px 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.ph-note, .ph-empty { margin: 0; }
.ph-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.ph-item { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line-2, var(--line)); min-width: 0; }
.ph-item:last-child { border-bottom: 0; }
.ph-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.ph-at { font-size: 12.5px; }
.ph-record { font-weight: 650; overflow-wrap: anywhere; }
.ph-changes { display: grid; gap: 4px; }
.ph-change { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--panel-2); min-width: 0; font-size: 13.5px; }
.ph-change[hidden] { display: none; }
.ph-field { font-weight: 650; min-width: 110px; overflow-wrap: anywhere; }
.ph-from, .ph-to { overflow-wrap: anywhere; padding: 1px 8px; border-radius: 6px; max-width: 100%; }
.ph-from { background: var(--danger-soft); }
.ph-to { background: var(--ok-soft); }
.ph-arrow { display: inline-flex; color: var(--muted); }
.ph-more { justify-self: start; min-height: 44px; }
.ph-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ph-load { min-height: 44px; }
@media (max-width: 600px) {
  .ph-det > summary { padding-inline: 12px; }
  .ph-body { padding-inline: 12px; }
  .ph-field { min-width: 100%; }
}

/* user menu rows are touch targets */
.user-menu .menu a, .user-menu .menu button { min-height: 44px; }

