.us-directory { display: grid; gap: 10px; }
.us-heading, .us-actions, .us-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.us-heading { justify-content: space-between; }
.us-heading h2 { margin: 0; font-size: clamp(22px, 3vw, 28px); }
.us-heading button, .us-filters :is(input, select) { min-height: 44px; }
.us-directory .us-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}
.us-kpis .card { padding: 9px 12px; }
.us-kpis .card h3 { margin-bottom: 2px; }
.us-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 180px) minmax(0, 180px) auto;
  align-items: center;
  gap: 8px;
}
.us-filters :is(input, select) { min-width: 0; width: 100%; }
.us-table table { table-layout: fixed; }
.us-table thead th:first-child { width: 30%; }
.us-table thead th:nth-child(2) { width: 22%; }
.us-table thead th:nth-child(3) { width: 24%; }
.us-table :is(th, td) { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.us-table tbody tr:last-child > * { border-bottom: 0; }
.us-table tbody th { color: var(--ink); font-size: 14px; }
.us-table tbody th .hint { font-weight: 400; }
.us-status { margin-bottom: 3px; }
.us-actions { align-items: start; }
.us-actions button, .us-actions summary {
  min-height: 36px;
  padding: 6px 8px;
  font-size: 13px;
}
.us-actions details { position: relative; }
.us-actions summary { color: var(--pri); cursor: pointer; }
.us-menu {
  display: grid;
  position: absolute;
  inset: calc(100% + 4px) 0 auto auto;
  z-index: 4;
  min-width: 164px;
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 8px 18px var(--brand-shadow);
}
.us-menu button { text-align: left; }
@media (max-width: 760px) {
  .us-directory .us-kpis, .us-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #usQ, #usCount { grid-column: 1 / -1; }
  .us-table :is(table, tbody) { display: block; }
  .us-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .us-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 6px 0; border-bottom: 1px solid var(--line); }
  .us-table tbody tr:last-child { border-bottom: 0; }
  .us-table tbody tr > * { border: 0; padding: 4px 0; }
  .us-table tbody tr > :is(th, td:last-child) { grid-column: 1 / -1; }
  .us-actions button, .us-actions summary { min-height: 44px; }
  .us-menu { inset: calc(100% + 4px) auto auto 0; }
}

.us-permissions { display: grid; gap: 10px; margin-bottom: 14px; min-width: 0; }
.us-permissions h2 { margin: 0; min-width: 0; overflow-wrap: break-word; font-size: clamp(22px, 3vw, 28px); }
.us-permissions > p { margin: 0; }
.us-permission-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 8px; }
.us-permission-filters label { display: grid; gap: 4px; min-width: 0; margin: 0; }
.us-permission-filters select { width: 100%; min-width: 0; min-height: 44px; }
.us-permission-legend summary {
  width: fit-content;
  min-height: 44px;
  padding: 10px;
  color: var(--pri);
  cursor: pointer;
}
.us-permission-legend dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 8px 16px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.us-permission-legend dd { margin: 4px 0 0; color: var(--mut); font-size: 13px; }
.us-permission-matrix { overflow: auto; max-height: 68vh; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.us-permission-matrix:focus-visible { outline-offset: -2px; }
.ptree { table-layout: fixed; min-width: 940px; }
.ptree.ptree-single { min-width: 0; }
.ptree :is(th, td) { padding: 8px; white-space: normal; overflow-wrap: anywhere; }
.ptree thead th { position: sticky; top: 0; z-index: 1; background: var(--tint); color: var(--ink); }
.ptree thead th:first-child { width: 31%; }
.ptree-single thead th:first-child { width: 65%; }
.ptree .pmod th { background: var(--surface-soft); color: var(--ink); font-size: 14px; }
.ptree th[scope="row"] { color: var(--ink); font-size: 13px; font-weight: 550; }
.ptree th .hint { margin-top: 3px; font-weight: 400; }
.ptree tbody:last-child tr:last-child > * { border-bottom: 0; }
@media (max-width: 420px) {
  .us-permission-filters { grid-template-columns: minmax(0, 1fr); }
  .ptree-single thead th:first-child { width: 60%; }
}
