﻿/* =================================================================
   === Dashboard Page (extracted from adatelemzes.html)
================================================================= */

        /* ── Dropdown multi-select widget ── */
        .dms-wrapper {
            position: relative;
        }
        .dms-trigger {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.5rem 0.75rem;
            border: 1px solid var(--color-border-medium);
            border-radius: 6px;
            background: white;
            font-size: 0.875rem;
            cursor: pointer;
            color: var(--color-text-strong-gray);
            transition: border-color 0.15s;
        }
        .dms-trigger:hover {
            border-color: var(--color-accent-ruddy);
        }
        .dms-trigger[aria-expanded="true"] {
            border-color: var(--color-primary);
            box-shadow: 0 0 0 2px rgba(2,33,54,0.12);
        }
        .dms-arrow {
            flex-shrink: 0;
            transition: transform 0.2s;
        }
        .dms-trigger[aria-expanded="true"] .dms-arrow {
            transform: rotate(180deg);
        }
        .dms-panel {
            display: none;
            position: absolute;
            top: calc(100% + 2px);
            left: 0;
            right: 0;
            z-index: 200;
            background: white;
            border: 1px solid var(--color-border-medium);
            border-radius: 6px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.12);
            max-height: 220px;
            overflow-y: auto;
        }
        .dms-panel.dms-panel--open {
            display: block;
        }
        .dms-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            cursor: pointer;
            font-size: 0.875rem;
            color: var(--color-text-strong-gray);
            transition: background 0.1s;
        }
        .dms-item:hover {
            background: var(--color-surface-muted);
        }
        .dms-item--all {
            font-weight: 600;
            border-bottom: 1px solid var(--color-border-subtle);
        }
        .dms-item input[type="checkbox"],
        .dms-item input[type="radio"] {
            accent-color: var(--color-primary);
            cursor: pointer;
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }


        /* ── Diagnosis dropdown panel ── */
        .diag-item {
            display: flex;
            align-items: center;
            gap: 0.45rem;
            padding: 0.3rem 0.65rem;
            cursor: pointer;
            font-size: 0.75rem;
            color: var(--color-gray-700);
            border-bottom: 1px solid var(--color-gray-100);
            transition: background 0.1s;
        }
        .diag-item:last-child { border-bottom: none; }
        .diag-item:hover { background: var(--color-gray-50); }
        .diag-item input[type="checkbox"] {
            accent-color: var(--color-primary);
            cursor: pointer;
            width: 13px;
            height: 13px;
            flex-shrink: 0;
            pointer-events: none;
        }

        /* Server-side "hidden until JS decides", the successor to Alpine's
           [x-cloak]. #chartsContainer, #dataTableContainer and #filterBackdrop
           ship with `hidden` in the markup so they cannot flash before
           dashboardChrome.js reveals the right one. !important is what keeps an
           author `display` rule (.view-card, or #filtersColumn's mobile block)
           from re-showing them — which also means a hidden element can only be
           re-shown by removing the attribute, never from CSS. */
        [hidden] { display: none !important; }

        /* ── View selector (above chart area) ── */
        .chart-view-selector {
            display: flex;
            gap: 0.5rem;
            align-items: flex-start;
        }
        /* Two explicit groups — incidence (2/3) and survival (1/3) */
        .cvs-group {
            display: flex;
            flex-direction: column;
            gap: 0.4rem;
            min-width: 0;
        }
        .cvs-group--incidence { flex: 2; }
        .cvs-group--survival  { flex: 1; }
        .cvs-btns {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.4rem;
        }
        /* Survival buttons stack in one column on desktop */
        .cvs-group--survival .cvs-btns {
            grid-template-columns: 1fr;
        }
        /* Group headers as grid items */
        .view-group-header {
            display: flex;
            align-items: flex-end;
            font-size: 0.68rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.07em;
            color: var(--color-primary);
            padding-bottom: 0.3rem;
            border-bottom: 2px solid var(--color-primary);
        }
        .view-group-header--survival {
            color: var(--color-accent-orange);
            border-color: var(--color-accent-orange);
        }
        /* Card buttons */
        .view-sel-btn {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.5rem 0.65rem;
            border: 1.5px solid transparent;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.82rem;
            font-weight: 500;
            transition: all 0.14s;
            text-align: left;
            box-sizing: border-box;
            /* Single-line height as before (0.8rem label at line-height 1.3 +
               padding + border); a wrapped label grows the button but keeps the
               tighter 1.15 spacing of .vsb-title. */
            min-height: calc(0.8rem * 1.3 + 1rem + 3px);
        }
        .view-sel-btn--incidence {
            background: #eef4fb;
            color: var(--color-primary);
            border-color: #d0e3f5;
        }
        .view-sel-btn--survival {
            background: #fff4ee;
            color: #7a3010;
            border-color: #ffd5b8;
        }
        .view-sel-btn:hover:not(:disabled) {
            filter: brightness(0.96);
            border-color: var(--color-primary);
        }
        .view-sel-btn--survival:hover:not(:disabled) {
            border-color: var(--color-accent-orange);
        }
        .view-sel-btn.active {
            background: var(--color-primary);
            color: white;
            border-color: var(--color-primary);
        }
        .view-sel-btn--survival.active {
            background: var(--color-accent-orange);
            color: white;
            border-color: var(--color-accent-orange);
        }
        .view-sel-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }
        .vsb-title { font-size: 0.8rem; font-weight: 700; line-height: 1.15; }
        /* Desktop: both groups share ONE grid (3 columns: incidence 1-2,
           survival 3), so each button row is as tall as its tallest button
           across both groups. Rows stay single-line height and grow only when
           a label actually wraps — and then the survival button in that row
           grows with it. Phones keep the stacked group layout below. */
        @media (min-width: 641px) {
            .chart-view-selector {
                display: grid;
                grid-template-columns: 1fr 1fr 1fr;
                grid-auto-rows: auto;
                column-gap: 0.45rem;
                row-gap: 0.4rem;
                align-items: stretch;
            }
            .chart-view-selector .cvs-group,
            .chart-view-selector .cvs-btns { display: contents; }
            .cvs-group--incidence .view-group-header { grid-area: 1 / 1 / 2 / 3; }
            .cvs-group--survival  .view-group-header { grid-area: 1 / 3 / 2 / 4; }
            .cvs-group--incidence .view-sel-btn:nth-child(1) { grid-area: 2 / 1; }
            .cvs-group--incidence .view-sel-btn:nth-child(2) { grid-area: 2 / 2; }
            .cvs-group--incidence .view-sel-btn:nth-child(3) { grid-area: 3 / 1; }
            .cvs-group--incidence .view-sel-btn:nth-child(4) { grid-area: 3 / 2; }
            .cvs-group--survival  .view-sel-btn:nth-child(1) { grid-area: 2 / 3; }
            .cvs-group--survival  .view-sel-btn:nth-child(2) { grid-area: 3 / 3; }
        }
        /* URL warning banner */
        #urlWarningBanner { border-radius: 8px; background: #fffbeb; border: 1px solid #f59e0b; }
        .url-warning-content { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.65rem 0.85rem; }
        .url-warning-icon { font-size: 1rem; color: #d97706; flex-shrink: 0; margin-top: 1px; }
        .url-warning-messages { flex: 1; font-size: 0.8125rem; color: #92400e; line-height: 1.5; }
        .url-warning-messages p { margin: 0; }
        .url-warning-messages p + p { margin-top: 0.2rem; }
        .url-warning-close { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: #92400e; padding: 0; line-height: 1; flex-shrink: 0; opacity: 0.7; }
        .url-warning-close:hover { opacity: 1; }
        /* Unavailable view placeholder */
        .unavailable-view-placeholder { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:380px; gap:1rem; padding:2rem; text-align:center; }
        .unavailable-view-icon { color:var(--color-gray-300); }
        .unavailable-view-title { font-size:1.05rem; font-weight:700; color:var(--color-gray-600); margin:0; }
        .unavailable-view-desc { font-size:0.875rem; color:var(--color-gray-500); max-width:380px; margin:0; line-height:1.6; }
        /* Description line below grid */
        .chart-view-info {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 0.75rem;
            padding: 0.45rem 0.1rem 0;
            margin-top: 0.35rem;
            border-top: 1px solid var(--color-gray-200);
        }
        .chart-view-info__text {
            display: flex;
            align-items: baseline;
            gap: 0.5rem;
            flex: 1 1 0;
            min-width: 0;
        }
        .chart-view-info__title {
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--color-primary);
            white-space: nowrap;
            flex-shrink: 0;
        }
        .chart-view-info__desc {
            font-size: 0.75rem;
            color: var(--color-gray-500);
            line-height: 1.5;
        }
        /* Toolbar inline inside info row */
        .chart-toolbar--inline {
            box-shadow: none;
            border: 1px solid var(--color-gray-200);
            padding: 0.2rem 0.4rem;
            flex-shrink: 0;
        }
        .filter-section-label {
            display: block;
            margin-bottom: 0.3rem;
            font-weight: 600;
            color: var(--color-gray-500);
            font-size: 0.8rem;
            letter-spacing: 0.06em;
            text-transform: uppercase;
        }
        .filter-section-label.has-info {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            position: relative;
            margin-bottom: 0.45rem;
        }
        .filter-info-button {
            width: 18px;
            height: 18px;
            border: 1px solid #fdba74;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--color-accent-orange-tint) 0%, #ffedd5 100%);
            color: #c2410c;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 0.68rem;
            font-weight: 800;
            line-height: 1;
            cursor: help;
            padding: 0;
            box-shadow: 0 1px 2px rgba(2, 33, 54, 0.12);
            transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
        }
        .filter-info-button:hover,
        .filter-info-button:focus-visible {
            border-color: var(--color-accent-orange);
            color: #9a3412;
            background: var(--color-accent-orange-tint);
            outline: none;
        }
        .filter-info-tooltip {
            /* display:none removes it from layout entirely while hidden — with only
               opacity:0 (no display toggle), these tooltips still occupy their full
               box (some are 500px+ tall, long explanatory text) and, being absolutely
               positioned with nothing clipping the overflow, were stretching the
               whole page's scrollable height far past the visible footer. */
            display: none;
            position: absolute;
            top: calc(100% + 10px);
            left: 0;
            min-width: 280px;
            max-width: 560px;
            padding: 0.85rem 0.95rem;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: linear-gradient(165deg, var(--color-primary-deep) 0%, var(--color-primary) 75%);
            color: var(--color-gray-100);
            font-size: 0.76rem;
            font-weight: 400;
            letter-spacing: normal;
            text-transform: none;
            line-height: 1.55;
            white-space: pre-line;
            box-shadow: 0 14px 32px rgba(2, 6, 23, 0.34);
            z-index: 320;
            opacity: 0;
            pointer-events: none;
            transform: translateY(-6px);
            transition: opacity 0.14s ease, transform 0.14s ease;
        }
        .filter-info-tooltip::before {
            content: "";
            position: absolute;
            top: -7px;
            left: 12px;
            width: 12px;
            height: 12px;
            background: var(--color-primary-deep);
            border-left: 1px solid rgba(255, 255, 255, 0.12);
            border-top: 1px solid rgba(255, 255, 255, 0.12);
            transform: rotate(45deg);
        }
        .filter-section-label.has-info:hover .filter-info-tooltip,
        .filter-section-label.has-info:focus-within .filter-info-tooltip,
        .rates-indicator-label.has-info .filter-info-button:hover + .filter-info-tooltip,
        .rates-indicator-label.has-info .filter-info-button:focus + .filter-info-tooltip {
            display: block;
            opacity: 1;
            transform: translateY(0);
        }
        /* Per-indicator (i): the tooltip opens from the button only — hovering the
           row to tick its checkbox should not cover the rows below. */
        .rates-indicator-label.has-info {
            position: relative;
        }
        .rates-indicator-label .filter-info-button {
            width: 16px;
            height: 16px;
            font-size: 0.62rem;
            flex-shrink: 0;
            margin-left: auto; /* pinned to the right end of the row */
        }
        /* Anchored to the right edge, so the arrow sits under the (i) */
        .rates-indicator-label .filter-info-tooltip {
            left: auto;
            right: -4px;
        }
        .rates-indicator-label .filter-info-tooltip::before {
            left: auto;
            right: 6px; /* 16px button: centre at 8px from the row edge (+4px offset) */
        }

        /* ── Dashboard layout ── */
        #gridLayout {
            display: grid;
            grid-template-columns: 305px 1fr;
            gap: 1.25rem;
            align-items: start;
        }
        #filtersColumn { grid-row: 1 / -1; }

        /* ── Filter panel ── */
        #filtersColumn {
            background: white;
            border-radius: 10px;
            border: 1px solid var(--color-gray-200);
            overflow: visible;
        }
        .filter-mobile-header {
            display: none;
            align-items: center;
            justify-content: space-between;
            padding: 0.75rem 1rem;
            background: var(--color-primary);
            color: white;
            font-size: 0.875rem;
            font-weight: 600;
            cursor: pointer;
        }
        .filter-mobile-header svg { transition: transform 0.2s; }
        /* Keyboard-reachable close affordance inside the mobile header. */
        .filter-mobile-close {
            display: flex;
            padding: 0;
            background: transparent;
            border: none;
            color: inherit;
            cursor: pointer;
        }
        .filter-tab-bar {
            display: flex;
            border-bottom: 1px solid var(--color-gray-200);
        }
        .filter-tab-btn {
            flex: 1;
            padding: 0.45rem 0.75rem;
            background: transparent;
            border: none;
            border-bottom: 2px solid transparent;
            cursor: pointer;
            font-weight: 600;
            font-size: 0.85rem;
            color: var(--color-gray-500);
            transition: all 0.15s;
        }
        .filter-tab-btn.active {
            color: var(--color-primary);
            border-bottom-color: var(--color-primary);
            background: transparent;
        }
        .filter-tab-pane {
            display: none;
            padding: 0;
        }
        .filter-tab-pane.active { display: block; }
        .filter-section {
            padding: 0.75rem 0.875rem;
            border-top: 1px solid var(--color-gray-200);
        }
        .filter-section:first-child { border-top: none; }
        /* Compact sections when in mobile drawer */
        @media (max-width: 900px) {
            .filter-section { padding: 0.55rem 0.75rem; }
        }
        /* ── Chart area cards ── */
        .view-card {
            background: transparent;
            border-radius: 0;
            border: none;
            padding: 0;
            min-height: 420px;
            box-sizing: border-box;
            width: 100%;
        }
        .view-empty-state {
            text-align: center;
            color: var(--color-gray-300);
        }
        .view-empty-state svg { display: block; margin: 0 auto 1rem; opacity: 0.4; }
        .view-empty-state p { margin: 0; font-size: 0.875rem; color: var(--color-gray-500); }

        /* ── Mobile filter drawer ── */
        .mobile-filter-fab {
            display: none;
            position: fixed;
            bottom: 1.5rem;
            right: 1.25rem;
            z-index: 600;
            align-items: center;
            gap: 0.5rem;
            padding: 0.65rem 1.1rem;
            background: var(--color-primary);
            color: white;
            border: none;
            border-radius: 24px;
            font-size: 0.875rem;
            font-weight: 600;
            cursor: pointer;
            background: var(--color-accent-orange);
            box-shadow: 0 4px 16px rgba(255,97,0,0.40);
            transition: transform 0.15s, box-shadow 0.15s;
        }
        .mobile-filter-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,97,0,0.5); }

        /* ── Chart Export Toolbar ─────────────────────────────────────────────── */
        #chartExportToolbar {
            display: flex;
            justify-content: flex-end;
            flex-shrink: 0;
            align-self: flex-start;
            padding-top: 0.1rem;
        }
        @media (max-width: 968px) {
            /* Matches mobile.css's #filtersColumn hide breakpoint (968px) so
               the drawer/FAB replacement is always available exactly when the
               desktop sidebar disappears — no dead zone in between. */
            /* Toolbar wraps below description on tablet */
            .chart-view-info {
                flex-direction: column;
                gap: 0.5rem;
            }
            #chartExportToolbar {
                justify-content: flex-start;
                align-self: auto;
            }
            #gridLayout {
                grid-template-columns: 1fr;
            }
            /* Override old mobile.css rules that assumed a different layout */
            #filtersColumn,
            #gridLayout > div:first-child,
            #gridLayout > div:nth-child(2),
            #gridLayout > div:nth-child(3),
            #gridLayout > div:last-child {
                display: revert !important;
            }
            /* Drawer behaviour */
            #filtersColumn {
                display: block !important;
                position: fixed;
                top: 0;
                left: 0;
                bottom: 0;
                width: min(88vw, 320px);
                z-index: 1010;
                border-radius: 0 12px 12px 0;
                overflow-y: auto;
                overflow-x: hidden;
                transform: translateX(-105%);
                transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
                background: white;
                border-right: 1px solid var(--color-gray-200);
                box-shadow: none;
            }
            #filtersColumn.is-open {
                transform: translateX(0);
                box-shadow: 6px 0 32px rgba(2,33,54,0.18);
            }
            .filter-mobile-header { display: flex; }
            .mobile-filter-fab { display: flex; }
        }

        /* ── Desktop sidebar collapse (FilterCollapse in dashboardChrome.js) ── */
        .filter-collapse-btn {
            display: flex;
            justify-content: flex-end;
            width: 100%;
            padding: 0.4rem 0.875rem;
            background: transparent;
            border: none;
            border-bottom: 1px solid var(--color-gray-200);
            border-radius: 10px 10px 0 0;
            cursor: pointer;
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--color-gray-500);
            transition: color 0.15s, background 0.15s;
        }
        .filter-collapse-btn:hover,
        .filter-collapse-btn:focus-visible {
            color: var(--color-primary);
            background: color-mix(in srgb, var(--color-primary) 5%, white);
        }
        .fcb-expanded {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
        }
        .fcb-collapsed { display: none; }
        @media (min-width: 969px) {
            #gridLayout { transition: grid-template-columns 0.25s cubic-bezier(0.4,0,0.2,1); }
            #gridLayout.filters-collapsed { grid-template-columns: 44px 1fr; }
            /* Only the toggle stays — it becomes the vertical rail */
            #gridLayout.filters-collapsed #filtersColumn > :not(.filter-collapse-btn) { display: none; }
            #gridLayout.filters-collapsed #filtersColumn { position: sticky; top: 1rem; }
            #gridLayout.filters-collapsed .filter-collapse-btn {
                justify-content: center;
                padding: 0.85rem 0;
                border-bottom: none;
                border-radius: 10px;
                color: var(--color-primary);
            }
            #gridLayout.filters-collapsed .fcb-expanded { display: none; }
            #gridLayout.filters-collapsed .fcb-collapsed {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 0.6rem;
            }
            .fcb-collapsed__label {
                writing-mode: vertical-rl;
                transform: rotate(180deg);
                font-size: 0.72rem;
                font-weight: 700;
                letter-spacing: 0.07em;
                text-transform: uppercase;
            }
        }
        @media (max-width: 968px) {
            .filter-collapse-btn { display: none; }
        }

        /* ── Fullscreen chart (ChartFullscreen in dashboardChrome.js) ──
           !important beats #chartsContainer's inline card styles and the
           mobile.css min-height/margin overrides. */
        #chartsContainer.is-fullscreen {
            position: fixed !important;
            inset: 0;
            z-index: 1100;
            margin: 0 !important;
            min-height: 0 !important;
            border: none !important;
            border-radius: 0 !important;
            padding: 1.5rem 2rem !important;
            overflow: auto;
            background: white;
        }
        body.chart-fullscreen-open { overflow: hidden; }
        /* Body-anchored chart tooltips (createD3Tooltip) ship with inline z-index 1000 */
        body.chart-fullscreen-open .d3-tooltip { z-index: 1200 !important; }
        .chart-fullscreen-close {
            position: fixed;
            top: 0.75rem;
            right: 0.75rem;
            z-index: 1150;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            padding: 0;
            background: white;
            border: 1px solid var(--color-gray-200);
            border-radius: 50%;
            box-shadow: 0 2px 8px rgba(2,33,54,0.12);
            color: var(--color-primary);
            font-size: 22px;
            line-height: 1;
            cursor: pointer;
        }
        .chart-fullscreen-close:hover,
        .chart-fullscreen-close:focus-visible {
            background: color-mix(in srgb, var(--color-primary) 8%, white);
        }
        @media (max-width: 640px) {
            #chartsContainer.is-fullscreen { padding: 3rem 0.75rem 1rem !important; }
        }

        /* ── Full-width disease-group bar (hu/dashboard_test.html only) ──
           Buttons are the regular .filter-button-small from renderDiseaseGroupButtons,
           enlarged into tabs and coloured by the group (--group-color). */
        .disease-group-bar {
            display: flex;
            align-items: center;
            gap: 1rem;
            margin-bottom: 1rem;
            padding: 0.6rem 0.875rem;
            background: white;
            border: 1px solid var(--color-gray-200);
            border-radius: 10px;
        }
        .disease-group-bar__label {
            flex-shrink: 0;
            font-size: 0.68rem;
            font-weight: 700;
            letter-spacing: 0.07em;
            text-transform: uppercase;
            color: var(--color-primary);
        }
        .disease-group-bar__buttons {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            min-width: 0;
        }
        .disease-group-bar .filter-button-small {
            padding: 0.45rem 1rem;
            border-radius: 7px;
            border-left: 4px solid var(--group-color);
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--color-primary);
        }
        .disease-group-bar .filter-button-small:hover {
            border-color: var(--group-color);
            color: var(--group-color);
            background: color-mix(in srgb, var(--group-color) 8%, white);
        }
        .disease-group-bar .filter-button-small.active {
            border-color: var(--group-color);
            background: var(--group-color);
            color: white;
        }
        @media (max-width: 640px) {
            .disease-group-bar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
            .disease-group-bar .filter-button-small { flex: 1 1 auto; min-height: 44px; }
        }

        /* ── Chart header (buildChartHeader): disease logo tile + title/subtitle ── */
        /* Bleeds into the card's top-left corner (#chartsContainer padding is
           1rem): the tile fills the corner, the title + filters sit beside it. */
        .chart-header {
            --tile: 84px;              /* square logo tile; bigger on wide screens */

            display: flex;
            align-items: flex-start;
            margin: -1rem -1rem 1.1rem;
            text-align: left;
        }
        /* Logo tile in the disease colour; ink (icon + text) is white, or dark
           navy on the light disease colours (.chart-header--ink-dark). */
        .chart-header__disease {
            flex: 0 0 var(--tile);
            width: var(--tile);
            height: var(--tile);       /* 1:1 */
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 0.2rem;
            padding: 0.4rem 0.3rem;
            border-radius: 10px 0 0 10px; /* left corners rounded, right side square */
            background: var(--disease-color, var(--color-primary));
            text-align: center;
            color: #fff;
        }
        .chart-header--ink-dark .chart-header__disease { color: var(--color-primary); }
        .chart-header__icon {
            width: 30px;
            height: 30px;
            display: block;
            margin-bottom: 0.1rem;
            /* the icon SVGs are dark navy: white on the tile, kept navy on light tiles */
            filter: brightness(0) invert(1);
        }
        .chart-header--ink-dark .chart-header__icon { filter: none; }
        .chart-header__diag {
            font-size: 0.56rem;
            font-weight: 700;
            line-height: 1.15;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            overflow-wrap: normal;     /* wrap between words only */
        }
        .chart-header__diag--long { font-size: 0.5rem; letter-spacing: 0.02em; }
        .chart-header__code {
            font-size: 0.52rem;
            font-weight: 600;
            line-height: 1;
            letter-spacing: 0.06em;
            opacity: 0.8;
        }
        .chart-header__text {
            flex: 1 1 auto;
            min-width: 0;
            display: flex;
            flex-direction: column;
            justify-content: center; /* title + filters centred on the tile */
            box-sizing: border-box;
            min-height: var(--tile);   /* centred on the tile's full height */
            padding: 0.5rem 0 0.5rem 1.4rem;
        }
        /* Fullscreen pads the card differently and puts the close button in the
           corner — no bleed there, a free-standing tile instead. */
        #chartsContainer.is-fullscreen .chart-header { margin: 0 0 1.1rem; }
        #chartsContainer.is-fullscreen .chart-header__disease { border-radius: 12px 0 0 12px; }
        .chart-header__title {
            margin: 0 0 0.3rem;
            color: var(--color-primary);
            font-size: 1.2rem;
            font-weight: 600;
            line-height: 1.25;
        }
        .chart-header__subtitle {
            margin: 0;
            color: var(--color-gray-500);
            font-size: 0.78rem;
            line-height: 1.4;
        }
        @media (min-width: 1280px) {
            .chart-header { --tile: 96px; }
            .chart-header__icon { width: 36px; height: 36px; }
            .chart-header__diag { font-size: 0.6rem; }
            .chart-header__diag--long { font-size: 0.54rem; }
        }
        @media (max-width: 480px) {
            .chart-header { --tile: 64px; }
            .chart-header__disease { padding: 0.3rem 0.2rem; }
            .chart-header__text { padding: 0.4rem 0 0.4rem 1rem; }
            .chart-header__icon { width: 24px; height: 24px; }
            .chart-header__diag { font-size: 0.5rem; }
            .chart-header__diag--long { font-size: 0.42rem; letter-spacing: 0; }
            .chart-header__title { font-size: 1rem; }
        }

        /* ── Chart Export Toolbar (styles above) ──────────────────────────────── */
        .chart-toolbar {
            display: flex;
            align-items: center;
            gap: 0.15rem;
            background: white;
            border: 1px solid var(--color-gray-200);
            border-radius: 8px;
            padding: 0.28rem 0.5rem;
            box-shadow: 0 1px 2px rgba(0,0,0,0.06);
        }
        .chart-toolbar-label {
            font-size: 0.65rem;
            font-weight: 700;
            color: var(--color-gray-400);
            margin-right: 0.2rem;
            text-transform: uppercase;
            letter-spacing: 0.07em;
            white-space: nowrap;
        }
        .chart-toolbar-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 0.12rem;
            padding: 0.3rem 0.42rem;
            background: transparent;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            color: var(--color-primary);
            font-size: 0.6rem;
            font-weight: 700;
            letter-spacing: 0.04em;
            line-height: 1;
            transition: background 0.13s, color 0.13s;
            min-width: 36px;
        }
        .chart-toolbar-btn:hover:not(:disabled) {
            background: color-mix(in srgb, var(--color-primary) 8%, white);
        }
        .chart-toolbar-btn:disabled {
            opacity: 0.28;
            cursor: not-allowed;
        }
        .chart-toolbar-btn--feedback {
            color: #16a34a !important;
            background: #f0fdf4 !important;
            overflow: hidden;
        }
        .chart-toolbar-btn .tb-label {
            overflow: hidden;
            max-width: 100%;
            white-space: nowrap;
        }
        .chart-toolbar-sep {
            width: 1px;
            height: 22px;
            background: var(--color-gray-200);
            margin: 0 0.18rem;
            flex-shrink: 0;
        }
        /* ── Tour help button ─────────────────────────────────────────────── */
        .chart-toolbar-btn--tour {
            color: var(--color-accent-orange);
        }
        .chart-toolbar-btn--tour:hover,
        .chart-toolbar-btn--tour:focus-visible {
            background: var(--color-accent-orange-tint);
            color: #c2410c;
        }
        /* ── Mobile dashboard layout ─────────────────────────────────────────── */
        @media (max-width: 640px) {
            /* View selector: groups stack vertically, each full width */
            .chart-view-selector { flex-direction: column; }
            .cvs-group--incidence,
            .cvs-group--survival  { width: 100%; flex: none; }
            /* Survival: side-by-side on mobile too */
            .cvs-group--survival .cvs-btns { grid-template-columns: 1fr 1fr; }

            /* View info: title on own line above description */
            .chart-view-info__text {
                flex-direction: column;
                align-items: flex-start;
                gap: 0.15rem;
            }
            .chart-view-info__title {
                white-space: normal;
                padding-bottom: 0.2rem;
            }
            .chart-toolbar--inline {
                width: 100%;
                justify-content: flex-start;
            }
            /* .chart-toolbar-label { display: none; } */

            .chart-toolbar-btn {
                min-height: 44px;
                min-width: 44px;
                padding: 0.5rem 0.6rem;
                font-size: 0.7rem;
            }
        }
        @media (max-width: 480px) {
            .chart-toolbar-label { display: none; }
        }
    
/* ── Driver.js product tour — brand theme overrides ─────────────────────────
   Driver.js 1.4.0 (MIT) — https://driverjs.com/docs/theming
   ──────────────────────────────────────────────────────────────────────────── */
:root {
    --driver-popover-bg-color:          var(--color-primary-deep);
    --driver-popover-title-color:       var(--color-gray-100);
    --driver-popover-description-color: var(--color-gray-300);
    --driver-popover-progress-color:    var(--color-accent-orange);
    --driver-popover-border-radius:     10px;
    --driver-overlay-color:             rgba(2, 33, 54, 0.72);
}
.driver-popover {
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 16px 40px rgba(2, 6, 23, 0.45);
    font-family: 'DM Sans', sans-serif !important;
    font-size: 0.82rem !important;
    line-height: 1.55;
    max-width: 340px;
}
.driver-popover-title {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    letter-spacing: 0em;
    margin-bottom: 0.4rem;
    padding: 0;
}
.driver-popover-description {
    white-space: pre-line;
    font-family: 'DM Sans', sans-serif !important;
    font-size: 0.82rem !important;
    font-weight: 400 !important;
    padding: 0;
    margin: 0;
}
.driver-popover-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding: 0.55rem 0 0 0;
    background: transparent !important;
    border-top: 1px solid var(--color-gray-200);
}
/* Selectors are prefixed with .driver-popover (0,2,x) so they beat the vendor
   driver-1.4.0.css rules (same-specificity, loaded later; its :focus/:hover
   background and white text-shadow otherwise win and double the label). */
.driver-popover .driver-popover-footer button {
    background: var(--color-white);
    border: 1.5px solid var(--color-gray-300);
    color: var(--color-gray-700);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    padding: 0.35rem 0.8rem;
    text-shadow: none;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.driver-popover .driver-popover-footer button:not(.driver-popover-next-btn):hover,
.driver-popover .driver-popover-footer button:not(.driver-popover-next-btn):focus {
    background: var(--color-gray-100);
    border-color: var(--color-gray-500);
}
.driver-popover .driver-popover-footer button.driver-popover-next-btn,
.driver-popover .driver-popover-footer button.driver-popover-next-btn:focus {
    background: var(--color-accent-orange);
    border-color: var(--color-accent-orange);
    color: var(--color-white);
    font-weight: 500 !important;
}
.driver-popover .driver-popover-footer button.driver-popover-next-btn:hover {
    background: #e55500;
    border-color: #e55500;
}
.driver-popover-progress-text {
    color: #94a3b8;
    font-size: 0.72rem;
    align-self: center;
    margin: 0;
}

/* ── Chart source citation ── */
.chart-source-citation {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-skeleton-dark);
    font-size: 0.75rem;
    color: var(--color-text-muted-dark);
    line-height: 1.5;
}

.chart-source-citation em {
    font-style: italic;
    color: var(--color-text-muted-dark);
}

.chart-source-citation a {
    color: var(--color-text-muted-dark) !important;
    text-decoration: underline;
    transition: color 0.15s;
}

.chart-source-citation a:hover {
    color: #333 !important;
}

/* Mobile responsiveness for citation */
@media (max-width: 768px) {
    .chart-source-citation {
        font-size: 0.7rem;
        padding-top: 0.5rem;
        margin-top: 0.75rem;
    }
}

/* Sticky footer layout (replaces Tailwind's h-full / flex flex-col min-h-screen / flex-grow) */
html.full-height {
    height: 100%;
}

body.sticky-footer-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main.sticky-footer-main {
    flex: 1 0 auto;
}