:root,
[data-bs-theme="dark"] {
	color-scheme: dark;
	--cortex-void: #0b121d;
	--cortex-ink: #111c2b;
	--cortex-deep: #173346;
	--surface-raised: #1a293c;
	--border: #2a3b50;
	--signal-blue: #71d7ed;
	--synapse-mint: #93e5cf;
	--pulse-amber: #f0c078;
	--alert-coral: #ff9ba5;
	--mist-white: #edf3fa;
	--steel-grey: #a3b2c5;
	--font-body: Inter, "Segoe UI", system-ui, sans-serif;
	--font-heading: Sora, "Segoe UI", system-ui, sans-serif;
	--font-code: "JetBrains Mono", Consolas, monospace;
	--bs-body-font-family: var(--font-body);
	--bs-body-bg: var(--cortex-void);
	--bs-body-bg-rgb: 11, 18, 29;
	--bs-body-color: var(--mist-white);
	--bs-body-color-rgb: 237, 243, 250;
	--bs-secondary-color: var(--steel-grey);
	--bs-secondary-color-rgb: 163, 178, 197;
	--bs-primary: var(--signal-blue);
	--bs-primary-rgb: 113, 215, 237;
	--bs-link-color: var(--signal-blue);
	--bs-link-color-rgb: 113, 215, 237;
	--bs-link-hover-color: var(--synapse-mint);
	--bs-link-hover-color-rgb: 147, 229, 207;
	--bs-border-color: var(--border);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cortex-void); color: var(--mist-white); font-family: var(--font-body); font-size: .9375rem; line-height: 1.6; }
a { color: var(--signal-blue); text-underline-offset: .2em; }
a:hover { color: var(--synapse-mint); }
:focus-visible { outline: 2px solid var(--signal-blue); outline-offset: 4px; }
h1[tabindex="-1"]:focus { outline: none; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; line-height: 1.3; color: var(--mist-white); }
h1 { font-size: clamp(1.8rem, 2.6vw, 2.35rem); letter-spacing: -.045em; margin: .5rem 0 .75rem; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; letter-spacing: -.025em; margin: 0 0 1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }
.muted, .help-text { color: var(--steel-grey); }
.eyebrow, .workspace-label { font: 500 .6875rem var(--font-code); letter-spacing: .12em; color: var(--steel-grey); }
.eyebrow.accent { color: var(--signal-blue); }
.circuit-surface { border: 0; min-width: 0; margin: 0; padding: 0; }
.detail-grid > *, .page-heading > * { min-width: 0; }

/* Shared application shell. Domain views retain their own component styles. */
.cortex-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.cortex-sidebar { padding: 2rem 1rem; background: #0e1826; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.cortex-brand { display: block; font: 600 1.45rem var(--font-heading); letter-spacing: .13em; color: var(--mist-white); text-decoration: none; margin: 0 .8rem 3rem; }
.cortex-brand span { display: block; font: 400 .55rem var(--font-code); letter-spacing: .13em; color: var(--steel-grey); margin-top: .65rem; }
.workspace-label { margin: 0 0 .8rem .85rem; }
.cortex-sidebar nav { display: grid; gap: .35rem; }
.cortex-sidebar nav a { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; color: #bccadd; text-decoration: none; border: 1px solid transparent; border-radius: .5rem; font-size: .83rem; font-weight: 500; }
.cortex-sidebar nav a > span { flex: 0 0 1rem; text-align: center; color: var(--steel-grey); }
.cortex-sidebar nav a.active { border-color: #285064; background: var(--cortex-deep); color: var(--signal-blue); }
.cortex-sidebar nav a.active > span { color: var(--signal-blue); }
.cortex-sidebar nav a:hover { background: var(--surface-raised); color: var(--mist-white); }
.sidebar-note { margin-top: auto; padding: 3rem .85rem 0; color: var(--steel-grey); font-size: .7rem; line-height: 1.8; }
.sidebar-note p { margin-top: .65rem; margin-bottom: 0; }
.workspace-frame { display: flex; flex-direction: column; min-width: 0; }
.workspace-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--border); padding: 1rem 2.5rem; min-height: 4.25rem; font-size: .75rem; }
.workspace-header a { text-decoration: none; }
.workspace-header a:hover { text-decoration: underline; }
.header-divider { color: var(--border); margin: 0 1rem; }
.user-context { overflow-wrap: anywhere; color: var(--steel-grey); }
.workspace-frame > main { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 2.5rem; }
.workspace-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem 2.5rem; border-top: 1px solid var(--border); color: var(--steel-grey); font-size: .6875rem; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; margin-bottom: 2rem; }
.page-heading p { max-width: 65ch; color: var(--steel-grey); margin-bottom: 0; font-size: .875rem; }
.panel { background: var(--cortex-ink); border: 1px solid var(--border); border-radius: .75rem; padding: 1.5rem; margin-bottom: 1.5rem; min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.panel-heading h2 { margin: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.metric { padding: 1.3rem 1.5rem; border: 1px solid var(--border); background: var(--cortex-ink); border-radius: .75rem; }
.metric strong { font: 500 2.3rem var(--font-heading); display: block; margin: .4rem 0; letter-spacing: -.04em; }
.metric span { color: var(--steel-grey); font-size: .8rem; }
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--steel-grey); }
.empty-state h2 { color: var(--mist-white); }
.empty-symbol { font-size: 2rem; color: var(--signal-blue); margin-bottom: .7rem; }

/* Product controls are scoped so Foundry's floating authentication fields keep their behaviour. */
.cortex-shell .button, .cortex-shell button { min-height: 2.75rem; border: 1px solid #3b5069; border-radius: .5rem; background: var(--surface-raised); color: var(--mist-white); padding: .6rem 1rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; cursor: pointer; font: 500 .8125rem var(--font-body); line-height: 1.4; transition: background-color 120ms, border-color 120ms; }
.cortex-shell .button.primary, .cortex-shell button.primary { background: var(--signal-blue); border-color: var(--signal-blue); color: var(--cortex-void); font-weight: 600; }
.cortex-shell .button:hover, .cortex-shell button:hover { background: #25394f; border-color: var(--signal-blue); color: var(--mist-white); }
.cortex-shell .button.primary:hover, .cortex-shell button.primary:hover { background: var(--synapse-mint); border-color: var(--synapse-mint); color: var(--cortex-void); }
.cortex-shell button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.field { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.cortex-shell label { color: #c4d1e2; font-size: .75rem; font-weight: 500; }
.cortex-shell input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .cortex-shell select, .cortex-shell textarea { width: 100%; padding: .7rem .85rem; background: var(--cortex-void); border: 1px solid #3b5069; border-radius: .5rem; color: var(--mist-white); min-height: 2.75rem; font: inherit; font-size: .875rem; line-height: 1.5; }
.cortex-shell input:focus, .cortex-shell select:focus, .cortex-shell textarea:focus { border-color: var(--signal-blue); }
.cortex-shell input[type=checkbox], .cortex-shell input[type=radio] { accent-color: var(--signal-blue); }
.cortex-shell textarea { min-height: 7rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--steel-grey); opacity: 1; }
.help-text { font-size: .75rem; }
.validation-message, .validation-errors { color: var(--alert-coral); }
.invalid { border-color: var(--alert-coral) !important; }
.notice { padding: 1rem 1.2rem; margin: 1rem 0; background: var(--surface-raised); border-left: 3px solid var(--signal-blue); border-radius: .4rem; }
.notice.error { border-color: var(--alert-coral); }
.notice.success { border-color: var(--synapse-mint); }
.notice.warning { border-color: var(--pulse-amber); }
.notice p:last-child { margin-bottom: 0; }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 650px; }
.table-scroll td.mono { min-width: 15rem; }
.scroll-hint { display: none; }
table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
caption { caption-side: top; color: var(--steel-grey); font-size: .75rem; padding: 0 0 .8rem; }
th { color: var(--steel-grey); font: 500 .65rem var(--font-code); letter-spacing: .06em; text-transform: uppercase; text-align: left; }
td, th { padding: 1rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
td:first-child, th:first-child { padding-left: 0; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; background: var(--surface-raised); border: 1px solid var(--border); color: #c4d1e2; border-radius: .35rem; padding: .3rem .5rem; font: .65rem var(--font-code); white-space: nowrap; }
.mono { font-family: var(--font-code); font-size: .8rem; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 1.5rem; }
dl { margin: 0; }
dt { color: var(--steel-grey); font-size: .72rem; font-weight: 400; margin-top: 1rem; }
dt:first-child { margin-top: 0; }
dd { margin: .25rem 0 0; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.skip-link { position: fixed; top: -10rem; left: 1rem; z-index: 10000; padding: .75rem; background: var(--cortex-ink); border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
#components-reconnect-modal { position: fixed; inset: 0; z-index: 9999; background: #0b121ded; padding: 10vh 1rem; }
.components-reconnect-hide { display: none; }
.components-reconnect-show, .components-reconnect-failed, .components-reconnect-rejected { display: block; }
.connection-notice { max-width: 38rem; margin: auto; border: 1px solid var(--pulse-amber); border-radius: .75rem; padding: 2rem; background: var(--cortex-ink); }

/* Existing Blazor Bootstrap notifications share the local application theme. */
.cortex-toasts { --bs-danger-rgb: 68, 34, 47; --bs-success-rgb: 24, 61, 56; --bs-warning-rgb: 73, 56, 30; z-index: 1080; padding: 1rem; margin-top: 4.25rem; max-width: 100vw; max-height: calc(100dvh - 5.25rem); overflow-y: auto; pointer-events: none; }
.cortex-toasts .toast { --bs-toast-bg: var(--cortex-ink); --bs-toast-color: var(--mist-white); --bs-toast-header-bg: var(--surface-raised); --bs-toast-header-color: var(--mist-white); --bs-toast-border-color: var(--border); --bs-toast-header-border-color: var(--border); --bs-toast-border-radius: .65rem; --bs-toast-box-shadow: 0 .75rem 2rem #0005; width: min(25rem, calc(100vw - 2rem)); border-left: 3px solid var(--signal-blue); pointer-events: auto; overflow-wrap: anywhere; }
.cortex-toasts .toast.bg-danger, .cortex-toasts .toast.text-bg-danger { border-left-color: var(--alert-coral); }
.cortex-toasts .toast.bg-success, .cortex-toasts .toast.text-bg-success { border-left-color: var(--synapse-mint); }
.cortex-toasts .toast-header { gap: .4rem; padding: .7rem .85rem; }
.cortex-toasts .toast-body { padding: .85rem; font-size: .875rem; line-height: 1.55; }
.cortex-toasts .btn-close { flex-shrink: 0; padding: .7rem; }
.workspace-error { max-width: 52rem; }
.workspace-error h1 { font-size: 1.4rem; }
#blazor-error-ui { display: none; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 10001; width: min(52rem, calc(100% - 2rem)); padding: 1.25rem 3.5rem 1.25rem 1.5rem; background: var(--cortex-ink); color: var(--mist-white); border: 1px solid var(--alert-coral); border-radius: .75rem; box-shadow: 0 .75rem 3rem #0007; }
#blazor-error-ui p { margin: .4rem 0 .75rem; font-size: .875rem; color: var(--steel-grey); }
#blazor-error-ui .reload { display: inline-block; font-weight: 600; }
#blazor-error-ui .dismiss { position: absolute; top: .6rem; right: .6rem; width: 2.5rem; height: 2.5rem; padding: 0; border: 0; border-radius: .4rem; background: transparent; color: var(--mist-white); font-size: 1.5rem; cursor: pointer; }
#blazor-error-ui .dismiss:hover { background: var(--surface-raised); }

/* Theme the existing Foundry identity components; credentials and forms remain Foundry-owned. */
/* Preserve Foundry's background image and overlay; set only the fallback colour. */
[data-bs-theme="dark"] .auth-shell { background-color: var(--cortex-void); }
.auth-shell .auth-card { --bs-card-bg: var(--cortex-ink); border: 1px solid var(--border) !important; border-radius: 1rem; box-shadow: 0 20px 70px #0004 !important; }
.auth-card .auth-logo { max-height: 2.25rem; }
.auth-card .auth-eyebrow { font: 500 .6875rem var(--font-code); letter-spacing: .12em; }
.auth-card .form-control, .auth-card .form-select { background-color: var(--cortex-void); border-color: #3b5069; font-family: var(--font-body); font-size: .875rem; }
.auth-card .form-control:focus, .auth-card .form-select:focus { border-color: var(--signal-blue); }
.auth-card .form-floating label { color: var(--steel-grey); font-size: .875rem; }
.auth-card .form-check-input:checked { background-color: #258298; border-color: #258298; }
.auth-card .btn-primary { --bs-btn-bg: var(--signal-blue); --bs-btn-border-color: var(--signal-blue); --bs-btn-color: var(--cortex-void); --bs-btn-hover-bg: var(--synapse-mint); --bs-btn-hover-border-color: var(--synapse-mint); --bs-btn-hover-color: var(--cortex-void); --bs-btn-active-bg: var(--synapse-mint); --bs-btn-active-border-color: var(--synapse-mint); --bs-btn-active-color: var(--cortex-void); font-size: .9375rem; min-height: 3rem; }
.auth-card .auth-form-footer { font-size: .875rem; }

@media (max-width: 1100px) {
	.cortex-shell { grid-template-columns: 224px minmax(0, 1fr); }
	.workspace-frame > main { padding: 2rem 1.5rem; }
	.workspace-header, .workspace-footer { padding: 1rem 1.5rem; }
}
@media (max-width: 900px) {
	.detail-grid { grid-template-columns: minmax(0, 1fr) !important; }
	.scroll-hint { display: block; font-size: .75rem; color: var(--steel-grey); }
	.workspace-header { flex-wrap: wrap; }
}
@media (max-width: 640px) {
	.cortex-shell { display: block; }
	.cortex-sidebar { padding: 1rem; border-right: 0; border-bottom: 1px solid var(--border); }
	.cortex-brand { margin: .25rem 0 1.25rem; font-size: 1.2rem; }
	.cortex-sidebar nav a { font-size: .8rem; gap: .4rem; padding: .65rem; }
	.workspace-label, .sidebar-note, .header-divider, .workspace-header .eyebrow { display: none; }
	.workspace-header { padding: 1rem; }
	.workspace-frame > main { padding: 1.75rem 1rem; }
	.page-heading { flex-direction: column; gap: 1rem; }
	.metric-grid { grid-template-columns: 1fr; gap: .65rem; }
	.metric { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
	.metric strong { margin: 0; font-size: 1.6rem; }
	.form-grid { grid-template-columns: 1fr; }
	.panel { padding: 1.25rem; }
	.workspace-footer { flex-direction: column; gap: .3rem; padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
:root {
	--surface-raised: #132132;
}

/* Presentation modes reuse the same authorised rows and preserve table semantics. */
.data-view { min-width: 0; }
.data-view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.data-view-switch { display: inline-flex; gap: .2rem; padding: .25rem; background: var(--background, #0b121c); border: 1px solid var(--border, #283c50); border-radius: .65rem; }
.data-view-switch button { margin: 0; min-width: 4.1rem; padding: .42rem .75rem; border: 0; background: transparent; }
.data-view-switch button.selected { background: #1d4150; color: #83e6f2; box-shadow: inset 0 0 0 1px #37768a; }
.data-view-grid .table-scroll, .data-view-tiles .table-scroll { overflow: visible; }
.data-view-grid table, .data-view-tiles table { display: block; width: 100%; min-width: 0; }
.data-view-grid thead, .data-view-tiles thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.data-view-grid tbody, .data-view-tiles tbody { display: grid; gap: 1rem; }
.data-view-grid tbody { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.data-view-tiles tbody { grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.data-view-grid tr, .data-view-tiles tr { display: flex; flex-direction: column; min-width: 0; padding: 1rem; background: var(--surface-raised); border: 1px solid var(--border, #283c50); border-radius: .8rem; }
.data-view-grid td, .data-view-tiles td { display: block; border: 0; padding: .35rem 0; white-space: normal; overflow-wrap: anywhere; }
.data-view-grid td:first-child, .data-view-tiles td:first-child { font-size: 1.08rem; font-weight: 600; padding-bottom: .7rem; }
.data-view-grid td:not(:first-child)::before, .data-view-tiles td:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted, #9cb1c9); font-size: .75rem; font-weight: 500; }
.data-view-tiles tr { padding: 1.5rem; border-top: 3px solid #3d8eaa; }
.data-view-tiles td:first-child { font-size: 1.3rem; }
.data-view-grid caption, .data-view-tiles caption { display: block; margin-bottom: .6rem; }
.selection-chips { display: flex; flex-wrap: wrap; list-style: none; gap: .4rem; padding: 0; margin: .5rem 0; }
.selection-chips li { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .5rem .3rem .75rem; border: 1px solid #36596b; border-radius: 1rem; background: #173344; font-size: .8rem; }
.selection-chips li.unavailable { border-color: #d78b96; background: #4b2635; }
.selection-chips button { border: 0; background: transparent; padding: 0 .25rem; min-height: 1.7rem; font-size: 1.2rem; }
.named-record-select { gap: .45rem; }
.named-record-select summary { font-size: .8rem; color: var(--muted, #9cb1c9); cursor: pointer; }
.handling-banner { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .35rem 1rem; padding: .42rem 1rem; background: var(--handling-background, #293544); color: var(--handling-foreground, #ffffff); font-size: .69rem; line-height: 1.4; letter-spacing: .05em; text-align: center; overflow-wrap: anywhere; }
.handling-banner strong { font-weight: 750; letter-spacing: .12em; }
.handling-banner .handling-scope { opacity: .85; font-size: .65rem; letter-spacing: .02em; }
.handling-unassessed { background: repeating-linear-gradient(135deg, #293544, #293544 12px, #313f50 12px, #313f50 24px); }
.authoring-toolbar { position: sticky; top: .75rem; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; box-shadow: 0 .6rem 1.8rem #00000030; }
.authoring-toolbar .help-text { display: block; margin-top: .2rem; }
.authoring-toolbar button { min-height: 2.75rem; }
.authoring-section { scroll-margin-top: 7rem; }
@media (max-width: 640px) {
	.authoring-toolbar { top: 0; flex-wrap: wrap; gap: .65rem; padding: .8rem; }
	.authoring-toolbar .actions { width: 100%; }
	.authoring-toolbar .actions button { flex: 1; }
}
@media print {
	.handling-banner { print-color-adjust: exact; -webkit-print-color-adjust: exact; border: 1px solid currentColor; }
	.data-view-toolbar { display: none; }
	.authoring-toolbar { display: none; }
}
