/* ==========================================================================
   Tokens live in frontend/theme.py and are injected as :root custom
   properties after this stylesheet loads (see app.index_string).
   ========================================================================== */

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-400-normal.woff2?v=5.3.0") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-500-normal.woff2?v=5.3.0") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-600-normal.woff2?v=5.3.0") format("woff2");
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-bg-body);
    accent-color: var(--color-primary);
}

::selection {
    background-color: var(--color-selection);
    color: var(--color-ink);
}

/* Figures in tables, totals and charts line up digit for digit. */
table,
.total-display,
.rankings-stat,
.mobile-ranking-row__meta,
.js-plotly-plot .main-svg text {
    font-variant-numeric: tabular-nums;
}

/* Plotly writes its default face inline; keep chart text in the UI face. */
.js-plotly-plot .main-svg text {
    font-family: var(--font-sans) !important;
}

/* One visible focus treatment for every keyboard-reachable control. Bootstrap
   sets outline: 0 on form controls and nav links, so this rule must win. */
:focus-visible:not(#main-content) {
    outline: 2px solid var(--color-focus) !important;
    outline-offset: 2px;
}

.nav-link:focus-visible,
.form-control:focus-visible {
    box-shadow: none;
}

/* A date input's calendar button is its own Tab stop; with focus there the
   input shows no ring, so the button carries it. */
input[type="date"]::-webkit-calendar-picker-indicator:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
    border-radius: 2px;
}

.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1000;
    padding: 10px 16px;
    border-radius: var(--radius-control);
    background-color: var(--color-ink);
    color: var(--color-bg-body);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus,
.skip-link:focus-visible {
    color: var(--color-bg-body);
    transform: none;
}

#main-content:focus {
    outline: none;
}

/* ==========================================================================
   Typography & Base Styles
   (Consolidated from legacy app.css - Skeleton CSS framework subset)
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0;
    color: var(--color-text);
    font-weight: 500;
    letter-spacing: normal;
    text-wrap: balance;
}

h1 { font-size: 2.25rem; line-height: 1.2; margin-bottom: 1.25rem; }
h2 { font-size: 1.5rem; line-height: 1.3; margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.25rem; line-height: 1.35; margin-top: 1.5rem; margin-bottom: 0.5rem; }
h4 { font-size: 1.125rem; line-height: 1.4; margin-top: 1.25rem; margin-bottom: 0.5rem; }
h5 { font-size: 1rem; line-height: 1.5; margin-top: 1rem; margin-bottom: 0.5rem; }
h6 { font-size: 0.875rem; line-height: 1.5; margin-bottom: 0.5rem; }

.about-content {
    max-width: 72ch;
}

/* Running prose keeps a 65-75 character line. Plex's average letter is
   narrower than its "0", so 72ch let paragraphs run to about 90 characters;
   tables beside them keep the wider container. */
.about-content p,
.about-content li,
.prerender__body p,
.prerender__body li,
.rankings-quality p {
    max-width: 60ch;
}

p {
    margin-top: 0;
}

/* Blockquotes - used in About page markdown */
blockquote {
    border-left: 1px solid var(--color-border);
    padding-left: 1rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    margin-left: 0;
}

code {
    color: var(--color-text);
    background-color: rgba(var(--color-text-rgb), 0.08);
    padding: 0.1em 0.3em;
    border-radius: 4px;
}

/* Links */
a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 0.18em;
    cursor: pointer;
}

a:hover {
    color: var(--color-primary-hover);
}

/* Lists */
ul {
    list-style: circle inside;
}

ol {
    list-style: decimal inside;
}

ol, ul {
    padding-left: 0;
    margin-top: 0;
}

ul ul, ul ol, ol ol, ol ul {
    margin: 1.5rem 0 1.5rem 3rem;
    font-size: 90%;
}

li {
    margin-bottom: 1rem;
}

p, ul, ol {
    margin-bottom: 0.75rem;
}

/* Tables */
table {
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

th:first-child, td:first-child {
    padding-left: 0;
}

th:last-child, td:last-child {
    padding-right: 0;
}

/* Horizontal rule */
hr {
    margin-top: 3rem;
    margin-bottom: 3.5rem;
    border-width: 0;
    border-top: 1px solid var(--color-border-light);
}

/* Clearfix utilities */
.container:after,
.row:after,
.u-cf {
    content: "";
    display: table;
    clear: both;
}

/* Note: .app__container margin now handled by Bootstrap classes (px-4 py-3) in layouts/main.py */

/* ==========================================================================
   dbc Component Overrides - Beige Theme
   Using high-specificity selectors to minimize !important usage
   ========================================================================== */

/* Card components */
.card {
    background-color: var(--color-bg-card);
    border: none;
    box-shadow: none;
    border-radius: var(--radius-card);
}

.card > .card-header {
    background-color: var(--color-bg-card);
    border-bottom: none;
    color: var(--color-text);
    letter-spacing: 0.3rem;
    font-size: 1em;
    font-weight: 600;
    padding: 25px 25px 10px 25px;
}

.card-heading {
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
}

.card > .card-body {
    background-color: var(--color-bg-card);
    padding: 10px 25px 25px 25px;
}

.chart-card-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chart-controls-row {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.chart-controls-row > [class*="col"] {
    min-width: 0;
}

/* Slider labels share the left edge of the date and dropdown labels above
   and below them (.date-range-inputs, .dropdown-container: 25px). */
.chart-controls-row__sliders {
    padding-left: 25px;
}

@media (max-width: 991.98px) {
    .chart-controls-row__sliders {
        padding-left: 0.5rem;
    }
}

.chart-graph-frame {
    /* Contain the absolutely positioned .chart-summary: without a positioned
       frame it escapes a scrolling chart (rankings, phones) and stretches the
       page by the chart's full height. */
    position: relative;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.chart-graph-frame .dash-graph {
    width: 100%;
    min-width: 0;
}

/* Hold each chart's height until Plotly has drawn it: dcc.Graph renders
   nothing, then an unstyled placeholder, while its code loads. Phones use the
   fixed chart heights in the mobile media query instead. */
@media (min-width: 601px) {
    .chart-graph-frame:not(:has(.js-plotly-plot)) {
        min-height: var(--chart-reserved-height, 0);
    }
}

/* Hold the slider controls at their drawn height (label, track and marks)
   while dcc.Slider's code loads; it first renders a shorter placeholder,
   which pushed the controls and charts below it down. */
.slider-control {
    min-height: 66px;
}

/* InputGroup components */
.input-group-text {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.input-group {
    align-items: stretch;
}

/* Date input styling - high specificity to override Bootstrap */
.date-input-container .input-group .form-control,
.date-input-container .input-group .form-control[type="date"],
.date-input-container .input-group input[type="date"] {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    color: var(--color-text);
    min-height: var(--control-height);
    height: auto;
    padding: 6px 10px;
    margin: 0;
    box-sizing: border-box;
    line-height: 1.5;
    align-self: stretch;
}

.date-input-container .input-group .form-control:focus {
    background-color: var(--color-bg-card);
    border-color: var(--color-focus);
    box-shadow: 0 0 0 1px var(--color-focus);
}

/* Unified font styling for form components */
.date-input-container label,
.date-input-container .form-label,
.query-input-container label,
.query-input-container .form-label,
.dropdown-container label {
    font-size: inherit;
    font-weight: 400;
    text-transform: none;
}

.date-input-container .input-group .form-control,
.date-input-container .input-group .btn,
.query-input-container .form-control {
    font-size: inherit;
    font-weight: 400;
    text-transform: none;
}

.query-input-container {
    padding: 5px 25px;
    color: var(--color-text);
}

.query-input-container .form-control {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    color: var(--color-text);
    min-height: var(--control-height);
    height: auto;
    padding: 6px 10px;
    margin: 0;
    box-sizing: border-box;
    line-height: 1.5;
}

.query-input-container .form-control:focus {
    background-color: var(--color-bg-card);
    border-color: var(--color-focus);
    box-shadow: 0 0 0 1px var(--color-focus);
}

.ranking-top-k-control .form-control {
    max-width: 300px;
}

.revenue-option-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
}

.revenue-option-controls .form-check,
.revenue-option-checkbox {
    margin-bottom: 0;
}

/* InputGroup button - connects to input */
.date-input-container .input-group .btn-outline-secondary {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-left: none;
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
    color: var(--color-text);
    min-height: var(--control-height);
    height: auto;
    padding: 6px 12px;
    margin: 0;
    box-sizing: border-box;
    align-self: stretch;
}

.date-input-container .input-group .btn-outline-secondary:hover,
.date-input-container .input-group .btn-outline-secondary:focus-visible {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-bg-light);
}

.btn:focus-visible,
.form-check-input:focus-visible,
.form-select:focus-visible {
    box-shadow: none;
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* Dash 4 core components take the brand accent instead of their default violet. */
:root {
    --Dash-Fill-Interactive-Strong: var(--color-primary);
    --Dash-Fill-Interactive-Weak: rgba(var(--color-primary-rgb), 0.14);
    --Dash-Fill-Primary-Hover: var(--color-primary-hover);
    --Dash-Fill-Primary-Active: var(--color-primary-active);
    --Dash-Text-Primary: var(--color-text);
    --Dash-Text-Strong: var(--color-ink);
    --Dash-Text-Weak: var(--color-text-muted);
}

/* Slider marks beyond the selected value took Dash's translucent disabled
   blue-grey (4.5:1 on the card, at the AA edge and off-palette); the muted
   text token gives 5.9:1 in the theme's brown. */
.dash-slider-mark-outside-selection {
    color: var(--color-text-muted);
}

/* Flatly's grey secondary buttons read at about 2.5:1 on cream. */
.btn-secondary,
.btn-outline-secondary {
    --bs-btn-color: var(--color-text);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: var(--color-border);
    --bs-btn-hover-color: var(--color-bg-light);
    --bs-btn-hover-bg: var(--color-primary);
    --bs-btn-hover-border-color: var(--color-primary);
    --bs-btn-active-color: var(--color-bg-light);
    --bs-btn-active-bg: var(--color-primary-active);
    --bs-btn-active-border-color: var(--color-primary-active);
    --bs-btn-disabled-color: var(--color-text-muted);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--color-border-light);
}

.btn-check:checked + .btn-outline-secondary,
.btn-outline-secondary.active {
    color: var(--color-bg-light);
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Toggle-button groups (frontend/toggles.py): label above, options packed
   6 px apart without Bootstrap's form-check indent, each on one line. */
.toggle-group .form-label {
    display: block;
    margin-bottom: 6px;
}

.toggle-group [role="radiogroup"],
.toggle-group > div:not(.form-label) {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.toggle-group .form-check {
    min-height: 0;
    margin: 0;
    padding-left: 0;
}

/* The touch rules below indent check rows for a visible box; a toggle's input
   is hidden (btn-check), so that indent only pushed the buttons apart. */
.toggle-group .form-check:not(.form-switch) {
    padding-left: 0;
}

.toggle-group .form-check .btn {
    display: inline-flex;
    align-items: center;
    margin: 0 !important;
    white-space: nowrap;
}

.form-check-input {
    border-color: var(--color-border);
    background-color: var(--color-bg-light);
}

.form-check-input:checked {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

/* Flatly's warning alert puts white text on orange (about 2:1). */
.alert-warning {
    --bs-alert-color: var(--color-warning-text);
    --bs-alert-bg: var(--color-warning-bg);
    --bs-alert-border-color: var(--color-warning-border);
    --bs-alert-link-color: var(--color-warning-text);
    color: var(--color-warning-text);
    background-color: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
}

/* Bootstrap's warning text is too light on cream; keep the meaning legible. */
.text-warning {
    color: var(--color-warning-text) !important;
}

.text-danger {
    color: var(--color-danger) !important;
}

/* Primary button styling */
.btn.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn.btn-primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn.btn-primary:active {
    background-color: var(--color-primary-active);
    border-color: var(--color-primary-active);
}

/* Header navigation: plain text links, as on deepdelved.com. The border
   stays (transparent) so the links keep their size and tap area. */
.navbar .nav-link.nav-link-button {
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    color: var(--color-text);
    padding: 4px 10px;
    margin-left: 4px;
    font-size: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
}

.navbar .nav-link.nav-link-button:hover,
.navbar .nav-link.nav-link-button:focus-visible {
    background-color: transparent;
    color: var(--color-ink);
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

/* The page you are on: ink, heavier, with a steady underline. */
.navbar .nav-link.nav-link-button[aria-current="page"] {
    background-color: transparent;
    border-color: transparent;
    color: var(--color-ink);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.3em;
}

/* The language menu and theme toggle are controls, not page links: no underline. */
.navbar .nav-link.lang-menu__toggle:hover,
.navbar .nav-link.theme-toggle:hover {
    text-decoration: none;
}

.app__header {
    display: flex;
    justify-content: space-between;
    color: var(--color-text);
}

/* The wordmark in ink: Bootstrap's navbar-brand painted it pure black (white
   on the dark theme), off the palette. */
.app__header__title,
.app__header__title:hover,
.app__header__title:focus {
    letter-spacing: 0.23rem;
    color: var(--color-ink);
}

.app__header__title--grey {
    color: var(--color-text-muted);
    letter-spacing: normal;
}

.mobile-section-nav {
    display: none;
}

.dropdown-container {
    padding: 10px 25px;
    color: var(--color-text);
}

.date-input-container {
    padding: 5px 25px;
    color: var(--color-text);
}

.date-range-inputs {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 24px;
    padding: 5px 25px;
}

.date-range-inputs .date-input-container {
    flex: 0 1 300px;
    padding: 0;
}

.date-range-inputs .input-group {
    max-width: 300px;
}

#unit-dropdown {
    width: 100%;
    margin-top: 5px;
}

/* ==========================================================================
   Update Button Styling
   ========================================================================== */

.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
    height: 40px;
}

/* ==========================================================================
   Insight Panel Layout
   ========================================================================== */

.insight-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
}

.insight-row__main {
    flex: 1 1 0;
    min-width: 0;
}

.insight-row__panel-col {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    min-width: 320px;
    position: relative;
}

.insight-panel {
    position: relative;
    min-height: 32px;
}

.insight-panel__toggle {
    position: absolute;
    top: 0.25rem;
    left: -14px;
    z-index: 15;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-height: 48px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control) 0 0 var(--radius-control);
    background-color: var(--color-bg-card);
    color: var(--color-text);
    font-family: inherit;
    font-size: 1.45rem;
    line-height: 1;
    font-weight: bold;
    cursor: pointer;
}

/* Desktop rail: a drawn chevron points the way the panel will move. */
@media (min-width: 992px) {
    .insight-panel__toggle::before {
        content: "";
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: translateX(-1px) rotate(-45deg);
    }

    .insight-panel__toggle[aria-expanded="false"]::before {
        transform: translateX(1px) rotate(135deg);
    }
}

.insight-panel__toggle:hover,
.insight-panel__toggle:focus-visible {
    background-color: var(--color-primary);
    color: var(--color-bg-light);
}

.insight-panel__content {
    width: 100%;
}

.insight-panel__content > .card {
    width: 100%;
}

.insight-row--collapsed .insight-row__panel-col {
    flex-basis: 28px;
    max-width: 28px;
    min-width: 28px;
}

.insight-row--collapsed .insight-panel__toggle {
    left: 0;
    border-radius: var(--radius-control) 0 0 var(--radius-control);
}

.insight-row--collapsed .insight-panel__content {
    display: none;
}

.mobile-ranking-list-frame {
    display: none;
}

/* The ranking chart draws asset names (left) and £/MW/yr, MW and participation
   (right) as fixed columns about 650px wide together; below 1100px that left
   the bars too little room and their labels collided. Tablets and narrow
   windows get the compact list phones use, with the same figures per row. */
@media only screen and (max-width: 1099.98px) {
    .ranking-graph-frame {
        display: none;
    }

    .mobile-ranking-list-frame {
        display: block;
        margin-top: 10px;
    }
}

.mobile-ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-ranking-list--empty {
    color: var(--color-text-muted);
    padding: 12px 0;
}

.mobile-ranking-list__note {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    text-align: center;
}

.mobile-ranking-row {
    border: 1px solid rgba(var(--color-text-rgb), 0.22);
    border-radius: var(--radius-tile);
    background-color: rgba(255, 255, 255, 0.18);
    padding: 10px 12px;
}

.mobile-ranking-row__primary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.mobile-ranking-row__rank {
    flex: 0 0 auto;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.mobile-ranking-row__name {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-ranking-row__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 0.82rem;
}

.mobile-ranking-strip {
    display: flex;
    width: 100%;
    height: 8px;
    overflow: hidden;
    margin-top: 8px;
    border-radius: var(--radius-pill);
    background-color: rgba(var(--color-text-rgb), 0.12);
}

.mobile-ranking-strip--empty {
    background-color: rgba(var(--color-text-rgb), 0.08);
}

.mobile-ranking-strip__segment {
    display: block;
    min-width: 2px;
    height: 100%;
}

.mobile-ranking-strip__segment--negative {
    opacity: 0.72;
}

/* ==========================================================================
   Date Input Base Styling
   ========================================================================== */

/* Base styling for all date inputs */
input[type="date"] {
    background-color: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    padding: 6px 10px;
    font-family: inherit;
    min-height: var(--control-height);
    height: auto;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* ==========================================================================
   Loading Indicators
   ========================================================================== */

._dash-loading {
    margin: 50px auto;
    color: var(--color-primary);
}

/* The label is generated content (app.app_entry), so it is not page text. */
._dash-loading::after {
    content: attr(data-label);
}

._dash-loading-callback {
    border: 3px solid rgba(var(--color-primary-rgb), 0.3);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media only screen and (max-width: 991.98px) {
    .insight-row {
        display: block;
    }

    .insight-row__panel-col {
        max-width: none;
        min-width: 0;
        width: 100%;
    }

    .insight-row--collapsed .insight-row__panel-col {
        max-width: none;
        min-width: 0;
        width: 100%;
    }

    .insight-panel__toggle,
    .insight-row--collapsed .insight-panel__toggle {
        position: relative;
        top: auto;
        left: auto;
        width: 32px;
        min-height: 32px;
        margin-bottom: 0.75rem;
        border-radius: var(--radius-control);
        box-shadow: none;
    }

    .chart-controls-row {
        row-gap: 12px;
    }

    .chart-controls-row > [class*="col"] {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }

    .chart-controls-row .text-end {
        text-align: left !important;
        padding-left: 0.5rem !important;
    }

    /* The stacked total arrives after the first callback; keep its line. */
    .chart-controls-row .chart-total {
        min-height: 1.5em;
    }

    .date-range-inputs {
        gap: 12px;
    }
}

@media only screen and (max-width: 600px) {
    .app__container.container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
        padding-top: 10px !important;
    }

    .app__header {
        display: flex;
        flex-direction: column;
        margin-bottom: 8px;
    }

    .app__header .container-fluid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding-left: 0;
        padding-right: 0;
    }

    .app__header__desc {
        text-align: center;
    }

    /* The subtitle is the home page's H1 and value proposition: keep it
       readable on phones rather than visually hidden. */
    .app__header__title--grey {
        margin-top: 2px;
        font-size: 1rem;
        line-height: 1.35;
    }


    .navbar .navbar-nav {
        flex-direction: row;
        justify-content: center;
        width: 100%;
    }

    .navbar .nav-link.nav-link-button {
        min-height: var(--touch-target);
        padding: 6px 12px;
        margin-left: 4px;
        margin-right: 4px;
        font-size: 0.9rem;
    }

    .app__header__title {
        font-size: 1.5em;
        padding-top: 8px;
        text-align: center;
    }

    .mobile-section-nav {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        gap: 6px;
        justify-content: space-between;
        margin: 8px 0 12px 0;
        padding: 6px;
        border: 1px solid rgba(var(--color-text-rgb), 0.18);
        border-radius: var(--radius-tile);
        background-color: var(--color-bg-card);
    }

    .mobile-section-nav__link {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1 1 0;
        min-width: 0;
        min-height: var(--touch-target);
        padding: 7px 6px;
        border-radius: var(--radius-control);
        color: var(--color-text);
        font-size: 0.86rem;
        font-weight: 600;
        text-align: center;
        text-decoration: none;
    }

    .mobile-section-nav__link:hover,
    .mobile-section-nav__link:focus-visible {
        background-color: var(--color-primary);
        color: var(--color-bg-light);
        text-decoration: none;
    }

    .dashboard-section {
        scroll-margin-top: 58px;
    }

    .card {
        border-radius: var(--radius-tile);
    }

    .card > .card-header {
        letter-spacing: 0.18rem;
        padding: 18px 16px 8px 16px;
        font-size: 0.9rem;
    }

    .card > .card-body {
        padding: 8px 12px 18px 12px;
    }


    .dropdown-container {
        padding: 6px 4px 10px 4px;
    }

    .date-range-inputs {
        padding: 4px;
        gap: 8px;
    }

    .date-range-inputs .date-input-container {
        flex-basis: 100%;
    }

    .date-range-inputs .input-group,
    .date-range-inputs .date-input-container {
        max-width: none;
        width: 100%;
    }

    .date-input-container .input-group .form-control,
    .date-input-container .input-group .form-control[type="date"],
    .date-input-container .input-group input[type="date"] {
        min-width: 0;
        min-height: var(--touch-target);
        font-size: 0.95rem;
    }

    .date-input-container .input-group .btn {
        flex: 0 0 72px;
        min-height: var(--touch-target);
        padding-left: 8px;
        padding-right: 8px;
        font-size: 0.95rem;
    }

    .chart-controls-row {
        margin-left: 0;
        margin-right: 0;
    }

    .chart-controls-row > [class*="col"] {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    .chart-controls-row .text-end {
        font-size: 0.95rem;
        line-height: 1.25;
    }

    /* Phones wrap the total onto two lines. */
    .chart-controls-row .chart-total {
        min-height: 2.5em;
    }

    .slider-control {
        min-height: 58px;
        margin-bottom: 4px !important;
    }

    .slider-control .form-label,
    .slider-control .control-label {
        margin-bottom: 2px;
        font-size: 0.92rem;
        line-height: 1.2;
    }

    .slider-control .rc-slider {
        height: 28px;
        padding: 7px 0 12px 0;
    }

    .slider-control .rc-slider-mark {
        top: 16px;
    }

    .chart-controls-row .dash-slider-mark,
    .chart-controls-row .rc-slider-mark-text {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Phones label 30m, 1d, Month and Year only: 1h sat 16 px from 30m.
       Marks render in slider order (30m first), so these are positions
       2-5, 7 and 9. Every step stays selectable; only its caption is dropped. */
    .granularity-slider-control .dash-slider-mark:nth-of-type(2),
    .granularity-slider-control .dash-slider-mark:nth-of-type(3),
    .granularity-slider-control .dash-slider-mark:nth-of-type(4),
    .granularity-slider-control .dash-slider-mark:nth-of-type(5),
    .granularity-slider-control .dash-slider-mark:nth-of-type(7),
    .granularity-slider-control .dash-slider-mark:nth-of-type(9),
    .granularity-slider-control .rc-slider-mark-text:nth-child(2),
    .granularity-slider-control .rc-slider-mark-text:nth-child(3),
    .granularity-slider-control .rc-slider-mark-text:nth-child(4),
    .granularity-slider-control .rc-slider-mark-text:nth-child(5),
    .granularity-slider-control .rc-slider-mark-text:nth-child(7),
    .granularity-slider-control .rc-slider-mark-text:nth-child(9) {
        display: none;
    }

    .button-container {
        height: auto;
        margin: 8px 0 10px 0;
    }

    .button-container .btn {
        min-height: var(--touch-target);
        padding: 6px 16px;
        font-size: 0.98rem;
    }

    .chart-graph-frame {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .chart-graph-frame .gtitle,
    .chart-graph-frame .xtitle,
    .chart-graph-frame .ytitle,
    .chart-graph-frame .y2title {
        display: none;
    }

    /* With the axis titles hidden, the unit still heads the plot so a phone
       screenshot keeps it (exports stamp their own, chart_a11y_export.js).
       The dispatch chart keeps its axis titles (below). */
    .chart-graph-frame[data-chart-unit]:not(:has(#revenue-graph))::before {
        content: attr(data-chart-unit);
        display: block;
        position: sticky;
        left: 0;
        padding: 0 0 4px 4px;
        font-size: 0.82rem;
        color: var(--color-text-muted);
        font-variant-numeric: tabular-nums;
    }

    /* Ranking charts are one row per asset; their own figure height (30 px
       a row) keeps names apart inside the scrolling frame. */
    .chart-graph-frame:not(.rankings-chart-frame) .dash-graph {
        height: 380px !important;
        min-height: 380px !important;
    }

    /* Charts fit the screen: Plotly autosizes to the frame, the legend wraps
       below the plot and plotly_resize.js trims the side margins. */
    #market-avg-per-mw-graph,
    #revenue-graph,
    #raw-revenue-graph {
        width: 100% !important;
        min-width: 0 !important;
        height: 420px !important;
        min-height: 420px !important;
    }

    #revenue-graph {
        height: 380px !important;
        min-height: 380px !important;
    }

    #market-avg-per-mw-summary-graph,
    #revenue-summary-graph {
        height: 210px !important;
        min-height: 210px !important;
    }

    #market-avg-per-mw-stacked-graph,
    #revenue-stacked-profit-graph {
        height: 180px !important;
        min-height: 180px !important;
    }

    .insight-row {
        margin-top: 12px !important;
    }

    .insight-panel {
        padding-top: 0;
    }

    .insight-panel__toggle,
    .insight-row--collapsed .insight-panel__toggle {
        width: 100%;
        min-height: var(--touch-target);
        margin-bottom: 8px;
        border-radius: var(--radius-control);
        font-size: 0.9rem;
        font-weight: 600;
    }

    .insight-row--collapsed .insight-panel__content {
        display: none;
    }

    .insight-row--open .insight-panel__content {
        display: block;
    }

    .insight-card {
        margin-bottom: 10px !important;
    }

    #unit-ranking-total-display {
        display: block;
        font-size: 0.85rem;
        line-height: 1.35;
    }

    .ranking-top-k-control {
        padding: 4px;
    }

    .ranking-top-k-input {
        min-height: var(--touch-target);
    }

    .revenue-option-controls {
        gap: 8px 18px;
    }
}


/* Keep the dispatch stack responsive on narrow screens. */
@media only screen and (max-width: 600px) {
    #revenue-graph {
        width: 100% !important;
        min-width: 0 !important;
        height: 480px !important;
        min-height: 480px !important;
    }

    #revenue-graph .gtitle,
    #revenue-graph .xtitle,
    #revenue-graph .ytitle,
    #revenue-graph .y2title {
        display: block;
    }
}

/* Dispatch charts with the SoC panel underneath (charts/soc_overlay.py: a
   second plot area with its own y2 axis title) get the panel's height on top
   of the dispatch plot; without published SoC they keep their usual height. */
#revenue-graph:has(.y2title),
#asset-activity-chart:has(.y2title) {
    height: 600px !important;
    min-height: 600px !important;
}

@media only screen and (max-width: 600px) {
    #revenue-graph:has(.y2title) {
        height: 640px !important;
        min-height: 640px !important;
    }

    #asset-activity-chart:has(.y2title) {
        height: 560px !important;
        min-height: 560px !important;
    }
}

/* Dispatch data notes: collapsed under the chart, opened on demand. */
.activity-notes {
    margin: 8px 25px 0;
    color: var(--color-text-muted);
}

.activity-notes > summary {
    width: fit-content;
    cursor: pointer;
}

.activity-notes__body p {
    margin: 6px 0 0;
}

/* Server-sent shell (prerender.py): the page's own header and a summary card,
   shown while the app renders out of sight, then swapped in one step (app.py). */
/* Dash's hidden dropdown focus input is sized from its text and can outgrow the
   control at large text sizes; keep it inside so it cannot widen the page. */
.dash-dropdown-focus-target {
    max-width: 100%;
}

html.app-pending #react-entry-point {
    visibility: hidden;
    height: 0;
    overflow: hidden;
}

.prerender:not(.prerender--about) .card-body {
    padding: 25px;
}

.prerender__body {
    max-width: 72ch;
    color: var(--color-text);
}

.prerender__body h1 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0 0 0.75rem;
}

.prerender__body h2 {
    font-size: 1.125rem;
    line-height: 1.35;
    margin: 1.5rem 0 0.5rem;
}

.prerender__body table {
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.75rem;
}

.prerender__body th,
.prerender__body td {
    padding: 0.25rem 1rem 0.25rem 0;
    border-bottom: 1px solid var(--color-border-light);
    text-align: left;
}

.prerender__body th {
    font-weight: 500;
}

.prerender__body dl > dt {
    font-weight: 500;
    color: var(--color-text-muted);
}

/* Rankings: every ranked asset page, A to Z, in compact columns. */
.asset-index {
    columns: 14rem auto;
    column-gap: 1.5rem;
    padding-left: 0;
    list-style: none;
}

.asset-index li {
    break-inside: avoid;
    padding: 0.125rem 0;
}

/* Monthly reports: headline figures, bar tables and the month pager. */
.report {
    max-width: 52rem;
}

.report-eyebrow {
    margin: 1rem 0 0.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.report h1 {
    color: var(--color-ink);
    text-wrap: balance;
}

.report .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.report-down {
    color: var(--color-danger);
}

.report-provisional {
    color: var(--color-warning-text);
}

.report-headline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    margin: 1.25rem 0 1rem;
    border-top: 2px solid var(--color-ink);
    border-bottom: 1px solid var(--color-border-light);
}

.report-headline > div {
    min-width: 0;
    padding: 0.75rem 1rem 0.875rem 0;
}

.prerender__body .report-headline dd {
    margin: 0;
}

.prerender__body .report-headline .report-headline__value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-ink);
    font-variant-numeric: tabular-nums;
}

.report-headline__note {
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.report-summary {
    max-width: 65ch;
    font-size: 1.0625rem;
}

.prerender__body .report-table {
    width: 100%;
}

.report-table caption {
    caption-side: bottom;
    padding-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.prerender__body .report-table th small {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.report-trend td:nth-child(2),
.report-streams td:nth-child(2) {
    width: 50%;
    min-width: 6rem;
}

.report-current th,
.report-total th,
.report-total td {
    font-weight: 600;
    color: var(--color-ink);
}

.report-bar {
    position: relative;
    display: block;
    height: 0.75rem;
}

.report-bar__zero {
    position: absolute;
    top: -0.25rem;
    bottom: -0.25rem;
    width: 1px;
    background: var(--color-border);
}

.report-bar__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 1px;
    background: var(--color-selection);
}

.report-streams .report-bar__fill,
.report-bar--now .report-bar__fill {
    background: var(--color-primary);
}

.report-bar__fill--neg,
.report-streams .report-bar__fill--neg {
    background: var(--color-danger);
}

.report-method {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border-light);
    background: var(--color-bg-card);
    font-size: 0.875rem;
}

.report-method p:last-child {
    margin-bottom: 0;
}

.report-pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-top: 1.25rem;
}

.prerender__links {
    margin: 0.75rem 0 0;
    color: var(--color-text-muted);
}

@media (max-width: 600px) {
    /* Large text: let the header buttons wrap instead of running off screen. */
    .navbar .navbar-nav {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    /* Gutters in px to match the 12px container padding; rem gutters outgrow
       it at large text sizes and push rows past the screen edge. */
    .app__container .row {
        --bs-gutter-x: 24px;
    }

    .prerender:not(.prerender--about) .card-body {
        padding: 16px 12px;
    }

    /* Disclosure rows reach the same 44px touch target as the buttons. */
    .rankings-details > summary,
    .activity-notes > summary {
        min-height: var(--touch-target);
        padding-block: 10px;
        box-sizing: border-box;
    }
}

/* Reduced motion: state still changes, nothing travels or spins fast. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0s !important;
        scroll-behavior: auto !important;
    }

    ._dash-loading-callback {
        animation-duration: 3s;
    }
}

/* Language menu (layout_components.language_menu, assets/lang_switch.js):
   an outlined nav button showing a globe and the current language, over a
   list of every language named in itself. English pages offer it only once
   Chinese is published (BESS_ZH_PUBLISHED); Chinese pages always do. */
.lang-menu[data-lang-current="en"] { display: none; }
[data-zh-published] .lang-menu[data-lang-current="en"] { display: block; }

.lang-menu {
    position: relative;
}

.navbar .nav-link.lang-menu__toggle {
    gap: 6px;
}

.lang-menu__icon {
    width: 1em;
    height: 1em;
    flex: none;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M2.5 12h19M12 2.5c2.6 2.6 3.9 5.8 3.9 9.5s-1.3 6.9-3.9 9.5c-2.6-2.6-3.9-5.8-3.9-9.5S9.4 5.1 12 2.5z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M2.5 12h19M12 2.5c2.6 2.6 3.9 5.8 3.9 9.5s-1.3 6.9-3.9 9.5c-2.6-2.6-3.9-5.8-3.9-9.5S9.4 5.1 12 2.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The toggle is the globe alone, sized like the theme toggle beside it and
   as tall as the page links (the bare icon left it 26px high). */
.navbar .nav-link.lang-menu__toggle {
    min-width: 38px;
    min-height: calc(1.5em + 10px);
}

.lang-menu__list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1050;
    min-width: 100%;
    margin: 0;
    padding: 4px;
    list-style: none;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
}

.lang-menu__list[hidden] {
    display: none;
}

.lang-menu__list > li {
    margin: 0;
}

.lang-menu__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-control);
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
}

/* The current language: bold, with a drawn tick in front; others keep the
   tick's width so the names line up. */
.lang-menu__option::before {
    content: "";
    width: 0.35em;
    height: 0.7em;
    margin: -0.2em 0.2em 0 0.1em;
    flex: none;
    border-right: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transform: rotate(45deg);
}

.lang-menu__option[aria-current] {
    font-weight: 600;
}

.lang-menu__option[aria-current]::before {
    border-color: currentColor;
}

.lang-menu__option:hover,
.lang-menu__option:focus-visible {
    background-color: var(--color-primary);
    color: var(--color-bg-light);
    text-decoration: none;
}

@media (max-width: 600px) {
    .lang-menu__option {
        min-height: var(--touch-target);
    }
}
:lang(zh) body {
  font-family: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
}

/* Touch screens: the Plotly mode bar opens on tap and covers the chart, and
   its 22 px buttons are too small to hit, so hide it there. Elsewhere give its
   buttons, the slider thumbs and the check/radio inputs 24 px targets. */
.js-plotly-plot .plotly .modebar-btn {
    min-height: 24px;
    min-width: 24px;
}

@media (hover: none) and (pointer: coarse) {
    .js-plotly-plot .plotly .modebar-container {
        display: none !important;
    }

    .dash-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .form-check:not(.form-switch) {
        min-height: 1.5rem;
        padding-left: 2rem;
    }

    .form-check:not(.form-switch) .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
        margin-top: 0;
        margin-left: -2rem;
    }
}

/* ==========================================================================
   Touch targets: 44 x 44 CSS px on touch screens and phones
   Hit areas grow with padding, overlays or pseudo-elements where a bigger
   visual would crowd the layout.
   ========================================================================== */

/* The asset name is the row's link; let the whole card take the tap. */
.mobile-ranking-row {
    position: relative;
}

.mobile-ranking-row__name a::after {
    content: "";
    position: absolute;
    inset: 0;
}

@media (pointer: coarse), (max-width: 600px) {
    .navbar .nav-link.nav-link-button {
        min-width: var(--touch-target);
        min-height: var(--touch-target);
    }

    /* input[type="date"] is listed again: the desktop rule for it (0,1,1)
       outranks .form-control (0,1,0) and held date fields at 38 px. */
    .form-control,
    input[type="date"].form-control,
    .query-input-container .form-control,
    .form-select,
    .btn,
    .dash-dropdown {
        min-height: var(--touch-target);
    }

    /* Check and radio rows are 44 px tall and their label overlays the whole
       row, so a tap on the box, the text or the gap between toggles it. */
    .form-check:not(.form-switch) {
        position: relative;
        display: flex;
        align-items: center;
        min-width: var(--touch-target);
        min-height: var(--touch-target);
        margin-bottom: 0;
    }

    .form-check.form-check-inline:not(.form-switch) {
        display: inline-flex;
    }

    .form-check:not(.form-switch) .form-check-input {
        flex: 0 0 auto;
        margin-top: 0;
        margin-right: 0.5rem;
    }

    .form-check:not(.form-switch) .form-check-label::before {
        content: "";
        position: absolute;
        inset: 0;
    }

    /* Reports on phones: drop the stream bars and the top table's nation,
       so the figures fit without scrolling sideways. */
    .report-streams th:nth-child(2),
    .report-streams td:nth-child(2),
    .report-top th:nth-child(4),
    .report-top td:nth-child(4) {
        display: none;
    }

    /* Report pager and index links: 44 px rows. */
    .report-pager a,
    .report-index th a {
        display: inline-flex;
        align-items: center;
        min-height: var(--touch-target);
    }

    /* Rankings A-Z index: each asset link fills a 44 px row. */
    .asset-index li {
        padding: 0;
    }

    .asset-index a {
        display: flex;
        align-items: center;
        min-height: var(--touch-target);
    }

    /* Inline asset links in summary lists (related assets): taller lines keep
       neighbouring links apart, and padding grows each link's hit area. */
    .page-summary li {
        line-height: 2.25;
    }

    .page-summary li > a {
        padding-block: 0.375rem;
    }

    /* The dropdown's clear (x) is a 16 px icon; give it a 44 px hit area. */
    .dash-dropdown-clear {
        position: relative;
    }

    .dash-dropdown-clear::after {
        content: "";
        position: absolute;
        inset: calc((100% - var(--touch-target)) / 2);
    }

    /* The slider thumb keeps its look and gains a 44 px touch ring, sized
       from the thumb so a different Dash thumb size cannot shrink it. */
    .dash-slider-thumb {
        position: relative;
    }

    .dash-slider-thumb::after {
        content: "";
        position: absolute;
        inset: calc((100% - var(--touch-target)) / 2);
        border-radius: 50%;
    }

    /* Server-sent summary tables: 44 px rows, and the link fills its row. */
    .prerender__body th,
    .prerender__body td {
        padding-block: 0.75rem;
    }

    .prerender__body td a {
        display: inline-block;
        padding-block: 0.75rem;
        margin-block: -0.75rem;
    }
}

/* ==========================================================================
   Colour theme. Tokens switch under <html data-theme="dark"> (theme.css_root);
   these rules cover what the tokens alone do not reach.
   ========================================================================== */

/* Text on primary fills follows the theme (white on brown, dark on tan). */
.btn.btn-primary,
.btn.btn-primary:hover,
.btn.btn-primary:active {
    color: var(--color-on-primary);
}

/* The header's theme button: a sun on the light theme and a moon on the
   dark one, masked so it takes the button's text colour. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    /* A text button's line (1.5em), padding (8px) and border (2px). */
    min-height: calc(1.5em + 10px);
    background: transparent;
}

.theme-toggle__icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask: var(--theme-icon) center / contain no-repeat;
    mask: var(--theme-icon) center / contain no-repeat;
    --theme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Cpath d='M12 2v2.5M12 19.5V22M2 12h2.5M19.5 12H22M4.9 4.9l1.8 1.8M17.3 17.3l1.8 1.8M4.9 19.1l1.8-1.8M17.3 6.7l1.8-1.8'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] .theme-toggle__icon {
    --theme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.5 14.6A8.5 8.5 0 0 1 9.4 3.5a8.5 8.5 0 1 0 11.1 11.1z'/%3E%3C/svg%3E");
}

/* Dark theme: Dash 4 widget surfaces, and check marks drawn in the dark
   on-primary colour over the tan fill (Bootstrap draws them white). */
:root[data-theme="dark"] {
    --Dash-Fill-Inverse-Strong: var(--color-bg-card);
    --Dash-Fill-Disabled: rgba(var(--color-text-rgb), 0.12);
    --Dash-Stroke-Strong: var(--color-border);
    --Dash-Stroke-Weak: var(--color-border-light);
    --Dash-Shading-Strong: rgba(0, 0, 0, 0.6);
    --Dash-Shading-Weak: rgba(0, 0, 0, 0.4);
    --Dash-Text-Disabled: var(--color-text-muted);
}

:root[data-theme="dark"] .form-check-input:checked[type="checkbox"] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%2315110D' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] .form-check-input:checked[type="radio"] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3E%3Ccircle r='2' fill='%2315110D'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] .mobile-ranking-row {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Revenue chart hover (chart_hover.js): a card above or below the pointer
   replaces Plotly's unified label, which stays rendered (hidden) as its source.
   The hovered period stays lit, the rest dims. */
.js-plotly-plot.hc-chart .hoverlayer .legend,
.js-plotly-plot.hc-chart .hoverlayer .hoverlabel,
.js-plotly-plot.hc-chart .hoverlayer .spikeline {
    visibility: hidden;
}

/* One cursor on every chart: a plain arrow over the plot and its axes instead
   of Plotly's zoom crosshair, its hand on locked axes and its resize arrows at
   the edges. Drag-to-zoom stays; links and legend entries keep their hand. */
.js-plotly-plot .draglayer .drag {
    cursor: default !important;  /* over Plotly's cursor-* classes */
}

.js-plotly-plot.hc-chart .barlayer .point path {
    transition: opacity 120ms ease-out;
}

.js-plotly-plot.hc-hovering .barlayer .point:not(.hc-col) path {
    opacity: 0.35 !important;  /* over Plotly's inline opacity */
}

/* Category highlight (chart_hover.js): every trace of another category dims;
   group opacity, so it stacks with Plotly's own marker opacity. */
.js-plotly-plot .barlayer .trace,
.js-plotly-plot .scatterlayer .trace {
    transition: opacity 120ms ease-out;
}

.js-plotly-plot.hl-on .trace.hl-dim {
    opacity: 0.25 !important;  /* over Plotly's inline trace opacity */
}

.js-plotly-plot.hl-on .barlayer .point.hc-seg path,
.js-plotly-plot.hc-hovering .barlayer .point.hc-seg path {
    stroke: var(--color-text) !important;
    stroke-width: 1.5px !important;
    stroke-opacity: 1 !important;
}

.chart-hover-card {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1080;
    min-width: 220px;
    max-width: min(360px, calc(100vw - 16px));
    padding: 10px 12px;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    background: var(--color-bg-card);
    color: var(--color-text);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    line-height: 1.35;
    pointer-events: none;
}

.chart-hover-card__title {
    margin-bottom: 6px;
    color: var(--color-text-muted);
}

.chart-hover-card__row {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    align-items: center;
    column-gap: 8px;
    padding: 2px 0;
    color: var(--color-text-muted);
}

.chart-hover-card__row.is-total,
.chart-hover-card__row.is-active {
    color: var(--color-text);
    font-weight: 600;
}

.chart-hover-card__row.is-total {
    margin-top: 4px;
    padding-top: 5px;
    border-top: 1px solid var(--color-border-light);
}

.chart-hover-card__value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.chart-hover-card__swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--swatch, transparent);
}

.chart-hover-card__swatch.is-line {
    height: 2px;
    border-radius: 1px;
}

.chart-hover-ring {
    position: fixed;
    z-index: 1079;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border: 2px solid var(--color-bg-card);
    border-radius: 50%;
    background: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 30%, transparent);
    pointer-events: none;
}

.chart-hover-ring.is-dim {
    opacity: 0.3;
}

.chart-hover-ring.is-active {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--ring) 35%, transparent);
}

/* Charts with thousands of bar segments (the full ranking) switch without
   the fade, which cost more than the hover itself. */
.js-plotly-plot.hc-many .barlayer .point path,
.js-plotly-plot.hc-many .barlayer .trace,
.js-plotly-plot.hc-many .scatterlayer .trace {
    transition: none;
}

@media (prefers-reduced-motion: reduce) {
    .js-plotly-plot.hc-chart .barlayer .point path,
    .js-plotly-plot .barlayer .trace,
    .js-plotly-plot .scatterlayer .trace {
        transition: none;
    }
}

/* A hidden series' legend entry: Plotly fades the whole entry to 0.5, which
   took its text to about 2.2:1. Keep the name at full contrast and fade only
   the swatch, so "off" still reads at a glance. */
.js-plotly-plot .legend .traces[style*="opacity: 0.5"] {
    opacity: 1 !important;
}

.js-plotly-plot .legend .traces[style*="opacity: 0.5"] .legendsymbols {
    opacity: 0.3;
}
