:root {
    color-scheme: dark;
    --color-canvas: #080D17;
    --color-sidebar: #0B111B;
    --color-surface: #101722;
    --color-surface-raised: #141D29;
    --color-surface-subtle: #0D141F;
    --color-surface-hover: #182231;
    --color-border-subtle: #1A2432;
    --color-border: #202B3A;
    --color-border-strong: #344257;
    --color-text-strong: #E7EDF5;
    --color-text: #CFD9E5;
    --color-text-muted: #93A4B8;
    --color-text-faint: #718197;
    --color-accent: #4DB5E8;
    --color-accent-hover: #73C6EE;
    --color-accent-soft: rgba(77, 181, 232, 0.1);
    --color-info-soft: rgba(92, 169, 255, 0.1);
    --color-info-text: #91C8FF;
    --color-positive: #39C58A;
    --color-positive-soft: rgba(57, 197, 138, 0.1);
    --color-positive-text: #75D9AD;
    --color-caution: #E7A94B;
    --color-caution-soft: rgba(231, 169, 75, 0.1);
    --color-caution-text: #F0C477;
    --color-critical: #F06A74;
    --color-critical-soft: rgba(240, 106, 116, 0.1);
    --color-critical-text: #F69AA1;
    --color-violet: #9B8AFB;
    --color-violet-soft: rgba(155, 138, 251, 0.1);
    --color-violet-text: #BEB3FF;
    --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.025), 0 18px 50px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Backward-compatible aliases for existing research pages and scoped styles. */
    --research-bg: var(--color-canvas);
    --research-surface: var(--color-surface);
    --research-card: var(--color-surface-raised);
    --research-border: var(--color-border);
    --research-text: var(--color-text-strong);
    --research-muted: var(--color-text-muted);
    --research-primary: var(--color-accent);
    --research-success: var(--color-positive);
    --research-warning: var(--color-caution);
    --research-danger: var(--color-critical);
    --research-purple: var(--color-violet);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    background: var(--color-canvas);
    color: var(--color-text);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    min-width: 0;
    text-rendering: optimizeLegibility;
}

body.navigation-locked {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

.shell-card,
.research-table,
.mud-table-container {
    max-width: 100%;
    min-width: 0;
}

.mud-table-container {
    overscroll-behavior-inline: contain;
}

.research-table .status-pill,
.top-gate-grid .status-pill {
    max-width: 100%;
}

.research-table .status-pill > span:last-child,
.top-gate-grid .status-pill > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.reason-details,
.reason-details p,
.reason-details dd,
.hash-code {
    overflow-wrap: anywhere;
}

a {
    color: var(--color-accent);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

::selection {
    background: rgba(77, 181, 232, 0.24);
    color: var(--color-text-strong);
}

.page-shell {
    display: grid;
    gap: clamp(1rem, 2vw, 1.4rem);
}

.page-header {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.page-header h1 {
    color: var(--color-text-strong);
    font-size: clamp(1.75rem, 2.4vw, 2.4rem);
    letter-spacing: -0.035em;
    line-height: 1.1;
    margin: 0;
}

.page-kicker {
    color: var(--color-accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    margin: 0 0 0.45rem;
    text-transform: uppercase;
}

.page-summary {
    color: var(--color-text-muted);
    line-height: 1.6;
    margin: 0.65rem 0 0;
    max-width: 760px;
}

.shell-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.012), transparent 55%), var(--color-surface-raised);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    height: 100%;
    padding: 1rem;
}

.shell-card.metric {
    border-left: 2px solid var(--color-accent);
}

.shell-card.metric.accent-success {
    border-left-color: var(--research-success);
}

.shell-card.metric.accent-warning {
    border-left-color: var(--research-warning);
}

.shell-card.metric.accent-danger {
    border-left-color: var(--research-danger);
}

.shell-card.metric.accent-purple {
    border-left-color: var(--research-purple);
}

.metric-label,
.module-label {
    color: var(--color-text-faint);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.065em;
    text-transform: uppercase;
}

.metric-value {
    color: var(--color-text-strong);
    display: block;
    font-size: 1.45rem;
    font-weight: 750;
    line-height: 1.2;
    margin: 0.35rem 0;
}

.muted {
    color: var(--color-text-muted);
}

.section-title {
    align-items: center;
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
}

.section-title h2 {
    font-size: 1.05rem;
    margin: 0;
}

.pipeline-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pipeline-step {
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    display: grid;
    gap: 0.45rem;
    min-height: 126px;
    padding: 1rem;
}

.step-index {
    align-items: center;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 999px;
    color: var(--research-primary);
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 800;
    height: 28px;
    justify-content: center;
    width: 28px;
}

.module-link {
    color: inherit;
    display: block;
    height: 100%;
    text-decoration: none;
}

.module-link:hover .shell-card {
    border-color: var(--research-primary);
}

.empty-state {
    align-items: center;
    background: var(--color-surface-subtle);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    display: flex;
    line-height: 1.55;
    min-height: 132px;
    padding: 1rem;
}

.planned-table {
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    overflow: hidden;
}

.planned-table-row {
    align-items: center;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    padding: 0.85rem 1rem;
}

.planned-table-row + .planned-table-row {
    border-top: 1px solid var(--research-border);
}

.status-list {
    display: grid;
    gap: 0.75rem;
}

.status-row {
    align-items: flex-start;
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.9rem 1rem;
}

.safety-columns {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rule-list {
    display: grid;
    gap: 0.65rem;
    margin: 0;
    padding: 0;
}

.rule-list li {
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    list-style: none;
    padding: 0.85rem;
}

@media (max-width: 900px) {
    .page-header {
        display: grid;
    }

    .pipeline-grid,
    .safety-columns,
    .auth-card-grid {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        min-height: 0;
        padding: 1rem;
    }
}

/* Phase 12: account / auth forms and topbar account area */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-field label {
    font-size: 0.8rem;
    color: #94A3B8;
}

.auth-input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    border: 1px solid #263244;
    background: #0B1120;
    color: #E5E7EB;
    font-size: 0.95rem;
}

.auth-input:focus {
    outline: none;
    border-color: #38BDF8;
}

.auth-submit {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    border: none;
    background: #38BDF8;
    color: #0B1120;
    font-weight: 600;
    cursor: pointer;
}

.auth-submit:hover {
    background: #5cc8fb;
}

.auth-public-shell {
    display: grid;
    gap: 1.25rem;
    margin: 0 auto;
    max-width: 1120px;
}

.auth-hero {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(23, 32, 51, 0.98));
    border: 1px solid var(--research-border);
    border-radius: 8px;
    display: grid;
    gap: 0.8rem;
    min-height: 220px;
    overflow: hidden;
    padding: 1.35rem;
    position: relative;
}

.auth-hero::after {
    background:
        linear-gradient(90deg, rgba(56, 189, 248, 0.12) 1px, transparent 1px),
        linear-gradient(0deg, rgba(139, 92, 246, 0.1) 1px, transparent 1px);
    background-size: 42px 42px;
    content: "";
    inset: 0;
    opacity: 0.28;
    pointer-events: none;
    position: absolute;
}

.auth-hero > * {
    position: relative;
    z-index: 1;
}

.auth-hero .mud-chip {
    justify-self: start;
}

.auth-hero h1 {
    font-size: clamp(2.1rem, 4vw, 4rem);
    line-height: 1.03;
    margin: 0;
    max-width: 720px;
}

.auth-hero p:last-child {
    color: var(--research-muted);
    font-size: 1.05rem;
    line-height: 1.55;
    margin: 0;
    max-width: 720px;
}

.auth-card-grid {
    align-items: stretch;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
}

.auth-panel {
    background: var(--research-card);
    border: 1px solid var(--research-border);
    border-radius: 8px;
    padding: 1.1rem;
}

.auth-form-panel,
.auth-access-panel,
.auth-panel-heading,
.auth-disabled-box {
    display: grid;
}

.auth-form-panel {
    gap: 1rem;
}

.auth-access-panel {
    align-content: start;
    gap: 0.85rem;
}

.auth-panel-heading,
.auth-disabled-box {
    gap: 0.35rem;
}

.auth-access-panel h2,
.auth-panel-heading h2 {
    font-size: 1.15rem;
    line-height: 1.25;
    margin: 0;
}

.auth-access-panel p,
.auth-panel-heading p {
    color: var(--research-muted);
    line-height: 1.55;
    margin: 0;
}

.auth-tabs {
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.25rem;
}

.auth-tabs a {
    border-radius: 6px;
    color: var(--research-muted);
    font-size: 0.86rem;
    font-weight: 700;
    padding: 0.65rem 0.75rem;
    text-align: center;
    text-decoration: none;
}

.auth-tabs a.active {
    background: rgba(56, 189, 248, 0.14);
    color: var(--research-text);
}

.auth-checkbox {
    align-items: center;
    color: var(--research-muted);
    display: flex;
    font-size: 0.88rem;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.auth-secondary-link,
.auth-submit-link {
    text-align: center;
    text-decoration: none;
}

.auth-secondary-link {
    border: 1px solid rgba(56, 189, 248, 0.45);
    border-radius: 6px;
    color: var(--research-primary);
    font-weight: 700;
    padding: 0.62rem 0.9rem;
}

.auth-secondary-link:hover {
    border-color: var(--research-primary);
}

.auth-disabled-box {
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    color: var(--research-muted);
    padding: 0.85rem;
}

.auth-disabled-box strong {
    color: var(--research-text);
}

@media (max-width: 900px) {
    .auth-card-grid {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        min-height: 0;
        padding: 1rem;
    }

    .auth-hero h1 {
        font-size: 2rem;
    }

    .research-topbar {
        flex-wrap: wrap;
    }

    .topbar-subtitle {
        display: none;
    }

    .research-topbar .mud-spacer {
        display: none;
    }

    .topbar-account {
        flex-wrap: wrap;
    }

    .paper-mode-badge {
        margin-left: 0;
    }
}

.topbar-account {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.topbar-account .account-email {
    color: #94A3B8;
    font-size: 0.85rem;
}

.topbar-account a {
    color: #38BDF8;
    text-decoration: none;
    font-size: 0.85rem;
}

.topbar-account .logout-button {
    background: transparent;
    border: 1px solid #263244;
    color: #E5E7EB;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.topbar-account .logout-button:hover {
    border-color: #38BDF8;
}

.operations-kpi-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.operations-kpi-grid > div,
.freshness-tile {
    background: #111827;
    border: 1px solid var(--research-border);
    border-radius: 8px;
    display: grid;
    gap: 0.35rem;
    padding: 0.85rem;
}

.freshness-tile strong {
    color: var(--research-text);
    font-size: 1.05rem;
}

.runbook-hint {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.decision-stat-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.decision-filter-bar {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.decision-filter {
    display: grid;
    gap: 0.35rem;
    min-width: 150px;
}

.decision-filter span {
    color: var(--research-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.decision-filter select {
    background: #0B1120;
    border: 1px solid var(--research-border);
    border-radius: 6px;
    color: var(--research-text);
    min-height: 38px;
    padding: 0.45rem 0.65rem;
}

.decision-filter select:focus {
    border-color: var(--research-primary);
    outline: none;
}

.decision-short-reason {
    font-size: 0.82rem;
    margin-top: 0.35rem;
    max-width: 340px;
}

.reason-details {
    max-width: 420px;
}

.reason-details summary {
    color: var(--research-text);
    cursor: pointer;
}

.reason-details div {
    color: var(--research-muted);
    margin-top: 0.5rem;
    white-space: normal;
}

@media (max-width: 720px) {
    .operations-kpi-grid {
        grid-template-columns: 1fr;
    }

    .decision-stat-grid {
        grid-template-columns: 1fr;
    }

    .runbook-hint {
        align-items: flex-start;
        display: grid;
    }
}

/* Public Identity entry: rendered with static SSR inside AuthLayout. */
.auth-experience {
    align-items: center;
    display: grid;
    gap: clamp(2rem, 6vw, 5.5rem);
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.72fr);
    margin: 0 auto;
    max-width: 1180px;
    width: 100%;
}

.auth-story {
    min-width: 0;
}

.auth-story__label {
    align-items: center;
    color: var(--color-text-muted);
    display: inline-flex;
    font-size: 0.7rem;
    font-weight: 700;
    gap: 0.5rem;
    letter-spacing: 0.075em;
    margin-bottom: 2rem;
    text-transform: uppercase;
}

.auth-story__signal {
    background: var(--color-positive);
    border-radius: 999px;
    box-shadow: 0 0 0 4px var(--color-positive-soft);
    height: 7px;
    width: 7px;
}

.auth-story h1 {
    color: var(--color-text-strong);
    font-size: clamp(2.5rem, 5vw, 4.75rem);
    font-weight: 660;
    letter-spacing: -0.055em;
    line-height: 0.98;
    margin: 0;
    max-width: 780px;
}

.auth-story__summary {
    color: var(--color-text-muted);
    font-size: clamp(0.95rem, 1.5vw, 1.08rem);
    line-height: 1.72;
    margin: 1.5rem 0 0;
    max-width: 680px;
}

.auth-feature-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 2rem;
}

.auth-feature-grid > div,
.auth-boundary-note {
    background: rgba(16, 23, 34, 0.68);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
}

.auth-feature-grid > div {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
    min-height: 92px;
    padding: 0.95rem;
}

.auth-feature-grid .mud-icon-root,
.auth-boundary-note .mud-icon-root {
    color: var(--color-accent);
    flex: 0 0 auto;
    font-size: 1.15rem;
}

.auth-feature-grid span,
.auth-boundary-note span {
    display: grid;
    gap: 0.25rem;
}

.auth-feature-grid strong,
.auth-boundary-note strong {
    color: var(--color-text-strong);
    font-size: 0.82rem;
}

.auth-feature-grid small,
.auth-boundary-note small,
.auth-boundary-note span {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1.5;
}

.auth-boundary-note {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.9rem 0.95rem;
}

.auth-form-panel {
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.024), transparent 42%),
        var(--color-surface-raised);
    border-color: var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.025);
    padding: clamp(1.1rem, 3vw, 1.5rem);
    width: 100%;
}

.auth-panel-kicker {
    color: var(--color-accent);
    font-size: 0.65rem;
    font-weight: 750;
    letter-spacing: 0.085em;
    text-transform: uppercase;
}

.auth-panel-footer {
    align-items: center;
    border-top: 1px solid var(--color-border-subtle);
    color: var(--color-text-faint);
    display: flex;
    font-size: 0.73rem;
    gap: 0.8rem;
    justify-content: space-between;
    padding-top: 1rem;
}

.auth-panel-footer a {
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.auth-disabled-box {
    align-items: center;
    display: flex;
    gap: 0.75rem;
}

.auth-disabled-box__icon {
    align-items: center;
    background: var(--color-caution-soft);
    border: 1px solid rgba(231, 169, 75, 0.22);
    border-radius: var(--radius-md);
    color: var(--color-caution-text);
    display: inline-flex;
    flex: 0 0 38px;
    height: 38px;
    justify-content: center;
}

.auth-submit {
    background: var(--color-accent);
    border-radius: var(--radius-md);
    color: #061019;
    min-height: 42px;
    transition: background-color 120ms ease, transform 120ms ease;
}

.auth-submit:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
}

.auth-input {
    background: var(--color-canvas);
    border-color: var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-strong);
    min-height: 44px;
}

.auth-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.system-state-shell {
    margin: min(12vh, 7rem) auto 0;
    max-width: 880px;
}

.primary-action,
.secondary-action {
    border-radius: var(--radius-md);
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 700;
    min-height: 38px;
    padding: 0.58rem 0.85rem;
    text-decoration: none;
}

.primary-action {
    background: var(--color-accent);
    border: 1px solid var(--color-accent);
    color: #061019;
}

.secondary-action {
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

#blazor-error-ui {
    align-items: center;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-critical);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.36);
    color: var(--color-text);
    display: none;
    gap: 0.85rem;
    left: 50%;
    max-width: min(760px, calc(100vw - 2rem));
    padding: 0.85rem 1rem;
    position: fixed;
    transform: translateX(-50%);
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .blazor-error-ui__mark {
    align-items: center;
    background: var(--color-critical-soft);
    border-radius: 999px;
    color: var(--color-critical-text);
    display: inline-flex;
    flex: 0 0 28px;
    font-weight: 800;
    height: 28px;
    justify-content: center;
}

#blazor-error-ui .reload {
    font-weight: 700;
    margin-left: auto;
    white-space: nowrap;
}

#blazor-error-ui .dismiss {
    background: transparent;
    border: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.25rem;
}

@media (max-width: 860px) {
    .auth-experience {
        grid-template-columns: 1fr;
        max-width: 640px;
    }

    .auth-form-panel {
        order: -1;
    }

    .auth-story h1 {
        font-size: clamp(2.25rem, 11vw, 3.7rem);
    }
}

@media (max-width: 560px) {
    .auth-feature-grid {
        grid-template-columns: 1fr;
    }

    .auth-story__label {
        margin-bottom: 1.3rem;
    }

    .auth-story h1 {
        font-size: clamp(2rem, 9vw, 2.65rem);
    }

    .auth-panel-footer {
        align-items: flex-start;
        display: grid;
    }

    #blazor-error-ui {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .mud-table-pagination-toolbar {
        align-items: center;
        flex-wrap: wrap;
        gap: 0.45rem;
        justify-content: center;
        min-height: 48px;
    }

    .mud-table-pagination-spacer {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-submit {
        transition: none;
    }
}
