:root {
  --dh-bg: #050816;
  --dh-surface: #0f172a;
  --dh-surface-2: #111c31;
  --dh-surface-3: #18243b;
  --dh-border: rgba(148, 163, 184, 0.22);
  --dh-text: #e5edf8;
  --dh-muted: #94a3b8;
  --dh-primary: #8d7cff;
  --dh-primary-strong: #aa9dff;
  --dh-primary-soft: rgba(141, 124, 255, 0.14);
  --dh-success: #55d6a1;
  --dh-warning: #f1bd66;
  --dh-danger: #ff7d91;
  --dh-blue: #5eb7ff;
  --dh-radius: 14px;
  --dh-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
}

[data-bs-theme="light"] {
  --dh-bg: #f3f5f9;
  --dh-surface: #ffffff;
  --dh-surface-2: #f8f9fc;
  --dh-surface-3: #eef1f6;
  --dh-border: #dfe3eb;
  --dh-text: #1c2230;
  --dh-muted: #677184;
  --dh-primary: #6456d8;
  --dh-primary-strong: #4f41bd;
  --dh-primary-soft: rgba(100, 86, 216, 0.11);
  --dh-shadow: 0 18px 50px rgba(37, 45, 65, 0.1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; background: var(--dh-bg); color: var(--dh-text); font-family: "Open Sans", sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, label, [role="tab"] { touch-action: manipulation; }
.material-symbols-outlined { font-size: 20px; vertical-align: middle; }
.skip-link { position: fixed; z-index: 2000; top: 8px; left: 8px; padding: 10px 14px; background: var(--dh-primary); color: white; border-radius: 8px; }
.eyebrow { margin: 0 0 6px; color: var(--dh-primary-strong); font-size: 11px; font-weight: 700; letter-spacing: .12em; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 18% 10%, rgba(141,124,255,.18), transparent 34%), radial-gradient(circle at 82% 88%, rgba(94,183,255,.1), transparent 32%), var(--dh-bg); }
.login-card { width: min(100%, 430px); padding: 44px; border: 1px solid var(--dh-border); border-radius: 24px; background: color-mix(in srgb, var(--dh-surface) 92%, transparent); box-shadow: var(--dh-shadow); }
.login-card h1 { margin: 12px 0 6px; font-size: 34px; letter-spacing: -.04em; }
.login-lead { color: var(--dh-muted); font-size: 15px; line-height: 1.65; }
.brand-mark, .app-icon { display: grid; place-items: center; color: white; background: linear-gradient(145deg, var(--dh-primary), #5c77f2); box-shadow: 0 8px 24px rgba(110, 93, 230, .3); }
.app-icon { padding: 0; border: 0; }
.app-icon:hover, .app-icon:focus-visible { color: white; transform: translateY(-1px); }
.brand-mark { width: 56px; height: 56px; border-radius: 16px; }
.brand-mark .material-symbols-outlined { font-size: 30px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--dh-primary); --bs-btn-border-color: var(--dh-primary); --bs-btn-hover-bg: var(--dh-primary-strong); --bs-btn-hover-border-color: var(--dh-primary-strong); }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 1030; height: 68px; display: flex; align-items: center; border-bottom: 1px solid var(--dh-border); background: linear-gradient(135deg, #020617, #0f172a); box-shadow: 0 8px 22px rgba(0, 0, 0, .32); }
[data-bs-theme="light"] .topbar { background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); box-shadow: 0 8px 22px var(--dh-shadow); }
.topbar-shell { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.topbar-brand, .topbar-actions, .account-button, .system-status { display: flex; align-items: center; }
.topbar-brand { gap: 11px; min-width: 0; }
.app-icon { width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto; }
.brand-copy { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.brand-copy .organization { color: var(--dh-muted); font-size: 12px; font-weight: 600; }
.brand-copy strong { font-size: 15px; }
.version-badge, .status-pill, .count-badge { display: inline-flex; align-items: center; border: 1px solid var(--dh-border); background: var(--dh-surface-2); color: var(--dh-muted); border-radius: 999px; font-size: 11px; font-weight: 700; }
.version-badge { padding: 4px 8px; }
.primary-nav { align-items: center; gap: 4px; margin-left: 14px; padding: 4px; border: 1px solid var(--dh-border); border-radius: 999px; background: color-mix(in srgb, var(--dh-surface-2) 82%, transparent); }
.view-tab { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--dh-muted); font-weight: 700; }
.view-tab .material-symbols-outlined { font-size: 18px; }
.view-tab:hover, .view-tab:focus-visible, .view-tab.active { background: var(--dh-surface); color: var(--dh-text); }
.topbar-actions { gap: 9px; margin-left: auto; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--dh-muted); }
.icon-button:hover, .icon-button:focus-visible { background: var(--dh-surface-3); color: var(--dh-text); }
.system-status { gap: 7px; padding: 7px 10px; color: var(--dh-muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #6d7481; box-shadow: 0 0 0 4px rgba(109,116,129,.1); }
.system-status.ok .status-dot { background: var(--dh-success); box-shadow: 0 0 0 4px rgba(85,214,161,.1); }
.system-status.error .status-dot { background: var(--dh-danger); box-shadow: 0 0 0 4px rgba(255,125,145,.1); }
.account-button { gap: 9px; min-height: 40px; padding: 3px 9px 3px 4px; border: 1px solid var(--dh-border); border-radius: 14px; background: var(--dh-surface-2); color: var(--dh-text); }
.account-button:hover, .account-button:focus-visible { background: var(--dh-surface-3); }
.avatar { width: 32px; height: 32px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--dh-primary-soft); color: var(--dh-primary-strong); font-size: 11px; font-weight: 700; }
.avatar-stack { display: flex; padding-left: 8px; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--dh-surface); }
.avatar-button { padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.avatar-button:hover, .avatar-button:focus-visible { position: relative; z-index: 2; outline: 2px solid var(--dh-primary); outline-offset: 2px; }

.mobile-tabbar { display: none; }
.sidebar-backdrop { display: none; }
.workspace-grid { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 292px minmax(0, 1fr) 310px; }
.workspace-grid.admin-mode { grid-template-columns: minmax(0, 1fr); }
.workspace-grid.admin-mode .sidebar, .workspace-grid.admin-mode .context-panel { display: none; }
.workspace-grid.admin-mode .workspace { width: min(100%, 1440px); margin-inline: auto; }
.sidebar, .context-panel { position: sticky; top: 68px; height: calc(100vh - 68px); overflow: hidden; background: var(--dh-surface); }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--dh-border); }
.context-panel { overflow-y: auto; border-left: 1px solid var(--dh-border); }
.sidebar-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--dh-border); color: var(--dh-muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-heading > span { display: flex; align-items: center; gap: 7px; }
.sidebar-heading .material-symbols-outlined { font-size: 18px; }
.sidebar-search { margin: 12px; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--dh-border); border-radius: 10px; background: var(--dh-surface-2); color: var(--dh-muted); }
.sidebar-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--dh-text); }
.sidebar-search kbd { padding: 2px 6px; border: 1px solid var(--dh-border); background: var(--dh-surface); color: var(--dh-muted); }
.entity-tree { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.tree-root { width: 100%; display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--dh-text); text-align: left; font-weight: 600; }
.tree-root:hover { background: var(--dh-surface-2); }
.tree-root.active { background: var(--dh-primary-soft); color: var(--dh-primary-strong); }
.tree-root .material-symbols-outlined { color: var(--dh-primary-strong); }
.tree-section { margin-top: 8px; }
.tree-branch { min-width: 0; }
.tree-node-row { display: flex; align-items: center; min-width: 0; padding-left: calc(var(--tree-depth) * 18px); border-radius: 9px; }
.tree-node-row:hover { background: var(--dh-surface-2); }
.tree-node-row.active { background: var(--dh-primary-soft); color: var(--dh-primary-strong); }
.tree-toggle, .tree-toggle-spacer { width: 26px; height: 34px; flex: 0 0 26px; }
.tree-toggle { display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--dh-muted); }
.tree-toggle:hover, .tree-toggle:focus-visible { color: var(--dh-text); background: var(--dh-surface-3); }
.tree-toggle .material-symbols-outlined { font-size: 18px; }
.tree-entry { min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 2px; border: 0; background: transparent; color: inherit; text-align: left; }
.tree-node-icon { color: var(--dh-muted); font-size: 18px; }
.tree-node-row.active .tree-node-icon { color: var(--dh-primary-strong); }
.tree-label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-presence-stack { display: flex; flex: 0 0 auto; padding-right: 5px; }
.tree-presence-stack .avatar-button { margin-left: -5px; }
.tree-presence-stack .avatar { width: 22px; height: 22px; border: 2px solid var(--dh-surface-2); font-size: 8px; }
.tree-empty { padding: 4px 12px 8px 44px; }
.tree-archive { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--dh-border); }
.tree-node-row.archived { opacity: .82; }
.archive-badge { margin-left: auto; padding: 2px 6px; border: 1px solid color-mix(in srgb, var(--dh-warning) 40%, var(--dh-border)); border-radius: 999px; color: var(--dh-warning); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--dh-border); }

.workspace { min-width: 0; padding: 0 34px 60px; background: var(--dh-bg); }
.workspace-header { min-height: 132px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 26px 0 20px; border-bottom: 1px solid var(--dh-border); }
.breadcrumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--dh-muted); font-size: 12px; }
.breadcrumbs button { padding: 2px 0; border: 0; background: transparent; color: var(--dh-primary-strong); font: inherit; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.breadcrumbs button:hover, .breadcrumbs button:focus-visible { text-decoration-color: currentColor; }
.breadcrumbs > * + *::before { content: "/"; margin-right: 6px; color: var(--dh-border); text-decoration: none; }
.title-row { display: flex; align-items: center; gap: 11px; }
.title-row h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.035em; }
.status-pill { padding: 5px 9px; color: var(--dh-warning); border-color: color-mix(in srgb, var(--dh-warning) 35%, var(--dh-border)); background: color-mix(in srgb, var(--dh-warning) 10%, transparent); }
.status-pill.archived { color: var(--dh-warning); }
.entity-meta { margin: 7px 0 0; color: var(--dh-muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--dh-muted); font-size: 12px; }
.save-state .material-symbols-outlined { color: var(--dh-success); }
.notice-area:not(:empty) { margin-top: 18px; }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--dh-border); border-radius: 11px; background: var(--dh-surface); }
.notice.warning { border-color: color-mix(in srgb, var(--dh-warning) 40%, var(--dh-border)); background: color-mix(in srgb, var(--dh-warning) 8%, var(--dh-surface)); }
.field-groups { display: grid; gap: 18px; padding-top: 24px; }
.entity-collections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; padding-top: 24px; }
.entity-section-tabs { position: sticky; top: 68px; z-index: 1010; display: flex; gap: 6px; margin: 0 -4px; padding: 12px 4px; overflow-x: auto; scrollbar-width: none; background: color-mix(in srgb, var(--dh-bg) 92%, transparent); backdrop-filter: blur(10px); }
.entity-section-tabs::-webkit-scrollbar { display: none; }
.entity-section-tab { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--dh-muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.entity-section-tab:hover, .entity-section-tab:focus-visible, .entity-section-tab.active { border-color: var(--dh-border); background: var(--dh-surface); color: var(--dh-text); }
.entity-section-tab.active { box-shadow: inset 0 -2px var(--dh-primary); }
.entity-section-tab .material-symbols-outlined { font-size: 18px; }
.collection-card { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); overflow: hidden; }
.collection-card > header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 11px; padding: 15px; border-bottom: 1px solid var(--dh-border); background: var(--dh-surface-2); }
.collection-card h2, .collection-card p { margin: 0; }
.collection-card h2 { font-size: 14px; }
.collection-card p { margin-top: 3px; color: var(--dh-muted); font-size: 11px; line-height: 1.45; }
.collection-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--dh-primary-soft); color: var(--dh-primary-strong); }
.collection-items { min-width: 0; display: grid; }
.collection-item, .collection-person { min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--dh-border); background: transparent; color: var(--dh-text); text-align: left; }
.collection-item:hover, .collection-item:focus-visible { background: var(--dh-primary-soft); }
.collection-item > .material-symbols-outlined:first-child { color: var(--dh-primary-strong); }
.collection-item > span:nth-child(2), .collection-person > span:last-child { min-width: 0; flex: 1; }
.collection-item strong, .collection-item small, .collection-person strong, .collection-person small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-item strong, .collection-person strong { font-size: 12px; }
.collection-item small, .collection-person small { color: var(--dh-muted); font-size: 10px; }
.collection-chevron { margin-left: auto; color: var(--dh-muted); }
.collection-empty { padding: 16px; }
.collection-card > footer { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 9px 12px; }
.collection-card > footer .btn { min-height: 36px; }
.folder-browser { margin-top: 24px; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); overflow: hidden; }
.folder-browser > header { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--dh-border); background: var(--dh-surface-2); }
.folder-browser > header > .material-symbols-outlined { color: var(--dh-primary-strong); font-size: 28px; }
.folder-browser h2, .folder-browser p, .folder-empty h2, .folder-empty p { margin: 0; }
.folder-browser h2 { font-size: 14px; }
.folder-browser p, .folder-empty p { color: var(--dh-muted); font-size: 12px; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 18px; }
.folder-item { min-width: 0; display: grid; justify-items: start; gap: 6px; padding: 16px; border: 1px solid var(--dh-border); border-radius: 12px; background: var(--dh-surface-2); color: var(--dh-text); text-align: left; }
.folder-item:hover, .folder-item:focus-visible { border-color: var(--dh-primary); background: var(--dh-primary-soft); }
.folder-item > .material-symbols-outlined { color: var(--dh-primary-strong); font-size: 28px; }
.folder-item strong, .folder-item small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item small { color: var(--dh-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.folder-empty { min-height: 280px; display: grid; place-items: center; align-content: center; gap: 8px; margin-top: 24px; padding: 36px; border: 1px dashed var(--dh-border); border-radius: var(--dh-radius); color: var(--dh-muted); text-align: center; }
.folder-empty > .material-symbols-outlined { color: var(--dh-primary-strong); font-size: 42px; }
.folder-empty h2 { color: var(--dh-text); font-size: 17px; }
.field-group { border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); overflow: hidden; }
.field-group-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 18px; border-bottom: 1px solid var(--dh-border); background: var(--dh-surface-2); }
.field-group-header h2 { margin: 0; font-size: 14px; }
.group-chip { padding: 4px 8px; border-radius: 999px; background: var(--dh-primary-soft); color: var(--dh-primary-strong); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.field-list { display: grid; }
.field-row { position: relative; display: grid; grid-template-columns: minmax(150px, 32%) minmax(0, 1fr); gap: 22px; padding: 18px; border-bottom: 1px solid var(--dh-border); }
.field-row:last-child { border-bottom: 0; }
.field-row.is-focused { box-shadow: inset 3px 0 var(--dh-primary); background: var(--dh-primary-soft); }
.field-row.is-locked { background: color-mix(in srgb, var(--dh-surface-2) 50%, transparent); }
.field-label { display: flex; flex-direction: column; gap: 5px; }
.field-label label { font-weight: 600; }
.field-label p { margin: 0; color: var(--dh-muted); font-size: 12px; line-height: 1.5; }
.field-group-tag { width: max-content; color: var(--dh-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.field-control-wrap { min-width: 0; }
.field-control { min-height: 42px; border-color: var(--dh-border); background: var(--dh-surface-2); color: var(--dh-text); }
.field-control:focus { border-color: var(--dh-primary); box-shadow: 0 0 0 3px var(--dh-primary-soft); background: var(--dh-surface); color: var(--dh-text); }
.field-control:disabled { opacity: .72; }
.field-footer { min-height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
.field-meta { color: var(--dh-muted); font-size: 10px; }
.field-actions { display: flex; align-items: center; gap: 7px; }
.field-save { padding: 5px 10px; font-size: 11px; }
.field-save:not(.d-none) { display: inline-flex !important; }
.presence-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border: 1px solid color-mix(in srgb, var(--dh-primary) 35%, var(--dh-border)); border-radius: 999px; background: var(--dh-primary-soft); color: var(--dh-primary-strong); font-size: 10px; }
.presence-chip .avatar { width: 20px; height: 20px; font-size: 8px; }
.lock-copy { display: flex; align-items: center; gap: 5px; color: var(--dh-muted); font-size: 11px; }
.lock-copy .material-symbols-outlined { font-size: 16px; }

.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 0 20px; }
.section-toolbar h2 { margin: 0; font-size: 24px; }
.relation-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.entity-relations { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--dh-border); }
.relation-card { padding: 16px; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); }
.relation-direction { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.relation-node { min-width: 0; flex: 1; padding: 10px; border-radius: 9px; background: var(--dh-surface-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.relation-type { color: var(--dh-primary-strong); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.relation-card p { margin: 0; color: var(--dh-muted); font-size: 12px; }
.user-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; padding-bottom: 28px; }
.user-card { min-width: 0; padding: 16px; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); }
.user-card header { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.user-card header strong, .user-card header small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card header small { color: var(--dh-muted); font-size: 10px; }
.user-card dl { display: grid; gap: 10px; margin: 14px 0 0; }
.user-card dl div { min-width: 0; padding-top: 10px; border-top: 1px solid var(--dh-border); }
.user-card dt { color: var(--dh-muted); font-size: 10px; text-transform: uppercase; }
.user-card dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 12px; }
.user-card > .btn { margin-top: 14px; min-height: 38px; }
.permission-filters { margin-bottom: 18px; }
.permission-filters .sidebar-search { max-width: 520px; margin: 0; }
.role-chip { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: var(--dh-primary-soft); color: var(--dh-primary-strong); font-size: 10px; font-weight: 700; }
.groups-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; padding-bottom: 28px; }
.permissions-groups { margin-top: 10px; border-top: 1px solid var(--dh-border); }
.group-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); }
.group-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.group-card h3, .group-card p { margin: 0; }
.group-card h3 { font-size: 15px; }
.group-card p { color: var(--dh-muted); font-size: 12px; line-height: 1.55; }
.group-id { color: var(--dh-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.group-members-preview { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.group-members-preview .avatar { margin-right: -4px; }
.group-members-preview small { margin-left: 4px; color: var(--dh-muted); }
.group-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; }
.group-member { display: flex; align-items: center; gap: 9px; padding: 10px; border: 1px solid var(--dh-border); border-radius: 10px; background: var(--dh-surface-2); }
.group-member-copy { min-width: 0; flex: 1; }
.group-member-copy strong, .group-member-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-member-copy strong { font-size: 11px; }
.group-member-copy small { color: var(--dh-muted); font-size: 9px; }

.schema-filters { display: grid; grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(150px, 220px)); gap: 12px; margin-bottom: 18px; }
.schema-filters .sidebar-search { margin: 0; }
.schema-fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); gap: 14px; padding-bottom: 28px; }
.schema-field-card { min-width: 0; display: flex; flex-direction: column; gap: 13px; padding: 17px; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); }
.schema-field-card.is-hidden { opacity: .72; }
.schema-field-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.schema-field-card h3, .schema-field-card p { margin: 0; }
.schema-field-card h3 { font-size: 15px; }
.schema-field-card p { min-height: 38px; color: var(--dh-muted); font-size: 12px; line-height: 1.55; }
.schema-field-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.schema-field-card dl div { min-width: 0; padding: 9px; border-radius: 9px; background: var(--dh-surface-2); }
.schema-field-card dt { color: var(--dh-muted); font-size: 9px; text-transform: uppercase; }
.schema-field-card dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 600; }
.schema-field-card dd small { display: block; color: var(--dh-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 400; }
.schema-field-card footer { min-height: 24px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--dh-border); padding-top: 11px; }
.schema-chip { display: inline-flex; padding: 4px 7px; border-radius: 999px; background: var(--dh-primary-soft); color: var(--dh-primary-strong); font-size: 9px; font-weight: 700; }
.schema-chip.muted { background: var(--dh-surface-3); color: var(--dh-muted); }
.entity-files { padding-bottom: 30px; }
.file-filters { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 220px)); gap: 12px; margin-bottom: 18px; }
.file-filters .sidebar-search { margin: 0; }
.file-cards { display: grid; gap: 12px; }
.file-card { min-width: 0; padding: 17px; border: 1px solid var(--dh-border); border-radius: var(--dh-radius); background: var(--dh-surface); }
.file-card > header { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.file-card h3, .file-card p { margin: 0; }
.file-card h3 { font-size: 14px; }
.file-card p { margin-top: 4px; color: var(--dh-muted); font-size: 11px; line-height: 1.5; }
.file-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--dh-primary-soft); color: var(--dh-primary-strong); }
.file-status.review { color: var(--dh-warning); }
.file-status.approved { color: var(--dh-success); }
.file-status.archived { color: var(--dh-muted); }
.file-facts { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.file-facts span { padding: 5px 8px; border-radius: 999px; background: var(--dh-surface-2); color: var(--dh-muted); font-size: 10px; }
.file-card footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--dh-border); }
.file-source { color: var(--dh-muted); font-size: 10px; }
.file-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.file-actions .btn { display: inline-flex; align-items: center; gap: 5px; }
.file-actions .material-symbols-outlined { font-size: 17px; }
.file-source-switch { display: flex; flex-wrap: wrap; gap: 10px; }
.file-source-switch label { min-height: 42px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--dh-border); border-radius: 10px; background: var(--dh-surface-2); }
.field-scope-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.field-scope-option { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 11px; border: 1px solid var(--dh-border); border-radius: 10px; background: var(--dh-surface-2); }

.context-section { padding: 20px; border-bottom: 1px solid var(--dh-border); }
.context-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.context-heading h2 { margin: 0; font-size: 13px; }
.count-badge { min-width: 24px; justify-content: center; padding: 3px 7px; }
.text-button { padding: 0; border: 0; background: none; color: var(--dh-primary-strong); font-size: 11px; font-weight: 600; }
.empty-copy { margin: 0; color: var(--dh-muted); font-size: 12px; line-height: 1.55; }
.presence-list, .relation-summary, .activity-list { display: grid; gap: 12px; }
.presence-person, .activity-item { display: flex; align-items: flex-start; gap: 10px; }
.presence-person { width: 100%; padding: 8px; border: 0; border-radius: 9px; background: var(--dh-surface-2); color: var(--dh-text); text-align: left; }
.presence-person:hover, .presence-person:focus-visible { background: var(--dh-primary-soft); }
.presence-person > div { min-width: 0; }
.presence-person strong, .presence-person small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row.is-presence-target { animation: presence-target 1.8s ease-out; box-shadow: inset 3px 0 var(--dh-success); }
@keyframes presence-target { 0%, 45% { background: color-mix(in srgb, var(--dh-success) 16%, var(--dh-surface)); } 100% { background: transparent; } }
.presence-person strong, .activity-item strong { display: block; font-size: 11px; }
.presence-person small, .activity-item small { color: var(--dh-muted); font-size: 10px; }
.relation-summary-item { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 9px; background: var(--dh-surface-2); }
.relation-summary-item .material-symbols-outlined { color: var(--dh-primary-strong); }
.relation-summary-item div { min-width: 0; }
.relation-summary-item strong, .relation-summary-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relation-summary-item strong { font-size: 11px; }
.relation-summary-item small { color: var(--dh-muted); font-size: 9px; }
.activity-item .activity-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--dh-surface-3); color: var(--dh-muted); }
.activity-item .activity-icon .material-symbols-outlined { font-size: 17px; }
.context-activity { min-height: 220px; }

.modal-content { border: 1px solid var(--dh-border); border-radius: 16px; background: var(--dh-surface); color: var(--dh-text); }
.modal-header, .modal-footer { border-color: var(--dh-border); }
.creation-path { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--dh-border); border-radius: 10px; background: var(--dh-surface-2); }
.creation-path > .material-symbols-outlined { color: var(--dh-primary-strong); }
.creation-path small, .creation-path strong { display: block; }
.creation-path small { color: var(--dh-muted); font-size: 10px; text-transform: uppercase; }
.form-control, .form-select { border-color: var(--dh-border); background-color: var(--dh-surface-2); color: var(--dh-text); }
.form-control:focus, .form-select:focus { border-color: var(--dh-primary); box-shadow: 0 0 0 3px var(--dh-primary-soft); background-color: var(--dh-surface); color: var(--dh-text); }
.field-option-editor { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.modal-body { overflow-x: hidden; }
.account-menu { width: min(380px, 100vw) !important; border-color: var(--dh-border); background: var(--dh-bg); color: var(--dh-text); }
.account-menu .offcanvas-header { min-height: 68px; border-bottom: 1px solid var(--dh-border); background: var(--dh-surface-2); }
.account-menu .offcanvas-header small { color: var(--dh-muted); }
.account-menu-heading { margin: 0 0 9px; color: var(--dh-muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.account-menu-profile { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--dh-border); border-radius: 14px; background: var(--dh-surface); }
.account-menu-profile .avatar { width: 42px; height: 42px; }
.account-menu-profile > span:last-child { min-width: 0; }
.account-menu-profile strong, .account-menu-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-profile small { color: var(--dh-muted); font-size: 10px; }
.account-menu-nav { display: grid; gap: 8px; }
.account-menu-link { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 14px; border: 1px solid var(--dh-border); border-radius: 14px; background: var(--dh-surface); color: var(--dh-text); text-align: left; }
.account-menu-link > span { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.account-menu-link small { color: var(--dh-muted); }
.account-menu-link:hover, .account-menu-link:focus-visible { border-color: var(--dh-primary); background: var(--dh-primary-soft); }
.account-menu-link .material-symbols-outlined { font-size: 19px; }

@media (max-width: 1199.98px) {
  .workspace-grid { grid-template-columns: 270px minmax(0, 1fr); }
  .context-panel { display: none; }
}

@media (max-width: 991.98px) {
  .topbar { height: 60px; }
  .brand-copy .organization, .version-badge { display: none; }
  .workspace-grid { display: block; }
  .mobile-tabbar { position: sticky; top: 60px; z-index: 1020; display: flex; gap: 5px; margin: 8px 10px 0; padding: 5px; border: 1px solid var(--dh-border); border-radius: 16px; background: color-mix(in srgb, var(--dh-bg) 90%, transparent); backdrop-filter: blur(10px); box-shadow: 0 8px 22px var(--dh-shadow); }
  .mobile-tabbar-link { min-width: 0; min-height: 42px; flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 8px; border: 0; border-radius: 12px; background: transparent; color: var(--dh-muted); font-size: 11px; font-weight: 800; }
  .mobile-tabbar-link .material-symbols-outlined { font-size: 18px; }
  .mobile-tabbar-link:hover, .mobile-tabbar-link:focus-visible, .mobile-tabbar-link.active { border: 1px solid var(--dh-border); background: var(--dh-surface); color: var(--dh-text); }
  .sidebar { position: fixed; z-index: 1040; top: 60px; left: 0; width: min(86vw, 310px); height: calc(100dvh - 60px); transform: translateX(-105%); box-shadow: var(--dh-shadow); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { position: fixed; z-index: 1035; inset: 60px 0 0; display: block; border: 0; background: rgba(2, 6, 23, .62); backdrop-filter: blur(2px); }
  .workspace { padding-inline: 20px; }
  .entity-section-tabs { top: 118px; }
}

@media (max-width: 639.98px) {
  .modal-fullscreen-sm-down .modal-body.row { align-content: start; }
  .topbar { height: 60px; }
  .topbar-shell { display: grid; grid-template-columns: 40px minmax(0, 1fr) 44px; gap: 8px; padding-inline: 10px; }
  .topbar-brand { display: contents; }
  .topbar-brand .app-icon { grid-column: 1; }
  .app-icon { width: 32px; height: 32px; }
  .brand-copy { display: none; }
  .topbar-actions { display: contents; }
  .system-status { grid-column: 2; justify-self: center; max-width: 100%; padding: 6px 8px; overflow: hidden; border: 1px solid var(--dh-border); border-radius: 999px; background: var(--dh-surface-2); }
  .system-status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account-button { grid-column: 3; justify-self: end; min-width: 40px; min-height: 40px; padding: 3px; }
  .avatar-stack { display: none; }
  .sidebar { width: min(92vw, 340px); }
  .workspace { padding: 0 12px calc(40px + env(safe-area-inset-bottom)); }
  .workspace-header { min-height: 0; align-items: stretch; flex-direction: column; gap: 14px; padding: 18px 0 14px; }
  .breadcrumbs { max-width: 100%; overflow: hidden; flex-wrap: wrap; }
  .title-row { min-width: 0; flex-wrap: wrap; }
  .title-row h1 { max-width: 100%; overflow-wrap: anywhere; font-size: 24px; }
  .entity-meta { overflow-wrap: anywhere; }
  .header-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .save-state { grid-column: 1 / -1; }
  .header-actions .btn { min-height: 44px; min-width: 0; }
  .field-row { grid-template-columns: 1fr; gap: 10px; padding: 15px; }
  .field-footer { align-items: flex-start; flex-direction: column; }
  .field-actions, .field-save:not(.d-none) { width: 100%; }
  .field-save:not(.d-none) { min-height: 42px; justify-content: center; }
  .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 12px; }
  .folder-item { padding: 13px; }
  .entity-collections { grid-template-columns: 1fr; gap: 12px; padding-top: 16px; }
  .entity-section-tabs { top: 118px; margin-inline: -12px; padding-inline: 12px; }
  .entity-section-tab { flex: 1 0 auto; min-height: 44px; }
  .collection-card > header { padding: 13px; }
  .collection-card > footer { position: sticky; bottom: 0; background: var(--dh-surface); }
  .collection-add { min-height: 42px !important; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .section-toolbar .btn { width: 100%; }
  .schema-filters { grid-template-columns: minmax(0, 1fr); }
  .file-filters { grid-template-columns: minmax(0, 1fr); }
  .file-card > header { grid-template-columns: auto minmax(0, 1fr); }
  .file-card > header .file-status { grid-column: 2; justify-self: start; }
  .file-card footer { align-items: stretch; flex-direction: column; }
  .file-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-actions .btn { min-height: 42px; justify-content: center; }
  .file-actions .icon-button { width: 100%; min-height: 42px; }
  .schema-field-card dl { grid-template-columns: minmax(0, 1fr); }
  .field-scope-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .relation-cards, .groups-grid, .group-members { grid-template-columns: minmax(0, 1fr); }
  .relation-direction { align-items: stretch; flex-direction: column; }
  .relation-direction > .material-symbols-outlined { transform: rotate(90deg); align-self: center; }
  .modal-header, .modal-footer { flex: 0 0 auto; }
  .modal-footer { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; background: var(--dh-surface); }
  .modal-footer .btn { min-height: 46px; margin: 0; }
  .form-control, .form-select { min-height: 46px; font-size: 16px; }
  .field-option-editor { grid-template-columns: minmax(0, 1fr); }
  .field-option-add { min-height: 44px; }
  .login-card { padding: 30px 24px; }
}

@media (max-width: 359.98px) {
  .folder-grid { grid-template-columns: 1fr; }
  .brand-copy { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
