/* ==========================================================================
   Hivemind Admin Console — design tokens, shell layout, shared components
   Shared design tokens and responsive shell components.
   Proof viewports: 1440x900 (desktop), 768x1024 (narrow)
   ========================================================================== */

/* ───────────────────────── @font-face (contract §2.2.3) ───────────────────────── */

@font-face {
    font-family: 'Space Grotesk';
    src: url('/static/fonts/space-grotesk-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Space Grotesk';
    src: url('/static/fonts/space-grotesk-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Hanken Grotesk';
    src: url('/static/fonts/hanken-grotesk-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Hanken Grotesk';
    src: url('/static/fonts/hanken-grotesk-500.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Hanken Grotesk';
    src: url('/static/fonts/hanken-grotesk-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/jetbrains-mono-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/jetbrains-mono-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ───────────────────────── Design tokens (contract §2.1) ───────────────────────── */

:root {
    /* Color tokens — §2.1.1 */
    --hm-ink: #111827;
    --hm-paper: #F7F8F5;
    --hm-surface-deep: #0E141F;
    --hm-panel: #FFFFFF;
    --hm-sunken: #EEF0EC;
    --hm-border: #E4E7EC;
    --hm-border-strong: #C9CFD6;
    --hm-text: #111827;
    --hm-text-muted: #475569;
    --hm-text-faint: #64748B;
    --hm-cyan: #00A7C7;
    --hm-cyan-mid: #0096B4;
    --hm-cyan-deep: #00788F;
    --hm-cyan-wash: rgba(0,167,199,.12);
    --hm-amber: #F59E0B;
    --hm-amber-text: #8A5700;
    --hm-amber-wash: rgba(245,158,11,.12);
    --hm-green: #22C55E;
    --hm-green-wash: rgba(34,197,94,.12);
    --hm-red: #E5484D;
    --hm-red-deep: #C63C42;
    --hm-red-wash: rgba(229,72,77,.08);
    --hm-side-text: #F7F8F5;
    --hm-side-muted: #8B94A3;
    --hm-side-hover: rgba(247,248,245,.06);
    --hm-side-active: rgba(0,167,199,.15);
    --hm-side-border: rgba(247,248,245,.08);

    /* Focus rings — §2.8.1 (light vs dark surfaces) */
    --hm-focus: #0096B4;
    --hm-focus-dark: #00A7C7;

    /* Shape / motion / layout — §2.1.2 */
    --hm-radius: 8px;
    --hm-radius-card: 12px;
    --hm-radius-pill: 999px;
    --hm-transition: 120ms ease-out;
    --hm-sidebar-w: 240px;
    --hm-rail-w: 64px;
    --hm-content-max: 1160px;

    --hm-font-display: var(--hm-font-body);
    --hm-font-body: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --hm-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace;
    --hm-font-wordmark: 'Newsreader', Georgia, 'Times New Roman', serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--hm-font-body);
    font-size: 14px;
    line-height: 20px;
    color: var(--hm-text);
    background: var(--hm-paper);
    -webkit-font-smoothing: antialiased;
}
:where(html:not([data-hm-bootstrap="react-shell"]), .hm-legacy-island:not(.hm-dashboard-island, .hm-mesh-island, .hm-ds-island, .hm-rules-island), .hm-legacy-fragment, #adminModal:not(:has(.hm-rules-dialog)), #toastStack) :is(h1,h2,h3) { font-family: var(--hm-font-display); margin: 0; color: var(--hm-text); }
p { margin: 0; }
button { font-family: inherit; }
:where(html:not([data-hm-bootstrap="react-shell"])) a,
:where(.hm-legacy-island:not(.hm-dashboard-island, .hm-mesh-island, .hm-ds-island, .hm-rules-island), .hm-legacy-fragment, #adminModal:not(:has(.hm-rules-dialog)), #toastStack) a { color: inherit; text-decoration: none; }

/* Type scale — §2.2.2 */
:where(html:not([data-hm-bootstrap="react-shell"]), .hm-legacy-island:not(.hm-dashboard-island, .hm-mesh-island, .hm-ds-island, .hm-rules-island), .hm-legacy-fragment, #adminModal:not(:has(.hm-rules-dialog)), #toastStack) h1 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: normal; }
:where(html:not([data-hm-bootstrap="react-shell"]), .hm-legacy-island:not(.hm-dashboard-island, .hm-mesh-island, .hm-ds-island, .hm-rules-island), .hm-legacy-fragment, #adminModal:not(:has(.hm-rules-dialog)), #toastStack) h2 { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: normal; }
:where(html:not([data-hm-bootstrap="react-shell"]), .hm-legacy-island:not(.hm-dashboard-island, .hm-mesh-island, .hm-ds-island, .hm-rules-island), .hm-legacy-fragment, #adminModal:not(:has(.hm-rules-dialog)), #toastStack) h3 { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: normal; }
.body-small { font-size: 13px; line-height: 18px; }
.micro-label {
    font-family: var(--hm-font-body);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    letter-spacing: normal;
    text-transform: none;
}
.metric-value {
    font-family: var(--hm-font-mono);
    font-size: 22px;
    line-height: 28px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.mono, .mono-data {
    font-family: var(--hm-font-mono);
    font-size: 12.5px;
    line-height: 18px;
}
.unit-timezone { color: var(--hm-text-faint); font-family: var(--hm-font-mono); font-size: 11px; }

/* Focus visibility — §2.8.1 (never suppressed) */
:focus-visible:not(:where(.hm-mesh-island :is(button, a, input, textarea, [role="checkbox"]))) {
    outline: 2px solid var(--hm-focus);
    outline-offset: 2px;
}
.sidebar :focus-visible,
.login-overlay :focus-visible {
    outline-color: var(--hm-focus-dark);
}

/* Reduced motion for the legacy surfaces: no transition, no animation. Design-system components are exempt (#2265):
   the design system keeps its own reduced-motion alternative (a 300 ms opacity fade for the Drawer, a slowed
   spinner, a fading toast) and marks every such element with an `hm:motion-reduce:` utility class. An `!important`
   rule on `*` would override those declarations, so the elements that declare one are left out. Legacy markup
   never carries that class, so every legacy element is still covered. Guarded by tests/test_portal_reduced_motion_2265.py. */
@media (prefers-reduced-motion: reduce) {
    :not([class*="hm:motion-reduce:"]),
    :not([class*="hm:motion-reduce:"])::before,
    :not([class*="hm:motion-reduce:"])::after { transition: none !important; animation: none !important; }
}

/* ───────────────────────── App shell (contract §2.3.1) ───────────────────────── */

.app { display: flex; height: 100vh; }

.sidebar {
    width: var(--hm-sidebar-w);
    flex-shrink: 0;
    background: var(--hm-surface-deep);
    color: var(--hm-side-text);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10;
}

.content {
    flex: 1;
    overflow-y: auto;
    background: var(--hm-paper);
}
.content:focus { outline: none; }

/* Portal shell. The main reader scrolls independently of the instance bar. */
.portal-workspace { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.portal-topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 24px; background: var(--hm-panel); border-bottom: 1px solid var(--hm-border); }
/* #699 header banner: GET /health chips with their read time (§18.3). */
.portal-status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.portal-health { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; font-size: 13px; color: var(--hm-text-muted); }
.portal-health-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--hm-radius-pill); font-size: 12.5px; font-weight: 600; background: var(--hm-paper); color: var(--hm-text); }
.portal-health-pill .status-dot-label { color: inherit; }
.portal-health-pill--ok { background: var(--hm-green-wash); }
.portal-health-pill--warn { background: var(--hm-amber-wash); color: var(--hm-amber-text); }
.portal-health-pill--error { background: var(--hm-red-wash); color: var(--hm-red-deep); }
.portal-health-time { font-size: 12px; color: var(--hm-text-muted); white-space: nowrap; }
.portal-services-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 12px 0; font-size: 13px; }
.portal-services-grid dt { color: var(--hm-text-faint); }
.portal-services-grid dd { margin: 0; color: var(--hm-text); overflow-wrap: anywhere; }
.portal-services-item { margin-top: 12px; overflow-wrap: anywhere; }
.portal-services-item h3 { margin-bottom: 4px; }
.portal-services > .btn { margin-top: 16px; }
/* #598: compact read-only session badge, visible at every width (§17.8). */
.portal-readonly-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--hm-radius-pill); background: var(--hm-cyan-wash); color: var(--hm-cyan-deep); font-family: var(--hm-font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.portal-readonly-badge[hidden], .nav-group[hidden] { display: none; }
.portal-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.portal-controls [hidden] { display: none; }
.portal-auto { display: flex; align-items: center; gap: 6px; font-size: 13px; min-height: 44px; cursor: pointer; }
.portal-interval .form-input { width: 76px; min-height: 36px; }
.portal-controls .body-small { color: var(--hm-text-muted); }
#loginOverlay .login-intro { margin: 8px 0 24px; color: var(--hm-side-muted); }
#loginOverlay .login-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
#loginOverlay .login-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--hm-cyan); }
.sd-space-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 24px 0 16px; }
.sd-space-nav > .sd-link { display: inline-flex; align-items: center; min-height: 44px; }
.sd-space-tabs { display: flex; flex: 1; min-width: 0; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--hm-border); }
.sd-space-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--hm-text-muted); font: inherit; font-size: 14px; padding: 10px 12px; min-height: 44px; cursor: pointer; }
.sd-space-tab:hover { background: var(--hm-paper); }
.sd-space-tab.active { color: var(--hm-cyan-deep); border-bottom-color: var(--hm-cyan-deep); font-weight: 600; }
#sdMaintenanceTools > .page { padding: 0; }
@media (max-width: 767px) {
    .portal-topbar { padding: 12px; align-items: flex-start; }
    .portal-controls { width: 100%; }
    .portal-controls .btn, .portal-interval .form-input { min-height: 44px; }
    .sd-space-tab { padding: 10px 8px; }
}

.page {
    max-width: var(--hm-content-max);
    margin: 0 auto;
    padding: 32px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }

/* ───────────────────────── Sidebar spec (contract §2.3.2) ───────────────────────── */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid var(--hm-side-border);
    flex-shrink: 0;
}
.brand-wordmark {
    font-family: var(--hm-font-wordmark);
    font-size: 18px;
    color: var(--hm-side-text);
    line-height: 1;
}

.sidebar-menu-toggle svg { width: 20px; height: 20px; }
.sidebar-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 40px;
    background: none;
    border: none;
    color: var(--hm-side-muted);
    cursor: pointer;
}

.identity {
    padding: 12px 16px;
    border-bottom: 1px solid var(--hm-side-border);
}
.identity-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.identity-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--hm-side-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.identity-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.identity-unavailable { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.chip {
    display: inline-block;
    font-family: var(--hm-font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: var(--hm-radius-pill);
    background: var(--hm-side-border);
    color: var(--hm-side-muted);
}
.chip-expiry { white-space: nowrap; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--hm-side-muted);
    border-radius: var(--hm-radius);
    cursor: pointer;
    transition: background var(--hm-transition), color var(--hm-transition);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--hm-side-hover); color: var(--hm-side-text); }
.icon-btn svg { width: 16px; height: 16px; }

.nav-primary, .nav-operator {
    list-style: none;
    margin: 0;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 8px 12px;
    border-radius: var(--hm-radius);
    color: var(--hm-side-muted);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--hm-transition), color var(--hm-transition);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; color: inherit; }
.nav-item:hover { background: var(--hm-side-hover); }
.nav-item.active {
    background: var(--hm-side-active);
    color: var(--hm-side-text);
}
.nav-item.active svg { color: var(--hm-cyan); }

.nav-flex-spacer { flex: 1; }

.nav-group-label {
    padding: 8px 16px 4px;
    color: var(--hm-side-muted);
}

/* #699: instance and version share the navigation footer. */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    border-top: 1px solid var(--hm-side-border);
    color: var(--hm-side-muted);
    font-size: 11px;
    flex-shrink: 0;
    min-width: 0;
}
.sidebar-footer .sidebar-instance { font-size: 11px; color: var(--hm-side-text); overflow-wrap: anywhere; }

.sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14,20,31,.5);
    z-index: 900;
}
.sidebar-scrim.visible { display: block; }

/* ───────────────────────── Login screen (contract §2.3.3) ───────────────────────── */

#loginOverlay.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--hm-surface-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 16px;
    z-index: 10000;
    transition: opacity 200ms ease-out;
}
.login-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

#loginOverlay .login-card {
    width: 464px;
    max-width: calc(100vw - 32px);
    margin: auto;
    background: var(--hm-ink);
    border: 1px solid var(--hm-side-border);
    border-radius: var(--hm-radius-card);
    padding: 32px;
    text-align: center;
}
.login-logo { display: block; margin: 0 auto 8px; }
.login-wordmark {
    font-family: var(--hm-font-wordmark);
    font-size: 22px;
    color: var(--hm-side-text);
    margin-bottom: 20px;
}
.login-title {
    color: var(--hm-paper);
    font-size: 18px;
    line-height: 26px;
    font-weight: 600;
    margin-bottom: 4px;
}
.login-form { text-align: left; }
.login-form label {
    display: block;
    font-family: var(--hm-font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hm-side-muted);
    margin-bottom: 6px;
}
#loginOverlay .login-form input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    background: var(--hm-surface-deep);
    border: 1px solid var(--hm-side-border);
    border-radius: var(--hm-radius);
    color: var(--hm-side-text);
    font-family: var(--hm-font-mono);
    font-size: 14px;
    margin-bottom: 0;
}
#loginOverlay .login-form input::placeholder { color: var(--hm-side-muted); opacity: 1; }
#loginOverlay .login-form input:focus {
    outline: none;
    border-color: var(--hm-focus-dark);
    box-shadow: 0 0 0 3px rgba(0,167,199,.25);
}
#loginOverlay .login-permission-help {
    color: var(--hm-side-muted);
    font-size: 12px;
    line-height: 18px;
    margin: 10px 0 16px;
}
#loginOverlay .login-error {
    color: var(--hm-red);
    font-size: 13px;
    line-height: 18px;
    min-height: 18px;
    margin-top: 8px;
    margin-bottom: 8px;
}
#loginOverlay .login-submit {
    display: block;
    width: min(176px, 100%);
    min-height: 44px;
    margin: 8px auto 0;
}
.login-footer {
    margin-top: 20px;
    color: var(--hm-side-muted);
    font-size: 11px;
}
#loginOverlay #loginVersion { font-size: 11px; }

@media (max-width: 480px) {
    #loginOverlay .login-card { padding: 24px; }
}

/* OAuth consent page (AUTH-5b #1264, contract §2.3.3.1): the same sign-in card on
   its own page, no script. Rules stay scoped to body.oauth-consent. */
.oauth-consent #loginOverlay .login-card { width: 520px; text-align: left; }
.oauth-consent #loginOverlay .login-logo, .oauth-consent #loginOverlay .login-wordmark,
.oauth-consent #loginOverlay .login-title { text-align: center; }
.oauth-consent .login-title { overflow-wrap: anywhere; }
.oauth-consent-body { display: grid; gap: 12px; margin-top: 16px; color: var(--hm-side-text); font-size: 14px; line-height: 20px; }
.oauth-consent-body p { margin: 0; overflow-wrap: anywhere; }
.oauth-consent-body strong { color: var(--hm-paper); }
.oauth-consent-body code { font-family: var(--hm-font-mono); font-size: 12px; overflow-wrap: anywhere; }
.oauth-consent-muted { color: var(--hm-side-muted); font-size: 12px; line-height: 18px; }
.oauth-consent-error { color: var(--hm-red); font-size: 13px; line-height: 18px; }
.oauth-consent-card { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--hm-side-border); border-radius: var(--hm-radius); background: var(--hm-surface-deep); }
.oauth-consent-client { color: var(--hm-paper); font-weight: 600; }
.oauth-consent-form { display: grid; gap: 12px; }
.oauth-consent-form fieldset { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.oauth-consent-form legend {
    padding: 0;
    margin-bottom: 4px;
    font-family: var(--hm-font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hm-side-muted);
}
.oauth-consent-option { display: flex; align-items: flex-start; gap: 8px; min-height: 32px; cursor: pointer; overflow-wrap: anywhere; }
.oauth-consent-option > input { margin-top: 2px; flex: none; }
.oauth-consent #loginOverlay .oauth-consent-input {
    display: block;
    width: 100%;
    height: 36px;
    margin-top: 6px;
    padding: 0 10px;
    background: var(--hm-surface-deep);
    border: 1px solid var(--hm-side-border);
    border-radius: var(--hm-radius);
    color: var(--hm-side-text);
    font-family: var(--hm-font-mono);
    font-size: 13px;
}
.oauth-consent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.oauth-consent-actions form { display: contents; }
.oauth-consent-button { min-height: 44px; justify-content: center; flex: 1 1 160px; }
.oauth-consent .btn-secondary { background: transparent; color: var(--hm-side-text); border-color: var(--hm-side-border); }
.oauth-consent .btn-secondary:hover:not(:disabled) { background: var(--hm-surface-deep); border-color: var(--hm-side-muted); }
.oauth-consent .btn-ghost { color: var(--hm-cyan); padding: 0; height: auto; min-height: 32px; }
@media (max-width: 480px) {
    .oauth-consent #loginOverlay .login-card { padding: 24px; }
}
@media (max-width: 240px) {
    #loginOverlay .login-form input { font-size: 12px; }
}

/* Publication pages (PUB-1 #714, DESIGN/hivemind/PORTAL_PUBLICATION_V170.md): server-rendered, no script.
   Rules stay scoped to body.publication-page and use the contract §2.1 tokens only. */
.publication-page { background: var(--hm-paper); color: var(--hm-text); min-height: 100vh; }
.pub-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px;
    background: var(--hm-surface-deep); color: var(--hm-side-text); }
.pub-brand { font-family: var(--hm-font-wordmark); font-size: 20px; line-height: 1; color: var(--hm-side-text); min-height: 44px; display: inline-flex; align-items: center; }
.pub-nav a { color: var(--hm-side-text); min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px; }
.pub-nav a:focus-visible, .pub-brand:focus-visible { outline: 2px solid var(--hm-focus-dark); outline-offset: 2px; }
.pub-main { max-width: 960px; margin: 0 auto; padding: 24px; display: grid; gap: 16px; }
.pub-main h1 { overflow-wrap: anywhere; }
.pub-main h2 { margin-top: 8px; }
.pub-muted { color: var(--hm-text-muted); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.pub-error { color: var(--hm-red-deep); font-size: 14px; line-height: 20px; }
.pub-guidance { padding: 12px; border-left: 4px solid var(--hm-cyan-deep); background: var(--hm-cyan-wash); border-radius: var(--hm-radius); }
.pub-card { background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 16px; }
.pub-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; margin: 0; }
.pub-facts dt { color: var(--hm-text-muted); font-size: 12px; }
.pub-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.pub-main code { font-family: var(--hm-font-mono); font-size: 12px; overflow-wrap: anywhere; }
.pub-chip { display: inline-block; padding: 2px 10px; border-radius: var(--hm-radius-pill); border: 1px solid var(--hm-border-strong);
    background: var(--hm-sunken); font-size: 12px; line-height: 18px; }
.pub-state-approved, .pub-state-completed, .pub-change-unchanged { background: var(--hm-green-wash); border-color: var(--hm-green); }
.pub-state-submitted, .pub-state-source_confirmed, .pub-state-applying, .pub-change-changed, .pub-change-added { background: var(--hm-cyan-wash); border-color: var(--hm-cyan-deep); }
.pub-state-rejected, .pub-state-cancelled, .pub-state-recovery_required, .pub-change-removed { background: var(--hm-red-wash); border-color: var(--hm-red-deep); }
.pub-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.pub-form { display: grid; gap: 8px; margin: 0; }
.pub-button { min-height: 44px; min-width: 44px; justify-content: center; }
.pub-field { display: grid; gap: 4px; font-size: 13px; }
.pub-input { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--hm-border-strong); border-radius: var(--hm-radius);
    background: var(--hm-panel); color: var(--hm-text); font: inherit; }
.pub-input:focus-visible, .pub-text:focus-visible, .pub-table a:focus-visible { outline: 2px solid var(--hm-focus); outline-offset: 2px; }
.pub-item { background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 16px; display: grid; gap: 8px; }
.pub-item h3 { overflow-wrap: anywhere; }
.pub-text { margin: 0; padding: 12px; background: var(--hm-sunken); border-radius: var(--hm-radius); font-family: var(--hm-font-mono);
    font-size: 12px; line-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.pub-line { display: block; }
.pub-mark { display: inline-block; width: 1.5em; font-weight: 700; }
.pub-line-add { background: var(--hm-green-wash); }
.pub-line-del { background: var(--hm-red-wash); }
.pub-table-wrap { overflow-x: auto; }
.pub-table { width: 100%; border-collapse: collapse; background: var(--hm-panel); border: 1px solid var(--hm-border); }
.pub-table caption { text-align: left; padding: 8px 0; }
.pub-table th, .pub-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hm-border); vertical-align: top; }
.pub-table a { text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; }
@media (max-width: 640px) {
    .pub-main { padding: 16px; }
    .pub-header { padding: 8px 16px; }
    .pub-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .pub-table tr { display: block; border-bottom: 1px solid var(--hm-border); padding: 8px 0; }
    .pub-table td { display: block; border: 0; padding: 4px 12px; }
    .pub-table td::before { content: attr(data-label) ": "; color: var(--hm-text-muted); font-size: 12px; }
    .pub-actions { display: grid; }
}

/* ───────────────────────── Buttons (contract §2.4.1) ───────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--hm-radius);
    border: none;
    font-family: var(--hm-font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--hm-transition), border-color var(--hm-transition), color var(--hm-transition);
    white-space: nowrap;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }

.btn-primary { background: var(--hm-cyan); color: var(--hm-surface-deep); }
.btn-primary:hover:not(:disabled) { background: var(--hm-cyan-mid); }

.btn-secondary {
    background: var(--hm-panel);
    color: var(--hm-text);
    border: 1px solid var(--hm-border-strong);
}
.btn-secondary:hover:not(:disabled) { border-color: #9AA3AF; background: #F8F9F7; }

.btn-danger { background: var(--hm-red-deep); color: #FFFFFF; }
.btn-danger:hover:not(:disabled) { background: #AF343B; }

.btn-ghost { background: transparent; color: var(--hm-cyan-deep); }
.btn-ghost:hover:not(:disabled) { background: var(--hm-cyan-wash); }

/* ───────────────────────── Compact tables (contract §2.4.2) ───────────────────────── */

.table-scroll { overflow-x: auto; }
.sd-pending-table { min-width: 64rem; table-layout: fixed; }
.sd-pending-table td { overflow-wrap: anywhere; vertical-align: top; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    font-family: var(--hm-font-body);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    letter-spacing: normal;
    text-transform: none;
    color: var(--hm-text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--hm-border-strong);
    text-align: left;
}
.data-table td {
    font-size: 13px;
    line-height: 18px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--hm-border);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #F6F7F4; }
.data-table .row-muted { opacity: .55; }
.data-table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.data-table td.actions { text-align: right; white-space: nowrap; }

/* ───────────────────────── Cards (contract §2.4.3) ───────────────────────── */

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.metric-card {
    background: var(--hm-panel);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-card);
    padding: 16px;
    text-align: left;
    transition: border-color var(--hm-transition), transform var(--hm-transition);
}
button.metric-card { cursor: pointer; }
button.metric-card:hover { border-color: var(--hm-border-strong); transform: translateY(-1px); }

.item-card {
    background: var(--hm-panel);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-card);
    padding: 12px 16px;
}
.item-card.tier-short { box-shadow: inset 0 2px 0 var(--hm-cyan); }
.item-card.tier-mid { box-shadow: inset 0 2px 0 var(--hm-amber); }
.item-card.tier-long { box-shadow: inset 0 2px 0 var(--hm-ink); }

/* ───────────────────────── Chips, badges, status dots, pills (§2.4.4) ───────────────────────── */

.status-dot-wrap { display: inline-flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--hm-green); }
.dot-warn { background: var(--hm-amber); }
.dot-error { background: var(--hm-red); }
.dot-neutral { background: var(--hm-text-faint); }
.status-dot-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--hm-text); }

.pill {
    display: inline-flex;
    align-items: center;
    font-family: var(--hm-font-body);
    font-size: 11px;
    line-height: 14px;
    font-weight: 500;
    letter-spacing: normal;
    text-transform: none;
    padding: 2px 10px;
    border-radius: var(--hm-radius-pill);
}
.pill-ok { background: var(--hm-green-wash); color: var(--hm-text); }
.pill-warn { background: var(--hm-amber-wash); color: var(--hm-amber-text); }
.pill-error { background: var(--hm-red-wash); color: var(--hm-red-deep); }
.pill-neutral { background: var(--hm-sunken); color: var(--hm-text-muted); }

.badge-reserved {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--hm-sunken);
    color: var(--hm-text-muted);
    font-family: var(--hm-font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: var(--hm-radius-pill);
}
.badge-reserved svg { width: 12px; height: 12px; }

.count-pill {
    display: inline-flex;
    font-family: var(--hm-font-mono);
    font-variant-numeric: tabular-nums;
    background: var(--hm-sunken);
    color: var(--hm-text-muted);
    padding: 2px 10px;
    border-radius: var(--hm-radius-pill);
    font-size: 12px;
}

/* ───────────────────────── Forms (contract §2.4.5) ───────────────────────── */

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-family: var(--hm-font-body);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    letter-spacing: normal;
    text-transform: none;
    color: var(--hm-text-muted);
    margin-bottom: 6px;
}
.form-label .req { color: var(--hm-red-deep); }
.typed-challenge { text-transform: none; letter-spacing: normal; }
.form-input, select.form-input, textarea.form-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--hm-border-strong);
    border-radius: var(--hm-radius);
    background: var(--hm-panel);
    color: var(--hm-text);
    font-family: var(--hm-font-body);
    font-size: 14px;
}
textarea.form-input { height: auto; padding: 8px 12px; resize: vertical; }
.form-input.mono { font-family: var(--hm-font-mono); }
.form-input::placeholder { color: var(--hm-text-faint); }
.form-input:focus {
    outline: none;
    border-color: var(--hm-focus);
    box-shadow: 0 0 0 3px rgba(0,150,180,.25);
}
.form-hint { font-size: 12px; line-height: 16px; color: var(--hm-text-faint); margin-top: 4px; }
.form-error { font-size: 12px; line-height: 16px; color: var(--hm-red-deep); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.form-error[hidden] { display: none; }
.form-error svg { width: 14px; height: 14px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--hm-cyan); width: 16px; height: 16px; }

/* ───────────────────────── Single-modal architecture (contract §2.4.6) ───────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14,20,31,.55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}
.modal-card {
    background: var(--hm-panel);
    border-radius: var(--hm-radius-card);
    width: 560px;
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.modal-card.wide { width: 720px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hm-border);
}
.modal-header h3 { margin: 0; }
/* Destructive variant (§2.4.6, §7.4.4: Critical Red family, alert-icon header) */
.modal-header--danger { gap: 8px; }
.modal-header-icon { display: inline-flex; color: var(--hm-red); flex-shrink: 0; }
.modal-header-icon svg { width: 20px; height: 20px; }
.modal-close { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: none; border: none; color: var(--hm-text-muted); border-radius: var(--hm-radius); cursor: pointer; }
.modal-close:hover { background: var(--hm-sunken); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--hm-border); display: flex; justify-content: flex-end; gap: 8px; }

.destructive-summary {
    background: var(--hm-red-wash);
    border: 1px solid var(--hm-red);
    border-radius: var(--hm-radius-card);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 18px;
}

/* ───────────────────────── Mono blocks, copy affordance (contract §2.4.7) ───────────────────────── */

.mono-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    min-width: 0;
    font-family: var(--hm-font-mono);
    font-size: 12.5px;
    background: var(--hm-sunken);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius);
    padding: 2px 8px;
}
.mono-chip-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    color: var(--hm-text-muted);
    cursor: pointer;
    border-radius: var(--hm-radius);
    flex-shrink: 0;
}
.copy-btn:hover { background: var(--hm-border); }
.copy-btn svg { width: 14px; height: 14px; }

.mono-block {
    font-family: var(--hm-font-mono);
    font-size: 12.5px;
    line-height: 18px;
    background: var(--hm-sunken);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius);
    padding: 12px;
    max-height: 40vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.mono-block.secret { user-select: all; }

/* ───────────────────────── Toasts and server-message slot (contract §2.4.8) ───────────────────────── */

.toast-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 360px;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9500;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--hm-panel);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-card);
    padding: 10px 12px;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-ok { border-color: var(--hm-green); }
.toast-warn { border-color: var(--hm-amber); }
.toast-error { border-color: var(--hm-red); }
.toast-text { flex: 1; font-size: 13px; line-height: 18px; }
.toast-close { background: none; border: none; color: var(--hm-text-faint); cursor: pointer; width: 20px; height: 20px; flex-shrink: 0; }
.toast-close svg { width: 14px; height: 14px; }

.server-msg {
    background: var(--hm-sunken);
    border-radius: var(--hm-radius);
    padding: 8px 12px;
    margin-top: 8px;
}
.server-msg-label {
    display: block;
    font-family: var(--hm-font-body);
    font-size: 13px;
    letter-spacing: normal;
    text-transform: none;
    color: var(--hm-text-muted);
    margin-bottom: 2px;
}
.server-msg-text { display: block; font-size: 13px; line-height: 18px; color: var(--hm-text); }

/* ───────────────────────── Panels ───────────────────────── */

.panel {
    background: var(--hm-panel);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-card);
    padding: 16px;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ───────────────────────── State patterns (contract §2.7) ───────────────────────── */

.state {
    text-align: center;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.state svg { width: 24px; height: 24px; color: var(--hm-text-faint); }
.state h3 { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--hm-text); }
.state-empty--compact { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; padding: 8px 0; text-align: left; font-size: 13px; color: var(--hm-text-muted); }
.state-hint { font-size: 13px; line-height: 18px; color: var(--hm-text-faint); }

.state-loading { flex-direction: row; padding: 24px; color: var(--hm-text-muted); font-size: 13px; }
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--hm-border-strong);
    border-top-color: var(--hm-cyan);
    animation: hm-spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
}
@keyframes hm-spin { to { transform: rotate(360deg); } }

.skeleton-row {
    height: 14px;
    border-radius: var(--hm-radius);
    background: var(--hm-sunken);
    animation: hm-pulse 1.2s ease-in-out infinite;
}
@keyframes hm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
    .skeleton-row { animation: none; }
}

.state-error {
    background: var(--hm-red-wash);
    border: 1px solid rgba(229,72,77,.35);
    border-radius: var(--hm-radius-card);
}
.state-error svg { color: var(--hm-red); }
.state-error h3 { color: var(--hm-red-deep); }

.state-degraded {
    background: var(--hm-amber-wash);
}
.state-degraded svg { color: var(--hm-amber); }
.state-degraded h3 { color: var(--hm-amber-text); }

.state-unavailable {
    background: var(--hm-sunken);
    border-radius: var(--hm-radius);
    padding: 16px;
    text-align: left;
}
.state-unavailable p { font-size: 12px; line-height: 16px; color: var(--hm-text-faint); margin-top: 4px; }

.fail-closed-banner {
    background: var(--hm-red-wash);
    border: 1px solid var(--hm-red);
    border-radius: var(--hm-radius-card);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
}
.fail-closed-banner svg { width: 20px; height: 20px; color: var(--hm-red); flex-shrink: 0; }

.dot-running { animation: hm-dot-pulse 1.6s ease-in-out infinite; }
@keyframes hm-dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
    .dot-running { animation: none; }
}

/* ───────────────────────── Layout grid & responsive behavior (contract §2.6) ───────────────────────── */

@media (max-width: 1023px) {
    .sidebar {
        width: var(--hm-rail-w);
        position: relative;
    }
    .sidebar-menu-toggle { display: flex; }
    .brand-wordmark { display: none; }
    .nav-item .nav-label { display: none; }
    .nav-group-label { display: none; border-top: 1px solid var(--hm-side-border); height: 1px; padding: 0; margin: 8px; }
    .sidebar-footer { display: none; }
    .identity { padding: 8px; }
    .identity-chips, .identity-name { display: none; }
    .identity-row { justify-content: center; }
    /* Degraded identity (system_whoami failed, §3.2.2) must collapse the
       same way the populated identity block does — otherwise the
       full-width .state-unavailable block overflows the 64px rail. */
    .identity-unavailable { justify-content: center; }
    .identity-unavailable .state-unavailable { display: none; }

    .sidebar.sidebar--drawer-open {
        width: var(--hm-sidebar-w);
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 901;
    }
    .sidebar--drawer-open .brand-wordmark,
    .sidebar--drawer-open .nav-item .nav-label,
    .sidebar--drawer-open .nav-group-label,
    .sidebar--drawer-open .sidebar-footer,
    .sidebar--drawer-open .identity-chips,
    .sidebar--drawer-open .identity-name,
    .sidebar--drawer-open .identity-unavailable .state-unavailable {
        display: block;
    }
    .sidebar--drawer-open .sidebar-footer { display: flex; }
    .sidebar--drawer-open .identity-row,
    .sidebar--drawer-open .identity-unavailable { justify-content: space-between; }

    .page { padding: 20px; }
    .grid-2 { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (min-width: 1024px) {
    .sidebar-scrim { display: none !important; }
}

/* #781 mobile menu band (≤ 767 px, design screen 15): the rail becomes a
   compact top band holding the existing menu button and brand; the existing
   drawer, scrim, inert and focus handling open from it unchanged. */
@media (max-width: 767px) {
    .app { flex-direction: column; }
    .sidebar { flex-direction: row; align-items: center; width: 100%; height: 48px; flex-shrink: 0; overflow: visible; }
    .sidebar:not(.sidebar--drawer-open) > :not(.sidebar-menu-toggle):not(.sidebar-brand) { display: none; }
    .sidebar:not(.sidebar--drawer-open) .sidebar-menu-toggle { flex: 0 0 48px; width: 48px; height: 48px; }
    .sidebar:not(.sidebar--drawer-open) .sidebar-brand { height: 48px; min-width: 0; padding: 0 8px; border-bottom: 0; }
    .sidebar:not(.sidebar--drawer-open) .brand-wordmark { display: inline; }
    .sidebar.sidebar--drawer-open { flex-direction: column; align-items: stretch; height: auto; overflow-y: auto; }
    .sd-space-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
    .sd-space-tab { flex: 0 0 auto; white-space: nowrap; }
    .portal-topbar { gap: 4px 12px; padding: 8px 12px; }
    .portal-controls { gap: 4px 8px; }
}

/* ==========================================================================
   Per-view CSS banner sections — each sibling PR appends only inside its
   own delimited region below (parallel-safe by construction, §2.3.1).
   ========================================================================== */

/* ===== view:dashboard (P8-2) ===== */

/* #698: the interactive statistical Dashboard. Existing tokens only: no remote
   font or asset, SVG primitives, state never carried by colour alone. */
.dash-page { display: flex; flex-direction: column; gap: 16px; }
.dash-page .page-header { margin-bottom: 0; }
.dash-page .text-muted { color: var(--hm-text-muted); }
.dash-page h3 { font-size: 14px; line-height: 20px; font-weight: 600; margin: 0 0 8px; }
.dash-page [hidden] { display: none; }

/* Filters, scope, coverage */
.dash-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 12px 16px; }
.dash-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dash-field .form-input { height: 32px; min-width: 160px; width: auto; max-width: 100%; }
.dash-field--inline { flex-direction: row; align-items: center; gap: 8px; }
.dash-segment { display: inline-flex; border: 1px solid var(--hm-border-strong); border-radius: var(--hm-radius); overflow: hidden; }
.dash-seg { height: 30px; min-width: 52px; padding: 0 12px; border: 0; border-right: 1px solid var(--hm-border-strong); background: var(--hm-panel); color: var(--hm-text); font-size: 13px; font-weight: 500; cursor: pointer; }
.dash-seg:last-child { border-right: 0; }
.dash-seg:hover { background: var(--hm-sunken); }
.dash-seg[aria-pressed="true"] { background: var(--hm-ink); color: #FFFFFF; }
.dash-scope { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 0; color: var(--hm-text-muted); }
.dash-scope-parts { color: var(--hm-text); font-weight: 500; }
.dash-fresh { margin-left: auto; }
.dash-coverage { background: var(--hm-amber-wash); border: 1px solid rgba(245,158,11,.35); border-radius: var(--hm-radius); padding: 8px 12px; color: var(--hm-amber-text); font-size: 13px; }
.dash-coverage p { margin: 0; }
.dash-gaps { margin-top: 6px; }
.dash-gaps summary, .dash-equivalent summary, .dash-destinations summary, .dash-service summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.dash-panel details[data-details^="analytics-"] > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.dash-gaps ul { margin: 4px 0 0; padding-left: 18px; }
.dash-state { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 12px 16px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); background: var(--hm-panel); font-size: 13px; }
.dash-state p { margin: 0; }
.dash-state-loading { flex-direction: row; align-items: center; gap: 8px; color: var(--hm-text-muted); }
.dash-state-error { border-color: rgba(229,72,77,.4); background: var(--hm-red-wash); }
.dash-line { margin: 0; padding: 4px 0; font-size: 13px; }
.dash-stale { color: var(--hm-amber-text); }

/* Active work: the board's dark band with the shared #779 tiles */
.dash-live { position: relative; overflow: hidden; background: #111827; color: #F7F8F5; border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.dash-live::after { content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, rgba(0,167,199,.18), transparent 70%); pointer-events: none; }
.dash-live-head { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dash-live h2 { margin: 0; font-family: var(--hm-font-mono); font-size: 11px; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; color: #7FD4E6; font-weight: 600; }
.dash-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--hm-cyan); animation: dash-pulse 1.6s ease-in-out infinite; }
.dash-live-count { font-family: var(--hm-font-mono); font-size: 12px; color: #C9CFD6; }
.dash-live-link { margin-left: auto; color: #7FD4E6; font-weight: 600; font-size: 13px; min-height: 28px; display: inline-flex; align-items: center; }
.dash-live-link:hover { text-decoration: underline; }
.dash-live-note { position: relative; z-index: 1; margin: 0; color: #C9CFD6; }
.dash-job-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; }
.dash-job-scope .body-small { display: block; }
.dash-job-scope, .consol-scope-label { overflow-wrap: anywhere; }
.dash-job-card { min-width: 0; background: rgba(247,248,245,.05); border: 1px solid rgba(247,248,245,.12); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; overflow-wrap: anywhere; }
.dash-job-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dash-live .consol-space-name { font-family: var(--hm-font-mono); font-weight: 600; font-size: 14px; color: #F7F8F5; }
.dash-live .status-dot-label, .dash-live .consol-tiles-counters, .dash-live .consol-tile-legend, .dash-live .body-small { color: #C9CFD6; }
.dash-live .consol-tile-pending { background: rgba(247,248,245,.12); border-color: rgba(247,248,245,.3); }
.dash-live .consol-tile-error { box-shadow: inset 0 0 0 2px #111827; }
.dash-live .consol-tile-unconfirmed { background: rgba(245,158,11,.18); border-color: #F5B74A; }
.dash-live .mono-chip, .dash-live .mono-chip-value { color: #C9CFD6; }
.dash-live-history { position: relative; z-index: 1; color: #C9CFD6; }
.dash-live-history summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: #7FD4E6; }
.dash-live-history code { color: #F7F8F5; }
.dash-live .btn-secondary { background: transparent; color: #F7F8F5; border-color: rgba(247,248,245,.35); }
.dash-live :focus-visible { outline-color: var(--hm-focus-dark); }
.dash-job-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid rgba(247,248,245,.1); padding-top: 8px; margin-top: auto; }
@keyframes dash-pulse { 50% { opacity: .4; } }

/* KPI row */
/* Columns follow the available width, not the viewport: browser zoom and narrow panes reflow alike. */
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(168px, 100%), 1fr)); gap: 12px; }
.dash-analytics-row { display: grid; grid-template-columns: minmax(6rem, 10rem) minmax(0, 1fr); gap: 8px; margin-bottom: 12px; }
.dash-analytics-section { display: grid; gap: 16px; margin-top: 24px; min-width: 0; }
.dash-analytics-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.75rem; }
.dash-analytics-legend span { display: inline-flex; align-items: center; gap: 4px; }
.dash-analytics-legend i { width: 8px; height: 8px; background: var(--hm-accent); }
.dash-analytics-daily-scroll { overflow-x: auto; max-width: 100%; }
.dash-analytics-daily { display: flex; gap: 4px; min-width: max-content; align-items: stretch; }
.dash-analytics-day { flex: 0 0 56px; width: 56px; min-width: 44px; min-height: 180px; padding: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; text-align: center; font-size: 0.7rem; color: inherit; }
.dash-analytics-day strong, .dash-analytics-day > span { white-space: nowrap; font-size: 0.65rem; }
.dash-analytics-day small { white-space: nowrap; font-size: 0.6rem; }
button.dash-analytics-day { border: 0; background: transparent; cursor: pointer; }
.dash-analytics-daily-stack { height: 110px; width: 16px; display: flex; flex-direction: column-reverse; }
.dash-analytics-daily-stack i { width: 100%; flex: none; background: var(--hm-accent); }
.dash-analytics-daily-stack .dash-analytics-color-1 { background: #987bb8; }
.dash-analytics-daily-stack .dash-analytics-color-2 { background: #5d9b92; }
.dash-analytics-daily-stack .dash-analytics-color-3 { background: #c88851; }
.dash-analytics-stack-row { width: 100%; min-height: 44px; display: grid; grid-template-columns: minmax(6rem, 9rem) minmax(2rem, 1fr) auto; gap: 8px; align-items: center; text-align: left; color: inherit; }
button.dash-analytics-stack-row { border: 0; background: transparent; cursor: pointer; }
.dash-analytics-stack { display: flex; height: 9px; overflow: hidden; border-radius: 5px; background: var(--hm-border); }
.dash-analytics-stack i { height: 100%; flex: none; background: var(--hm-accent); }
.dash-analytics-legend .dash-analytics-color-1, .dash-analytics-stack .dash-analytics-color-1 { background: #987bb8; }
.dash-analytics-legend .dash-analytics-color-2, .dash-analytics-stack .dash-analytics-color-2 { background: #5d9b92; }
.dash-analytics-legend .dash-analytics-color-3, .dash-analytics-stack .dash-analytics-color-3 { background: #c88851; }
.dash-analytics-legend .dash-analytics-color-4, .dash-analytics-stack .dash-analytics-color-4 { background: #756e68; }
.dash-analytics-results .dash-analytics-color-0 { background: var(--hm-success, #438575); }
.dash-analytics-results .dash-analytics-color-1 { background: var(--hm-warning, #c88851); }
.dash-analytics-results .dash-analytics-color-2 { background: var(--hm-danger, #bc6561); }
.dash-analytics-results .dash-analytics-color-3 { background: #9d958e; }
.dash-analytics-results .dash-analytics-color-4 { background: var(--hm-accent); }
.dash-analytics-mark { width: 100%; min-height: 44px; display: grid; grid-template-columns: minmax(5rem, 8rem) minmax(2rem, 1fr) auto; gap: 8px; align-items: center; text-align: left; color: inherit; }
button.dash-analytics-mark { border: 0; background: transparent; cursor: pointer; }
.dash-analytics-track { height: 8px; border-radius: 4px; overflow: hidden; background: var(--hm-border); }
.dash-analytics-fill { display: block; height: 100%; background: var(--hm-accent); }
.dash-analytics-color-1 { background: #987bb8; }
.dash-analytics-color-2 { background: #5d9b92; }
.dash-analytics-color-3 { background: #c88851; }
@media (max-width: 600px) { .dash-analytics-row { grid-template-columns: 1fr; } .dash-analytics-mark { grid-template-columns: minmax(4rem, 6rem) minmax(2rem, 1fr) auto; } }
.dash-kpi { background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dash-kpi-label { font-size: 12.5px; color: var(--hm-text-muted); }
.dash-kpi-value { overflow-wrap: anywhere; font-family: 'Space Grotesk', var(--hm-font-body); font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--hm-ink); }
.dash-kpi-detail, .dash-kpi-compare { margin: 0; overflow-wrap: anywhere; }
.dash-spark { width: 100%; height: 28px; margin-top: 6px; }
.dash-spark-line { fill: none; stroke: var(--hm-cyan-deep); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.dash-spark-area { fill: var(--hm-cyan-wash); stroke: none; }

/* Panels and grid */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 16px; align-items: start; }
.dash-cell-wide { grid-column: 1 / -1; }
.dash-grid > div, .dash-page > div { min-width: 0; }
.dash-panel { background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dash-panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.dash-panel-head h2 { font-size: 16px; line-height: 24px; margin: 0; }
.dash-panel-head p { margin: 0; }
.dash-panel-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dash-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin: 0; }
.dash-dl > div { min-width: 0; }
.dash-dl dt { font-size: 12px; color: var(--hm-text-muted); }
.dash-dl dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dash-dl--stack { grid-template-columns: minmax(0, 1fr); }
.dash-dl--grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.dash-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.dash-chips li, .dash-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 2px 10px; border-radius: var(--hm-radius-pill); background: var(--hm-sunken); font-size: 12px; border: 0; }
.dash-chip { cursor: pointer; color: var(--hm-text); border: 1px solid var(--hm-border-strong); background: var(--hm-panel); }
.dash-chip:hover { background: var(--hm-sunken); }
/* Positioned so visually hidden captions and headers stay clipped inside the scroller (#699). */
.dash-table-scroll, .dash-matrix-scroll, .dash-ops-scroll { position: relative; overflow-x: auto; max-width: 100%; }
.dash-data-table th, .dash-data-table td { white-space: nowrap; }
.dash-data-table th.num { text-align: right; }
.dash-count { min-width: 32px; min-height: 28px; padding: 0 8px; border: 1px solid var(--hm-border-strong); border-radius: 6px; background: var(--hm-panel); color: var(--hm-cyan-deep); font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.dash-count:hover { background: var(--hm-cyan-wash); }
.dash-space-link { background: none; border: 0; padding: 0; min-height: 28px; font: inherit; font-family: var(--hm-font-mono); font-size: 12.5px; color: var(--hm-cyan-deep); cursor: pointer; text-align: left; }
.dash-space-link:hover { text-decoration: underline; }

/* Timeline: two lanes (notes are not operations), one control per bucket */
.dash-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-series-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; background: var(--hm-panel); border: 1px solid var(--hm-border-strong); border-radius: var(--hm-radius-pill); font-size: 13px; cursor: pointer; color: var(--hm-text); }
.dash-series-toggle[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.dash-series-toggle:hover { border-color: #9AA3AF; }
.dash-series-total { font-family: var(--hm-font-mono); font-size: 12px; color: var(--hm-text-muted); }
.dash-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dash-fam-short { fill: var(--hm-cyan); background: var(--hm-cyan); }
.dash-fam-consolidation { fill: #1F3B63; background: #1F3B63; }
.dash-fam-compaction { fill: var(--hm-amber); background: var(--hm-amber); }
.dash-fam-long_document { fill: #15803D; background: #15803D; }
.dash-fam-long_archive { fill: #7C6A9C; background: #7C6A9C; }
.dash-chart { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dash-chart-scroll { position: relative; overflow-x: auto; max-width: 100%; }
.dash-chart-inner { min-width: 0; }
.dash-lanes { position: relative; display: flex; flex-direction: column; gap: 12px; }
.dash-lane-title { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.dash-lane-plot { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
.dash-yaxis { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; font-family: var(--hm-font-mono); font-size: 11px; color: var(--hm-text-faint); height: 96px; }
.dash-lane-svg { width: 100%; height: 96px; display: block; overflow: visible; }
.dash-lane-svg .dash-gridline { stroke: var(--hm-border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.dash-bucket-row { position: absolute; left: 40px; right: 0; top: 0; bottom: 0; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); }
.dash-bucket-row[data-buckets="7"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.dash-bucket-row[data-buckets="30"] { grid-template-columns: repeat(30, minmax(0, 1fr)); }
.dash-bucket { background: transparent; border: 0; border-radius: 4px; padding: 0; cursor: pointer; min-width: 0; }
.dash-bucket:hover, .dash-bucket.is-selected { background: rgba(0,167,199,.12); }
.dash-bucket.is-selected { box-shadow: inset 0 0 0 2px var(--hm-cyan-deep); }
.dash-xaxis { display: grid; margin-left: 40px; font-family: var(--hm-font-mono); font-size: 10.5px; color: var(--hm-text-faint); grid-template-columns: repeat(24, minmax(0, 1fr)); }
.dash-xaxis[data-buckets="7"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.dash-xaxis[data-buckets="30"] { grid-template-columns: repeat(30, minmax(0, 1fr)); }
.dash-xaxis { overflow: hidden; }
.dash-xaxis span { text-align: center; white-space: nowrap; }
.dash-xaxis span:first-child { text-align: left; }
.dash-xaxis span:last-child { text-align: right; }
.dash-xaxis .dash-xlabel-skip { visibility: hidden; }
.dash-readout { margin: 0; min-height: 18px; color: var(--hm-text-muted); }
.dash-equivalent { border-top: 1px solid var(--hm-border); padding-top: 6px; }

/* Ranked bars, histograms */
.dash-bars-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dash-bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 56px; align-items: center; gap: 12px; width: 100%; min-height: 32px; padding: 2px 4px; background: none; border: 0; border-radius: 6px; font: inherit; color: inherit; text-align: left; }
button.dash-bar-row { cursor: pointer; }
button.dash-bar-row:hover { background: var(--hm-sunken); }
.dash-bar-name { font-family: var(--hm-font-mono); font-size: 12.5px; overflow-wrap: anywhere; }
.dash-bar-svg { width: 100%; height: 8px; display: block; }
.dash-bar-track { fill: var(--hm-sunken); }
.dash-bar-fill { fill: var(--hm-cyan); }
.dash-bar-value { font-family: var(--hm-font-mono); font-size: 12.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.dash-dists, .dash-longs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; }
.dash-dist, .dash-long { min-width: 0; border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.dash-long-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.dash-long-head h3 { margin: 0; }
.dash-hist { display: flex; flex-direction: column; gap: 4px; }
.dash-hist-bins { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; align-items: end; }
.dash-bin { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-height: 64px; padding: 2px; background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font: inherit; color: inherit; justify-content: flex-end; }
.dash-bin-empty { cursor: default; }
button.dash-bin:hover { background: var(--hm-sunken); border-color: var(--hm-border-strong); }
.dash-hist-svg { width: 100%; height: 40px; display: block; }
.dash-hist-count { font-family: var(--hm-font-mono); font-size: 11px; text-align: center; color: var(--hm-text-muted); }
.dash-hist-edges { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; font-family: var(--hm-font-mono); font-size: 10px; color: var(--hm-text-faint); text-align: center; }

/* Space x time matrix: a real table, one tab stop, cells are the controls */
.dash-matrix { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.dash-matrix td { padding: 0; }
.dash-matrix th { font-weight: 500; text-align: left; padding: 2px 6px; white-space: nowrap; }
.dash-matrix thead th { color: var(--hm-text-faint); font-family: var(--hm-font-mono); font-size: 10px; text-align: center; position: sticky; top: 0; background: var(--hm-panel); }
.dash-matrix tbody th { position: sticky; left: 0; background: var(--hm-panel); z-index: 1; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.dash-cell { width: 100%; min-width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 4px; font-family: var(--hm-font-mono); font-size: 10.5px; cursor: pointer; color: var(--hm-ink); background: var(--hm-sunken); }
.dash-cell.is-selected { box-shadow: 0 0 0 2px var(--hm-cyan-deep); }
.dash-heat-0 { background: var(--hm-sunken); }
.dash-heat-1 { background: rgba(0,167,199,.22); }
.dash-heat-2 { background: rgba(0,167,199,.45); }
.dash-heat-3 { background: rgba(0,150,180,.75); color: #FFFFFF; }
.dash-heat-4 { background: var(--hm-cyan-deep); color: #FFFFFF; }
.dash-heat-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--hm-text-muted); }
.dash-heat-legend li { display: inline-flex; align-items: center; gap: 6px; }
.dash-heat-key { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--hm-border-strong); display: inline-block; }

/* Service diagnostics and operations table */
.dash-service { background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); padding: 10px 18px; display: flex; flex-direction: column; gap: 12px; }
.dash-service[open] { padding-bottom: 16px; }
.dash-table-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.dash-ops-table { min-width: 960px; }
.dash-ops-table th, .dash-ops-table td { white-space: nowrap; }
.dash-ops-table td:nth-child(8) { white-space: normal; min-width: 150px; }
.dash-ops-table th[scope="row"] { font-weight: 500; text-align: left; }
.dash-op-row--active > th[scope="row"] { box-shadow: inset 3px 0 0 var(--hm-cyan); }
.dash-op-row--failed > th[scope="row"] { box-shadow: inset 3px 0 0 var(--hm-red); }
.dash-ops-table td { vertical-align: middle; }
.dash-pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.dash-links { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.dash-links a { color: var(--hm-cyan-deep); font-weight: 600; }

/* Touch targets reach 44 px: a chart wider than its panel scrolls inside the panel, never the page. */
@media (max-width: 900px), (pointer: coarse) {
    .dash-chart-inner[data-buckets="7"] { min-width: 348px; }
    .dash-chart-inner[data-buckets="24"] { min-width: 1096px; }
    .dash-chart-inner[data-buckets="30"] { min-width: 1360px; }
    .dash-hist { overflow-x: auto; }
    .dash-hist-bins, .dash-hist-edges { min-width: 432px; }
    .dash-gaps summary, .dash-equivalent summary, .dash-destinations summary, .dash-service summary, .dash-live-history summary { min-height: 44px; }
}
/* Narrow screens: panels stack; matrix and table scroll inside their panel; targets reach 44 px. */
@media (max-width: 900px) {
    .dash-filters { align-items: stretch; }
    .dash-field .form-input { min-width: 0; width: 100%; height: 44px; }
    .dash-field { flex: 1 1 140px; }
    .dash-seg { height: 44px; min-width: 56px; }
    .dash-series-toggle { min-height: 44px; }
    .dash-count, .dash-space-link, .dash-bar-row, .dash-chip { min-height: 44px; }
    .dash-cell { min-width: 44px; height: 44px; }
    .dash-pager .btn, .dash-table-controls .btn, .dash-panel .btn-sm, .dash-live .btn-sm { min-height: 44px; }
    .dash-fresh { margin-left: 0; }
    .dash-bar-row { grid-template-columns: minmax(70px, 120px) minmax(0, 1fr) 48px; gap: 8px; }
    .dash-panel { padding: 14px; }
    .dash-yaxis, .dash-lane-svg { height: 80px; }
}
@media (max-width: 560px) {
    .dash-xaxis { font-size: 9px; }
    .dash-xaxis[data-buckets="24"] span:not(:nth-child(6n+1)), .dash-xaxis[data-buckets="30"] span:not(:nth-child(7n+1)) { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .dash-pulse { animation: none; }
}
#dashActivityEmpty .state-loading { padding: 8px 0; justify-content: flex-start; }

/* ===== view:spaces (P8-2) ===== */

/* The index leads with identity; descriptions never set column width. */
.spaces-search { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.spaces-search .form-input { width: min(100%, 420px); }
.spaces-freshness, .consol-freshness { color: var(--hm-text-muted); font-size: 13px; margin: 8px 0 16px; }
.spaces-freshness[data-stale="true"] { color: var(--hm-amber-text); }
.spaces-table .data-table { table-layout: fixed; width: 100%; }
.spaces-table th:first-child { width: 50%; }
.spaces-table th:nth-child(2) { width: 18%; }
.spaces-table th:nth-child(3) { width: 32%; }
.spaces-table td { padding-block: 16px; vertical-align: top; }
.spaces-identity { min-width: 0; }
.spaces-id-link, .consol-space-name {
    font-family: var(--hm-font-body); font-size: 16px; line-height: 24px;
    font-weight: 600; color: var(--hm-text); overflow-wrap: anywhere;
}
.spaces-id-link:hover, .consol-space-name:hover { color: var(--hm-cyan-deep); text-decoration: underline; }
.spaces-description { color: var(--hm-text-muted); margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.spaces-owner { color: var(--hm-text-muted); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.spaces-memory { display: flex; flex-direction: column; gap: 4px; }
.spaces-memory-line, .spaces-activity-meta { color: var(--hm-text-muted); overflow-wrap: anywhere; }
.spaces-activity-cell a { color: var(--hm-cyan-deep); }
.spaces-activity-link { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.spaces-activity-cell a:hover { text-decoration: underline; }

/* ===== view:space-detail (P8-3) ===== */

.sd-page { display: flex; flex-direction: column; gap: 16px; }
.sd-page > .page-header { margin-bottom: 0; }
.sd-section { margin-top: 24px; }
.sd-page > .sd-section { margin-top: 0; }
.sd-page > .sd-space-nav { margin: 0; }
.sd-page-memory > #sdSpacePanel > .sd-section { margin-top: 0; }
/* #781 compact Space frame (§17.10): one identity line shared by every Space
   section; long names wrap; details stay behind a disclosure. */
.sd-frame { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sd-frame__line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.sd-breadcrumb { display: inline-flex; align-items: baseline; gap: 6px; color: var(--hm-text-muted); font-size: 14px; }
.sd-breadcrumb a { color: var(--hm-text-muted); text-decoration: underline; text-underline-offset: 2px; display: inline-flex; align-items: center; min-height: 32px; }
.sd-breadcrumb a:hover { color: var(--hm-cyan-deep); }
.sd-frame__name { margin: 0; font-size: 24px; line-height: 30px; overflow-wrap: anywhere; min-width: 0; }
.sd-frame__counts { margin: 0; color: var(--hm-text-muted); font-size: 13px; }
.sd-frame__counts .mono-data { color: var(--hm-text); font-variant-numeric: tabular-nums; }
.sd-frame__status { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.sd-frame #sdFrameAlert:empty { display: none; }
.sd-frame #sdFrameAlert .sd-banner { margin-bottom: 0; }
.sd-frame__details { margin-top: 0; }
.sd-frame__details[open] { flex-basis: 100%; padding: 8px 16px 12px; background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); }
.sd-frame__details summary { display: inline-flex; align-items: center; min-height: 32px; }
.sd-frame__identity { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; min-width: 0; }
.sd-frame__identity > .mono-chip, .sd-frame__identity > .mono-chip .mono-chip-value { white-space: normal; overflow-wrap: anywhere; }
.sd-frame__identity p { color: var(--hm-text-muted); overflow-wrap: anywhere; }
.sd-frame__identity .chip { width: fit-content; max-width: 100%; white-space: normal; }
.sd-frame #sdMeshReadiness:empty { display: none; }
.sd-frame #sdMeshReadiness { margin-top: 8px; }
.sd-status-plain { color: var(--hm-text-muted); font-size: 13px; }
.summary-stats { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 0; }
.summary-stats > div { flex: 1 1 100px; min-width: 0; }
.summary-stats dt { color: var(--hm-text-muted); font-size: 13px; line-height: 18px; }
.summary-stats dd { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 2px 0 0; }
.summary-stats__value { font-family: var(--hm-font-mono); font-size: 18px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.summary-stats .body-small { color: var(--hm-text-muted); font-family: var(--hm-font-mono); font-size: 12px; }
.sd-metrics { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--hm-border); }
.sd-metadata { margin-top: 12px; }
.sd-metadata summary { width: fit-content; color: var(--hm-text-muted); cursor: pointer; font-size: 13px; }
.sd-meta-row { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 12px; }
.sd-lane--idle { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; }
.sd-lane--idle .panel-header { display: contents; }
.sd-lane--idle .panel-header > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.sd-lane--idle .state-empty--compact { padding: 0; order: 1; }
.sd-lane--idle .panel-header > a { order: 2; margin-left: auto; }
.sd-kv .mono-data { overflow-wrap: anywhere; }
.sd-kv { display: flex; flex-direction: column; gap: 2px; min-width: 110px; max-width: 100%; }
.sd-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--hm-radius-card);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.sd-banner svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.sd-banner p { margin-top: 2px; font-size: 13px; line-height: 18px; }
.sd-banner--error { background: var(--hm-red-wash); border: 1px solid var(--hm-red); color: var(--hm-text); }
.sd-banner--error svg { color: var(--hm-red); }
.sd-banner--warn { background: var(--hm-amber-wash); border: 1px solid var(--hm-amber); color: var(--hm-text); }
.sd-banner--warn svg { color: var(--hm-amber-text); }
.sd-inline, .sd-chip-row, .sd-actions-row, .sd-access-counts, .sd-entities, .sd-tier-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.sd-lane-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.sd-link { color: var(--hm-cyan-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.sd-tier-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--hm-sunken);
    border-radius: var(--hm-radius-card);
    margin-bottom: 12px;
}
.sd-tier-tab {
    min-width: 88px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--hm-radius);
    background: transparent;
    color: var(--hm-text-muted);
    font-family: var(--hm-font-mono);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}
.sd-tier-tab:hover { color: var(--hm-cyan-deep); background: var(--hm-cyan-wash); }
.sd-tier-tab.active { color: var(--hm-text); background: var(--hm-panel); border: 1px solid var(--hm-border-strong); }
.sd-tier-card { padding: 20px; }
.sd-filter-grid {
    display: grid;
    grid-template-columns: 90px minmax(150px, 1fr) minmax(130px, 1fr) minmax(170px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}
.sd-filter-submit { margin-bottom: 0; }
.sd-split { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.2fr); gap: 16px; align-items: start; }
.sd-split > *, .sd-split .table-scroll { min-width: 0; max-width: 100%; }
.sd-list { display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow-y: auto; }
.sd-note {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: var(--hm-panel);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius);
    color: var(--hm-text);
    text-align: left;
    cursor: pointer;
}
.sd-note:hover { border-color: var(--hm-cyan-mid); background: var(--hm-cyan-wash); }
.sd-note__top, .sd-preview-header, .sd-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.sd-preview-header { margin-bottom: 8px; }
/* Memory readers keep their frame and scroll while the shared refresh updates data. */
.sd-note-feed { max-height: 65vh; overflow: auto; overflow-anchor: none; margin-top: 16px; }
.sd-note-day h3 { margin: 16px 0 8px; font-size: 14px; color: var(--hm-text-muted); }
.sd-note-day-list { display: flex; flex-direction: column; gap: 8px; }
.sd-note-feed .sd-note { cursor: default; }
.sd-note-feed .sd-note:hover { background: var(--hm-panel); border-color: var(--hm-border); }
.sd-note-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.sd-note-content code { font-family: var(--hm-font-mono); background: var(--hm-sunken); border-radius: 4px; padding: 1px 4px; }
.sd-file-tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; margin: 12px 0; padding-bottom: 4px; }
.sd-file-tab { flex: 0 0 auto; min-height: 44px; padding: 10px 12px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); background: var(--hm-panel); color: var(--hm-text); cursor: pointer; }
.sd-file-tab[aria-selected="true"] { background: var(--hm-cyan-wash); border-color: var(--hm-cyan-mid); }
.sd-file-tab:focus-visible, .sd-bank-reader:focus-visible { outline: 2px solid var(--hm-focus); outline-offset: -2px; }
.sd-bank-reader { margin-top: 8px; }
.sd-mid-reader { grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.4fr); }
.sd-file-row { cursor: pointer; }
.sd-file-row:hover, .sd-file-row:focus, .sd-file-row.selected { background: var(--hm-cyan-wash); }
.sd-file-row:focus { outline: 2px solid var(--hm-focus); outline-offset: -2px; }
.sd-reader {
    min-height: 260px;
    max-height: 620px;
    overflow: auto;
    padding: 18px 20px;
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-card);
    background: var(--hm-panel);
}
.markdown-body { color: var(--hm-text); font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.4em 0 .55em; }
.markdown-body h1 { font-size: 24px; }
.markdown-body h2 { font-size: 19px; border-bottom: 1px solid var(--hm-border); padding-bottom: 6px; }
.markdown-body h3 { font-size: 16px; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body pre, .markdown-body blockquote { margin: 0 0 1em; }
.markdown-body code { font-family: var(--hm-font-mono); font-size: .9em; background: var(--hm-sunken); border-radius: 4px; padding: 1px 4px; }
.markdown-body pre { overflow: auto; background: var(--hm-sunken); border: 1px solid var(--hm-border); border-radius: var(--hm-radius); padding: 12px; }
.markdown-body pre code { padding: 0; background: transparent; }
.markdown-body blockquote { border: 1px solid var(--hm-border); border-radius: var(--hm-radius); background: var(--hm-sunken); color: var(--hm-text-muted); padding: 10px 12px; }
.markdown-body table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.markdown-body th, .markdown-body td { border: 1px solid var(--hm-border); padding: 7px 9px; text-align: left; }
.markdown-body a { color: var(--hm-cyan-deep); text-decoration: underline; text-underline-offset: 2px; }
.sd-long-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
.sd-long-controls label { display: grid; gap: 6px; min-width: 0; }
.sd-long-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--hm-border); overflow-wrap: anywhere; }
.sd-ingest-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.sd-ingest-workspace.has-selection { grid-template-columns: minmax(0, 1fr) 300px; }
.sd-ingest-history { min-width: 0; }
#sdIngestPager[hidden] { display: none; }
.sd-ingest-table-scroll { max-height: 620px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); }
.sd-ingest-table { table-layout: fixed; width: 100%; }
.sd-ingest-table th { position: sticky; top: 0; background: var(--hm-panel); z-index: 1; }
.sd-ingest-table th:first-child { width: 22%; }
.sd-ingest-table th:nth-child(3) { width: 22%; }
.sd-ingest-table th:last-child { width: 16%; }
.sd-ingest-table td { overflow-wrap: anywhere; }
.sd-ingest-table td > span:not(.status-dot-wrap), .sd-ingest-stage > span { display: block; }
.sd-ingest-table .status-dot-label { white-space: nowrap; }
.sd-ingest-table tr.is-selected { background: var(--hm-cyan-wash); }
.sd-ingest-table tr.is-selected td:first-child { box-shadow: inset 3px 0 var(--hm-cyan-deep); }
.sd-ingest-id { font: 11px/1.5 var(--hm-font-mono); color: var(--hm-text-muted); margin-top: 4px; }
.sd-ingest-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.sd-ingest-detail { min-width: 0; max-height: 620px; overflow: auto; padding: 16px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); }
.sd-ingest-detail h3 { margin: 12px 0; overflow-wrap: anywhere; }
.sd-ingest-detail h4 { margin: 16px 0 8px; }
.sd-ingest-detail .btn { min-height: 44px; }
.sd-ingest-detail .sd-meta-row { display: grid; grid-template-columns: minmax(80px, .65fr) minmax(0, 1fr); gap: 8px; margin: 12px 0; overflow-wrap: anywhere; }
.sd-ingest-detail p, .sd-ingest-diagnostics { overflow-wrap: anywhere; }
.sd-ingest-diagnostics { margin: 8px 0; }
.sd-ingest-diagnostics > div { margin: 8px 0; }
.sd-ingest-diagnostics dt { font-weight: 600; }
.sd-ingest-diagnostics dd { margin: 4px 0 0 12px; }
.sd-ingest-diagnostics .sd-ingest-diagnostics > div { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-ingest-diagnostics .sd-ingest-diagnostics dd { margin: 0; }
.sd-ingest-diagnostics ul { padding-left: 16px; }
.sd-ingest-detail:focus-visible { outline: 2px solid var(--hm-cyan-deep); outline-offset: 2px; }
.sd-ingest-workspace progress { display: block; width: 100%; height: 8px; margin: 6px 0; accent-color: var(--hm-cyan-deep); }
@media (max-width: 1279px) {
    .sd-ingest-workspace.has-selection { grid-template-columns: minmax(0, 1fr); }
    .sd-ingest-detail { order: -1; max-height: none; }
    .sd-ingest-table-scroll { max-height: none; border: 0; overflow: visible; }
    .sd-ingest-table, .sd-ingest-table tbody { display: block; }
    .sd-ingest-table thead { display: none; }
    .sd-ingest-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); }
    .sd-ingest-table td { display: block; padding: 0; border: 0; }
    .sd-ingest-table td::before { content: attr(data-label); display: block; color: var(--hm-text-muted); font: 11px/1.5 var(--hm-font-mono); margin-bottom: 4px; }
    .sd-ingest-table td:first-child, .sd-ingest-table td:last-child { grid-column: 1 / -1; }
    .sd-ingest-table tr.is-selected td:first-child { box-shadow: none; }
    .sd-ingest-table tr.is-selected { border-color: var(--hm-cyan-deep); }
    .sd-ingest-table .btn { min-height: 44px; }
}
.sd-long-content { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Ingestion source scope and Space Active work (#651). */
.sd-ingest-scope { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.sd-ingest-scope .btn { min-height: 44px; }
.sd-ingest-scope .btn[aria-pressed="true"] { background: var(--hm-cyan-wash); border-color: var(--hm-cyan-deep); color: var(--hm-cyan-deep); font-weight: 600; }
.sd-activity-list { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 12px; }
.sd-activity-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; padding: 14px 16px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); background: var(--hm-panel); overflow-wrap: anywhere; }
.sd-activity-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.sd-activity-head h3 { margin: 0; font-size: 15px; }
.sd-activity-body { min-width: 0; }
.sd-activity-body p { margin: 4px 0; }
.sd-activity-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0; padding: 0; list-style: none; }
.sd-activity-jobs { display: grid; gap: 8px; margin: 8px 0; padding: 0; list-style: none; }
.sd-activity-job { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 8px; border-top: 1px solid var(--hm-border); }
.sd-activity-job-main { display: flex; flex: 1 1 240px; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.sd-activity-job-main .sd-ingest-stage { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.sd-activity progress { width: 140px; height: 8px; accent-color: var(--hm-cyan-deep); }
.sd-activity-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-activity .btn { min-height: 44px; }
@media (min-width: 900px) {
    .sd-activity-row { grid-template-columns: minmax(170px, 210px) minmax(0, 1fr) auto; align-items: start; }
    .sd-activity-head { flex-direction: column; align-items: flex-start; }
}
/* Documents (#629): bounded catalog and adjacent inspector, shared modal on narrow screens. */
.sd-documents-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.sd-documents-workspace.has-selection { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
.sd-documents-catalog, #sdDocumentHost { min-width: 0; }
.sd-documents-list { max-height: 58vh; overflow: auto; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); }
.sd-documents-table { width: 100%; table-layout: fixed; }
.sd-documents-table th:first-child { width: 32%; }
.sd-documents-table th:nth-child(2) { width: 18%; }
.sd-documents-table th:nth-child(3) { width: 23%; }
.sd-documents-table th:nth-child(4) { width: 13%; }
.sd-documents-table th:last-child { width: 14%; }
.sd-documents-table th, .sd-documents-table td { padding: 8px; overflow-wrap: anywhere; }
.sd-documents-table .status-dot-wrap { white-space: normal; max-width: 100%; }
.sd-documents-table .status-dot-label { min-width: 0; overflow-wrap: anywhere; }
.sd-documents-table .status-dot { flex-shrink: 0; }
.sd-documents-table td:last-child { text-align: right; }
.sd-documents-table thead { position: sticky; top: 0; background: var(--hm-panel); z-index: 1; }
.sd-documents-table tr.is-selected td { background: var(--hm-cyan-wash); }
.sd-documents-table tr.is-selected td:first-child { box-shadow: inset 3px 0 var(--hm-cyan-mid); }
.sd-document-path, .sd-document-date { margin-top: 4px; font-size: 12px; line-height: 18px; color: var(--hm-text-muted); }
.sd-document-path .mono-chip { padding: 0; border: 0; background: transparent; font-size: 12px; }
.sd-document-path .mono-chip-value { white-space: normal; overflow-wrap: anywhere; }
.sd-document-controls input { width: min(320px, 100%); }
.sd-document-origin-row { margin-top: 4px; }
.sd-document-origin { display: inline-block; max-width: 100%; padding: 1px 8px; border: 1px solid var(--hm-border); border-radius: 999px; font-size: 12px; line-height: 18px; font-weight: 600; color: var(--hm-text); overflow-wrap: anywhere; }
.sd-document-origin.is-mid-archive { border-color: var(--hm-cyan-mid); background: var(--hm-cyan-wash); }
.sd-document-origin.is-unreported { border-style: dashed; color: var(--hm-text-muted); font-weight: 400; }
.sd-document-pagination[hidden] { display: none; }
.sd-document-empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.sd-document-inspector { padding: 16px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); max-height: 68vh; overflow: auto; overflow-wrap: anywhere; }
.sd-document-heading { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sd-document-heading h3 { margin: 0; }
.sd-document-inspector .sd-meta-row { display: grid; grid-template-columns: minmax(90px, .65fr) minmax(0, 1fr); gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--hm-border); }
.sd-document-inspector .sd-meta-row > span { font-family: var(--hm-font-mono); font-size: 12px; }
.sd-document-inspector h4 { font-size: 16px; margin: 8px 0; }
.sd-document-detail { max-height: 55vh; overflow: auto; }
.sd-document-inspector [data-action="sd-document-content"], .sd-document-inspector [data-action="sd-document-retry"] { margin-top: 16px; }
.sd-document-inspector .mono-block { max-height: none; }
@media (max-width: 1199px) {
    .modal-overlay:has(.sd-document-inspector) { padding: 0; }
    .modal-card:has(.sd-document-inspector) { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; border-radius: 0; display: flex; flex-direction: column; padding: 16px; }
    .modal-card:has(.sd-document-inspector) .modal-body { flex: 1; overflow: auto; min-height: 0; }
    .modal-card:has(.sd-document-inspector) .sd-document-inspector { border: 0; padding: 0; max-height: none; overflow: visible; }
    .modal-card:has(.sd-document-inspector) .sd-document-detail { max-height: calc(100dvh - 175px); overflow: auto; }
    .modal-card:has(.sd-document-inspector) .sd-document-heading { display: none; }
    .modal-card:has(.sd-document-inspector) .modal-close, .modal-card:has(.sd-document-inspector) .btn { min-width: 44px; min-height: 44px; }
}
@media (max-width: 767px) {
    .sd-document-controls { align-items: stretch; }
    .sd-document-controls label { flex: 1 1 100%; }
    .sd-document-controls input, .sd-document-controls select { width: 100%; }
    .sd-document-controls .btn, .sd-documents-table .btn, .sd-document-empty-actions .btn { min-height: 44px; }
    .sd-documents-table .copy-btn { width: 44px; height: 44px; flex-shrink: 0; }
    .sd-documents-table, .sd-documents-table tbody { display: block; }
    .sd-documents-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .sd-documents-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 12px; border-bottom: 1px solid var(--hm-border); gap: 8px; }
    .sd-documents-table td { display: block; padding: 0; border: 0; }
    .sd-documents-table td:first-child, .sd-documents-table td:nth-child(3) { grid-column: 1 / -1; }
    .sd-documents-table td:nth-child(4) { grid-column: 1; }
    .sd-documents-table td:last-child { grid-column: 2; grid-row: 4; }
    .sd-documents-table tr.is-selected { background: var(--hm-cyan-wash); box-shadow: inset 3px 0 var(--hm-cyan-mid); }
    .sd-documents-table tr.is-selected td { background: transparent; box-shadow: none; }
    .sd-document-inspector .sd-meta-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
#sdLongTabs { flex-wrap: wrap; margin-bottom: 16px; }
#sdLongTabs .sd-tier-tab { flex: 0 0 auto; min-width: max-content; }
#sdLongBody { min-width: 0; }
.sd-long-stack { display: flex; flex-direction: column; gap: 20px; }
.sd-automation { overflow-wrap: anywhere; min-width: 0; margin-bottom: 24px; }
.sd-automation .sd-banner > div { min-width: 0; }
.sd-long-stack section > h3 { margin-bottom: 8px; }
#sdLongSnapshot .sd-long-overview, #sdLongSnapshot .sd-long-operational { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
#sdLongSnapshot .sd-long-health { display: grid; grid-template-columns: minmax(180px, 1.5fr) repeat(2, minmax(130px, 1fr)); align-items: start; gap: 12px 24px; min-width: 0; padding: 16px 0; border-bottom: 1px solid var(--hm-border); }
#sdLongSnapshot .sd-long-health-state, #sdLongSnapshot .sd-long-fact { display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
#sdLongSnapshot .sd-long-health-state > p { margin: 0; }
#sdLongSnapshot .sd-long-health-state--banner { grid-column: 1 / -1; }
#sdLongSnapshot .sd-long-state { display: flex; align-items: center; gap: 8px; font-weight: 600; overflow-wrap: anywhere; }
#sdLongSnapshot .sd-long-state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--hm-amber); }
#sdLongSnapshot .sd-long-state--healthy::before { background: var(--hm-green); }
#sdLongSnapshot .sd-long-state--error::before { background: var(--hm-red); }
#sdLongSnapshot .sd-long-ontology-note { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }
#sdLongSnapshot .sd-long-volume { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sd-long-metrics { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
#sdLongSnapshot .sd-long-metrics .metric-card { min-width: 0; overflow-wrap: anywhere; }
#sdLongSnapshot .sd-long-metrics .micro-label { white-space: normal; overflow-wrap: anywhere; }
#sdLongSnapshot .sd-long-entity-types { min-width: 0; }
#sdLongSnapshot .sd-long-entity-types h3 { margin-bottom: 8px; }
#sdLongSnapshot .sd-entity-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; padding: 0; list-style: none; }
#sdLongSnapshot .sd-entity-types li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-width: 0; padding: 8px 0; border-bottom: 1px solid var(--hm-border); }
#sdLongSnapshot .sd-entity-types li span { min-width: 0; overflow-wrap: anywhere; }
#sdLongSnapshot .sd-entity-types li strong { flex: 0 0 auto; font-family: var(--hm-font-mono); font-variant-numeric: tabular-nums; }
#sdLongSnapshot .sd-watermark h3, #sdLongSnapshot .sd-watermark p { overflow-wrap: anywhere; }
.sd-graph { display: flex; flex-direction: column; gap: 10px; min-width: 0; container-type: inline-size; container-name: long-graph; }
.sd-graph-toolbar, .sd-graph-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sd-graph-toolbar h3 { margin: 0; }
.sd-graph-counts { margin: 4px 0 0; }
.sd-graph .sd-graph-controls button, .sd-graph-results button, .sd-graph-neighbor { min-height: 44px; min-width: 44px; }
.sd-graph .sd-graph-controls { justify-content: flex-start; }
.sd-graph-results { display: flex; gap: 8px; flex-wrap: wrap; max-height: 220px; overflow: auto; }
.sd-graph-results p { width: 100%; margin: 0; }
.sd-graph-results button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.sd-graph-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--hm-text-muted); }
.sd-graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sd-graph-key { display: inline-block; width: 12px; height: 12px; background: var(--hm-cyan-deep); border-radius: 50%; }
.sd-graph-key.is-document { background: var(--hm-ink); border-radius: 2px; }
#sdGraphMode { margin-left: auto; }
.sd-graph-stage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); overflow: hidden; background: var(--hm-panel); min-width: 0; }
#sdGraphCanvas { display: block; width: 100%; height: 460px; cursor: grab; touch-action: none; background: var(--hm-paper); }
#sdGraphCanvas:active { cursor: grabbing; }
.sd-graph-edge { stroke: var(--hm-border-strong); stroke-width: 1.2; opacity: .7; vector-effect: non-scaling-stroke; }
.sd-graph-edge.is-mention { stroke: var(--hm-cyan-mid); stroke-dasharray: 4 5; opacity: .5; }
.sd-graph-label-link { stroke: var(--hm-ink); stroke-width: 1.5; pointer-events: none; vector-effect: non-scaling-stroke; }
.sd-graph-selected-caption { fill: var(--hm-paper); stroke: var(--hm-ink); stroke-width: 1; pointer-events: none; }
.sd-graph-node { cursor: pointer; pointer-events: none; }
.sd-graph-marker { pointer-events: all; }
.sd-graph-hit { fill: transparent; stroke: none; }
.sd-graph-shape { fill: var(--hm-cyan-deep); stroke: var(--hm-panel); stroke-width: 2; }
.sd-graph-node.is-document .sd-graph-shape { fill: var(--hm-ink); }
.sd-graph-node.is-selected .sd-graph-shape, .sd-graph-node:focus .sd-graph-shape, .sd-graph-node:hover .sd-graph-shape { fill: var(--hm-cyan-deep); stroke: var(--hm-ink); stroke-width: 3; }
.sd-graph-node.is-selected .sd-graph-hit, .sd-graph-node:focus-visible .sd-graph-hit { fill: var(--hm-cyan-wash); stroke: var(--hm-cyan-deep); stroke-width: 2; }
.sd-graph-node.is-hidden, .sd-graph-edge.is-hidden { display: none; }
.sd-graph-label { fill: var(--hm-text-muted); font-family: var(--hm-font-mono); pointer-events: all; paint-order: stroke; stroke: var(--hm-paper); stroke-width: 4px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sd-graph-node.is-selected .sd-graph-label { fill: var(--hm-ink); }
.sd-graph-details { min-width: 0; max-height: 460px; overflow: auto; padding: 16px; background: var(--hm-panel); border-left: 1px solid var(--hm-border); overflow-wrap: anywhere; }
.sd-graph-details h4 { margin: 12px 0 8px; font-size: 16px; }
.sd-graph-details h5 { margin: 20px 0 4px; font-size: 14px; font-weight: 600; }
.sd-graph-details p { color: var(--hm-text-muted); font-size: 13px; line-height: 18px; margin: 8px 0; }
.sd-graph-relations { list-style: none; padding: 0; margin: 0; }
.sd-graph-relations li { border-bottom: 1px solid var(--hm-border); padding: 4px 0; display: flex; flex-direction: column; gap: 4px; }
.sd-graph .sd-graph-neighbor { width: 100%; padding: 8px; justify-content: flex-start; text-align: left; white-space: normal; height: auto; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
    .sd-graph-stage { grid-template-columns: 1fr; }
    .sd-graph-details { border-left: 0; border-top: 1px solid var(--hm-border); max-height: none; }
    #sdGraphCanvas { height: 360px; }
}
@media (max-width: 600px) {
    #sdGraphCanvas { height: 300px; }
    .sd-graph-toolbar { align-items: flex-start; }
    #sdGraphMode { margin-left: 0; width: 100%; }
}
@container long-graph (max-width: 740px) {
    .sd-graph-stage { grid-template-columns: 1fr; }
    .sd-graph-details { border-left: 0; border-top: 1px solid var(--hm-border); max-height: none; }
    #sdGraphCanvas { height: 300px; }
}
.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; }
.sd-binding { margin-bottom: 12px; }
.sd-watermark { border-top: 1px solid var(--hm-border); padding-top: 16px; }
.sd-actions-row { margin-top: 16px; }
.sd-aux-grid { align-items: start; min-width: 0; }
.sd-aux-grid > *, .sd-aux-grid .table-scroll { min-width: 0; max-width: 100%; }
.sd-aux-main, .sd-aux-side, .sd-action-stack { display: flex; flex-direction: column; gap: 16px; }
.sd-aux-main > .sd-section, .sd-aux-side > .sd-section { margin-top: 0; }
.sd-rules-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.sd-counter { justify-content: flex-end; color: var(--hm-text-faint); font-family: var(--hm-font-mono); font-size: 11px; margin: 4px 0 8px; }
/* Rules review before saving (#603, §17.9) */
.modal-card.modal-card--rules { width: 980px; }
.sd-rules-editor { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sd-rules-editor [hidden] { display: none !important; }
.sd-rules-editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sd-rules-modes { display: inline-flex; gap: 4px; padding: 3px; background: var(--hm-sunken); border-radius: var(--hm-radius); }
.sd-rules-mode { min-height: 32px; padding: 5px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--hm-text-muted); font: inherit; font-size: 13px; cursor: pointer; }
.sd-rules-mode.is-active { background: var(--hm-panel); color: var(--hm-text); font-weight: 600; box-shadow: 0 1px 2px rgba(14,20,31,.08); }
.sd-rules-mode:focus-visible { outline: 2px solid var(--hm-cyan-deep); outline-offset: 1px; }
.sd-rules-mode:disabled { cursor: default; opacity: .7; }
.sd-rules-counts { display: inline-flex; gap: 10px; font-family: var(--hm-font-mono); font-size: 12px; font-weight: 600; }
.sd-diff-count--add { color: #15803D; }
.sd-diff-count--del { color: var(--hm-red-deep); }
.sd-rules-edit { margin: 0; }
.sd-rules-edit textarea { width: 100%; min-height: 320px; resize: vertical; }
.sd-rules-pane { max-height: 52vh; overflow: auto; border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); }
article.sd-rules-pane { padding: 12px 16px; }
.sd-rules-diff { font-family: var(--hm-font-mono); font-size: 12.5px; line-height: 1.7; min-width: 0; }
.sd-diff-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sd-diff-row--head { position: sticky; top: 0; z-index: 1; background: var(--hm-panel); border-bottom: 1px solid var(--hm-border); }
.sd-diff-row--head > span { padding: 8px 12px 6px; }
.sd-diff-row--head > span + span, .sd-diff-cell--new, .sd-diff-cell--echo { border-left: 1px solid var(--hm-border); }
.sd-diff-row--skip { display: block; padding: 4px 12px; background: var(--hm-sunken); color: var(--hm-text-faint); font-size: 11.5px; }
.sd-diff-cell { display: grid; grid-template-columns: 3.5em 1.2em minmax(0, 1fr); min-width: 0; padding: 0 12px 0 0; }
.sd-diff-cell--same { grid-template-columns: 3.5em minmax(0, 1fr); padding-right: 12px; }
.sd-diff-cell--same .sd-diff-text { padding-left: 1.2em; }
.sd-diff-line { color: var(--hm-text-faint); text-align: right; padding-right: 8px; user-select: none; }
.sd-diff-mark { user-select: none; text-align: center; }
.sd-diff-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.sd-diff-cell--old:not(.sd-diff-cell--empty) { background: rgba(229,72,77,.1); color: #9F2D32; }
.sd-diff-cell--new:not(.sd-diff-cell--empty) { background: rgba(34,197,94,.12); color: #166534; }
.sd-diff-cell--empty { background: var(--hm-sunken); }
.sd-rules-save { display: flex; flex-direction: column; gap: 10px; }
.sd-rules-backup { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; line-height: 1.5; cursor: pointer; }
.sd-rules-backup input { width: 16px; height: 16px; margin-top: 3px; flex: none; accent-color: var(--hm-cyan-deep); }
.sd-rules-warning { padding: 10px 12px; border-radius: var(--hm-radius); background: var(--hm-amber-wash); font-size: 13px; line-height: 1.5; }
.sd-rules-warning strong { color: var(--hm-amber-text); }
@media (max-width: 640px) {
    .modal-card.modal-card--rules { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; border-radius: 0; }
    .modal-card--rules .modal-body { padding: 16px; }
    .modal-card--rules .modal-footer { padding: 12px 16px; }
    .modal-card--rules .modal-footer .btn, .modal-card--rules .modal-close, .sd-rules-mode { min-height: 44px; }
    .modal-card--rules .modal-close { min-width: 44px; }
    .sd-diff-row { grid-template-columns: minmax(0, 1fr); }
    .sd-diff-row--head { display: none; }
    .sd-diff-cell--new, .sd-diff-cell--echo { border-left: 0; }
    .sd-diff-cell--echo, .sd-diff-cell--empty { display: none; }
    .sd-rules-pane { max-height: none; }
}
.sd-access-counts { margin: 12px 0; }
#sdAccessPanel h3 { margin: 16px 0 8px; }
.sd-compaction-results { margin-top: 16px; padding: 16px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); background: var(--hm-sunken); }
.sd-compaction-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sd-compaction-header h3 { margin: 3px 0 0; }
.sd-action-button { margin-top: 8px; }
.sd-danger-zone { border-top: 1px solid var(--hm-red); padding-top: 16px; }
.sd-danger-zone p { color: var(--hm-text-muted); margin: 4px 0 12px; }
.text-faint { color: var(--hm-text-faint); }

@media (max-width: 1100px) {
    .sd-filter-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .sd-filter-submit { width: max-content; }
    .sd-split { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
    #sdSpacePanel .sd-long-tier-card { padding: 8px; }
    .sd-filter-grid, .sd-long-metrics { grid-template-columns: 1fr; }
    #sdLongSnapshot .sd-long-health, #sdLongSnapshot .sd-entity-types { grid-template-columns: 1fr; }
    #sdLongSnapshot .sd-long-metrics { grid-template-columns: minmax(0, 1fr); }
    #sdLongSnapshot .sd-kv { min-width: 0; flex: 1 1 100%; overflow-wrap: anywhere; }
    #sdLongSnapshot .sd-actions-row > .btn { height: auto; min-width: 0; min-height: 44px; max-width: 100%; padding-inline: 4px; white-space: normal; overflow-wrap: anywhere; }
    .sd-tier-tabs { display: flex; width: 100%; }
    .sd-tier-tab { flex: 1; min-width: 0; }
}

/* #781 joint SHORT/MID reading (§17.10). The default, used for a narrow
   Memory region or without container-query support, shows one panel at a
   time behind the switch, with filters behind a disclosure button. */
.sd-memory-wrap { container-type: inline-size; container-name: sd-memory; min-width: 0; }
.sd-memory { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.sd-memory > * { min-width: 0; }
.sd-memory-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sd-memory-switch { display: grid; flex: 1; grid-template-columns: 1fr 1fr; gap: 2px; min-width: 0; padding: 0; background: var(--hm-sunken); border-radius: var(--hm-radius-card); }
.sd-memory-switch__btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--hm-radius); background: transparent; color: var(--hm-text-muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.sd-memory-switch__btn:hover { color: var(--hm-cyan-deep); }
.sd-memory-switch__btn[aria-pressed="true"] { background: var(--hm-panel); color: var(--hm-text); border-color: var(--hm-border-strong); }
.sd-memory-switch__btn:focus-visible, .sd-filters-toggle:focus-visible, .sd-facet:focus-visible { outline: 2px solid var(--hm-focus); outline-offset: 2px; }
.sd-memory[data-focus="short"] > #sdMidPanel,
.sd-memory[data-focus="mid"] > #sdShortPanel,
.sd-memory[data-focus="mid"] > .sd-memory-filters,
.sd-memory[data-focus="mid"] .sd-filters-toggle,
.sd-memory[data-filters="closed"] > .sd-memory-filters { display: none; }
.sd-memory-filters { padding: 2px 12px; background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius-card); }
.sd-filters-toggle { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius); background: var(--hm-panel); color: var(--hm-text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.sd-filters-toggle::after { content: "▾"; content: "▾" / ""; color: var(--hm-text-muted); }
.sd-filters-toggle[aria-expanded="true"]::after { content: "▴"; content: "▴" / ""; }
.sd-filters-toggle .count-pill:empty { display: none; }
.sd-filters-title { margin: 10px 0 4px; }
.sd-filter-body { padding: 4px 0 12px; }
.sd-memory .sd-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin-bottom: 8px; }
.sd-memory .sd-filter-submit { grid-column: 1 / -1; width: max-content; }
.sd-facets h3 { margin: 12px 0 6px; }
.sd-facets > p { margin-top: 10px; }
.sd-facet-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.sd-facet { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 32px; padding: 4px 10px; border: 1px solid var(--hm-border); border-radius: var(--hm-radius-pill); background: var(--hm-panel); color: var(--hm-text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.sd-facet:hover { border-color: var(--hm-cyan-mid); }
.sd-facet[aria-pressed="true"] { background: var(--hm-cyan-wash); border-color: var(--hm-cyan-mid); }
.sd-facet--static { cursor: default; }
.sd-facet--static:hover { border-color: var(--hm-border); }
.sd-facet__name { min-width: 0; overflow-wrap: anywhere; }
.sd-facet__count { color: var(--hm-text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sd-memory-panel { min-width: 0; padding: 12px; }
.sd-memory-panel > .panel-header { gap: 8px; margin-bottom: 4px; }
.sd-panel-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.sd-panel-title h2 { margin: 0; font-size: 17px; }
.sd-panel-title .count-pill:empty { display: none; }
.sd-memory-panel .sd-tier-actions { gap: 6px 8px; }
.sd-panel-meta { display: flex; flex-wrap: wrap; gap: 0 8px; }
.sd-panel-title > #sdMidFileFreshness .state-degraded { flex-basis: 100%; }
.sd-panel-title > #sdMidFileFreshness:empty { display: none; }
.sd-mid-actions { margin-top: 8px; }
.sd-memory .sd-note-day h3 { margin: 8px 0 6px; }
/* Narrow Memory: the switch already names the visible panel. */
.sd-memory .sd-panel-title > .micro-label, .sd-memory .sd-panel-title > h2 {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sd-memory-panel > .panel-header { flex-direction: row; flex-wrap: wrap; align-items: center; }
.sd-memory-panel .sd-panel-title:empty { display: none; }
.sd-memory .sd-note-feed { margin-top: 8px; }
.sd-memory .sd-file-tabs { margin: 4px 0; }
.sd-memory .sd-reader { padding: 12px 14px; }
.sd-memory .sd-preview-header { flex-wrap: wrap; gap: 0 12px; margin-bottom: 4px; font-size: 12px; }

/* Two columns: filters above the timeline, the selected MID file alongside.
   Panels share one bounded height and scroll internally. */
@container sd-memory (min-width: 720px) {
    .sd-memory {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "filters mid" "short mid";
        /* R1-F1: the filter row is capped and scrolls; SHORT keeps the rest. */
        grid-template-rows: fit-content(32%) minmax(0, 1fr);
        gap: 16px;
        height: clamp(520px, calc(100vh - 290px), 1400px);
    }
    .sd-memory-bar { display: none; }
    .sd-memory .sd-panel-title > .micro-label, .sd-memory .sd-panel-title > h2 {
        position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal;
    }
    .sd-memory-panel > .panel-header { flex-direction: column; align-items: stretch; }
    .sd-memory[data-focus] > .sd-memory-filters { display: block; grid-area: filters; min-height: 0; overflow-y: auto; }
    .sd-memory[data-focus] > #sdShortPanel { display: flex; grid-area: short; }
    .sd-memory[data-focus] > #sdMidPanel { display: flex; grid-area: mid; }
    .sd-memory .sd-filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .sd-memory .sd-facets { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
    .sd-memory .sd-facets h3 { margin: 4px 0; }
    .sd-memory .sd-facets > p { flex-basis: 100%; margin: 4px 0 0; }
    .sd-memory .sd-facet-list { flex: 1 1 60%; }
    .sd-memory-panel { flex-direction: column; min-height: 0; padding: 16px; overflow: hidden; }
    .sd-memory-panel .sd-note-feed { flex: 1; min-height: 0; max-height: none; }
    .sd-memory .sd-reader { padding: 16px 18px; }
    .sd-mid-body { display: flex; flex: 1; flex-direction: column; min-height: 0; }
    .sd-mid-body .sd-reader { flex: 1 1 auto; min-height: 160px; max-height: none; }
    #sdMidPanel #sdMidCompactionReport { flex-shrink: 0; max-height: 45%; overflow: auto; }
}

/* #781 compact frame on phones: touch-sized breadcrumb, tighter rhythm. */
@media (max-width: 767px) {
    .sd-page { padding-top: 8px; gap: 8px; }
    .sd-frame__line { align-items: center; }
    .sd-breadcrumb a { min-height: 44px; }
    .sd-frame__name { font-size: 20px; line-height: 26px; }
}

/* Three columns as in design screen 03: filters | timeline | reader. */
@container sd-memory (min-width: 960px) {
    .sd-memory {
        grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "filters short mid";
        grid-template-rows: minmax(0, 1fr);
    }
    .sd-memory .sd-filter-grid { grid-template-columns: minmax(0, 1fr); }
    .sd-memory .sd-filter-submit { width: 100%; }
    .sd-memory .sd-facets { display: block; }
    .sd-memory .sd-facets h3 { margin: 14px 0 6px; }
    .sd-memory .sd-facet-list { flex-direction: column; flex-wrap: nowrap; }
    .sd-memory .sd-facet { width: 100%; justify-content: space-between; border-radius: var(--hm-radius); }
}

/* ===== view:consolidation (P8-4) ===== */

#consolLanes > .panel + .panel { margin-top: 16px; }
.consol-job-list { display: flex; flex-direction: column; }
.consol-job-row { padding: 16px 0; border-top: 1px solid var(--hm-border); min-width: 0; }
.consol-job-row:first-child { border-top: 0; }
.consol-job-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.consol-job-heading .consol-space-name { flex: 1 1 240px; min-width: 0; }
.consol-job-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--hm-text-muted); margin-top: 6px; overflow-wrap: anywhere; }
.consol-job-row .consol-progress { margin-top: 8px; max-width: 480px; }
.consol-history-note { color: var(--hm-text-muted); font-size: 13px; margin: 8px 0; }
.consol-scope-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; overflow-wrap: anywhere; }
.consol-scope-filter a { color: var(--hm-cyan-deep); }
.consol-picker { display: flex; flex-direction: column; gap: 12px; }


.consol-subtitle { color: var(--hm-text-muted); margin: -4px 0 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.consol-batch { color: var(--hm-text-muted); }
.consol-scope { color: var(--hm-text-muted); }
.consol-progress { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.consol-bar { height: 6px; border-radius: 999px; background: var(--hm-sunken); overflow: hidden; }
.consol-bar-fill { display: block; height: 100%; background: var(--hm-cyan); border-radius: 999px; }
.consol-bar-indeterminate { width: 40%; animation: consol-indeterminate 1.4s ease-in-out infinite; }
@keyframes consol-indeterminate { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.consol-progress-meta { color: var(--hm-text-faint); font-size: 12px; }
.consol-asof { color: var(--hm-text-faint); }
.consol-denied { margin-top: 16px; padding: 12px 16px; border-radius: var(--hm-radius-card); border: 1px solid var(--hm-amber); }
.consol-denied .micro-label { color: var(--hm-amber-text); display: block; margin-bottom: 8px; }
.consol-denied-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.consol-nothing { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.consol-partial { color: var(--hm-amber-text); margin-top: 8px; }
.consol-jobinspect { display: flex; flex-direction: column; gap: 12px; }
.consol-jobmeta { display: flex; flex-direction: column; gap: 6px; }
.consol-jobmeta-row { display: flex; align-items: center; gap: 8px; }
.consol-stale-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.consol-stale-controls .form-group { margin-bottom: 0; }
.consol-stale-controls .form-input { width: 120px; }
.consol-scan-line { color: var(--hm-text-muted); margin-bottom: 12px; }
.consol-confirm-list { margin: 8px 0 0; padding-left: 20px; max-height: 40vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
/* #779 per-note tiles: 14px squares, 4px gap, ~3px radius; state never by colour alone. */
.consol-tiles { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; min-width: 0; }
.consol-tiles-unavailable { color: var(--hm-text-muted); }
.consol-tiles-counters { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--hm-text-muted); }
.consol-tile-grid { display: flex; flex-wrap: wrap; gap: 4px; max-width: 100%; }
.consol-tile { box-sizing: border-box; flex: none; width: 14px; height: 14px; border-radius: 3px; border: 1px solid transparent; }
.consol-tile-pending { background: var(--hm-sunken); border-color: var(--hm-border-strong); }
.consol-tile-active { background: repeating-linear-gradient(135deg, var(--hm-cyan) 0 3px, var(--hm-cyan-deep) 3px 6px); border-color: var(--hm-cyan-deep); animation: consol-tile-pulse 1.6s ease-in-out infinite; }
.consol-tile-done { background: var(--hm-green); border-color: #15803D; }
.consol-tile-error { background: var(--hm-red); border-color: var(--hm-red-deep); box-shadow: inset 0 0 0 2px var(--hm-panel); }
.consol-tile-unconfirmed { background: var(--hm-amber-wash); border: 2px dashed var(--hm-amber-text); }
@keyframes consol-tile-pulse { 50% { opacity: .55; } }
.consol-tile-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--hm-text-muted); }
.consol-tile-legend li { display: inline-flex; align-items: center; gap: 6px; }
.consol-sources { color: var(--hm-text-muted); margin: 0; }
@media (prefers-reduced-motion: reduce) {
    .consol-bar-indeterminate { animation: none; width: 100%; opacity: .4; }
    .consol-tile-active { animation: none; }
}

/* ===== view:audit (P8-6) ===== */

.audit-view > .audit-scope-banner:first-child {
    display: flex;
}
.audit-scope-banner {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid rgba(0,167,199,.38);
    border-radius: var(--hm-radius-card);
    background: var(--hm-surface-deep);
    color: var(--hm-paper);
}
.audit-scope-banner .micro-label {
    display: block;
    margin-bottom: 4px;
    color: var(--hm-cyan);
}
.audit-scope-banner p {
    font-size: 13px;
    line-height: 19px;
    color: var(--hm-paper);
}
.audit-scope-banner code {
    font-family: var(--hm-font-mono);
    font-size: 12px;
    color: var(--hm-paper);
}
.audit-scope-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--hm-cyan-wash);
    color: var(--hm-cyan);
}
.audit-scope-icon svg { width: 18px; height: 18px; }

.audit-view > .page-header { margin-bottom: 16px; }
.audit-filters {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(220px, 1fr) minmax(220px, 1fr);
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--hm-border);
}
.audit-filter-field { min-width: 0; }
.audit-filter-field .form-label { margin-bottom: 6px; }
.audit-results { min-height: 160px; }
.audit-filters + .audit-results { padding-top: 16px; }

.audit-result-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--hm-text-muted);
    font-size: 12px;
    line-height: 16px;
}
.audit-result-meta strong {
    color: var(--hm-text);
    font-family: var(--hm-font-mono);
    font-weight: 600;
}
.audit-server-scope {
    margin-bottom: 14px;
    padding: 9px 12px;
    border-radius: var(--hm-radius);
    background: var(--hm-sunken);
}
.audit-server-scope .micro-label {
    display: block;
    margin-bottom: 2px;
    color: var(--hm-text-muted);
}
.audit-server-scope p {
    color: var(--hm-text);
    font-size: 12px;
    line-height: 17px;
}

.audit-view .table-scroll { overflow-x: auto; }
.audit-view .data-table { min-width: 960px; }
.audit-view .data-table th:nth-child(1) { width: 168px; }
.audit-view .data-table th:nth-child(2) { width: 150px; }
.audit-view .data-table th:nth-child(3) { width: 170px; }
.audit-view .data-table th:nth-child(4) { width: 250px; }
.audit-view .data-table th:nth-child(5) { width: 130px; }
.audit-view .data-table th:nth-child(6) { width: 110px; }
.audit-time { white-space: nowrap; }
.audit-tool,
.audit-client,
.audit-auth-type {
    display: inline-block;
    max-width: 180px;
    overflow-wrap: anywhere;
}
.audit-null {
    color: var(--hm-text-faint);
    font-size: 12px;
}
.audit-key-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.audit-key-chip {
    display: inline-flex;
    max-width: 100%;
    padding: 2px 7px;
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-pill);
    background: var(--hm-sunken);
    color: var(--hm-text);
    font-family: var(--hm-font-mono);
    font-size: 11px;
    line-height: 16px;
    overflow-wrap: anywhere;
}
.audit-key-chip--overflow {
    border-style: dashed;
    color: var(--hm-text-faint);
    background: transparent;
}

@media (max-width: 820px) {
    .audit-filters { grid-template-columns: 1fr; }
    .audit-result-meta { flex-direction: column; gap: 2px; }
}

/* ===== view:access (P8-5) ===== */

/* Shared faint-text utility referenced by the shell (renderTimestamp, empty
   cells) and by this view; defined here to back those "—" placeholders. */
.text-faint { color: var(--hm-text-faint); }

.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title h2 {
    font-family: var(--hm-font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--hm-text);
    margin: 0;
}

.access-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--hm-sunken);
    color: var(--hm-text-muted);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius);
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
}
.access-banner svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--hm-text-muted); }

/* Timer-free recovery affordance for an indefinitely pending create.
   Hidden until the request is in flight; lets the operator stop waiting on a
   stalled request without a full reload. */
.pending-escape {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--hm-border);
    font-size: 12px;
}
.pending-escape[hidden] { display: none; }

.token-name { font-weight: 600; color: var(--hm-text); }
.cell-sub { font-size: 11px; color: var(--hm-text-muted); font-family: var(--hm-font-mono); margin-top: 2px; }
.cell-actions { text-align: right; white-space: nowrap; width: 44px; }

/* Native disclosure keeps the per-row menu keyboard-operable without adding a
   second focus manager beside the shared modal. The table retains horizontal
   recovery while the viewport-positioned panel escapes its scroll container. */
.access-token-table .data-table .row-muted { opacity: 1; }
.access-token-table .data-table .row-muted > td:not(.cell-actions) { opacity: .55; }

/* #655: the actions column stays pinned to the visible right edge of the
   scroller, so every row menu is reachable at scrollLeft 0 while the other
   columns keep their internal horizontal scroll. Sticky cells are opaque and
   form stacking contexts painted in row order; the cell holding the open menu
   is raised so its panel is never painted under a later row's actions cell. */
.access-token-table .data-table tr > :last-child {
    position: sticky;
    right: 0;
    background: var(--hm-panel);
    box-shadow: inset 1px 0 0 var(--hm-border);
}
.access-token-table .data-table tbody tr:hover > .cell-actions { background: #F6F7F4; }
.access-token-table .data-table .cell-actions:has(.row-action-menu[open]) { z-index: 120; }
.row-action-menu { display: inline-block; text-align: left; }
.row-action-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: var(--hm-radius);
    color: var(--hm-text-muted);
    cursor: pointer;
    font-family: var(--hm-font-body);
    font-size: 14px;
    letter-spacing: 1px;
    list-style: none;
    user-select: none;
}
.row-action-trigger::-webkit-details-marker { display: none; }
.row-action-trigger:hover,
.row-action-menu[open] .row-action-trigger {
    background: var(--hm-sunken);
    border-color: var(--hm-border-strong);
    color: var(--hm-text);
}
.row-action-trigger:focus-visible {
    background: var(--hm-sunken);
    border-color: var(--hm-border-strong);
    color: var(--hm-text);
    outline: 2px solid var(--hm-focus);
    outline-offset: 2px;
}
.row-action-menu-panel {
    position: fixed;
    z-index: 120;
    top: 0;
    left: 0;
    width: 236px;
    padding: 6px;
    background: var(--hm-panel);
    border: 1px solid var(--hm-border-strong);
    border-radius: var(--hm-radius-card);
    box-shadow: 0 10px 28px rgba(14,20,31,.16);
}
.row-action-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--hm-radius);
    background: transparent;
    color: var(--hm-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.row-action-item:hover:not(:disabled),
.row-action-item:focus-visible { background: var(--hm-sunken); }
.row-action-item:focus-visible {
    outline: 2px solid var(--hm-focus);
    outline-offset: -2px;
}
.row-action-item:disabled { color: var(--hm-text-faint); cursor: not-allowed; }
.row-action-item small { margin-top: 1px; color: var(--hm-text-muted); font-size: 11px; }
.row-action-item:disabled small { color: inherit; }
.row-action-danger { color: var(--hm-red-deep); }
.row-action-close { display: none; }
.row-action-separator { height: 1px; margin: 5px 4px; background: var(--hm-border); }
.replacement-banner { align-items: flex-start; }
.replacement-steps { margin: 12px 0; padding-left: 22px; color: var(--hm-text); }
.replacement-steps li { margin: 6px 0; }

@media (max-width: 1100px) {
    .row-action-menu-panel {
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }
    .row-action-close { display: flex; }
}

.access-all { font-size: 13px; color: var(--hm-text-muted); font-style: italic; }
.space-chips { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 4px; max-width: 360px; overflow: hidden; white-space: nowrap; vertical-align: middle; }
.chip-space { background: var(--hm-sunken); color: var(--hm-text-muted); }
.chip-overflow { flex: 0 0 auto; color: var(--hm-cyan-deep); }
.chip-current {
    background: var(--hm-cyan-wash);
    color: var(--hm-cyan-deep);
    margin-left: 6px;
}

/* In the token table the reserved badge sits under the name and can wrap; a
   rounded-rect (not a full pill) keeps the wrapped label a legible tag rather
   than a lumpy circle. */
.data-table .badge-reserved {
    margin-top: 4px;
    border-radius: var(--hm-radius);
    white-space: normal;
    line-height: 1.3;
    text-align: left;
    align-items: flex-start;
}

/* One-time secret display (§7.1.6). */
.secret-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--hm-red-deep);
    font-size: 13px;
    margin: 0 0 8px;
}
.secret-warning svg { width: 16px; height: 16px; flex-shrink: 0; }
.secret-actions { margin: 8px 0; }
.token-meta { font-size: 13px; color: var(--hm-text-muted); margin-top: 8px; }
.mono-block.secret {
    border: 1px solid var(--hm-cyan);
    background: var(--hm-cyan-wash);
    color: var(--hm-text);
}

/* Destructive warning row (revoke / delete / purge). */
.destructive-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--hm-red-wash);
    border: 1px solid var(--hm-red);
    border-radius: var(--hm-radius);
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--hm-text);
}
.destructive-note svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--hm-red); margin-top: 1px; }

.modal-footer.inline-footer { padding: 16px 0 0; border-top: none; }

/* Edit-token space checkboxes. */
.space-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.space-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.chip-orphan { color: var(--hm-amber-text); font-size: 11px; font-family: var(--hm-font-mono); }

.form-hint.form-warn { color: var(--hm-amber-text); }

.access-help {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--hm-border);
    font-size: 12px;
    line-height: 18px;
    color: var(--hm-text-muted);
}
.access-help p { margin: 0 0 6px; }
.access-help code {
    font-family: var(--hm-font-mono);
    background: var(--hm-sunken);
    padding: 0 4px;
    border-radius: 3px;
}

/* #785 credential handoff (mock 06) and Connect an agent checklist (mock 05).
   One dialog carries the one-time secret, the non-secret Token ID and the
   optional space grants; its inline footer stays reachable while the body
   scrolls at narrow widths and 200% zoom. */
.modal-card:has(.handoff) { width: 640px; }
.modal-card:has(.connect-flow) { width: 880px; }
.handoff { display: flex; flex-direction: column; gap: 14px; }
.handoff .secret-warning { margin: 0; }
.handoff-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.handoff-field .micro-label, .handoff-field .form-hint { margin: 0; }
.handoff-value-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.handoff-value-row .mono-block { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.handoff-value-row .btn { flex: none; }
.handoff-identity { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--hm-text-muted); }
.handoff-cleared { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: var(--hm-radius); background: var(--hm-green-wash); color: var(--hm-text); font-size: 13px; }
.handoff-cleared svg { width: 16px; height: 16px; flex: none; }
.handoff-grants { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--hm-cyan); border-radius: 10px; background: rgba(0,167,199,.06); }
.handoff-grants__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.handoff-grants__head h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--hm-text); }
.handoff-grants__head span { font-size: 12px; color: var(--hm-text-muted); }
.handoff-grants__global { margin: 0; font-size: 13px; color: var(--hm-text-muted); }
.handoff-spaces { display: flex; flex-direction: column; gap: 6px; }
.handoff-space { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: var(--hm-radius); font-size: 13px; cursor: pointer; }
.handoff-space:has(input:checked) { border-color: var(--hm-cyan); }
.handoff-space:has(input:disabled) { background: var(--hm-paper); cursor: default; }
.handoff-space .mono { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.handoff-space small { color: var(--hm-text-muted); font-size: 12px; }
.handoff-results { display: flex; flex-direction: column; gap: 6px; }
.handoff-results:empty { display: none; }
.handoff-result { padding: 8px 10px; border-radius: var(--hm-radius); background: var(--hm-sunken); color: var(--hm-text); font-size: 13px; overflow-wrap: anywhere; }
.handoff-result--granted, .handoff-result--noop { background: var(--hm-green-wash); }
.handoff-result--failed, .handoff-result--refused, .handoff-result--recovery { background: var(--hm-amber-wash); }
.handoff-grant-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.handoff-grant-actions .btn[hidden] { display: none; }
.modal-body .handoff-footer { position: sticky; bottom: -20px; z-index: 1; flex-wrap: wrap; align-items: center; margin: 4px -20px -20px; padding: 12px 20px 16px; background: var(--hm-panel); border-top: 1px solid var(--hm-border); }
.handoff-footer__hint { flex: 1 1 220px; margin: 0; }

.connect-flow { display: flex; flex-direction: column; gap: 16px; }
.connect-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.connect-step { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--hm-radius); background: var(--hm-sunken); }
.connect-step--done { background: var(--hm-green-wash); }
.connect-step--warn { background: var(--hm-amber-wash); }
.connect-step--current { background: var(--hm-cyan-wash); border-color: var(--hm-cyan); }
.connect-step__mark { display: flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--hm-border-strong); color: var(--hm-surface-deep); font-size: 12px; font-weight: 700; }
.connect-step--done .connect-step__mark { background: var(--hm-green); color: var(--hm-surface-deep); }
.connect-step--warn .connect-step__mark { background: var(--hm-amber); }
.connect-step--current .connect-step__mark { background: var(--hm-cyan); }
.connect-step__mark svg { width: 14px; height: 14px; }
.connect-step__text { display: flex; flex-direction: column; min-width: 0; }
.connect-step__text strong { font-size: 13px; color: var(--hm-text); }
.connect-step__text small { font-family: var(--hm-font-mono); font-size: 11px; color: var(--hm-text-muted); overflow-wrap: anywhere; }
.connect-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; }
.connect-config { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.connect-config .form-group, .connect-config .form-hint { margin: 0; }
.segmented { position: relative; display: inline-flex; flex-wrap: wrap; align-self: flex-start; gap: 4px; min-width: 0; margin: 0; padding: 3px; border: 0; border-radius: var(--hm-radius); background: var(--hm-sunken); }
.segmented__option { position: relative; display: inline-flex; }
.segmented__option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented__option span { display: inline-flex; align-items: center; min-height: 32px; padding: 6px 12px; border-radius: 6px; color: var(--hm-text-muted); font-size: 13px; }
.segmented__option input:checked + span { background: var(--hm-panel); color: var(--hm-text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmented__option input:focus-visible + span { outline: 2px solid var(--hm-focus); outline-offset: 1px; }
.connect-snippet { min-height: 72px; margin: 0; background: var(--hm-surface-deep); border-color: var(--hm-surface-deep); color: #E4E7EC; }
.connect-snippet:empty::before { content: 'Enter the external MCP URL to generate the configuration.'; color: var(--hm-side-muted); font-family: var(--hm-font-body); }
.connect-verify { display: flex; flex-direction: column; align-self: start; gap: 10px; padding: 16px; border: 1px solid var(--hm-border); border-radius: 10px; background: var(--hm-paper); }
.connect-verify .micro-label, .connect-verify .form-hint { margin: 0; }
.connect-verify__state { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--hm-text); font-size: 14px; font-weight: 600; }
.connect-verify__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--hm-amber); }

.access-session-hint { margin: -4px 0 12px; }
.access-session-table .cell-actions { width: auto; }

@media (max-width: 767px) {
    .connect-grid { grid-template-columns: minmax(0, 1fr); }
    .handoff-value-row { flex-direction: column; align-items: stretch; }
    .handoff-footer .btn, .handoff-grant-actions .btn, .handoff-value-row .btn, .segmented__option span { min-height: 44px; }
    .handoff-footer .btn { flex: 1 1 auto; }
}

/* ===== view:operator (P8-4) ===== */

.op-actions-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.op-filtered-banner { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--hm-radius-card); border: 1px solid var(--hm-amber); margin-bottom: 12px; color: var(--hm-amber-text); }
.op-filtered-banner svg { width: 18px; height: 18px; color: var(--hm-amber); flex: none; }
.op-backup-desc { color: var(--hm-text-muted); margin-top: 4px; }
.op-restore-error { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.op-restore-doctrine { color: var(--hm-text-muted); }
.op-maint-intro { color: var(--hm-text-muted); margin: -4px 0 16px; }
.op-maint-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.op-sub { font-size: 13px; font-weight: 600; color: var(--hm-text); margin: 16px 0 8px; }
.op-gc-age { max-width: 200px; }
.op-gc-space { padding: 8px 0; border-top: 1px solid var(--hm-border); }
.op-gc-space .micro-label { color: var(--hm-text); }
.op-gc-agents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.op-gc-delete-hint { display: flex; align-items: flex-start; gap: 4px; }
.op-gc-delete-hint svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.op-maint-intro + #opMaintPicker .panel { margin-bottom: 16px; }
#opMaintPanels .panel { margin-bottom: 16px; }
.state-success { background: var(--hm-green-wash); border: 1px solid var(--hm-green); border-radius: var(--hm-radius-card); }
.state-success svg { color: var(--hm-green); }

/* ===== view:mesh (P10-4) ===== */

.mesh-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mesh-diag-row td { padding: 0 12px 12px; border-bottom: 1px solid var(--hm-border); background: #FAFBF8; }
.mesh-diagnostics { margin: 0; }
.mesh-diagnostics summary { font-size: 12px; }
.mesh-join-summary { margin: 0 0 12px; }
.mesh-join-summary .sd-meta-row { margin-bottom: 8px; }
.mesh-join-id { overflow-wrap: anywhere; word-break: break-all; }
.mesh-join-steps { margin: 12px 0; padding-left: 22px; }
.mesh-join-steps li { margin: 4px 0; }
.mesh-join-page > .sd-breadcrumb { margin: 0 0 12px; }
.mesh-join-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.mesh-join-main, .mesh-join-guide { min-width: 0; }
.mesh-join-guide { position: sticky; top: 16px; }
.mesh-join-submit { justify-content: flex-start; margin-top: 16px; }
.mesh-join-submit .btn { min-height: 44px; }

@media (max-width: 900px) {
    .mesh-join-layout { grid-template-columns: minmax(0, 1fr); }
    .mesh-join-guide { position: static; }
}

/* Mobile interaction contract (§14): keep every primary control reachable,
   comfortably tappable, and inside the narrow content column. */
@media (max-width: 600px) {
    .page-header { align-items: flex-start; gap: 12px; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn,
    .modal-footer .btn { flex: 1 1 auto; justify-content: center; }
    .modal-footer { flex-wrap: wrap; }
    .sd-tier-card > .panel-header,
    .sd-compaction-header { flex-direction: column; align-items: stretch; }
    .sd-tier-actions { width: 100%; }

    .row-action-trigger,
    .row-action-item { min-width: 44px; min-height: 44px; }
    .row-action-trigger { width: 44px; height: 44px; }

    .btn,
    .btn-sm,
    .sd-tier-tab,
    .sidebar-menu-toggle,
    .nav-item { min-height: 44px; height: auto; }

    .icon-btn,
    .copy-btn,
    .modal-close,
    .toast-close { min-width: 44px; min-height: 44px; }
}

/* Compaction outcomes stay visible; supplementary evidence opens on demand. */
.diagnostic-details { margin-top: 8px; }
.diagnostic-details > summary { cursor: pointer; padding: 6px 0; font-weight: 500; }
.diagnostic-details code { overflow-wrap: anywhere; }
@media (max-width: 640px) {
    .diagnostic-details > summary { min-height: 44px; }
}
.compaction-details { min-width: 0; margin-top: 16px; }
.sd-compaction-results .state > div,
#opCompactResults .state > div { min-width: 0; max-width: 100%; text-align: left; overflow-wrap: anywhere; }
.sd-compaction-results .table-scroll,
#opCompactResults .table-scroll { min-width: 0; max-width: 100%; }
.sd-compaction-results .data-table,
#opCompactResults .data-table { min-width: 560px; overflow-wrap: normal; }
.compaction-details > summary { cursor: pointer; padding: 10px 0; font-weight: 500; }
.compaction-details .table-scroll { max-width: 100%; }
.compaction-details td { overflow-wrap: anywhere; white-space: normal; }
.compaction-file-evidence { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--hm-border); }
.compaction-file-evidence h4 { overflow-wrap: anywhere; }
.compaction-file-evidence dl { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 6px 16px; margin-top: 8px; font-size: 13px; }
.compaction-file-evidence dt { color: var(--hm-text-muted); }
.compaction-file-evidence dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.compaction-failures { padding-left: 20px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .compaction-details > summary { min-height: 44px; }
    .compaction-file-evidence dl { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .compaction-file-evidence dd { margin-bottom: 8px; }
}

/* Spaces reflow at narrow widths (also covers desktop at 200% zoom). */
@media (max-width: 767px) {
    .spaces-table .table-scroll { overflow: visible; }
    .spaces-table .data-table, .spaces-table tbody { display: block; min-width: 0; }
    .spaces-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .spaces-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; border-bottom: 1px solid var(--hm-border); padding: 16px 0; }
    .spaces-table td { display: block; min-width: 0; border: 0; padding: 0; }
    .spaces-table td:first-child { grid-column: 1 / -1; }
    .spaces-table td:not(:first-child)::before { content: attr(data-label); display: block; font-size: 12px; color: var(--hm-text-muted); margin-bottom: 4px; }
    .spaces-id-link { display: inline; }
    .consol-job-heading { align-items: flex-start; }
    .consol-job-heading .consol-space-name { flex-basis: 100%; }
    .consol-job-row .consol-progress { min-width: 0; }
}

@media (max-width: 767px) { .spaces-search .form-input { min-height: 44px; } }

/* Dashboard recent-consolidation composition — #633 / design §17.3, simplified by #699. */
.dash-section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.dash-section-heading h2 { font-size: 22px; margin: 0 0 6px; }
.dash-section-heading p { margin: 0; }
.dash-consolidated { margin-bottom: 30px; }
.dash-space-grid { display: grid; grid-template-columns: repeat(var(--dash-columns, 1), minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.dash-space-card { min-width: 0; background: var(--hm-panel); border: 1px solid var(--hm-border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; overflow-wrap: anywhere; transition: border-color .15s ease, box-shadow .15s ease; }
/* #699: no tile is highlighted for its position; hover, keyboard focus or an
   explicit selection are the only highlights. */
.dash-space-card:hover, .dash-space-card:focus-within, .dash-space-card[aria-current="true"] { border-color: var(--hm-cyan); box-shadow: inset 0 3px 0 var(--hm-cyan); }
.dash-space-card-heading { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--hm-text-muted); }
.dash-space-card h3 { font-family: 'Space Grotesk', var(--hm-font-body); font-size: 18px; margin: 10px 0 4px; }
.dash-space-card h3 a { color: var(--hm-text); }
.dash-space-description { color: var(--hm-text-muted); font-size: 12px; line-height: 1.5; margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.dash-space-results { margin-top: auto; border-top: 1px solid var(--hm-border); padding-top: 8px; }
.dash-space-results dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 4px 0 0; }
.dash-space-results dt { font-size: 11px; color: var(--hm-text-muted); }
.dash-space-results dd { font-family: 'Space Grotesk', var(--hm-font-body); font-size: 22px; font-weight: 600; margin: 2px 0 0; }
.dash-space-action { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; font-weight: 600; color: var(--hm-cyan-deep); }
#dashInventoryFreshness { margin-top: 8px; font-size: 12px; }
@media (max-width: 600px) {
    .dash-section-heading { flex-direction: column; gap: 4px; }
    .dash-section-heading h2 { font-size: 20px; }
    .dash-space-card { padding: 18px; }
}

/* #782: available definitions and the read-only ontology explorer. */
.sd-ontology-scopes { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.sd-ontology-scopes [aria-pressed="true"] { border-color: var(--hm-cyan-deep); }
.sd-ontology-workspace { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: 24px; }
.sd-ontology-catalog, .sd-ontology-explorer { min-width: 0; overflow-wrap: anywhere; }
.sd-ontology-catalog .sd-long-controls { flex-direction: column; align-items: stretch; }
.sd-ontology-choice { display: flex; flex-direction: column; text-align: left; gap: 4px; width: 100%; margin-top: 8px; padding: 12px; background: transparent; color: inherit; border: 1px solid var(--hm-border); border-radius: 8px; overflow-wrap: anywhere; cursor: pointer; font: inherit; }
.sd-ontology-choice span { font-size: 12px; color: var(--hm-text-muted); }
.sd-ontology-choice:hover, .sd-ontology-choice.active { border-color: var(--hm-cyan-deep); background: var(--hm-cyan-wash); }
.sd-ontology-choice:focus-visible, .sd-ontology-yaml summary:focus-visible { outline: 2px solid var(--hm-cyan-deep); outline-offset: 2px; }
.sd-ontology-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; }
.sd-ontology-explorer section { margin-top: 24px; }
.sd-ontology-table { overflow-x: auto; max-width: 100%; }
.sd-ontology-table table { width: 100%; min-width: 540px; table-layout: fixed; }
.sd-ontology-table td, .sd-ontology-table th { vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.sd-ontology-table td ul { margin: 0; padding-left: 16px; }
.sd-ontology-rules { margin: 0; }
.sd-ontology-rules > div { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--hm-border); }
.sd-ontology-rules dt { font-family: var(--hm-font-mono); font-size: 12px; }
.sd-ontology-rules dd { margin: 0; white-space: pre-wrap; }
.sd-ontology-context { white-space: pre-wrap; }
.sd-ontology-yaml { margin: 24px 0 16px; border-top: 1px solid var(--hm-border); padding-top: 16px; }
.sd-ontology-yaml summary { cursor: pointer; margin-bottom: 12px; }
.sd-ontology-yaml pre { max-height: 440px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 12px; }
@media (max-width: 900px) {
    .sd-ontology-workspace { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    #sdOntologyCatalog { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 8px; }
    .sd-ontology-rules > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* Creation keeps ontology choices readable inside the shared responsive modal. */
.modal-card:has(#csOntologySetup) { width: 880px; }

.cs-ontology-modes, .cs-ontology-library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 600px) { .cs-ontology-modes, .cs-ontology-library { grid-template-columns: 1fr; } }

.modal-card:has(#csOntologySetup .cs-ontology-library) { width: 1040px; }

.cs-ontology-library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 601px) and (max-width: 900px) { .cs-ontology-library { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .cs-ontology-library { grid-template-columns: 1fr; } }

/* #1352: compatibility bridge for retained Space fragments in the default
   React document. These are aliases of the SAME semantic tokens used by the
   Dashboard, not a second palette. The route class never exists in admin.html.
   Body-level legacy dialogs/toasts inherit the bridge only while Space owns
   the route; React portals keep their own DS tokens. No controller changes. */
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) {
    --hm-paper: var(--hm-elevation-surface-default);
    --hm-panel: var(--hm-elevation-surface-raised-default);
    --hm-sunken: var(--hm-elevation-surface-sunken);
    --hm-ink: var(--hm-color-text-default);
    --hm-text: var(--hm-color-text-default);
    --hm-text-muted: var(--hm-color-text-subtle);
    --hm-text-faint: var(--hm-color-text-subtle);
    --hm-border: var(--hm-color-border-default);
    --hm-border-strong: var(--hm-color-border-input);
    --hm-surface-deep: var(--hm-color-background-brand-bold-default);
    --hm-cyan: var(--hm-color-background-brand-bold-default);
    --hm-cyan-mid: var(--hm-color-background-brand-bold-hovered);
    --hm-cyan-deep: var(--hm-color-text-information);
    --hm-cyan-wash: var(--hm-color-background-information-default);
    --hm-amber: var(--hm-color-border-warning);
    --hm-amber-text: var(--hm-color-text-warning-default);
    --hm-amber-wash: var(--hm-color-background-warning-default);
    --hm-green: var(--hm-color-text-success);
    --hm-green-wash: var(--hm-color-background-success-default);
    --hm-red: var(--hm-color-text-danger);
    --hm-red-deep: var(--hm-color-text-danger);
    --hm-red-wash: var(--hm-color-background-danger-default);
    --hm-focus: var(--hm-color-border-focused);
    --hm-focus-dark: var(--hm-color-border-focused);
    --hm-font-body: var(--hm-font-body-family);
    --hm-font-display: var(--hm-font-body-family);
    --hm-font-mono: var(--hm-font-code-family);
    --hm-side-text: var(--hm-color-text-default);
    --hm-side-muted: var(--hm-color-text-subtle);
    --hm-side-border: var(--hm-color-border-default);
    --hm-side-hover: var(--hm-elevation-surface-hovered);
    --hm-side-active: var(--hm-color-background-selected-default);
    color: var(--hm-text);
    color-scheme: light;
}
:where(html[data-hm-theme="dark"]) :is(.hm-space-island, body:has(.hm-space-island) #adminModal, body:has(.hm-space-island) #toastStack) { color-scheme: dark; }
/* Hard-coded legacy paint that can appear in Space, including Rules diffs,
   Active work tiles, operator rows and transient handoff/confirmation dialogs.
   Scope ends at the route, so default legacy paint stays byte-for-byte intact. */
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .btn-primary { color: var(--hm-color-text-inverse); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .btn-secondary:hover:not(:disabled) { background: var(--hm-elevation-surface-raised-hovered); border-color: var(--hm-color-border-bold); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .btn-danger { background: var(--hm-color-background-danger-bold-default); color: var(--hm-color-text-inverse); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .btn-danger:hover:not(:disabled) { background: var(--hm-color-background-danger-bold-hovered); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .data-table tbody tr:hover,
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .access-token-table .data-table tbody tr:hover > .cell-actions { background: var(--hm-elevation-surface-hovered); }
/* Revocation is already explicit text. Dimming the whole row also dims that
   status below the required contrast; keep semantic muted text fully opaque. */
:where(.hm-space-island) .data-table .row-muted { opacity: 1; color: var(--hm-text-muted); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .mesh-diag-row td { background: var(--hm-sunken); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .sd-diff-count--add { color: var(--hm-color-text-success); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .sd-diff-cell--old:not(.sd-diff-cell--empty) { background: var(--hm-red-wash); color: var(--hm-color-text-danger); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .sd-diff-cell--new:not(.sd-diff-cell--empty) { background: var(--hm-green-wash); color: var(--hm-color-text-success); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .consol-tile-done { border-color: var(--hm-color-border-success); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live { background: var(--hm-sunken); color: var(--hm-text); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live::after { background: none; }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live :is(h2, .dash-live-link, .dash-live-history summary) { color: var(--hm-cyan-deep); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live :is(.dash-live-count, .dash-live-note, .status-dot-label, .consol-tiles-counters, .consol-tile-legend, .body-small, .mono-chip, .mono-chip-value, .dash-live-history) { color: var(--hm-text-muted); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live :is(.consol-space-name, .dash-live-history code, .btn-secondary) { color: var(--hm-text); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-job-card { background: var(--hm-panel); border-color: var(--hm-border); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-job-foot { border-color: var(--hm-border); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live .consol-tile-pending { background: var(--hm-panel); border-color: var(--hm-border-strong); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live .consol-tile-error { box-shadow: inset 0 0 0 2px var(--hm-sunken); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal, html:has(.hm-space-island) #toastStack) .dash-live .consol-tile-unconfirmed { background: var(--hm-amber-wash); border-color: var(--hm-amber); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal) .connect-snippet { color: var(--hm-color-text-inverse); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal) .connect-snippet:empty::before { color: var(--hm-color-text-inverse); }
:where(.hm-space-island, html:has(.hm-space-island) #adminModal) .handoff-grants { background: var(--hm-cyan-wash); }
