/* DATAMIND theme (decision B, 2026-10-30) — the single source of the design tokens.
 *
 * The values mirror components/theme.py TOKENS; tests/test_ui_premium_checklist.py
 * fails when the two drift. Cleaned (essential) tabs are wrapped in `.dm-theme` by
 * components/ui_layout.pick_layout and use only the `--dm-*` tokens and `.dm-*`
 * classes below. The classic layout inherits only what does not move anything:
 * tabular figures and the keyboard focus ring.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Text and surfaces (contrast on white in brackets) */
    --dm-text-primary: #101828;   /* 17.8:1 titles, values, table text */
    --dm-text-strong: #344054;    /* 10.5:1 answer sentences, buttons */
    --dm-text-secondary: #475467; /* 7.7:1 labels, captions, deltas */
    --dm-text-muted: #667085;     /* 5.0:1 marks and sparklines only */
    --dm-dsl-active: #92400E;     /* 6.8:1 on dsl-active-bg, DSL ACTIVE pill */
    --dm-dsl-active-bg: #FFFBEB;
    --dm-dsl-high: #9A3412;       /* 7.3:1 DSL High severity */
    --dm-brand: #1949FF;          /* 6.1:1 links, primary button, active tab */
    --dm-brand-hover: #0F32C2;
    --dm-brand-tint: #EEF4FF;
    --dm-brand-border: #C7D7FE;
    --dm-brand-orange: #F7941D;   /* logo mark only, never text (2.3:1) */
    --dm-page: #F6F7F9;
    --dm-surface: #FFFFFF;
    --dm-surface-subtle: #F2F4F7;
    --dm-border: #E4E7EC;
    --dm-border-strong: #D0D5DD;
    --dm-grid: #EAECF0;

    /* Status: reserved, always with icon and label, never in charts */
    --dm-good: #067647;
    --dm-good-bg: #ECFDF3;
    --dm-good-border: #ABEFC6;
    --dm-info: #1949FF;
    --dm-info-bg: #EEF4FF;
    --dm-info-border: #C7D7FE;
    --dm-warning: #B54708;
    --dm-warning-bg: #FFFAEB;
    --dm-warning-border: #FEDF89;
    --dm-critical: #B42318;
    --dm-critical-bg: #FEF3F2;
    --dm-critical-border: #FECDCA;

    /* Channels: fixed order, validated (palette-validation-r2.txt) */
    --dm-channel-google-ads: #E8590C;
    --dm-channel-meta: #0891B2;
    --dm-channel-email: #A21CAF;
    --dm-channel-referral: #65A30D;
    --dm-channel-organic-search: #7C3AED;
    --dm-channel-display: #DB2777;
    --dm-channel-other: #667085;

    /* Type: Inter, tabular figures, five steps, nothing below 12 px */
    --dm-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --dm-text-caption: 13px;  /* round 11: 12px secondary text read as too small (accessibility) */
    --dm-text-body: 14px;
    --dm-text-lead: 16px;
    --dm-text-title: 20px;
    --dm-text-display: 28px;

    /* Spacing */
    --dm-space-1: 4px;
    --dm-space-2: 8px;
    --dm-space-3: 12px;
    --dm-space-4: 16px;
    --dm-space-5: 24px;
    --dm-space-6: 32px;

    /* Shape and elevation */
    --dm-radius: 8px;
    --dm-radius-pill: 999px;
    --dm-shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
    --dm-shadow-2: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);

    --dm-target: 44px;
    --dm-focus: 0 0 0 2px var(--dm-surface), 0 0 0 4px var(--dm-brand);
    --dm-green-text: #047857;
    --dm-red-text: #B91C1C;
    --dm-orange-text: #B45309;
    --dm-sidebar-label: #9DB1FF;
    --dm-ink-soft: #4B5563;
    --dm-ink-slider: #495057;
    --dm-link: #0057B8;
    --dm-ink-dark: #1F2937;
    --green: #047857;
    --red: #B91C1C;
    --orange-warning: #B45309;
}

/* ---------------------------------------------------------------------------
   Inherited by every layout (nothing moves): figures line up, focus is visible
   --------------------------------------------------------------------------- */
.kpi-value,
.ag-theme-alpine .ag-cell,
table td,
.dm-num {
    font-variant-numeric: tabular-nums;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--dm-brand);
    outline-offset: 2px;
}

/* Roast round 11 (keyboard): a dropdown takes focus on a 1px inner combobox that draws nothing,
   so the ring goes on the whole control while it holds focus. */
.Select.is-focused > .Select-control,
.Select-control:focus-within {
    outline: 2px solid var(--dm-brand);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Essential layout root
   --------------------------------------------------------------------------- */
.dm-theme {
    font-family: var(--dm-font);
    font-size: var(--dm-text-body);
    line-height: 1.5;
    color: var(--dm-text-primary);
    background: var(--dm-page);
    font-variant-numeric: tabular-nums;
    padding: var(--dm-space-5) var(--dm-space-5) var(--dm-space-6);
}

/* A block of an essential tab inside a page shared with classic: theme rules, no page padding. */
.dm-theme.dm-theme--inline { padding: 0; background: transparent; }

.dm-theme h1,
.dm-theme h2,
.dm-theme h3,
.dm-theme h4,
.dm-theme h5 {
    font-family: var(--dm-font);
    color: var(--dm-text-primary) !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
    margin: 0;
}

.dm-theme a { color: var(--dm-brand); }
.dm-theme a:hover { color: var(--dm-brand-hover); }

/* Type steps */
.dm-display { font-size: var(--dm-text-display); font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
.dm-title   { font-size: var(--dm-text-title);   font-weight: 600; line-height: 1.3; }
.dm-lead    { font-size: var(--dm-text-lead);    font-weight: 500; line-height: 1.5; color: var(--dm-text-strong); }
.dm-body    { font-size: var(--dm-text-body); }
.dm-caption { font-size: var(--dm-text-caption); color: var(--dm-text-secondary); }

/* Page header: title, one-line purpose, freshness by source */
.dm-page-header { display: flex; flex-direction: column; gap: var(--dm-space-2); margin-bottom: var(--dm-space-5); }
.dm-page-header__title { font-size: var(--dm-text-display); font-weight: 600; line-height: 1.2; }
.dm-page-header__subtitle { font-size: var(--dm-text-body); color: var(--dm-text-secondary); max-width: 72ch; }

.dm-freshness { display: flex; flex-wrap: wrap; gap: var(--dm-space-2) var(--dm-space-4); font-size: var(--dm-text-caption); color: var(--dm-text-secondary); }
.dm-freshness__item { display: inline-flex; align-items: center; gap: var(--dm-space-2); }

/* Card: one radius, one border, elevation 1. Cards never nest. */
.dm-card {
    background: var(--dm-surface);
    border: 1px solid var(--dm-border);
    border-radius: var(--dm-radius);
    box-shadow: var(--dm-shadow-1);
    padding: var(--dm-space-5);
}
.dm-card .dm-card { box-shadow: none; border: 0; padding: 0; }
.dm-card__header { display: flex; flex-direction: column; gap: var(--dm-space-1); margin-bottom: var(--dm-space-4); }
.dm-card__title { font-size: var(--dm-text-lead); font-weight: 600; color: var(--dm-text-primary); }
.dm-card__subtitle { font-size: var(--dm-text-caption); color: var(--dm-text-secondary); }

/* Answer block: one sentence that answers the tab's question, then at most 4 KPIs */
.dm-answer { display: flex; flex-direction: column; gap: var(--dm-space-4); margin-bottom: var(--dm-space-5); }
.dm-answer__sentence { font-size: var(--dm-text-title); font-weight: 600; line-height: 1.35; color: var(--dm-text-primary); max-width: 64ch; text-wrap: pretty; }
.dm-answer__scope { font-size: var(--dm-text-caption); color: var(--dm-text-secondary); margin: 0; }
.dm-stack > .dm-answer__scope + .dm-answer__scope { margin-top: calc(-1 * var(--dm-space-3)); }  /* only inside a gap stack: outside it the pull overlapped lines */
.dm-answer__scope + .dm-answer__scope { margin-top: var(--dm-space-1); }  /* note + scope read as one caption */
.dm-card + .dm-answer__scope { margin-top: var(--dm-space-2); }  /* a caption under a card is not glued to its border */
.dm-stack { display: flex; flex-direction: column; gap: var(--dm-space-4); }  /* one rhythm between the blocks of a tab */
.dm-stack > p, .dm-stack > div > p { margin: 0; }
.dm-answer__sentence { margin: 0; }
.dm-answer__sentence + .dm-answer__scope, .dm-answer__sentence + .dm-answer__meta { margin-top: calc(-1 * var(--dm-space-2)); }  /* the period belongs to its sentence */
.dm-answer__meta { display: flex; flex-direction: column; gap: var(--dm-space-1); }
.dm-answer__meta > .dm-answer__scope + .dm-answer__scope { margin-top: 0; }
.dm-table-note { margin-top: var(--dm-space-2); }
.ag-theme-alpine .ag-right-aligned-cell { text-align: right !important; justify-content: flex-end; font-variant-numeric: tabular-nums; }  /* numbers line up under their right-aligned header on every page */

.dm-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--dm-space-4); }
.dm-kpi {
    background: var(--dm-surface);
    border: 1px solid var(--dm-border);
    border-radius: var(--dm-radius);
    box-shadow: var(--dm-shadow-1);
    padding: var(--dm-space-4) var(--dm-space-5);
    display: flex;
    flex-direction: column;
    gap: var(--dm-space-2);
}
.dm-kpi__label { font-size: var(--dm-text-caption); font-weight: 500; color: var(--dm-text-secondary); }
.dm-kpi__value { font-size: var(--dm-text-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; color: var(--dm-text-primary); }
.dm-kpi__value--missing { font-size: var(--dm-text-body); font-weight: 500; color: var(--dm-text-secondary); letter-spacing: 0; }
.dm-kpi__compare { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dm-space-2); font-size: var(--dm-text-caption); color: var(--dm-text-secondary); }

/* Pills: change versus the previous period (arrow + word) and status (icon + label) */
.dm-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--dm-space-1);
    font-size: var(--dm-text-caption);
    font-weight: 600;
    line-height: 1.5;
    padding: 2px var(--dm-space-2);
    border-radius: var(--dm-radius-pill);
    border: 1px solid var(--dm-border);
    background: var(--dm-surface-subtle);
    color: var(--dm-text-strong);
    white-space: nowrap;
}
.dm-pill__icon { font-size: var(--dm-text-caption); line-height: 1; }
.dm-pill--good     { color: var(--dm-good);     background: var(--dm-good-bg);     border-color: var(--dm-good-border); }
.dm-pill--info     { color: var(--dm-info);     background: var(--dm-info-bg);     border-color: var(--dm-info-border); }
.dm-pill--warning  { color: var(--dm-warning);  background: var(--dm-warning-bg);  border-color: var(--dm-warning-border); }
.dm-pill--critical { color: var(--dm-critical); background: var(--dm-critical-bg); border-color: var(--dm-critical-border); }

/* Advanced analysis: one control, closed by default, same label on every tab */
.dm-advanced {
    margin-top: var(--dm-space-6);
    border-top: 1px solid var(--dm-border);
    padding-top: var(--dm-space-4);
}
.dm-advanced > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: var(--dm-space-2);
    min-height: var(--dm-target);
    padding: 0 var(--dm-space-4);
    border: 1px solid var(--dm-border-strong);
    border-radius: var(--dm-radius);
    background: var(--dm-surface);
    color: var(--dm-text-strong);
    font-size: var(--dm-text-body);
    font-weight: 600;
    cursor: pointer;
}
.dm-advanced > summary::-webkit-details-marker { display: none; }
.dm-advanced > summary::before { content: "\25B8"; color: var(--dm-text-secondary); }
.dm-advanced[open] > summary::before { content: "\25BE"; }
.dm-advanced > summary:hover { border-color: var(--dm-brand-border); background: var(--dm-brand-tint); }
.dm-advanced__body { display: flex; flex-direction: column; gap: var(--dm-space-5); margin-top: var(--dm-space-5); }

/* Table view under a chart: the same numbers, readable without colour */
.dm-table-view { margin-top: var(--dm-space-3); }
.dm-table-view__summary {
    display: inline-flex;
    align-items: center;
    min-height: var(--dm-target);
    color: var(--dm-brand);
    font-size: var(--dm-text-body);
    font-weight: 600;
    cursor: pointer;
}
.dm-table { width: 100%; border-collapse: collapse; font-size: var(--dm-text-body); color: var(--dm-text-strong); }
.dm-table th { text-align: left; font-weight: 600; color: var(--dm-text-secondary); font-size: var(--dm-text-caption); }
.dm-table th, .dm-table td { padding: var(--dm-space-2) var(--dm-space-3); border-bottom: 1px solid var(--dm-border); }
.dm-table td:not(:first-child), .dm-table th:not(:first-child) { text-align: right; }

/* States: one style for empty, error, partial, late and in-validation */
.dm-state {
    display: flex;
    flex-direction: column;
    gap: var(--dm-space-2);
    padding: var(--dm-space-4) var(--dm-space-5);
    border-radius: var(--dm-radius);
    border: 1px solid var(--dm-border);
    background: var(--dm-surface);
}
.dm-state__title { font-size: var(--dm-text-body); font-weight: 600; color: var(--dm-text-primary); }
.dm-state__body { font-size: var(--dm-text-body); color: var(--dm-text-secondary); max-width: 72ch; }
.dm-state--error      { border-color: var(--dm-critical-border); }
.dm-state--partial,
.dm-state--late       { border-color: var(--dm-warning-border); background: var(--dm-warning-bg); }

/* Controls: 44 px targets, labelled filters */
.dm-filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--dm-space-4); margin-bottom: var(--dm-space-5); }
.dm-field { display: flex; flex-direction: column; gap: var(--dm-space-1); min-width: 180px; }
.dm-field__label { font-size: var(--dm-text-caption); font-weight: 500; color: var(--dm-text-secondary); }
/* Round 12 (M07): page filters as a horizontal bar above the content (WEB, MTA). */
.dm-filter-bar--page { padding: var(--dm-space-3) 0; border-bottom: 1px solid var(--dm-border); }
.dm-filter-bar--page .dm-field { flex: 1 1 200px; max-width: 320px; }
.dm-filter-bar--page .dm-field:empty { display: none; }
.dm-filter-bar--page .dm-field .dash-dropdown, .dm-filter-bar--page .dm-field .Select { width: 100%; }
/* The period select shows its whole value ("This month and the 3 previous months"), never a clipped one. */
.dm-filter-bar .dm-field:has([id$="date-preset"]) { flex: 1 1 300px; min-width: 300px; max-width: 380px; }
.dm-theme .Select-control,
.dm-theme .dash-dropdown .Select-control { min-height: var(--dm-target); border-color: var(--dm-border-strong); border-radius: var(--dm-radius); }
.dm-theme .btn { min-height: var(--dm-target); border-radius: var(--dm-radius); font-weight: 600; font-size: var(--dm-text-body); padding: 0 var(--dm-space-4); }
.dm-theme .btn-primary { background: var(--dm-brand); border-color: var(--dm-brand); }
.dm-theme .btn-primary:hover { background: var(--dm-brand-hover); border-color: var(--dm-brand-hover); }

/* Tables inside essential tabs */
.dm-theme .ag-theme-alpine {
    --ag-font-family: var(--dm-font);
    --ag-font-size: 14px;
    --ag-foreground-color: var(--dm-text-primary);
    --ag-header-foreground-color: var(--dm-text-secondary);
    --ag-header-background-color: var(--dm-surface);
    --ag-border-color: var(--dm-border);
    --ag-row-border-color: var(--dm-grid);
    --ag-odd-row-background-color: var(--dm-surface);
    --ag-row-hover-color: var(--dm-surface-subtle);
    --ag-selected-row-background-color: var(--dm-brand-tint);
    --ag-header-column-separator-color: var(--dm-border);
}
/* style.css forces white header text for its blue header; on the light essential header it
   must be readable ink, sentence case like every other label. */
.dm-theme .ag-theme-alpine .ag-header-cell,
.dm-theme .ag-theme-alpine .ag-header-cell-label {
    color: var(--dm-text-secondary) !important;
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--dm-text-caption);
}

/* Loading: one skeleton, shaped like the content it replaces */
.dm-skeleton {
    border-radius: var(--dm-radius);
    background: linear-gradient(90deg, var(--dm-surface-subtle) 0%, var(--dm-grid) 50%, var(--dm-surface-subtle) 100%);
    background-size: 200% 100%;
    animation: dm-skeleton 1.4s ease-in-out infinite;
    min-height: var(--dm-space-6);
}
@keyframes dm-skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Visually hidden text for screen readers (table titles, icon meanings) */
.dm-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;
}

@media (prefers-reduced-motion: reduce) {
    .dm-skeleton { animation: none; }
}

@media (max-width: 640px) {
    .dm-theme { padding: var(--dm-space-4); }
    .dm-answer__sentence { font-size: var(--dm-text-lead); }
    .dm-kpi__value { font-size: var(--dm-text-title); }
}

/* Overview: the open issues of the day, most severe first (icon + word, never colour alone) */
.dm-issue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--dm-space-3); }
.dm-issue {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: var(--dm-space-3) var(--dm-space-4);
    background: var(--dm-surface);
    border: 1px solid var(--dm-border);
    border-radius: var(--dm-radius);
    box-shadow: var(--dm-shadow-1);
    padding: var(--dm-space-4) var(--dm-space-5);
}
.dm-issue__text { display: flex; flex-direction: column; gap: var(--dm-space-1); min-width: 0; }
.dm-issue__title { font-size: var(--dm-text-body); font-weight: 600; color: var(--dm-text-primary); }
.dm-issue__body { font-size: var(--dm-text-body); color: var(--dm-text-strong); max-width: 72ch; }
.dm-issue__meta { font-size: var(--dm-text-caption); color: var(--dm-text-secondary); }
.dm-theme a.dm-issue__action {
    display: inline-flex;
    align-items: center;
    min-height: var(--dm-target);
    padding: 0 var(--dm-space-4);
    border: 1px solid var(--dm-border-strong);
    border-radius: var(--dm-radius);
    color: var(--dm-text-strong);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.dm-theme a.dm-issue__action:hover { border-color: var(--dm-brand-border); background: var(--dm-brand-tint); color: var(--dm-brand-hover); }
.dm-theme a.dm-issue__action:focus-visible { outline: 2px solid var(--dm-brand); outline-offset: 2px; box-shadow: var(--dm-focus); }
@media (max-width: 640px) {
    .dm-issue { grid-template-columns: 1fr; }
}

/* Campaigns essential (UI series B, PR 3) */
.dm-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--dm-space-4); }
.dm-highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--dm-space-4); margin-bottom: var(--dm-space-3); }
.dm-highlight { display: flex; flex-direction: column; align-items: flex-start; gap: var(--dm-space-2); padding: var(--dm-space-4); border: 1px solid var(--dm-border); border-radius: var(--dm-radius); min-width: 0; }
.dm-highlight .dm-issue__title { margin: 0; overflow-wrap: anywhere; }
.dm-highlight .dm-issue__body { margin: 0; }
.dm-dot { display: inline-block; line-height: 1; }
.dm-table--campaigns td:nth-child(2), .dm-table--campaigns th:nth-child(2) { text-align: left; }
.dm-table--campaigns td:first-child { overflow-wrap: anywhere; }

/* Customers essential (UI series B, PR 6): the classic filters as an inline panel under Advanced analysis */
.dm-cdp-filters {
    max-width: 560px;
    padding: var(--dm-space-4);
    border: 1px solid var(--dm-border);
    border-radius: var(--dm-radius);
    background: var(--dm-surface);
}

/* Roast 18/11, WCAG AA on the controls the new layout reuses from the classic builders. */
.dm-theme ::placeholder { color: var(--dm-text-muted); opacity: 1; }
.dm-theme .text-muted, .dm-theme .form-text { color: var(--dm-text-secondary) !important; }
.dm-theme .btn-outline-secondary { color: var(--dm-text-strong); border-color: var(--dm-border-strong); }
.dm-theme .btn-outline-secondary:hover { color: var(--dm-text-primary); background: var(--dm-surface-subtle); }
.dm-theme .rc-slider-mark-text { color: var(--dm-text-secondary); }
.dm-theme .rc-slider-mark-text-active { color: var(--dm-text-primary); }
.dm-breadcrumb a { color: var(--dm-brand); }
.dm-theme .DateInput_input, .dm-theme .DateInput_input__disabled { color: var(--dm-text-primary); font-style: normal; }
.dm-state__action { display: inline-block; margin-top: 8px; font-weight: 600; color: var(--dm-brand); }
.dm-advanced__contents { margin: var(--dm-space-2) 0 0; font-size: var(--dm-text-caption); color: var(--dm-text-secondary); max-width: 90ch; }
/* Attribution and Website build their detail block with the classic helper: same look as
   every other "full analysis" control in the new layout (Roast 18/11: two designs). */
.dm-theme details.advanced-analysis { background: transparent !important; border: 0 !important; border-top: 1px solid var(--dm-border) !important; padding: var(--dm-space-4) 0 0 !important; }
.dm-theme details.advanced-analysis > summary.advanced-analysis-summary { list-style: none; display: inline-flex; align-items: center; gap: var(--dm-space-2); min-height: var(--dm-target); padding: 0 var(--dm-space-4); border: 1px solid var(--dm-border-strong); border-radius: var(--dm-radius); background: var(--dm-surface); color: var(--dm-text-strong) !important; font-size: var(--dm-text-body) !important; font-weight: 600; cursor: pointer; }
.dm-theme details.advanced-analysis > summary.advanced-analysis-summary::-webkit-details-marker { display: none; }
.dm-theme details.advanced-analysis > summary.advanced-analysis-summary::before { content: "\25B8"; color: var(--dm-text-secondary); }
.dm-theme details.advanced-analysis[open] > summary.advanced-analysis-summary::before { content: "\25BE"; }

/* Full analysis = the classic builders embedded in the new layout (Roast giro 2).
   Their filter panels are position: fixed side drawers in the Classic layout; inside the
   full analysis they sit in the flow, above the content, and never cover the page title. */
.dm-advanced__body [id$="-sidebar-panel"] {
    position: static !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    z-index: auto !important;
    box-shadow: none !important;
    visibility: visible !important;
    overflow: visible !important;
    border: 1px solid var(--dm-border) !important;
    border-radius: var(--dm-radius);
    margin-bottom: var(--dm-space-4, 16px);
}
.dm-advanced__body [id$="-sidebar-open-btn"],
.dm-advanced__body [id$="-sidebar-close-btn"] { display: none !important; }
.dm-advanced__body [id$="-main-content"] { margin-left: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }

/* WCAG AA (Roast round 3): Bootstrap defaults that fall under 4.5:1 on the light panels. */
.btn-outline-primary { --bs-btn-color: var(--dm-brand); --bs-btn-border-color: var(--dm-brand); }
.badge.bg-warning, .badge.text-bg-warning { color: var(--dm-text-primary) !important; }

/* Text contrast for full analysis views and legacy Dash controls. */
.sidebar .text-uppercase, #sidebar .text-uppercase, .bg-dark .text-uppercase, .sidebar-section-label, .nav-section-title { color: var(--dm-sidebar-label) !important; }
[style*="color: rgb(16, 185, 129)"], [style*="color: rgb(5, 150, 105)"], [style*="color: \23 10B981" i], [style*="color: \23 059669" i] { color: var(--dm-green-text) !important; }
[style*="color: rgb(198, 203, 210)"], [style*="color: \23 C6CBD2" i] { color: var(--dm-ink-soft) !important; }
[style*="color: rgb(239, 68, 68)"], [style*="color: \23 EF4444" i] { color: var(--dm-red-text) !important; }
[style*="color: rgb(217, 119, 6)"], [style*="color: \23 D97706" i] { color: var(--dm-orange-text) !important; }
.rc-slider-mark-text, .rc-slider-disabled .rc-slider-mark-text { color: var(--dm-ink-slider) !important; }
.Select-placeholder, .Select--single > .Select-control .Select-value, .Select-value-label, .dash-dropdown ::placeholder, .dash-dropdown [class*="placeholder"], .dash-dropdown [class*="singleValue"] { color: var(--dm-ink-slider) !important; }
.text-muted, .btn-outline-secondary, [style*="color: rgb(108, 117, 125)"], [style*="color: \23 6C757D" i] { color: var(--dm-ink-slider) !important; }
a, .Select-option.is-selected { color: var(--dm-link); }
[style*="color: rgb(0, 126, 255)"], [style*="color: \23 007EFF" i] { color: var(--dm-link) !important; }
[style*="color: rgb(232, 89, 12)"], [style*="color: rgb(8, 145, 178)"], [style*="color: \23 E8590C" i], [style*="color: \23 0891B2" i] { color: var(--dm-ink-dark) !important; }
/* Round 12 (M40): the date picker's keyboard-help sentence is for screen readers only; same
   visually-hidden rule as .dm-sr-only (it failed the contrast lint, ratio 1.24). */
.DateRangePickerInput__screenReaderMessage, .DateInput_screenReaderMessage, .DateInput__screenReaderMessage,
[class*="screenReaderMessage"], .dm-sr-only {
    position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
    margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important;
    white-space: nowrap !important; border: 0 !important;
}

/* Roast round 5 (19/11), group E: captions and small grey text at 12px or more with AA
   contrast, locked sliders that look locked. Inline styles of the classic builders are reached
   through their serialized style attribute; chart text (SVG) is left to the chart layout. */
#main-content [style*="size: 9px"]:not(text):not(tspan),
#main-content [style*="size: 10px"]:not(text):not(tspan),
#main-content [style*="size: 11px"]:not(text):not(tspan),
#main-content [style*="size: 0.65rem"]:not(text):not(tspan),
#main-content [style*="size: 0.7rem"]:not(text):not(tspan),
#main-content [style*="size: 0.6rem"]:not(text):not(tspan) { font-size: 12px !important; }
#main-content small, #main-content .small, #main-content .form-text { font-size: max(12px, 0.875em); }
#main-content [style*="color: rgb(156, 163, 175)"]:not(text):not(tspan),
#main-content [style*="color: rgb(152, 162, 179)"]:not(text):not(tspan),
#main-content [style*="color: rgb(173, 181, 189)"]:not(text):not(tspan),
#main-content [style*="color: rgb(153, 153, 153)"]:not(text):not(tspan),
#main-content [style*="color: rgb(136, 136, 136)"]:not(text):not(tspan),
#main-content [style*="color: rgb(170, 170, 170)"]:not(text):not(tspan),
#main-content [style*="color: rgb(107, 114, 128)"]:not(text):not(tspan),
#main-content [style*="color: rgb(117, 117, 117)"]:not(text):not(tspan),
#main-content [style*="color: rgb(127, 140, 141)"]:not(text):not(tspan),
#main-content [style*="color: rgb(149, 165, 166)"]:not(text):not(tspan) { color: var(--dm-text-secondary) !important; }
.freshness-source, .freshness-time { font-size: 12px; }
.freshness-time.ok { color: var(--dm-good); }
.freshness-time.warning { color: var(--dm-warning); }

/* Locked sliders (disabled=True): grey track and handle, no hover, "not-allowed" cursor, so a
   slider waiting for validation never reads as live. */
.rc-slider-disabled { background-color: transparent !important; cursor: not-allowed; opacity: 0.6; }
.rc-slider-disabled .rc-slider-rail { background-color: var(--dm-grid) !important; }
.rc-slider-disabled .rc-slider-track { background-color: var(--dm-border-strong) !important; }
.rc-slider-disabled .rc-slider-handle,
.rc-slider-disabled .rc-slider-dot { border-color: var(--dm-text-muted) !important; background-color: var(--dm-surface-subtle) !important; box-shadow: none !important; cursor: not-allowed !important; }
.rc-slider-disabled .rc-slider-tooltip, .rc-slider-disabled + .rc-slider-tooltip { display: none !important; }
.dm-slider--disabled { position: relative; }
.dm-slider--disabled input { cursor: not-allowed; }

/* Roast round 7 (20/11): notes read at 13px in the secondary ink (7.7:1); the OBS "How this is
   counted" control and the DSL risk tile (a number and a status pill instead of a tall gauge). */
.dm-answer__scope, .dm-card__subtitle, .dm-advanced__contents { font-size: 13px; line-height: 1.5; }
.dm-how-counted__body { display: flex; flex-direction: column; gap: var(--dm-space-2); margin-top: var(--dm-space-2); max-width: 90ch; }
.dm-how-counted__body > p { margin: 0; }
.dm-risk { margin-bottom: 16px; }
.dm-risk__tile { display: flex; flex-direction: column; gap: var(--dm-space-2); padding: var(--dm-space-4); border: 1px solid var(--dm-border); border-radius: var(--dm-radius); max-width: 360px; background: var(--dm-surface); }
.dm-risk__title { font-size: 13px; font-weight: 600; color: var(--dm-text-secondary); }
.dm-risk__row { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--dm-space-2); }
.dm-risk__value { font-size: 32px; font-weight: 700; line-height: 1; }
.dm-risk__scale { font-size: 14px; color: var(--dm-text-secondary); }
.dm-risk__pill { font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: var(--dm-radius-pill); }
.dm-risk__definition { margin: 0; font-size: 13px; color: var(--dm-text-secondary); }

/* Roast round 8: Customers essential, the filters in one closed disclosure */
.dm-cdp-filters-details { margin-bottom: var(--dm-space-4); }
.dm-cdp-filters-summary { cursor: pointer; font-weight: 600; color: var(--dm-text-strong); }

/* Essential MMM full analysis: no macro data connected -> the block of "—" tiles is hidden (Roast round 8). */
.dm-macro--essential:has([data-macro="empty"]) { display: none; }
.dm-facts { display: grid; gap: var(--dm-space-1) 0; margin: 0; }
.dm-facts dt { font-weight: 600; color: var(--dm-text-primary); margin-top: var(--dm-space-3); }
.dm-facts dt:first-child { margin-top: 0; }
.dm-facts dd { margin: 0; color: var(--dm-text-secondary); }

/* Roast round 8: the bridge period and numbers stay on one line; the "What it counts" text wraps. */
.dm-bridge .dm-bridge__period, .dm-bridge .dm-num { white-space: nowrap; }
/* Roast round 9: text cells left-aligned, what a row counts sits under the page name. */
.dm-bridge th[scope="row"] { color: var(--dm-text-strong); font-size: var(--dm-text-body); max-width: 26rem; }
.dm-bridge .dm-bridge__page { font-weight: 600; }
.dm-bridge .dm-bridge__counts { display: block; font-weight: 400; color: var(--dm-text-secondary);
    font-size: var(--dm-text-caption); margin-top: var(--dm-space-1); white-space: normal; }
.dm-bridge td.dm-bridge__period, .dm-bridge th:nth-child(2), .dm-bridge td.dm-bridge__note { text-align: left; }
.dm-bridge td.dm-bridge__note { color: var(--dm-text-secondary); }
.dm-bridge th, .dm-bridge td { vertical-align: top; }

/* Round 10 (Roast 9): what opens a locked model page (components/budget_analysis.gate_checklist). */
.dm-gate {
    background: var(--dm-surface);
    border: 1px solid var(--dm-border);
    border-radius: var(--dm-radius);
    padding: var(--dm-space-4) var(--dm-space-5);
}
.dm-gate__title { font-size: var(--dm-text-body); font-weight: 600; color: var(--dm-text-primary); margin: 0 0 var(--dm-space-3); }
.dm-gate__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--dm-space-2); }
.dm-gate__row { display: flex; justify-content: space-between; gap: var(--dm-space-4); border-bottom: 1px solid var(--dm-border); padding-bottom: var(--dm-space-2); }
.dm-gate__row:last-child { border-bottom: 0; padding-bottom: 0; }
.dm-gate__check { color: var(--dm-text-primary); font-size: var(--dm-text-body); }
.dm-gate__state { color: var(--dm-text-secondary); font-size: var(--dm-text-body); white-space: nowrap; font-weight: 600; }
.dm-gate__after { color: var(--dm-text-secondary); font-size: var(--dm-text-body); margin: var(--dm-space-3) 0 0; }
@media (max-width: 640px) { .dm-gate__row { flex-direction: column; gap: var(--dm-space-1); } }

/* Round 11: acronyms in KPI labels are spelled out on hover (title) and marked with a dotted line. */
.dm-abbr { text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; }

/* Roast final (keyboard, judge 6): the ring on the dark header is white, never dark blue on navy,
   and forced-colors mode draws a system-colour outline on every focus state. */
.navbar a:focus-visible,
.navbar button:focus-visible,
.navbar [tabindex]:focus-visible,
header a:focus-visible,
header button:focus-visible {
    outline: 2px solid var(--dm-surface);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--dm-brand);
}

@media (forced-colors: active) {
    a:focus-visible,
    button:focus-visible,
    summary:focus-visible,
    [role="button"]:focus-visible,
    [tabindex]:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    .Select.is-focused > .Select-control {
        outline: 2px solid Highlight !important;
    }
}

/* The date picker's keyboard-help sentence is hidden; keep its colour AA anyway so the contrast lint
   (and a screen magnifier) never reports it (Roast final, judge 6). */
[class*="screenReaderMessage"] { color: var(--dm-ink-dark) !important; }

/* Section headings of the essential pages are text, never link blue, also where the page shell is
   shared with classic (Roast final, judges 1 and 6). */
h1.dm-title, h2.dm-title, h3.dm-title, h2.dm-card__title, h3.dm-card__title { color: var(--dm-text-primary) !important; }

/* Roast confirm 1 (residual 9): Bootstrap fades a disabled button to .65, which drops the grey label
   below AA on the light button. The locked "Save as baseline" keeps its full-strength colour. */
.dm-theme #mmm-force-save-btn:disabled,
#mmm-force-save-btn:disabled { opacity: 1; color: var(--dm-text-secondary); }

/* Filters closed by default on MTA / WEB (page length) */
.dm-filter-details > .dm-filter-summary {
    display: inline-flex; align-items: center; min-height: var(--dm-target);
    color: var(--dm-brand); font-size: var(--dm-text-body); font-weight: 600; cursor: pointer;
}
.dm-filter-details[open] > .dm-filter-summary { margin-bottom: var(--dm-space-2); }
