.access-editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: safe center;
  padding: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(5px);
}

.access-editor-dialog {
  width: min(1320px, 100%);
  margin: auto;
  border: 1px solid color-mix(in srgb, var(--line-strong) 72%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 96%, var(--bg));
  color: var(--text);
  box-shadow: var(--shadow-md);
}

.access-editor-dialog:has(.access-editor-loading) {
  width: min(460px, 100%);
}

.access-editor {
  display: grid;
  grid-template-rows: auto auto auto auto;
  width: 100%;
  min-width: 0;
}

.access-editor-head,
.access-editor-summary,
.access-editor-footer {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 94%, var(--bg));
}

.access-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 10px;
}

.access-editor-head h2,
.access-editor-head p,
.access-editor-panel-head h3,
.access-editor-panel-head p,
.access-editor-footer p {
  margin: 0;
}

.access-editor-head h2 {
  font-size: clamp(18px, 1.5vw, 23px);
  line-height: 1.15;
}

.access-editor-head p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.access-editor-head-actions,
.access-editor-footer-actions,
.access-editor-position-tools,
.access-editor-legend,
.access-editor-period > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.access-editor-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  font-weight: 400;
}

.access-editor-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--soft-panel) 78%, var(--panel));
  font-size: 12px;
  font-weight: 850;
}

.access-editor-status.is-custom {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  color: color-mix(in srgb, var(--accent) 66%, var(--text));
}

.access-editor-status.is-inherited {
  border-color: color-mix(in srgb, var(--yellow) 48%, var(--line));
  color: color-mix(in srgb, var(--yellow) 62%, var(--text));
}

.access-editor-summary {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(240px, 1fr) minmax(420px, 1.8fr);
  gap: 10px;
  padding: 0 18px 12px;
  border-bottom: 1px solid var(--line);
}

.access-editor-summary-card,
.access-editor-metrics {
  min-width: 0;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--soft-panel) 74%, var(--panel));
}

.access-editor-summary-card {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
}

.access-editor-summary-card > span,
.access-editor-summary-card > small,
.access-editor-metrics span,
.access-editor-panel-head p,
.access-editor-module summary small,
.access-editor-permission-row small,
.access-editor-position-row small,
.access-editor-footer small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.access-editor-summary-card > span {
  font-weight: 800;
}

.access-editor-summary-card > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.access-editor-summary-card select,
.access-editor-period input {
  min-height: 30px;
  padding-block: 4px;
  font-size: 12px;
}

.access-editor-period > div,
.access-editor-period input {
  min-width: 0;
}

.access-editor-period i {
  color: var(--muted);
  font-style: normal;
}

.access-editor-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0;
  overflow: hidden;
}

.access-editor-metrics > div {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 8px;
  border-left: 1px solid var(--line);
  text-align: center;
}

.access-editor-metrics > div:first-child {
  border-left: 0;
}

.access-editor-metrics strong {
  font-size: 20px;
  line-height: 1;
}

.access-editor-body {
  display: grid;
  grid-template-columns: minmax(210px, 0.72fr) minmax(520px, 2fr) minmax(300px, 1.05fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 10px 18px 12px;
  overflow: visible;
}

.access-editor-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--soft-panel) 64%, var(--panel));
}

.access-editor-structure,
.access-editor-modules,
.access-editor-restrictions {
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: 8px;
  overflow: visible;
  padding: 12px;
}

.access-editor-modules {
  grid-template-rows: auto auto auto;
}

.access-editor-panel-head {
  min-width: 0;
}

.access-editor-panel-head h3 {
  font-size: 14px;
}

.access-editor-panel-head p {
  margin-top: 4px;
}

.access-editor-panel-head--row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.access-editor-panel-head--row button,
.access-editor-position-tools button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 11px;
}

.access-editor :where(input[type="search"], textarea) {
  border-color: var(--line);
  background: color-mix(in srgb, var(--bg) 44%, var(--panel));
  font-size: 12px;
}

.access-editor :where(input[type="search"]) {
  min-height: 34px;
  padding-block: 6px;
}

.access-editor-structure-list,
.access-editor-module-list,
.access-editor-position-list {
  min-height: 0;
  max-height: min(460px, 50vh);
  overflow: auto;
  scrollbar-width: thin;
}

.access-editor-structure-list {
  display: grid;
  align-content: start;
  gap: 3px;
}

.access-editor-structure-row,
.access-editor-position-row {
  display: grid;
  align-items: center;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.access-editor-structure-row {
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  margin-left: calc(var(--access-tree-depth, 0) * 12px);
  padding: 7px 8px;
}

.access-tree-depth-0 { --access-tree-depth: 0; }
.access-tree-depth-1 { --access-tree-depth: 1; }
.access-tree-depth-2 { --access-tree-depth: 2; }
.access-tree-depth-3 { --access-tree-depth: 3; }
.access-tree-depth-4 { --access-tree-depth: 4; }
.access-tree-depth-5 { --access-tree-depth: 5; }
.access-tree-depth-6 { --access-tree-depth: 6; }
.access-tree-depth-7 { --access-tree-depth: 7; }
.access-tree-depth-8 { --access-tree-depth: 8; }

.access-editor-structure-row:hover,
.access-editor-position-row:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.access-editor-structure-row:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--line));
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
}

.access-editor-structure-row > span,
.access-editor-position-row > span,
.access-editor-permission-row > span,
.access-editor-module summary > span:nth-child(2) {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.access-editor-structure-row strong,
.access-editor-structure-row small,
.access-editor-position-row strong,
.access-editor-position-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-editor-structure-row strong,
.access-editor-position-row strong {
  font-size: 12px;
}

.access-editor-module-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.access-editor-module {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 86%, var(--soft-panel));
  overflow: hidden;
}

.access-editor-module[open] {
  border-color: color-mix(in srgb, var(--accent) 66%, var(--line));
}

.access-editor-module summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
}

.access-editor-page-toggle {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.access-editor-page-toggle > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.access-editor-page-section {
  display: grid;
  gap: 6px;
}

.access-editor-page-section > h4 {
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.access-editor-function-list {
  margin: 0 8px 8px;
}

.access-editor-assignment-list {
  display: grid;
  align-content: start;
  gap: 6px;
}

.access-editor-assignment {
  display: grid;
  justify-items: start;
  gap: 3px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  text-align: left;
}

.access-editor-assignment.is-active {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}

.access-editor-assignment.is-inherited {
  border-style: dashed;
  color: var(--muted);
  pointer-events: none;
}

.access-editor-assignment-subhead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.access-editor-assignment small {
  color: var(--muted);
  font-size: 10px;
}

.access-editor-module summary::-webkit-details-marker {
  display: none;
}

.access-editor-module summary strong {
  font-size: 13px;
}

.access-editor-module summary b {
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: color-mix(in srgb, var(--accent) 68%, var(--text));
  font-size: 10px;
}

.access-editor-module-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg) 36%, var(--panel));
  color: var(--text);
  font-size: 17px;
}

.access-editor-permission-grid {
  margin: 0 8px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.access-editor-permission-head,
.access-editor-permission-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(74px, 0.34fr));
  align-items: stretch;
  min-width: 0;
}

.access-editor-permission-head {
  min-height: 34px;
  background: color-mix(in srgb, var(--bg) 40%, var(--panel));
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.access-editor-permission-head > span,
.access-editor-permission-row > span,
.access-editor-permission-row > label {
  display: grid;
  place-items: center;
  min-width: 0;
  margin: 0;
  padding: 7px 8px;
  border-left: 1px solid var(--line);
}

.access-editor-permission-head > span:first-child,
.access-editor-permission-row > span:first-child {
  place-items: center start;
  border-left: 0;
}

.access-editor-permission-row {
  min-height: 44px;
  border-top: 1px solid var(--line);
}

.access-editor-permission-row strong {
  font-size: 11px;
}

.access-editor-permission-row input {
  width: 17px;
  min-width: 17px;
  height: 17px;
  min-height: 17px;
}

.access-editor-permission-row [data-access-deny] {
  accent-color: var(--red);
}

.access-editor-legend {
  flex-wrap: wrap;
  font-size: 11px;
}

.access-editor-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.access-editor-legend i {
  width: 13px;
  height: 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.access-editor-legend .is-allowed {
  border-color: var(--accent);
  background: var(--accent);
}

.access-editor-legend .is-inherited {
  border-color: var(--muted);
  background: color-mix(in srgb, var(--muted) 42%, transparent);
}

.access-editor-legend .is-denied {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 76%, transparent);
}

.access-editor-side {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.access-editor-position-tools {
  justify-content: space-between;
}

.access-editor-position-tools label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.access-editor-position-row {
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 8px;
}

.access-editor-position-count {
  display: flex;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.access-editor-side > .access-editor-panel:not(.access-editor-restrictions) {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.access-editor-reason textarea {
  min-height: 62px;
  max-height: 110px;
  resize: vertical;
}

.access-editor > .access-editor-reason {
  display: grid;
  grid-template-columns: minmax(180px, 0.6fr) minmax(320px, 1.4fr) auto minmax(260px, 0.9fr);
  align-items: center;
  gap: 10px;
  margin: 0 18px 12px;
  padding: 12px;
}

.access-editor-reason > span {
  justify-self: end;
  color: var(--muted);
  font-size: 10px;
}

.access-editor-last-change {
  display: grid;
  gap: 5px;
  margin: 0;
}

.access-editor-last-change > div {
  display: grid;
  grid-template-columns: minmax(74px, auto) minmax(0, 1fr);
  gap: 8px;
  font-size: 10px;
}

.access-editor-last-change dt {
  color: var(--muted);
}

.access-editor-last-change dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.access-editor-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
}

.access-editor-footer > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.access-editor-footer > div:first-child > span {
  color: var(--accent);
  font-size: 18px;
}

.access-editor-footer p {
  display: grid;
  gap: 1px;
}

.access-editor-footer p strong {
  font-size: 11px;
}

.access-editor-footer-actions button {
  min-width: 122px;
  min-height: 38px;
  font-size: 12px;
}

.access-editor-error {
  color: var(--red);
  font-size: 11px;
  font-weight: 750;
}

.access-editor-loading {
  display: grid;
  width: 100%;
  min-height: 180px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.access-editor-loading p {
  margin: 0;
}

.access-editor-loading.is-error strong {
  color: var(--red);
}

.access-editor-empty {
  padding: 14px 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.access-editor [hidden] {
  display: none !important;
}

.access-editor .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1280px) {
  .access-editor-summary {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }

  .access-editor-metrics {
    grid-column: 1 / -1;
    min-height: 62px;
  }

  .access-editor-body {
    grid-template-columns: minmax(200px, 0.72fr) minmax(480px, 2fr);
    overflow: visible;
  }

  .access-editor-side {
    grid-column: 1 / -1;
    grid-template-columns: minmax(300px, 1.5fr) minmax(240px, 0.75fr) minmax(240px, 0.75fr);
    grid-template-rows: minmax(240px, auto);
  }
}

@media (max-width: 860px) {
  .access-editor-dialog {
    overflow: visible;
  }

  .access-editor {
    display: block;
    height: auto;
  }

  .access-editor-summary,
  .access-editor-body,
  .access-editor-side,
  .access-editor-footer,
  .access-editor > .access-editor-reason {
    grid-template-columns: 1fr;
  }

  .access-editor-body {
    overflow: visible;
  }

  .access-editor-structure-list,
  .access-editor-module-list,
  .access-editor-position-list {
    max-height: none;
    overflow: visible;
  }

  .access-editor-side {
    grid-template-rows: none;
  }

  .access-editor-footer-actions {
    justify-content: stretch;
  }

  .access-editor-footer-actions button {
    flex: 1 1 0;
  }
}

@media (max-width: 620px) {
  .access-editor-backdrop {
    padding: 12px;
  }

  .access-editor-dialog {
    width: 100%;
    border-radius: var(--radius);
  }

  .access-editor-head,
  .access-editor-summary,
  .access-editor-body,
  .access-editor-footer {
    padding-inline: 10px;
  }

  .access-editor > .access-editor-reason {
    margin-inline: 10px;
  }

  .access-editor-summary,
  .access-editor-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .access-editor-metrics {
    grid-column: auto;
  }

  .access-editor-metrics > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .access-editor-metrics > div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .access-editor-permission-head,
  .access-editor-permission-row {
    grid-template-columns: minmax(145px, 1fr) repeat(3, 58px);
    min-width: 320px;
  }

  .access-editor-permission-grid {
    overflow-x: auto;
  }
}
