/* H4Connect directories: toolbar, table anatomies (Single-line 40 / Summary 60 / Data grid 36), pills, row menus,
   pagination, empty / loading / error states, detail-page cards. Tokens only (css/tokens.css). */

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

/* ----- page head ----- */
.dir-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--h4-space-4); margin: 0 0 var(--h4-space-4); flex-wrap: wrap; }
.dir-head h1 { margin: 0; font-size: var(--h4-text-2xl); line-height: var(--h4-leading-tight); letter-spacing: -.01em; display: flex; align-items: center; gap: var(--h4-space-2); flex-wrap: wrap; }
.dir-lede { margin: var(--h4-space-1) 0 0; color: var(--h4-text-muted); font-size: var(--h4-text-sm); max-width: 64ch; }
.dir-head-actions { display: flex; gap: var(--h4-space-2); align-items: center; flex-wrap: wrap; }
.dir-head-actions .btn, .dir-toolbar .btn { display: inline-flex; align-items: center; gap: 6px; min-height: var(--h4-control-height); }
.dir-back { display: inline-flex; align-items: center; gap: 4px; color: var(--h4-text-muted); text-decoration: none; font-size: var(--h4-text-sm); min-height: 32px; }
.dir-back:hover { color: var(--h4-text); }
.dir-sub-id { font: var(--h4-text-sm) var(--h4-font-mono); color: var(--h4-text-secondary); display: inline-flex; align-items: center; gap: 6px; }

/* ----- tabs ----- */
.dir-tabs { display: flex; gap: var(--h4-space-1); border-bottom: 1px solid var(--h4-border); margin: 0 0 var(--h4-space-4); overflow-x: auto; }
.dir-tab { display: inline-flex; align-items: center; gap: 6px; min-height: var(--h4-control-height); padding: 0 var(--h4-space-3); color: var(--h4-text-secondary); text-decoration: none; font-weight: var(--h4-weight-medium); font-size: var(--h4-text-sm); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.dir-tab:hover { color: var(--h4-text); background: var(--h4-surface-muted); }
.dir-tab.on { color: var(--h4-primary); border-bottom-color: var(--h4-primary); }
.dir-tab-n { font-size: var(--h4-text-xs); font-weight: var(--h4-weight-semibold); background: var(--h4-surface-muted); color: var(--h4-text-secondary); border-radius: var(--h4-radius-pill); padding: 1px 7px; }
.dir-tab.on .dir-tab-n { background: var(--h4-selected-bg); color: var(--h4-selected-fg); }

/* ----- toolbar ----- */
.dir-toolbar { display: flex; align-items: flex-end; gap: var(--h4-space-2); flex-wrap: wrap; margin: 0 0 var(--h4-space-3); }
.dir-toolbar label { display: grid; gap: 3px; font-size: var(--h4-text-xs); font-weight: var(--h4-weight-medium); color: var(--h4-text-muted); }
.dir-toolbar select, .dir-toolbar input { min-height: var(--h4-control-height); font-size: var(--h4-text-sm); }
.dir-toolbar select { padding-right: 28px; }
.dir-search { position: relative; flex: 1 1 240px; max-width: 420px; }
.dir-search input { width: 100%; padding-left: 34px; }
.dir-search-icon { position: absolute; left: 10px; bottom: 13px; color: var(--h4-text-muted); display: inline-flex; pointer-events: none; }
.dir-pres { margin-left: auto; }
.dir-count { font-size: var(--h4-text-sm); color: var(--h4-text-muted); align-self: center; white-space: nowrap; padding-bottom: 2px; margin-left: 4px; }
.dir-clear { font-size: var(--h4-text-sm); align-self: center; padding-bottom: 2px; }
.dir-toolbar .dir-apply { min-height: var(--h4-control-height); }

/* ----- the table ----- */
.directory { position: relative; }
.dir-wrap { background: var(--h4-surface); border: 1px solid var(--h4-border); border-radius: var(--h4-radius-card); overflow: hidden; }
.content .dir-wrap { max-width: 100%; }
.dir-region { overflow-x: auto; overscroll-behavior-x: contain; }
.dir-region:focus-visible { outline: 2px solid var(--h4-focus); outline-offset: 2px; }
table.dir { width: 100%; border-collapse: collapse; font-size: var(--h4-text-sm); min-width: 0; }
.content .card table.dir { min-width: 0; }
table.dir th, table.dir td { text-align: left; vertical-align: middle; padding: 8px 12px; border-bottom: 1px solid var(--h4-border); }
table.dir thead th { font-size: var(--h4-text-xs); font-weight: var(--h4-weight-semibold); color: var(--h4-text-muted); text-transform: none; letter-spacing: .01em; background: var(--h4-surface-muted); white-space: nowrap; height: 40px; }
table.dir tbody tr:last-child td { border-bottom: 0; }
table.dir tbody tr:hover > td { background: color-mix(in srgb, var(--h4-surface-muted) 55%, transparent); }
table.dir td:first-child, table.dir th:first-child { padding-left: var(--h4-space-4); }
table.dir td:last-child, table.dir th:last-child { padding-right: var(--h4-space-3); }
.dir-c-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dir-c-actions { width: 52px; text-align: right; }
.dir-c-mono, .dir code, .dir .mono { font-family: var(--h4-font-mono); font-size: 13px; }
.dir code { background: var(--h4-surface-muted); padding: 1px 6px; border-radius: var(--h4-radius-sm); word-break: normal; white-space: nowrap; color: var(--h4-text); }
.dir a { color: var(--h4-link); }
.dir a.plain { color: inherit; text-decoration: none; }
.dir a.plain:hover { text-decoration: underline; }
.dir .dim { color: var(--h4-text-muted); }

/* identity cell: avatar/icon + name + muted second line */
.ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ident-icon { flex: none; width: 32px; height: 32px; border-radius: var(--h4-radius-sm); display: inline-grid; place-items: center; background: var(--h4-surface-muted); color: var(--h4-text-secondary); font-weight: var(--h4-weight-semibold); font-size: var(--h4-text-sm); }
.ident-icon.avatar { border-radius: 50%; background: var(--h4-selected-bg); color: var(--h4-selected-fg); }
.ident-text { min-width: 0; display: grid; gap: 1px; }
.ident-name { font-weight: var(--h4-weight-medium); color: var(--h4-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-name a { color: inherit; text-decoration: none; }
.ident-name a:hover { text-decoration: underline; }
.ident-sub { font-size: var(--h4-text-xs); color: var(--h4-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-sub code { font-size: 12px; background: none; padding: 0; color: var(--h4-text-muted); }
.ident .brand { flex: none; width: 32px; height: 32px; border-radius: var(--h4-radius-sm); display: inline-grid; place-items: center; font-size: 11px; font-weight: var(--h4-weight-bold); letter-spacing: .02em; border: 1px solid var(--h4-border); background: var(--h4-surface); color: var(--h4-text-secondary); }
.brand-google { color: #1a73e8; } .brand-google-mail { color: #d93025; } .brand-microsoft { color: #0a7cd6; } .brand-ebay { color: #e53238; } .brand-fastmail { color: #0067b9; }
:root[data-theme="dark"] .ident .brand, :root:not([data-theme]) .ident .brand { background: var(--h4-surface-raised); }

/* Summary: 60px rows, identity + muted line. The ordinary default. */
.dir--summary tbody tr:not(.dir-details):not(.dir-skel) > td { height: var(--h4-row-summary); }
/* Single-line: 40px rows, the second line is folded away. */
.dir--single tbody tr:not(.dir-details):not(.dir-skel) > td { height: var(--h4-row-single); padding-top: 4px; padding-bottom: 4px; }
.dir--single .ident-sub { display: none; }
.dir--single .ident-icon, .dir--single .ident .brand { width: 24px; height: 24px; font-size: 11px; }
/* Data grid: 36px rows, thin horizontal and vertical rules, explicit headers, tabular values. */
.dir--grid tbody tr:not(.dir-details):not(.dir-skel) > td { height: var(--h4-row-grid); padding-top: 3px; padding-bottom: 3px; font-variant-numeric: tabular-nums; }
.dir--grid th, .dir--grid td { border-right: 1px solid var(--h4-border); }
.dir--grid th:last-child, .dir--grid td:last-child { border-right: 0; }
.dir--grid tbody tr:last-child td { border-bottom: 1px solid var(--h4-border); }
.dir--grid .ident-sub { display: none; }
.dir--grid .ident-icon, .dir--grid .ident .brand { display: none; }
.dir--grid td { white-space: nowrap; }
.dir--grid td.wrap { white-space: normal; }
.dir-region table.dir--grid { min-width: 720px; }

/* Coarse pointers: interactive rows at least 48px; controls 44px. */
@media (pointer: coarse) {
    table.dir tbody tr:not(.dir-details):not(.dir-skel) > td { height: var(--h4-row-touch-min); }
    .dir-menu-btn, .dir-disclose { min-width: 44px; min-height: 44px; }
}

/* status pills: a word, a dot, the status tokens */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--h4-text-xs); font-weight: var(--h4-weight-semibold); line-height: 1.6; padding: 1px 9px 1px 7px; border-radius: var(--h4-radius-pill); white-space: nowrap; vertical-align: middle; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.active { color: var(--h4-status-active-fg); background: var(--h4-status-active-bg); border-color: transparent; }
.pill.revoked { color: var(--h4-status-revoked-fg); background: var(--h4-status-revoked-bg); border-color: transparent; }
.pill.expired { color: var(--h4-status-expired-fg); background: var(--h4-status-expired-bg); border-color: transparent; }
.pill.pending { color: var(--h4-status-pending-fg); background: var(--h4-status-pending-bg); border-color: transparent; }
.pill.offline { color: var(--h4-status-offline-fg); background: var(--h4-status-offline-bg); border-color: transparent; }
.pill.kind-realm { color: var(--h4-kind-realm-fg); background: var(--h4-kind-realm-bg); border-color: transparent; }
.pill.kind-org { color: var(--h4-kind-org-fg); background: var(--h4-kind-org-bg); border-color: transparent; }
.pill.kind-folder { color: var(--h4-kind-folder-fg); background: var(--h4-kind-folder-bg); border-color: transparent; }
.pill.kind-space { color: var(--h4-kind-space-fg); background: var(--h4-kind-space-bg); border-color: transparent; }

/* chips */
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chip { font: 12px/1.6 var(--h4-font-mono); padding: 1px 7px; border-radius: var(--h4-radius-sm); background: var(--h4-surface-muted); color: var(--h4-text-secondary); border: 1px solid var(--h4-border); white-space: nowrap; }
.chip.more { font-family: var(--h4-font-sans); font-weight: var(--h4-weight-semibold); cursor: help; }
.chip.on { background: var(--h4-selected-bg); color: var(--h4-selected-fg); border-color: transparent; }

/* row overflow menu: details and navigation first; sensitive commands below a rule */
.dir-menu { position: relative; display: inline-block; }
.dir-menu-btn { list-style: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--h4-radius-sm); color: var(--h4-text-secondary); cursor: pointer; font-size: 18px; line-height: 1; }
.dir-menu-btn::-webkit-details-marker { display: none; }
.dir-menu-btn:hover { background: var(--h4-surface-muted); color: var(--h4-text); }
.dir-menu-btn:focus-visible { outline: 2px solid var(--h4-focus); outline-offset: 1px; }
.dir-menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: var(--h4-z-popover); min-width: 200px; padding: 6px; background: var(--h4-surface-raised); border: 1px solid var(--h4-border); border-radius: var(--h4-radius-control); box-shadow: var(--h4-shadow-menu); text-align: left; }
.dir-menu-group { display: grid; }
.dir-menu-group + .dir-menu-group { border-top: 1px solid var(--h4-border); margin-top: 6px; padding-top: 6px; }
.dir-menu-pop a, .dir-menu-pop button { display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0 10px; border: 0; background: none; border-radius: var(--h4-radius-sm); color: var(--h4-text); font: inherit; font-size: var(--h4-text-sm); text-decoration: none; text-align: left; cursor: pointer; white-space: nowrap; }
.dir-menu-pop a:hover, .dir-menu-pop button:hover { background: var(--h4-surface-muted); }
.dir-menu-pop form { margin: 0; }
.dir-menu-sensitive a, .dir-menu-sensitive button { color: var(--h4-danger-fg); }
.dir-menu-sensitive a:hover, .dir-menu-sensitive button:hover { background: var(--h4-danger-bg); }
.dir-row-actions { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.dir-row-actions .btn.sm { min-height: 32px; padding: 0 10px; font-size: var(--h4-text-sm); }

/* inherited rows: provenance, not health. Subdued ink, a source link, never opacity. */
tr.dir-inherited > td { color: var(--h4-text-muted); background: color-mix(in srgb, var(--h4-surface-muted) 45%, transparent); }
tr.dir-inherited .ident-name { color: var(--h4-text-secondary); font-weight: var(--h4-weight-normal); }
tr.dir-inherited .ident-icon { background: var(--h4-surface-muted); color: var(--h4-text-muted); }
.dir-source { display: inline-flex; align-items: center; gap: 4px; font-size: var(--h4-text-sm); }

/* phone details row (Summary): a button opens it; the whole row is never a button */
.dir-disclose { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; background: none; border-radius: var(--h4-radius-sm); color: var(--h4-text-secondary); cursor: pointer; }
.dir-disclose svg { transition: transform var(--h4-motion-fast) var(--h4-ease); transform: rotate(90deg); }
.dir-disclose[aria-expanded="true"] svg { transform: rotate(-90deg); }
.dir-disclose:focus-visible { outline: 2px solid var(--h4-focus); outline-offset: 1px; }
tr.dir-details { display: none; }
.dir-dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: 8px; font-size: var(--h4-text-sm); }
.dir-dl > div { display: grid; gap: 2px; }
.dir-dl dt { font-size: var(--h4-text-xs); color: var(--h4-text-muted); font-weight: var(--h4-weight-medium); }
.dir-dl dd { margin: 0; overflow-wrap: anywhere; }

/* pagination */
.dir-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--h4-space-3); margin: var(--h4-space-3) 0 0; font-size: var(--h4-text-sm); color: var(--h4-text-secondary); flex-wrap: wrap; }
.dir-pager-links { display: inline-flex; align-items: center; gap: var(--h4-space-2); }
.dir-pager .btn { min-height: 36px; padding: 0 12px; text-decoration: none; display: inline-flex; align-items: center; }
.dir-pager .btn[aria-disabled="true"] { color: var(--h4-disabled-fg); background: var(--h4-disabled-bg); border-color: transparent; }

/* empty, loading, error */
.dir-empty { display: grid; justify-items: center; text-align: center; gap: var(--h4-space-2); padding: var(--h4-space-12) var(--h4-space-4); background: var(--h4-surface); border: 1px solid var(--h4-border); border-radius: var(--h4-radius-card); }
.dir-empty h2 { margin: 4px 0 0; font-size: var(--h4-text-lg); }
.dir-empty p { margin: 0; color: var(--h4-text-muted); max-width: 44ch; }
.dir-empty .btn { margin-top: var(--h4-space-2); }
.dir-empty-icon { width: 56px; height: 56px; border-radius: var(--h4-radius-card); display: grid; place-items: center; background: var(--h4-selected-bg); color: var(--h4-selected-fg); }
.dir-empty-filtered { padding: var(--h4-space-8) var(--h4-space-4); }
.dir-empty-filtered p { color: var(--h4-text); }
.dir-skeleton { display: none; }
.dir-loading .dir-rows { display: none; }
.dir-loading .dir-skeleton { display: table-row-group; }
tr.dir-skel > td { height: var(--h4-row-summary); }
.dir--single tr.dir-skel > td { height: var(--h4-row-single); }
.dir--grid tr.dir-skel > td { height: var(--h4-row-grid); }
.skel { display: inline-block; height: 10px; border-radius: 5px; background: var(--h4-skeleton); margin-right: 12px; vertical-align: middle; animation: dir-pulse 1.2s ease-in-out infinite; }
.skel-a { width: 22%; } .skel-b { width: 34%; } .skel-c { width: 12%; }
@keyframes dir-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.dir-error { display: flex; align-items: center; gap: var(--h4-space-3); padding: var(--h4-space-3) var(--h4-space-4); margin: 0 0 var(--h4-space-3); background: var(--h4-danger-bg); color: var(--h4-danger-fg); border: 1px solid var(--h4-danger-border); border-radius: var(--h4-radius-control); }
.dir-error p { margin: 0; flex: 1; }
.dir-error-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--h4-danger-action); color: var(--h4-danger-action-fg); font-weight: var(--h4-weight-bold); font-size: var(--h4-text-sm); }
.dir-error .btn { color: var(--h4-text); }
.dir-note { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--h4-radius-control); border: 1px solid var(--h4-border); background: var(--h4-surface); font-size: var(--h4-text-sm); margin: 0 0 var(--h4-space-3); }
.dir-note.ok { border-color: var(--h4-success-border); background: var(--h4-success-bg); color: var(--h4-success-fg); }
.dir-note.warn { border-color: var(--h4-warning-border); background: var(--h4-warning-bg); color: var(--h4-warning-fg); }
.dir-note.bad { border-color: var(--h4-danger-border); background: var(--h4-danger-bg); color: var(--h4-danger-fg); }

/* ----- detail pages: cards, key/value lists, toggle ----- */
.dir-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--h4-space-4); margin: 0 0 var(--h4-space-4); align-items: start; }
.dir-cards.one { grid-template-columns: 1fr; }
.dir-cards .card { margin: 0; overflow: visible; }
.dir-cards .card h2 { font-size: var(--h4-text-base); margin: 0 0 var(--h4-space-3); }
.kv { margin: 0; display: grid; grid-template-columns: minmax(120px, 160px) 1fr; gap: 10px 16px; font-size: var(--h4-text-sm); align-items: start; }
.kv dt { color: var(--h4-text-muted); font-weight: var(--h4-weight-medium); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.kv dd.end { text-align: right; }
.kv code { font-family: var(--h4-font-mono); font-size: 13px; }
.copy-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 8px; border: 1px solid var(--h4-border); border-radius: var(--h4-radius-sm); background: var(--h4-surface); color: var(--h4-text-secondary); font: inherit; font-size: var(--h4-text-xs); cursor: pointer; margin-left: 6px; vertical-align: middle; }
.copy-btn:hover { background: var(--h4-surface-muted); color: var(--h4-text); }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: var(--h4-control-height); padding: 0 10px 0 4px; border: 1px solid var(--h4-border); border-radius: var(--h4-radius-pill); background: var(--h4-surface); color: var(--h4-text); font: inherit; font-size: var(--h4-text-sm); font-weight: var(--h4-weight-medium); cursor: pointer; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--h4-border-control); position: relative; transition: background var(--h4-motion-fast); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--h4-motion-fast) var(--h4-ease); }
.switch[aria-checked="true"] .track { background: var(--h4-primary); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--h4-focus); outline-offset: 2px; }
.steps-bar { display: flex; gap: var(--h4-space-3); align-items: center; margin: 0 0 var(--h4-space-4); font-size: var(--h4-text-sm); color: var(--h4-text-muted); flex-wrap: wrap; }
.steps-bar .step { display: inline-flex; align-items: center; gap: 6px; }
.steps-bar .step .n { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: var(--h4-text-xs); font-weight: var(--h4-weight-semibold); background: var(--h4-surface-muted); color: var(--h4-text-secondary); }
.steps-bar .step.on { color: var(--h4-text); font-weight: var(--h4-weight-medium); }
.steps-bar .step.on .n { background: var(--h4-primary); color: var(--h4-primary-fg); }
.steps-bar .step.done .n { background: var(--h4-status-active-bg); color: var(--h4-status-active-fg); }
.form-section { display: grid; gap: 12px; padding: var(--h4-space-4) 0; border-top: 1px solid var(--h4-border); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section h2 { margin: 0; font-size: var(--h4-text-base); }
.form-section .hint { margin: -6px 0 0; font-size: var(--h4-text-sm); color: var(--h4-text-muted); }
.scope-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; border: 0; padding: 0; }
.scope-grid label.check { min-height: 32px; align-items: center; }
.secret-card { border-color: var(--h4-warning-border); background: var(--h4-warning-bg); color: var(--h4-warning-fg); }
.secret-card code { background: var(--h4-surface); color: var(--h4-text); font-size: 13px; }
.danger-card { border-color: var(--h4-danger-border); }
.danger-card h2 { color: var(--h4-danger-fg); }
.override-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--h4-text-xs); font-weight: var(--h4-weight-semibold); color: var(--h4-status-expired-fg); background: var(--h4-status-expired-bg); border-radius: var(--h4-radius-sm); padding: 2px 8px; }
.override-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.override-form input { min-height: 36px; font-size: var(--h4-text-sm); }
details.override > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.override > summary::-webkit-details-marker { display: none; }
.policy-value { font-weight: var(--h4-weight-medium); }
.policy-value .chip { font-family: var(--h4-font-mono); }

/* side panel (Enroll device): slides from the right on wide screens, sheet on a phone */
.panel-host { position: relative; }
.side-panel { position: fixed; top: var(--h4-header-height); right: 0; bottom: 0; width: min(420px, 100vw); background: var(--h4-surface-raised); border-left: 1px solid var(--h4-border); box-shadow: var(--h4-shadow-dialog); z-index: var(--h4-z-dialog); padding: var(--h4-space-5); overflow-y: auto; display: grid; align-content: start; gap: var(--h4-space-3); }
.side-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-panel-head h2 { margin: 0; font-size: var(--h4-text-lg); }
.side-panel .icon-btn { min-width: 40px; min-height: 40px; }
.side-panel .backdrop { display: none; }
.panel-backdrop { position: fixed; inset: 0; background: var(--h4-backdrop); z-index: calc(var(--h4-z-dialog) - 1); border: 0; padding: 0; cursor: default; }
.side-panel .code-input { font-family: var(--h4-font-mono); font-size: var(--h4-text-lg); letter-spacing: .12em; text-transform: uppercase; }
.side-panel .preview { background: var(--h4-surface-muted); border-radius: var(--h4-radius-control); padding: 12px 14px; font-size: var(--h4-text-sm); display: grid; gap: 6px; }

/* ----- phone (≤639) ----- */
@media (max-width: 639px) {
    .dir-head h1 { font-size: var(--h4-text-xl); }
    .dir-head-actions { width: 100%; }
    .dir-head-actions .btn.primary { flex: 1; justify-content: center; }
    .dir-toolbar { gap: var(--h4-space-2); }
    .dir-search { flex-basis: 100%; max-width: none; }
    .dir-toolbar > label:not(.dir-search) { flex: 1 1 40%; }
    .dir-pres { margin-left: 0; }
    .dir-count { flex-basis: 100%; }
    .dir-apply { order: 9; }
    /* Summary (and a Data grid that was not chosen) folds optional columns into a details row behind a button */
    .dir--summary .dir-c-opt, .dir--grid.dir--auto .dir-c-opt, .dir--single .dir-c-opt { display: none; }
    .dir--summary .dir-disclose, .dir--grid.dir--auto .dir-disclose, .dir--single .dir-disclose { display: inline-flex; }
    .dir--summary tr.dir-details.open, .dir--grid.dir--auto tr.dir-details.open, .dir--single tr.dir-details.open { display: table-row; }
    tr.dir-details > td { background: var(--h4-surface-muted); padding: 12px var(--h4-space-4); }
    .dir--grid.dir--auto th, .dir--grid.dir--auto td { border-right: 0; white-space: normal; }
    .dir--grid.dir--auto tbody tr:not(.dir-details):not(.dir-skel) > td { height: var(--h4-row-summary); padding-top: 8px; padding-bottom: 8px; }
    .dir--grid.dir--auto .ident-sub { display: block; }
    .dir--grid.dir--auto .ident-icon { display: inline-grid; }
    .dir-region table.dir--grid.dir--auto { min-width: 0; }
    .dir-region:has(> .dir--auto) { overflow-x: visible; }
    .dir-c-actions { width: auto; }
    .dir-row-actions .btn.sm { display: none; }
    .dir-row-actions .dir-menu { display: inline-block; }
    .dir-cards { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 8px; }
    .kv dd.end { text-align: left; }
    .side-panel { top: auto; left: 0; width: 100%; max-height: 88vh; border-left: 0; border-top: 1px solid var(--h4-border); border-radius: var(--h4-radius-dialog) var(--h4-radius-dialog) 0 0; }
    .dir-pager { justify-content: center; text-align: center; }
    .dir-pager .dir-range { flex-basis: 100%; }
}
@media (min-width: 640px) {
    .dir-c-phone { display: none; }
}

/* ----- page-specific bits ----- */
.dir-section { font-size: var(--h4-text-base); margin: 0 0 var(--h4-space-2); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.dir-section .dim { font-size: var(--h4-text-sm); font-weight: var(--h4-weight-normal); }
.link-login > summary.btn { list-style: none; }
.link-login > summary::-webkit-details-marker { display: none; }
.link-login .link-login-form { display: grid; gap: 10px; min-width: 320px; padding: 14px; }
.link-login .link-login-form label { display: grid; gap: 4px; }
.link-login .link-login-form p { margin: 0; font-size: var(--h4-text-sm); }
.realm-cols { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.realm-admin { padding: 8px 0; border-bottom: 1px solid var(--h4-border); }
.realm-admin:last-child { border-bottom: 0; }
.realm-admin .pill { margin-left: auto; }
.policy-table td.wrap { white-space: normal; }
.policy-table .dir-c-actions { width: auto; text-align: left; white-space: nowrap; }
.policy-table .override-form { display: inline-flex; margin: 4px 0 0; }
.policy-table details.override { display: inline-block; vertical-align: middle; }
.policy-table details.override[open] { display: block; }
.policy-table .btn.sm { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 10px; font-size: var(--h4-text-sm); }
.reserved h2 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.reserved table.dir { border: 0; }
.reserved .dir-c-actions { width: auto; }
.dir-c-wide { min-width: 260px; }
@media (max-width: 639px) {
    .realm-cols { grid-template-columns: 1fr; }
    .policy-table .dir-c-actions { white-space: normal; }
    .policy-table .dir-c-opt { display: none; }
    .dir-c-wide { min-width: 0; }
}
.dir-group { margin: 0 0 var(--h4-space-6); }
.dir-group .dir-section { margin-top: var(--h4-space-2); }
/* phone: identity text wraps instead of collapsing; the actions column stays narrow */
@media (max-width: 639px) {
    .ident { gap: 10px; }
    .ident-name, .ident-sub { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
    table.dir td, table.dir th { padding-left: 10px; padding-right: 10px; }
    table.dir td:first-child, table.dir th:first-child { padding-left: 12px; width: 50%; }
    .dir-row-actions { gap: 0; }
    .dir-c-actions { white-space: nowrap; }
    .dir--grid.dir--auto td code { white-space: normal; }
}
/* phone: a row becomes a small card — identity on the first line, status and actions on the second. Real table
   semantics stay in the markup; the Data grid a user chose keeps its grid and scrolls instead. */
@media (max-width: 639px) {
    .dir--summary, .dir--single, .dir--grid.dir--auto, .dir--summary tbody, .dir--single tbody, .dir--grid.dir--auto tbody { display: block; width: 100%; }
    .dir--summary thead, .dir--single thead, .dir--grid.dir--auto thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr:not(.dir-details) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--h4-border); min-height: var(--h4-row-touch-min); }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr:last-of-type { border-bottom: 0; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr:not(.dir-details) > td { display: block; border: 0; padding: 0; height: auto !important; width: auto; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr:not(.dir-details) > td:first-child { grid-column: 1 / -1; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr:not(.dir-details) > td.dir-c-actions { grid-column: 2; justify-self: end; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr:not(.dir-details) > td.dir-c-opt { display: none; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr.dir-details { display: none; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr.dir-details.open { display: block; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr.dir-details > td { display: block; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tr.dir-skel { display: block; padding: 14px 12px; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tr.dir-skel > td { display: block; height: auto !important; padding: 0; border: 0; }
    .dir-row-actions { gap: 2px; }
    .policy-table tbody tr:not(.dir-details) > td.dir-c-actions { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 639px) {
    .dir-count { flex-basis: 100%; order: 10; margin-left: 0; padding-top: 2px; }
    .dir-apply { order: 8; }
    :is(.dir--summary, .dir--single, .dir--grid.dir--auto) tbody tr.dir-details > td { width: auto !important; }
}
/* inside a slide-in the sheet's own header carries the title and Close; the page's back link would open the directory inside the sheet */
.panel-body .dir-back { display: none; }
.panel-body .scope-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.form-errors { align-items: flex-start; }
.form-errors-list { margin: 4px 0 0; padding-left: 18px; }
.form-errors-list li + li { margin-top: 2px; }
/* a detail page inside the 520px sheet: one column of cards, narrower key column, so values never wrap a letter per line */
.panel-body .dir-cards { grid-template-columns: 1fr; }
.panel-body .kv { grid-template-columns: minmax(96px, 128px) minmax(0, 1fr); }
.panel-body .dir-head { flex-direction: column; }
.panel-body .dir-head-actions { width: 100%; justify-content: flex-start; }
/* "App → Login" in a title: the arrow is muted but stays part of the text the sheet title reads */
.dir-head h1 .dir-arrow { color: var(--h4-text-muted); font-weight: var(--h4-weight-normal); }
/* a time stamp in the first column (Audit, Signed calls, Access log) is never clipped to "Nov 4, 2…" */
table.dir td.dir-c-num .ident-name, table.dir td.dir-c-num .ident-sub { overflow: visible; text-overflow: clip; white-space: nowrap; }
table.dir td.dir-c-num .ident-text { min-width: max-content; }
.panel-body .dir-tab { padding: 0 10px; }
.panel-body .dir-tabs { margin-left: -4px; }
/* phone: the Link login popover opens under its button, inside the screen, instead of hanging off the left edge */
@media (max-width: 639px) {
    .link-login .link-login-form { left: 0; right: auto; min-width: 0; width: min(320px, calc(100vw - 72px)); }
}
/* A row with a detail page is itself the click target; its name link and the whole row read as one. */
table.dir tbody tr:not(.dir-details):has(.ident-name a[href]) { cursor: pointer; }
table.dir tbody tr:not(.dir-details):has(.ident-name a[href]):hover > td { background: var(--h4-surface-muted); }
table.dir tbody tr:not(.dir-details):has(.ident-name a[href]):active > td { background: var(--h4-selected-bg); }
table.dir tbody tr:has(.ident-name a[href]) .ident-name a { text-decoration: none; color: inherit; }
table.dir tbody tr:has(.ident-name a[href]):hover .ident-name a { color: var(--h4-link); }
@media (max-width: 639px) {
    table.dir tbody tr:has(.ident-name a[href]) .dir-disclose { display: none; }
    table.dir tbody tr:not(.dir-details):has(.ident-name a[href]):active { background: var(--h4-surface-muted); }
}
