/* Zebra Platform typography and accessible contrast baseline. */
:root {
    --atlas-type-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --atlas-type-page-title: clamp(1.875rem, 2.4vw, 2rem);
    --atlas-type-section-title: clamp(1.25rem, 1.8vw, 1.375rem);
    --atlas-type-card-title: clamp(1rem, 1.3vw, 1.125rem);
    --atlas-type-body: 0.9375rem;
    --atlas-type-control: 0.875rem;
    --atlas-type-small: 0.8125rem;
    --atlas-type-label: 0.8125rem;
    --atlas-type-nav: 0.875rem;
    --atlas-leading-body: 1.55;
    --atlas-leading-compact: 1.4;
    --atlas-control-height: 42px;
    --atlas-radius-control: 10px;
    --atlas-radius-card: 14px;
    --atlas-space-1: 8px;
    --atlas-space-2: 16px;
    --atlas-space-3: 24px;
    --atlas-space-4: 32px;
    --atlas-card-padding: 24px;
    --atlas-focus: #1689e8;
    --atlas-focus-ring: rgba(22, 137, 232, .28);
}

body,
button,
input,
select,
textarea {
    font-family: var(--atlas-type-family) !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    font-size: var(--atlas-type-body);
    font-weight: 450;
}

/* One platform-wide hierarchy. Page CSS may arrange type, but cannot invent it. */
h1 { font-size: var(--atlas-type-page-title); line-height: 1.1; letter-spacing: -.032em; }
h2 { font-size: var(--atlas-type-section-title); line-height: 1.2; letter-spacing: -.024em; }
h3 { font-size: var(--atlas-type-card-title); line-height: 1.3; letter-spacing: -.012em; }
h4 { font-size: 1rem; line-height: 1.35; }

:is(p, li, dd, td, input, select, textarea) {
    line-height: var(--atlas-leading-body);
}

:is(button, input, select, textarea) {
    font-size: var(--atlas-type-control);
}

:is(button, input, select) {
    min-height: var(--atlas-control-height);
}

:is(button, input, select, textarea) {
    border-radius: var(--atlas-radius-control);
}

:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--atlas-focus-ring) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px var(--atlas-focus) !important;
}

:is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]) { cursor: pointer; }
:is(button, input, select, textarea):disabled,
[aria-disabled="true"] { cursor: not-allowed; }

input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown),
select:invalid { border-color: #c7374f !important; }

:is(strong, h1, h2, h3, h4, h5, h6, button, th, .active, .status-pill, .status-chip) {
    font-weight: 700;
}

:is(small, .small, .meta, .panel-meta, .field-help, .section-note) {
    font-size: var(--atlas-type-small);
    line-height: var(--atlas-leading-compact);
}

:is(.eyebrow, .panel-kicker, .nav-label, th, .label, .section-label) {
    font-size: var(--atlas-type-label);
    line-height: var(--atlas-leading-compact);
}

:is(.sidebar nav a, .workspace-sidebar nav a, .operations-sidebar nav a, .asset-sidebar nav a, .workspace-nav button, .admin-sidebar nav a, .intelligence-tabs a) {
    font-size: var(--atlas-type-nav) !important;
    line-height: var(--atlas-leading-compact);
}

body nav :is(a, button) {
    font-size: var(--atlas-type-nav) !important;
    line-height: var(--atlas-leading-compact);
}

:is(.eyebrow, .panel-kicker, .nav-label, .section-label) {
    font-size: var(--atlas-type-label) !important;
}

:is(small, .small, .panel-meta, .field-help, .section-note) {
    font-size: var(--atlas-type-small) !important;
}

:is(.topbar .page-heading > p:last-child, .workspace-header > div > span, .automation-hero p:not(.eyebrow), .page-header > div > p) {
    font-size: 0.875rem !important;
    line-height: var(--atlas-leading-body) !important;
}

:is(.topbar .page-heading h1, .workspace-header h1, .automation-hero h1, .page-header h1) {
    font-size: var(--atlas-type-page-title) !important;
    line-height: 1.1 !important;
    letter-spacing: -0.032em !important;
}

body main h1 {
    font-size: var(--atlas-type-page-title) !important;
    line-height: 1.1 !important;
    letter-spacing: -0.032em !important;
}

:is(.panel-heading h2, .panel-header h2, .section-heading h2) {
    font-size: var(--atlas-type-section-title) !important;
    line-height: 1.2 !important;
}

/* Stronger neutral ink for every light-mode surface. */
html[data-theme="light"] body {
    --theme-text: #10243a;
    --theme-text-muted: #405a72;
    --theme-muted: #405a72;
    --portal-text: #10243a;
    --portal-text-strong: #081b30;
    --portal-text-muted: #405a72;
    --portal-text-subtle: #536b82;
    color: #10243a !important;
}

html[data-theme="light"] body :is(
    .muted,
    .subtitle,
    .panel-meta,
    .field-help,
    .section-note,
    .empty-state,
    .workspace-switcher small,
    .workspace-switcher em,
    .refresh-status small,
    .page-heading > p:last-child,
    .activity-copy p,
    .activity-item time,
    .part-item p,
    .rule-row p,
    .rule-meta,
    .form-status,
    .guide-summary-meta
) {
    color: #405a72 !important;
    opacity: 1 !important;
}

html[data-theme="light"] body :is(input, select, textarea) {
    color: #10243a !important;
    border-color: #b8c8d8 !important;
    background: #ffffff !important;
    box-shadow: inset 0 1px 1px rgba(25, 55, 85, .035) !important;
}

html[data-theme="light"] body :is(input, textarea)::placeholder {
    color: #5e7388 !important;
    opacity: 1 !important;
}

html[data-theme="light"] body :is(button, a, input, select, textarea):disabled,
html[data-theme="light"] body [aria-disabled="true"] {
    color: #536b82 !important;
    opacity: .78 !important;
}

html[data-theme="light"] body :is(button, .button, .btn, [role="button"]):not(.primary):not(.btn-primary) {
    border-color: #b8c8d8;
}

/* Common content surfaces must be truly light in light mode. Intentional dark
   heroes and the dark left navigation are handled by explicit page selectors. */
html[data-theme="light"] body :is(
    .panel,
    .card,
    .metric-card,
    .stat-card,
    .widget,
    .table-card,
    .form-card,
    .filter-panel,
    .empty-panel,
    .customer-card,
    .automation-panel,
    .execution-panel,
    .rule-library,
    .rule-builder,
    .workflow-guide
) {
    color: #10243a;
}

html[data-theme="light"] body :is(
    .panel,
    .card,
    .metric-card,
    .stat-card,
    .widget,
    .table-card,
    .form-card,
    .empty-panel,
    .customer-card,
    .execution-panel,
    .rule-library,
    .rule-builder,
    .workflow-guide
) :is(h1, h2, h3, h4, strong, th, label) {
    color: #10243a;
}

html[data-theme="light"] body :is(
    .panel,
    .card,
    .metric-card,
    .stat-card,
    .widget,
    .table-card,
    .form-card,
    .empty-panel,
    .customer-card,
    .execution-panel,
    .rule-library,
    .rule-builder,
    .workflow-guide
) :is(p, small, td, .meta, .muted) {
    color: #405a72;
}

html[data-theme="light"] body :is(.filter-panel, .filter-bar, .filters, .condition-card, .action-card) {
    color: #10243a !important;
    border-color: #c6d4e1 !important;
    background: #eef4f9 !important;
    background-image: none !important;
}

html[data-theme="light"] body :is(.filter-panel, .filter-bar, .filters, .condition-card, .action-card) :is(label, h2, h3, strong) {
    color: #17304a !important;
}

/* Diagnostics is a legacy server-rendered surface with intentionally dark
   defaults. Give every diagnostic result primitive an explicit light-mode
   treatment so generated analysis content cannot fall back to dark cards. */
html[data-theme="light"] body.diagnostics-page {
    color: #10243a !important;
    background: #f4f7fb !important;
}

html[data-theme="light"] body.diagnostics-page :is(
    .content,
    .result-panel,
    .upload-box
) {
    color: #10243a !important;
    background: #ffffff !important;
    background-image: none !important;
}

html[data-theme="light"] body.diagnostics-page :is(
    .kpi,
    .card,
    .quick-card,
    .confidence-wrap,
    .finding,
    pre
) {
    color: #10243a !important;
    border-color: #c6d4e1 !important;
    background: #f8fafc !important;
    background-image: none !important;
    box-shadow: none !important;
}

html[data-theme="light"] body.diagnostics-page :is(
    .kpi,
    .card,
    .quick-card,
    .confidence-wrap,
    .finding,
    pre
) :is(h1, h2, h3, h4, b, strong, .value, .confidence-big) {
    color: #10243a !important;
}

html[data-theme="light"] body.diagnostics-page :is(
    .muted,
    .section-title,
    .kpi .label,
    .confidence-wrap p,
    .finding pre
) {
    color: #405a72 !important;
    opacity: 1 !important;
}

html[data-theme="light"] body.diagnostics-page .section-title {
    color: #516b84 !important;
}

html[data-theme="light"] body.diagnostics-page :is(.bar, .confidence-track) {
    background: #dbe5ef !important;
}

html[data-theme="light"] body.diagnostics-page :is(.bar span, .confidence-fill) {
    background: linear-gradient(90deg, #159b5c, #1689e8) !important;
}

html[data-theme="light"] body.diagnostics-page .finding.Critical { border-left-color: #c7374f !important; }
html[data-theme="light"] body.diagnostics-page .finding.Error { border-left-color: #c65f17 !important; }
html[data-theme="light"] body.diagnostics-page .finding.Warning { border-left-color: #c28a08 !important; }

html[data-theme="light"] body.diagnostics-page :is(.critical, .error, .warning, .good, .info) {
    opacity: 1 !important;
}

html[data-theme="light"] body.diagnostics-page .critical { color: #9f1239 !important; background: #ffe4e9 !important; }
html[data-theme="light"] body.diagnostics-page .error { color: #9a3412 !important; background: #ffedd5 !important; }
html[data-theme="light"] body.diagnostics-page .warning { color: #854d0e !important; background: #fef3c7 !important; }
html[data-theme="light"] body.diagnostics-page .good { color: #166534 !important; background: #dcfce7 !important; }
html[data-theme="light"] body.diagnostics-page .info { color: #075985 !important; background: #e0f2fe !important; }

html[data-theme="light"] body.diagnostics-page .card:hover {
    border-color: #1689e8 !important;
    background: #eef6fc !important;
}

/* Preserve readable type on the Asset Command Center's intentional dark hero. */
html[data-theme="light"] body.portal-asset .asset-hero {
    color: #f4f8fc !important;
}

html[data-theme="light"] body.portal-asset .asset-hero :is(h1, h2, h3, strong) {
    color: #f4f8fc !important;
}

html[data-theme="light"] body.portal-asset .asset-hero :is(.hero-subtitle, .product-descriptor, p, small) {
    color: #b4c7d9 !important;
}

html[data-theme="light"] body.portal-asset .asset-hero .eyebrow {
    color: #67d9ee !important;
}

/*
 * Zebra light-shell contract.
 *
 * Page-level styles may define their dark navigation treatment, but no
 * authenticated Zebra shell may keep a dark rail after light mode is chosen.
 * This shared layer is loaded after page CSS so the theme cannot become mixed.
 */
html[data-theme="light"] body :is(
    .sidebar,
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav
) {
    color: #10243a !important;
    border-color: #d5e0ea !important;
    background: #ffffff !important;
    background-image: none !important;
    box-shadow: 12px 0 34px rgba(30, 64, 102, .07) !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav,
    .sidebar
) :is(.tenant-identity, .customer-identity, .workspace-switcher, .nav-context, .executive-customer) {
    color: #10243a !important;
    border-color: #c9d7e5 !important;
    background: #f7fafc !important;
    background-image: none !important;
    box-shadow: none !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav,
    .sidebar
) :is(.workspace-selector-trigger, .sidebar-collapse, .admin-nav-collapse) {
    color: #17304a !important;
    border-color: #c9d7e5 !important;
    background: #f7fafc !important;
    background-image: none !important;
    box-shadow: none !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar nav a,
    .workspace-sidebar nav a,
    .workspace-nav button,
    .executive-rail nav a,
    .admin-nav-row,
    .sidebar nav a
) {
    color: #405a72 !important;
    border-color: transparent !important;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar nav a,
    .workspace-sidebar nav a,
    .workspace-nav button,
    .executive-rail nav a,
    .admin-nav-row,
    .sidebar nav a
):hover {
    color: #10243a !important;
    border-color: #d5e0ea !important;
    background: #eef4fa !important;
    transform: none !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar nav a.active,
    .workspace-sidebar nav a.active,
    .workspace-nav button.active,
    .executive-rail nav a.active,
    .admin-nav-row.active,
    .sidebar nav a.active
) {
    color: #0c3158 !important;
    border-color: #b9d6f4 !important;
    background: linear-gradient(90deg, #deecfc, #f4f8fd) !important;
    box-shadow: inset 3px 0 #2f80ed !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav,
    .sidebar
) :is(.nav-group-label, .nav-label, nav p, .admin-nav-title, .admin-nav-subtitle) {
    color: #526b82 !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav,
    .sidebar
) :is(strong, .workspace-selector-copy strong) {
    color: #10243a !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav,
    .sidebar
) :is(small, em, .workspace-selector-copy small, .workspace-selector-copy em) {
    color: #526b82 !important;
    opacity: 1 !important;
}

html[data-theme="light"] body :is(
    .operations-sidebar,
    .workspace-sidebar,
    .executive-rail,
    .admin-nav,
    .sidebar
) :is(footer, .nav-status, .sidebar-footer) {
    color: #405a72 !important;
    border-color: #d5e0ea !important;
    background: transparent !important;
}

html[data-theme="light"] body :is(
    .platform-header,
    .platform-bar,
    .page-header,
    .topbar,
    .operations-topbar,
    .workspace-header,
    .executive-topbar
) {
    color: #10243a !important;
    border-color: #d5e0ea !important;
    background: rgba(255, 255, 255, .96) !important;
    background-image: none !important;
    box-shadow: 0 8px 28px rgba(30, 64, 102, .06) !important;
}

html[data-theme="light"] body.portal-operations .operations-topbar {
    color: #172b40 !important;
}

html[data-theme="light"] body.portal-operations .operations-topbar :is(a, span, small, strong) {
    color: #405a72 !important;
}

html[data-theme="light"] body.portal-operations .operations-topbar :is(.breadcrumb strong, .data-freshness strong) {
    color: #172b40 !important;
}

/* Convert the Operations Center's dense decision surfaces into native light cards. */
html[data-theme="light"] body.portal-operations :is(
    .operations-kpis,
    .operations-kpis .hero-card,
    .operations-signal-deck > article,
    .command-grid .widget,
    .widget,
    .storytelling-card,
    .workspace-context
) {
    border-color: #c9d7e4 !important;
    background: #ffffff !important;
    color: #10243a !important;
    box-shadow: 0 16px 38px rgba(35, 57, 81, .09) !important;
}

html[data-theme="light"] body.portal-operations .operations-kpis .hero-card:hover {
    background: #f3f7fb !important;
}

html[data-theme="light"] body.portal-operations :is(
    .operations-kpis .hero-card strong,
    .operations-signal-deck strong,
    .command-grid .widget h2,
    .command-grid .widget h3,
    .storytelling-card h3,
    .workspace-context strong
) {
    color: #10243a !important;
}

html[data-theme="light"] body.portal-operations :is(
    .operations-kpis .hero-card span,
    .operations-kpis .hero-card small,
    .operations-signal-deck > article > span,
    .operations-signal-deck small,
    .storytelling-card p,
    .command-grid .widget small,
    .command-grid .widget em
) {
    color: #405a72 !important;
}

html[data-theme="light"] body.portal-operations .operations-signal-deck :is(.ai-signal, .pm-signal) {
    background: #f6f8fc !important;
}

html[data-theme="light"] body.portal-operations :is(
    .operations-signal-deck a,
    .command-grid .widget > header a,
    .command-grid .widget a:not(.attention-item):not(.work-item),
    .secondary-widgets a
) {
    color: #0b6bad !important;
}

html[data-theme="light"] body.portal-operations :is(.widget-kicker, .command-grid .widget > header p) {
    color: #087a9a !important;
}

html[data-theme="light"] body.portal-operations :is(.widget-error, .operations-error) {
    color: #a51d36 !important;
    background: #fff1f3 !important;
}

/* Studio-specific reading density. */
.automation-main .automation-hero p:not(.eyebrow) { font-size: 1rem; }
.automation-main .workflow-guide > summary strong { font-size: 0.9375rem; }
.automation-main .workflow-guide > summary small { font-size: 0.8125rem; }
.automation-main .guide-heading h2 { font-size: 1.0625rem; }
.automation-main .guide-heading > p:not(.eyebrow),
.automation-main .guide-lifecycle li strong,
.automation-main .example-grid h3,
.automation-main .rule-filter button,
.automation-main .rule-builder label,
.automation-main .text-button,
.automation-main button.primary,
.automation-main button.secondary,
.automation-main .form-status {
    font-size: 0.8125rem;
}

.automation-main .guide-lifecycle li small,
.automation-main .guide-lifecycle aside p,
.automation-main .example-grid p,
.automation-main .example-grid button,
.automation-main .rule-meta,
.automation-main .execution-panel td {
    font-size: 0.75rem;
}

.automation-main .guide-heading > p:not(.eyebrow),
.automation-main .example-grid p,
.automation-main .rule-row p,
.automation-main .rule-builder label {
    line-height: 1.55;
}

.automation-main .rule-row p { font-size: 0.8125rem; }
.automation-main .rule-row strong { font-size: 0.9375rem; }
.automation-main .step-title h3 { font-size: 1rem; }

html[data-theme="light"] body .automation-main :is(
    .guide-heading > p:not(.eyebrow),
    .guide-lifecycle li small,
    .guide-lifecycle aside p,
    .example-grid p,
    .rule-row p,
    .rule-meta,
    .approval-card small,
    .test-result p,
    .test-result > small,
    .execution-panel td
) {
    color: #405a72 !important;
}

html[data-theme="light"] body .automation-main :is(
    .guide-lifecycle li strong,
    .example-grid h3,
    .rule-row strong,
    .approval-card strong,
    .execution-panel td strong
) {
    color: #17304a !important;
}

html[data-theme="light"] body .automation-main .eyebrow {
    color: #075f96 !important;
}

/* Dense operational tables stay compact but never drop below 12px body copy. */
:is(.table-wrap, .table-scroll, table) td { font-size: 0.875rem; }
:is(.table-wrap, .table-scroll, table) th { font-size: 0.8125rem; }

/* Tables retain all information at narrow widths and scroll inside their card. */
:is(.table-wrap, .table-scroll) {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}
:is(.table-wrap, .table-scroll) > table { min-width: 720px; }

/* Unified notifications for saves, approvals, automation runs and failures. */
.atlas-notifications {
    position: fixed;
    z-index: 100000;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    display: grid;
    gap: 10px;
    width: min(390px, calc(100vw - 32px));
    pointer-events: none;
}
.atlas-notification {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    min-height: 52px;
    padding: 12px 12px 12px 16px;
    color: #f4f8fc;
    border: 1px solid #37526d;
    border-left: 4px solid #55b4ff;
    border-radius: 12px;
    background: #10243a;
    box-shadow: 0 18px 48px rgba(3, 15, 28, .28);
    pointer-events: auto;
    animation: atlas-notification-in .18s ease-out;
}
.atlas-notification.success { border-left-color: #2dd49a; }
.atlas-notification.warning { border-left-color: #f1b53b; }
.atlas-notification.error { border-left-color: #ff6478; }
.atlas-notification button {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    color: inherit;
    border: 0;
    background: transparent;
}
.atlas-notification.leaving { opacity: 0; transform: translateY(6px); }
html[data-theme="light"] .atlas-notification {
    color: #10243a;
    border-color: #c4d2df;
    background: #fff;
}
@keyframes atlas-notification-in { from { opacity: 0; transform: translateY(8px); } }

.atlas-demo-badge {
    display: inline-flex;
    align-items: center;
    width: max-content;
    padding: 3px 7px;
    color: #8a4c00 !important;
    font-size: .625rem !important;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    border: 1px solid #f0c26b;
    border-radius: 999px;
    background: #fff7e6;
}

/* Shared operational states. Pages may customize layout, not legibility. */
.atlas-loading-state,
[data-ui-state="loading"] {
    color: var(--theme-text-muted, #91a4bd);
    cursor: progress;
}
.atlas-error-state,
[data-ui-state="error"] {
    color: #ff9aa8;
    border-color: rgba(255, 100, 120, .45) !important;
    background: rgba(255, 100, 120, .08) !important;
}
html[data-theme="light"] :is(.atlas-error-state, [data-ui-state="error"]) {
    color: #a51d36 !important;
    background: #fff1f3 !important;
}

/* Light mode is a real palette, not a translucent wash over dark components. */
html[data-theme="light"] body :is(
    .panel, .card, .metric-card, .stat-card, .widget, .table-card, .form-card,
    .empty-panel, .customer-card, .execution-panel, .rule-library, .rule-builder,
    .workflow-guide, .integration-card, .guardrail-card, .environment-banner
) {
    border-color: #c9d7e4 !important;
    background-color: #ffffff !important;
    background-image: none !important;
}
html[data-theme="light"] body :is(.configuration-form, .filter-panel, .filter-bar, .filters) {
    color: #10243a !important;
    border-color: #c6d4e1 !important;
    background: #eef4f9 !important;
}
html[data-theme="light"] body :is(.control-field, .configuration-form, .filter-panel, .filter-bar, .filters) :is(label, span) {
    color: #405a72 !important;
}
html[data-theme="light"] body :is(.asset-tag.attention, .status-pill.warning, .status-pill.awaiting_approval) {
    color: #7a4b00 !important;
    background: #fff4d6 !important;
}
html[data-theme="light"] body :is(.status-pill.connected, .status-pill.active, .status-pill.healthy) {
    color: #087a55 !important;
    background: #e5f8ef !important;
}
html[data-theme="light"] body :is(.status-pill.error, .status-pill.failed, .status-pill.critical, .incident-status-badge.status-escalated) {
    color: #a51d36 !important;
    background: #fff1f3 !important;
}
html[data-theme="light"] body .incident-status-badge.status-in-progress {
    color: #174ea6 !important;
    background: #e8f1ff !important;
}
html[data-theme="light"] body .portfolio-insight strong { color: #17304a !important; }
html[data-theme="light"] body :is(.portfolio-customer-mark, .briefing-mark, .account-avatar, .mission-atlas-mark, .step-number) {
    color: #ffffff !important;
}
html[data-theme="light"] body :is(.portfolio-empty-label, .workspace-selector-copy, .assist-form-status) {
    color: #405a72 !important;
}
html[data-theme="light"] body .assist-form-status[data-tone="error"] { color: #a51d36 !important; }
html[data-theme="light"] body .assist-primary { color: #061a2b !important; }
html[data-theme="light"] body .assist-primary:disabled { color: #29445e !important; opacity: .72; }

/* PM Tracking predates the shared shell. Give its operational tones explicit
   light-theme contrast instead of reusing pastel text intended for navy. */
html[data-theme="light"] body.pm-page .kpi .label {
    color: #315472 !important;
    font-size: 11px;
}
html[data-theme="light"] body.pm-page .kpi .sub,
html[data-theme="light"] body.pm-page :is(.muted, .empty) {
    color: #405a72 !important;
}
html[data-theme="light"] body.pm-page .kpi[data-tone="critical"] .label {
    color: #a51d36 !important;
}
html[data-theme="light"] body.pm-page .kpi[data-tone="warning"] .label {
    color: #7a4b00 !important;
}
html[data-theme="light"] body.pm-page .kpi[data-tone="positive"] .label {
    color: #087a55 !important;
}
html[data-theme="light"] body.pm-page .pill.Overdue {
    color: #a51d36 !important;
    border-color: #f0a4b1 !important;
    background: #fff1f3 !important;
}
html[data-theme="light"] body.pm-page .pill.DueSoon {
    color: #7a4b00 !important;
    border-color: #e2b94f !important;
    background: #fff4d6 !important;
}
html[data-theme="light"] body.pm-page .pill.Current {
    color: #087a55 !important;
    border-color: #7bcdaa !important;
    background: #e5f8ef !important;
}
html[data-theme="light"] body.pm-page .pill.NotScheduled {
    color: #405a72 !important;
    border-color: #bfd0de !important;
    background: #edf3f8 !important;
}

/* User Activity uses action badges as audit metadata. In light mode they should
   read as semantic labels, not retain the legacy dark-dashboard treatment. */
html[data-theme="light"] body.activity-page th {
    color: #315472 !important;
    border-color: #c6d4e1 !important;
    background: #e7eef6 !important;
}
html[data-theme="light"] body.activity-page .badge {
    color: #17324a !important;
    border-color: #bfd0de !important;
    background: #edf3f8 !important;
}
html[data-theme="light"] body.activity-page .badge.login {
    color: #087a55 !important;
    border-color: #7bcdaa !important;
    background: #e5f8ef !important;
}
html[data-theme="light"] body.activity-page .badge.incident {
    color: #a51d36 !important;
    border-color: #f0a4b1 !important;
    background: #fff1f3 !important;
}
html[data-theme="light"] body.activity-page .badge.pm {
    color: #7a4b00 !important;
    border-color: #e2b94f !important;
    background: #fff4d6 !important;
}
html[data-theme="light"] body.activity-page .badge.admin {
    color: #56358f !important;
    border-color: #c6afe9 !important;
    background: #f3edff !important;
}
html[data-theme="light"] body.activity-page .badge.view {
    color: #0b5b9d !important;
    border-color: #9dc9ed !important;
    background: #e8f4ff !important;
}
html[data-theme="light"] body.activity-page .table-wrap {
    border: 1px solid #c6d4e1;
    background: #fff;
}
html[data-theme="light"] body.activity-page :is(th, td, .mini-row) {
    border-bottom-color: #d4dee8 !important;
}

/* Explicitly preserve deliberate dark hero surfaces in light mode. */
html[data-theme="light"] body :is(.asset-hero, .workspace-hero, .executive-hero, .mission-atlas-hero) {
    color: #f4f8fc !important;
}
html[data-theme="light"] body :is(.asset-hero, .workspace-hero, .executive-hero, .mission-atlas-hero) :is(h1, h2, h3, strong) {
    color: #f4f8fc !important;
}
html[data-theme="light"] body :is(.asset-hero, .workspace-hero, .executive-hero, .mission-atlas-hero) :is(p, small, .muted) {
    color: #b9cad9 !important;
}

.sparkline-empty {
    fill: currentColor;
    color: var(--theme-text-muted, #91a4bd);
    font-size: 8px;
    letter-spacing: .04em;
}

/* Cross-page responsive contract. Specific layouts can be denser, never wider. */
@media (max-width: 1180px) {
    :is(.metric-grid, .metrics-grid, .stats-grid, .kpi-grid, .operations-kpis, .signal-grid) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    :is(.content-grid, .command-grid, .workspace-grid, .automation-layout, .customer-grid, .details-grid) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    :is(.automation-main, .workspace-main, .operations-main, main) { max-width: 100%; }
}

@media (max-width: 820px) {
    :is(.topbar, .platform-header, .workspace-header, .operations-topbar, .page-header) {
        flex-wrap: wrap;
        min-height: auto;
        height: auto;
    }
    :is(.form-grid, .condition-row, .builder-fields, .field-grid, .filter-grid, .action-fields) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    :is(.builder-actions, .form-actions, .execution-actions) { flex-wrap: wrap; }
}

@media (max-width: 700px) {
    :root {
        --atlas-type-body: 0.875rem;
        --atlas-type-control: 0.8125rem;
        --atlas-type-nav: 0.8125rem;
    }
    html, body { overflow-x: hidden; }
    :is(main, .main, .automation-main, .workspace-main, .operations-main, .page-content) {
        width: 100% !important;
        padding-inline: 14px !important;
    }
    :is(.metric-grid, .metrics-grid, .stats-grid, .kpi-grid, .operations-kpis, .signal-grid) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    :is(.builder-actions, .form-actions) > :is(button, a) { flex: 1 1 100%; justify-content: center; }
    :is(.table-wrap, .table-scroll) > table { min-width: 640px; }
    .atlas-notifications { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}

/* Resolve legacy drawer implementations that simultaneously use a negative
   left offset and a transform. One off-canvas mechanism prevents double
   translation and keeps navigation reachable by keyboard and touch. */
@media (max-width: 900px) {
    body.portal-app :is(.operations-sidebar, .workspace-sidebar),
    body.portal-dashboard .app-shell > .sidebar {
        left: 0 !important;
        transform: translateX(-105%) !important;
    }
    body.portal-app :is(.operations-sidebar, .workspace-sidebar).open,
    body.portal-dashboard .app-shell > .sidebar.open {
        transform: translateX(0) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* Enterprise UI consistency layer.
 * Keep layout ownership in each product surface while enforcing one readable
 * scale, one control rhythm, and one card language across Atlas. */
:is(
    .panel, .card, .workspace-card, .metric-card, .stat-card, .widget,
    .table-card, .form-card, .filter-panel, .asset-card, .operational-panel,
    .knowledge-card, .pm-card, .diagnostic-card
) {
    border-radius: var(--atlas-radius-card);
}

:is(
    .panel-header, .panel-heading, .workspace-card > header, .card > header,
    .widget > header, .table-card > header, .section-header
) {
    min-height: 64px;
    padding: var(--atlas-space-2) var(--atlas-card-padding);
    gap: var(--atlas-space-2);
}

:is(
    .panel-header h3, .panel-heading h3, .workspace-card header h3,
    .card > header h3, .widget > header h3
) {
    font-size: var(--atlas-type-card-title) !important;
    line-height: 1.3 !important;
}

:is(
    .topbar-actions, .header-actions, .platform-actions, .page-actions,
    .operations-actions, .filter-actions
) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--atlas-space-1);
}

:is(
    .topbar-actions, .header-actions, .platform-actions, .page-actions,
    .operations-actions, .filter-actions
) :is(button, a, input, select) {
    min-height: var(--atlas-control-height);
}

:is(
    .sidebar nav a, .operations-sidebar nav a, .workspace-sidebar nav a,
    .workspace-nav button, .workspace-nav > a, .admin-nav-row
) {
    min-height: 42px;
    margin-block: 2px;
    padding: 9px 12px;
    border-radius: 10px;
}

:is(
    .sidebar .nav-label, .operations-sidebar .nav-group-label,
    .workspace-sidebar .nav-group-label, .admin-nav-title
) {
    margin: 20px 12px 8px;
    font-size: var(--atlas-type-label) !important;
    line-height: 1.3;
}

:is(
    .topbar, .platform-header, .platform-bar, .workspace-header,
    .operations-topbar, .page-header
) {
    min-height: 88px;
}

/* The persistent Zebra affordance remains available without covering the last
 * dashboard row or bottom-right table actions. */
body:has(.atlas-launcher) :is(
    .workspace-content, .operations-content, .page-content,
    .assets-content, .knowledge-main, .diagnostics-content
) {
    padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 80px)) !important;
}

@media (max-width: 1280px) {
    :is(.topbar, .platform-header, .platform-bar, .workspace-header, .operations-topbar, .page-header) {
        align-items: flex-start;
        gap: var(--atlas-space-2);
    }
    :is(.topbar-actions, .header-actions, .platform-actions, .page-actions, .operations-actions) {
        justify-content: flex-end;
    }
}

@media (max-width: 1024px) {
    :is(.topbar, .platform-header, .platform-bar, .workspace-header, .operations-topbar, .page-header) {
        padding: var(--atlas-space-2) var(--atlas-space-3);
    }
    :is(.workspace-content, .operations-content, .page-content, .assets-content, .knowledge-main) {
        padding-inline: var(--atlas-space-3);
    }
}
