/* =====================================================================
   Results page styles (root: .nma-modern.nma-results in pages/results.py).
   Colours, font and base size come from assets/theme.css.

   The page's tabs and panels are shown/hidden and resized by callbacks
   through inline styles (display / width), so nothing here sets display
   or width on #one-half-1/2/3 or on the tabs. Older global rules in
   app.css/style.css use !important, which is why some overrides need it.
   ===================================================================== */

.nma-results.app__container {
    margin: 0; /* style.css: 2% all round */
    display: block;
}

/* nested empty-state wrapper must not add a second page padding */
.nma-results .ui-empty-page {
    padding: 0;
}

/* Rules written as ":is(.nma-results, .nma-kt, .kt-trans-modal) ..." are shared with the NMA-KIT
   page (network graph toolbar, Graph Options, Download / Reset buttons, class legend), so both pages
   look the same. */

/* ---------- header ---------- */

/* .ui-hero.results-hero: beats the theme's .nma-modern .ui-hero (theme.css loads later) */
.nma-results .ui-hero.results-hero {
    max-width: none;
    margin: 0 0 1.25em;
}

.nma-results .results-hero .ui-hero-text {
    flex: 1 1 28em;
}

.nma-results .results-hero .ui-heading {
    font-size: clamp(1.2em, 1.6vw, 1.45em);
}

.nma-results .results-protocol-label {
    font-weight: 600;
    color: var(--c-ink);
}

.nma-results .results-protocol-link {
    color: var(--c-primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.nma-results .results-select-row {
    display: flex;
    align-items: center;
    gap: 0.6em;
}

.nma-results .results-select-label {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--c-ink-muted);
}

.nma-results .results-select {
    width: 16em;
}

.nma-results .results-warning:empty {
    display: none;
}

/* ---------- panels: network graph, results tabs, lower tabs ---------- */

.nma-results #main_page::after {
    content: "";
    display: table;
    clear: both;
}

.nma-results #one-half-1,
.nma-results #one-half-2,
.nma-results #one-half-3 {
    padding: 1em 1.1em;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.nma-results #one-half-3 {
    margin-top: 1.25em;
}

.nma-results #all-control-tabs,
.nma-results #all-control-tabs2 {
    background: transparent !important;
}

/* "Graph Options" and other Bootstrap dropdown buttons (Graph Options also on the NMA-KIT page) */
.nma-results .dropdown-toggle,
.nma-kt .graph-options-toggle {
    height: auto;
    padding: 0.45em 1em !important;
    font-family: var(--font-ui);
    font-size: 0.95em !important;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: normal !important;
    text-transform: none;
    color: #fff !important;
    background: var(--c-primary) !important;
    border: 1px solid var(--c-primary) !important;
    border-radius: var(--radius-md) !important;
}

.nma-results .dropdown-toggle:hover,
.nma-kt .graph-options-toggle:hover {
    background: var(--c-primary-dark) !important;
}

.nma-results .dropdown-menu,
.nma-kt .graph-options .dropdown-menu {
    font-family: var(--font-ui);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* top of the results panel (expand icon + network item info): no coloured box */
.nma-results .info__container {
    display: block;
    margin-bottom: 0.5em !important;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.nma-results .info__container img {
    width: 1.6em !important;
    margin-top: 0.2em !important;
    opacity: 0.7;
}

.nma-results .info__container .info_box:empty {
    display: none;
}

/* hint under the network toolbar */
:is(.nma-results, .nma-kt, .kt-trans-modal) .results-network-hint {
    display: block; /* wraps like normal text, with the tag and key inline */
    line-height: 1.7;
    margin: 0.6em 0 0;
    padding: 0.5em 0.8em;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--c-ink);
    background: var(--c-accent-soft); /* red-orange, like the setup notes */
    border-radius: var(--radius-md);
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-network-hint-tag {
    margin-right: 0.45em;
    padding: 0.1em 0.55em;
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: var(--c-accent);
    border-radius: 999px;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-network-hint kbd {
    padding: 0.1em 0.45em;
    font-family: var(--font-ui);
    font-size: 0.9em;
    font-weight: 600;
    color: var(--c-ink);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    box-shadow: none;
}

/* "Select outcome" */
.nma-results .selectbox {
    font-family: var(--font-ui);
    font-size: 0.9em !important;
    font-weight: 600 !important;
    color: var(--c-ink-muted) !important;
}

.nma-results #_outcome_select {
    width: 10em !important;
    height: auto !important;
    margin-left: 0.6em;
    font-family: var(--font-ui) !important;
    font-size: 0.95em !important;
}

/* ---------- tabs ---------- */

.nma-results .tab-container {
    gap: 0.25em;
    border-bottom: 1px solid var(--c-border);
}

.nma-results .tab {
    padding: 0.65em 1.1em !important;
    font-family: var(--font-ui);
    font-size: 0.95em !important;
    font-weight: 500;
    color: var(--c-ink-muted) !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 3px solid transparent !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    transition: color 0.15s ease, background 0.15s ease;
}

.nma-results .tab:hover {
    color: var(--c-primary-dark) !important;
    background: var(--c-primary-soft) !important;
}

.nma-results .tab--selected,
.nma-results .tab--selected:hover {
    font-weight: 600;
    color: var(--c-primary-dark) !important;
    background: transparent !important;
    border-bottom-color: var(--c-primary) !important;
}

/* inner (second-level) tabs, e.g. Converted / Imported data: pill switch */
.nma-results .tab-content .tab-container {
    display: inline-flex;
    gap: 0.25em;
    margin: 0.75em 0;
    padding: 0.25em;
    background: var(--c-canvas);
    border: 1px solid var(--c-border);
    border-radius: 999px;
}

.nma-results .tab-content .tab {
    padding: 0.35em 1em !important;
    font-size: 0.88em !important;
    border-bottom: none !important;
    border-radius: 999px;
}

.nma-results .tab-content .tab--selected,
.nma-results .tab-content .tab--selected:hover {
    color: #fff !important;
    background: var(--c-primary) !important;
}

/* ---------- headings and helper text inside the tabs ---------- */

.nma-results .graph__title2 {
    padding: 0 0.75em 0 0;
    font-family: var(--font-ui) !important;
    font-size: 1em;
    font-weight: 600;
    letter-spacing: normal !important;
    color: var(--c-ink) !important;
}

.nma-results .box__title {
    font-family: var(--font-ui) !important;
    font-size: 0.95em !important;
    font-weight: 600;
    letter-spacing: normal !important;
    color: var(--c-ink) !important;
}



/* ---------- small screens: stack the two panels ---------- */

@media (max-width: 900px) {
    .nma-results #one-half-1,
    .nma-results #one-half-2 {
        float: none;
        width: 100% !important;
        margin-left: 0 !important;
        margin-bottom: 1.25em;
    }
}

/* data tables (dash_table): neutral header instead of orange */
.nma-results .dash-spreadsheet-container .dash-header,
.nma-results .dash-spreadsheet-container th.dash-header {
    background-color: var(--c-canvas) !important;
    color: var(--c-ink) !important;
    font-family: var(--font-ui) !important;
    font-weight: 600 !important;
}

.nma-results .dash-spreadsheet-container td {
    font-family: var(--font-ui) !important;
}

/* ---------- refinements ---------- */

/* tab names on one line */
.nma-results .tab {
    white-space: nowrap;
}

/* Dash's default beige tab-content background: use the panel's white */
.nma-results .tab-content {
    background: transparent !important;
}

/* Panel widths: the expand/zoom callback sets them inline (42% / 50.6% / 93.4%).
   Map those values to widths that line up with the title card above. */
.nma-results #one-half-2[style*="50.6%"],
.nma-results #one-half-3[style*="50.6%"] {
    width: 54% !important; /* half width: sits beside the network panel (42% + 4% gap) */
}

.nma-results #one-half-1[style*="93.4%"],
.nma-results #one-half-2[style*="93.4%"],
.nma-results #one-half-3[style*="93.4%"] {
    width: 100% !important; /* expanded: full width */
    margin-left: 0 !important;
}

/* lower panel: hide it when no lower tab is shown (e.g. Ranking) */
.nma-results #one-half-3:not(:has(.tab:not([style*="display: none"]))) {
    display: none;
}

/* Lower panel zoomed out (data-zoomout1) while the network panel is at its normal size:
   two-column grid.
   Network panel spans the whole left column, next to both right-hand panels
   (data / forest / league ... on top, transitivity / funnel ... below). */
.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) {
    display: grid !important; /* the page-visibility callback sets display: block inline */
    grid-template-columns: 42% minmax(0, 1fr);
    column-gap: 4%;
    row-gap: 1.25em;
    align-items: stretch;
}

.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) > br {
    display: none;
}

.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) > #one-half-1 {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex !important;
    flex-direction: column;
    float: none;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
}

.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) > #one-half-2,
.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) > #one-half-3 {
    grid-column: 2;
    float: none;
    width: auto !important;
    margin: 0 !important;
}

.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) > #one-half-3 {
    grid-row: 2;
}

/* the diagram fills the taller network panel */
.nma-results #main_page:has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"]):not([style*="93.4%"])):has(> #one-half-2:not([style*="93.4%"])) #cytoscape {
    flex: 1 1 0; /* size from the panel, not from the canvas cytoscape drew earlier */
    height: auto !important;
    min-height: 70vh;
    overflow: hidden;
}

/* Lower panel zoomed out while the top is expanded (network hidden or full width):
   no grid; the lower panel is a smaller window aligned with the right-hand column. */
.nma-results #one-half-3[style*="50.6%"] {
    margin-left: 46% !important;
}

/* Results panel expanded + lower panel zoomed out: results across the top,
   network panel on the left next to the lower panel underneath. */
.nma-results #main_page:has(> #one-half-2[style*="93.4%"]):has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"])) {
    display: grid !important;
    grid-template-columns: 42% minmax(0, 1fr);
    column-gap: 4%;
    row-gap: 1.25em;
    align-items: stretch;
}

.nma-results #main_page:has(> #one-half-2[style*="93.4%"]):has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"])) > br {
    display: none;
}

.nma-results #main_page:has(> #one-half-2[style*="93.4%"]):has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"])) > #one-half-2 {
    grid-column: 1 / -1;
    grid-row: 1;
    float: none;
    width: auto !important;
    margin: 0 !important;
}

.nma-results #main_page:has(> #one-half-2[style*="93.4%"]):has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"])) > #one-half-1 {
    grid-column: 1;
    grid-row: 2;
    display: flex !important;
    flex-direction: column;
    float: none;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
}

.nma-results #main_page:has(> #one-half-2[style*="93.4%"]):has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"])) > #one-half-3 {
    grid-column: 2;
    grid-row: 2;
    float: none;
    width: auto !important;
    margin: 0 !important;
}

.nma-results #main_page:has(> #one-half-2[style*="93.4%"]):has(> #one-half-3[style*="50.6%"]):has(> #one-half-1:not([style*="display: none"])) #cytoscape {
    flex: 1 1 0;
    height: auto !important;
    min-height: 60vh;
    overflow: hidden;
}

/* publication year slider row (Data tab): label, slider, info button on one line */
.nma-results .results-slider-row {
    display: flex;
    align-items: center;
    gap: 0.75em;
    margin: 0.5em 0 0.75em;
}

.nma-results .results-slider-label {
    flex: none;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--c-ink-muted);
}

.nma-results .results-slider {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 1.2em; /* room for the slider tooltip */
}

/* ---------- one info button per box, top-right corner ---------- */

.nma-results #one-half-1,
.nma-results #one-half-2,
.nma-results #one-half-3 {
    position: relative;
}

.nma-results .nma-panel-info {
    position: absolute;
    top: 0.9em;
    right: 0.9em;
    z-index: 1001; /* above the network canvas (z-index 999) */
    width: 26px;
    height: 26px;
    min-width: 26px;
    margin: 0;
    font-size: 16px;
}


/* ---------- network summary (toolbar button + floating card) ---------- */

/* "Network summary": solid teal like "Graph Options", with a small bar-chart icon */
.nma-results .ui-button.results-summary-button {
    gap: 0.5em;
    min-height: 0;
    padding: 0.5em 1.05em;
    font-size: 0.85em; /* Graph Options sits in a 15px wrapper: comparable size */
    line-height: 1.2;
    box-shadow: 0 1px 3px rgba(21, 107, 108, 0.35);
}

.nma-results .results-summary-icon {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 0.95em;
}

.nma-results .results-summary-icon i {
    display: block;
    width: 3px;
    background: currentColor;
    border-radius: 1px;
}

.nma-results .results-summary-icon i:nth-child(1) { height: 45%; }
.nma-results .results-summary-icon i:nth-child(2) { height: 100%; }
.nma-results .results-summary-icon i:nth-child(3) { height: 70%; }

/* popover is rendered outside the page, so these rules are not scoped to .nma-results;
   colours come from the .nma-modal tokens (theme.css) */
.popover.results-summary-card {
    z-index: 2000 !important; /* above the network canvas */
    width: 24em;
    max-width: calc(100vw - 32px);
    padding: 0;
    font-family: var(--font-ui);
    font-size: 15px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.popover.results-summary-card .popover-arrow {
    display: none;
}

.results-summary-card .results-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6em 0.9em;
    border-bottom: 1px solid var(--c-border);
    border-left: 4px solid var(--c-primary);
}

.results-summary-card .results-summary-title {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--c-ink);
}

.results-summary-card .results-summary-close {
    display: grid;
    place-items: center;
    width: 1.8em;
    height: 1.8em;
    margin: 0;
    padding: 0;
    font-size: 1em;
    line-height: 1;
    letter-spacing: normal;
    color: var(--c-ink-muted);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.results-summary-card .results-summary-close:hover {
    color: var(--c-ink);
    background: var(--c-canvas);
}

.results-summary-card .results-summary-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6em;
    padding: 0.9em;
}

.results-summary-card .results-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15em;
    padding: 0.6em 0.75em;
    background: var(--c-canvas);
    border-radius: var(--radius-md);
}

.results-summary-card .results-stat-value {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.1;
    color: var(--c-primary-dark);
}

.results-summary-card .results-stat-label {
    font-size: 0.78em;
    line-height: 1.3;
    color: var(--c-ink-muted);
}

/* participants: headline tile across the full width */
.results-summary-card .results-stat-wide {
    grid-column: 1 / -1;
    background: var(--c-primary-soft);
}

.results-summary-card .results-stat-wide .results-stat-value {
    font-size: 1.9em;
}

/* ---------- network toolbar ---------- */

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6em 1em;
    margin-right: 2.4em; /* clear of the corner info button */
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-group,
:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-icons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-modals {
    display: contents;
}

/* font size / search fields */
:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em 1.2em;
    margin: 0.75em 0 0;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-field {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin: 0;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-field-label {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--c-ink-muted);
    white-space: nowrap;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-field-input {
    width: 7.5em;
    height: 2.1em;
    margin: 0;
    padding: 0.25em 0.6em;
    font-family: var(--font-ui);
    font-size: 0.85em;
    color: var(--c-ink);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-field-input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}

/* ---------- Graph Options: all choices visible, grouped ---------- */

:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu {
    padding: 0.8em;
    min-width: 0;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu.show {
    display: grid;
    grid-template-columns: repeat(3, minmax(9.5em, auto));
    gap: 0.9em 1.2em;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options-heading {
    margin: 0 0 0.35em;
    padding: 0 0.6em;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--c-ink-muted);
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item {
    padding: 0.3em 0.6em;
    font-family: var(--font-ui);
    font-size: 0.88em;
    color: var(--c-ink);
    background: transparent;
    border-radius: 6px;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item:hover,
:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item:focus {
    color: var(--c-primary-dark);
    background: var(--c-primary-soft);
}

@media (max-width: 700px) {
    .nma-results .graph-options .dropdown-menu.show {
        grid-template-columns: repeat(2, minmax(9em, auto));
    }
}

/* Graph Options: same size as "Network summary" (it used to sit in a 15px wrapper) */
:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options-toggle {
    padding: 0.5em 1.05em !important;
    font-size: 0.85em !important;
    line-height: 1.2;
}

/* menu panel: white card instead of the global pale-green menu */
:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu {
    background: var(--c-surface) !important;
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-md) !important;
    z-index: 1003; /* above the network canvas */
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item {
    padding: 0.22em 0.6em !important;
    font-size: 0.85em !important;
    line-height: 1.45;
    letter-spacing: normal !important;
    text-transform: none;
    white-space: nowrap;
}

/* compact rows in the Graph Options menu (app.css gives menu items tall rows) */
:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item {
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.4 !important;
}

/* toolbar fits on two tidy rows: buttons + icons, then the two fields */
:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar {
    gap: 0.5em 0.6em;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-group {
    gap: 0.4em;
}



:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-icons {
    gap: 0.35em;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-field-input {
    width: 6.5em;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-toolbar-fields {
    gap: 0.5em 1em;
}

/* ---------- network drawing area: light frame (clicking blank space inside deselects) ---------- */

.nma-results #cytoscape {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    background: #fcfdfe;
    margin-top: 0.75em !important;
}

/* "Reset graph" button next to the icon buttons */
:is(.nma-results, .nma-kt, .kt-trans-modal) .ui-button-secondary.network-reset-button {
    gap: 0.35em;
    min-height: 0;
    height: 2.05em;
    padding: 0 0.75em;
    font-size: 0.8em;
    white-space: nowrap;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .network-reset-icon {
    font-size: 1.15em;
    line-height: 1;
}

/* disabled option in Graph Options (e.g. Grouping by class without classes) */
:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item.disabled,
:is(.nma-results, .nma-kt, .kt-trans-modal) .graph-options .dropdown-menu .dropdown-item:disabled {
    color: var(--c-ink-muted) !important;
    opacity: 0.6;
    white-space: normal;
    max-width: 14em;
}

/* ---------- class legend under the network (Grouping by class) ---------- */

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-class-legend {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em 0.9em;
    margin-top: 0.6em;
    padding: 0.55em 0.8em;
    font-size: 0.82em;
    color: var(--c-ink);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-class-title {
    font-weight: 700;
    color: var(--c-ink-muted);
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-class-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    white-space: nowrap;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-class-dot {
    width: 0.85em;
    height: 0.85em;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(29, 43, 58, 0.25);
}

/* ---------- labelled action buttons: Download / Expand / Reduce (all boxes) ---------- */
/* The outer link's display is set by callbacks (inline-block / none); the layout is on the inner span. */

:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action {
    margin: 0 0.15em;
    padding: 0;
    text-decoration: none !important;
    cursor: pointer;
    vertical-align: middle;
}

:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    height: 2.05em;
    padding: 0 0.7em 0 0.5em;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    color: var(--c-primary-dark);
    background: var(--c-surface);
    border: 1px solid #b9dedb;
    border-radius: var(--radius-md);
    transition: background 0.15s ease, border-color 0.15s ease;
}

:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action:hover .panel-action-inner,
:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action:focus-visible .panel-action-inner {
    background: var(--c-primary-soft);
    border-color: var(--c-primary);
}

:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action-inner img {
    width: 1.25em !important;
    height: 1.25em !important;
    margin: 0 !important;
    object-fit: contain;
    opacity: 0.85;
}

/* the expand/reduce buttons at the top of the results boxes */
.nma-results #one-half-2 .info__container .panel-action,
.nma-results #all-control-tabs2 .panel-action {
    margin: 0 0 0.4em;
}

/* ---------- old per-tab export buttons: replaced by the box "Download" button ---------- */
/* Kept in the page (hidden) because the box Download button clicks them to reuse their exports. */
.nma-results .btn-export,
.nma-results .btn-export2,
.nma-results .dash-spreadsheet-menu button.export,
.nma-results button.export {
    display: none !important;
}

/* ---------- tooltips: readable text (some had wide letter spacing and 9px text) ---------- */

.tooltip .tooltip-inner {
    max-width: 260px;
    padding: 0.4em 0.65em;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 12.5px !important;
    letter-spacing: normal !important;
    line-height: 1.4;
    text-align: left;
    color: #fff !important;
    background: #1d2b3a;
    border-radius: 6px;
}

/* protocol: plain text when there is no link */
.nma-results a.results-protocol-link:not([href]) {
    color: var(--c-ink-muted);
    text-decoration: none;
    cursor: default;
}

/* "Download as" (figure / table file types) in the title card */
.nma-results .results-format-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em 0.8em;
    padding-left: 0.9em;
    border-left: 1px solid var(--c-border); /* separates it from "Show" */
}

/* title across the full width, then Show | Download as | settings on one line */
.nma-results .results-hero .ui-hero-text {
    flex: 1 1 100%;
}

.nma-results .results-hero .ui-hero-actions {
    flex: 1 1 100%;
    gap: 0.6em 1.2em;
}

.nma-results .results-hero #statsettings {
    margin-left: auto;
}

.nma-results .results-format-field {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    margin: 0;
}

.nma-results .results-format-label {
    font-size: 0.82em;
    color: var(--c-ink-muted);
}

.nma-results .results-format-select {
    width: 6.5em;
    font-size: 0.85em;
}

/* space between Expand/Reduce window and Download */
:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action + .panel-action,
:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action + .tooltip + .panel-action {
    margin-left: 0.6em;
}

.nma-results #upper-download,
.nma-results #lower-download {
    margin-left: 0.9em !important;
}

/* ---------- clicked edge / node info, in the network box ---------- */
.nma-results .results-network-selection:empty {
    display: none;
}

.nma-results .results-network-selection {
    margin-top: 0.6em;
    padding: 0.5em 0.8em;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--c-primary-dark);
    background: var(--c-primary-soft);
    border-radius: var(--radius-md);
}

/* ---------- "Show": which results to display, more prominent ---------- */
.nma-results .results-select-row .results-select-label {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--c-ink);
}

.nma-results .results-select .Select-control {
    min-height: 2.6em;
    background: var(--c-primary-soft) !important;
    border: 2px solid var(--c-primary) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 1px 3px rgba(21, 107, 108, 0.2);
    cursor: pointer;
}

.nma-results .results-select .Select-value-label {
    font-weight: 700;
    color: var(--c-primary-dark) !important;
}

.nma-results .results-select .Select-arrow {
    border-top-color: var(--c-primary-dark) !important;
}

.nma-results .results-select .Select-menu-outer {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1100;
}

.nma-results .results-select .Select-option {
    padding: 0.55em 0.9em;
    font-size: 0.95em;
}

.nma-results .results-select .Select-option.is-focused {
    background: var(--c-primary-soft);
    color: var(--c-primary-dark);
}

/* ---------- graphs: Plotly's own hover toolbar replaced by the box Download / Expand buttons ---------- */
.nma-results .modebar-container,
.nma-results .modebar {
    display: none !important;
}

/* ---------- tables: lighter borders, readable header, theme font (cell colours kept) ---------- */
.nma-results .dash-spreadsheet-container .dash-spreadsheet-inner td,
.nma-results .dash-spreadsheet-container .dash-spreadsheet-inner th {
    border-color: #dfe6ec !important;
    font-family: var(--font-ui) !important;
}

.nma-results .dash-spreadsheet-container .dash-spreadsheet-inner th {
    font-size: 0.8em !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
    color: var(--c-ink) !important;
}

.nma-results .dash-spreadsheet-container .dash-spreadsheet-inner td {
    font-size: 0.82em !important;
    color: var(--c-ink);
}

.nma-results .dash-spreadsheet-container {
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* open dropdown menus always above graphs */
.nma-results .Select-menu-outer {
    z-index: 1100 !important;
}

/* ---------- outputs that need two outcomes: explanation when there is only one ---------- */
.nma-results .two-outcome-note {
    display: none;
}

.nma-results.single-outcome .two-outcome-note {
    display: flex;
    gap: 0.75em;
    margin: 1em 0;
    padding: 1em 1.1em;
    font-size: 0.92em;
    line-height: 1.5;
    color: var(--c-ink);
    background: var(--c-accent-soft);
    border-radius: var(--radius-md);
}

.nma-results.single-outcome .needs-two-outcomes > *:not(.two-outcome-note) {
    display: none !important;
}

/* ---------- own card: choose results (main) + downloads ---------- */
.nma-results .ui-card.results-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1em 2em;
    margin: 0 0 1.25em;
    padding: 1.1em 1.4em;
    border-left: 5px solid var(--c-accent);
}

.nma-results .results-choose {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75em 1.25em;
    flex: 1 1 32em;
}

.nma-results .results-choose-heading {
    display: flex;
    align-items: center;
    gap: 0.7em;
}

.nma-results .results-choose-heading .ui-badge {
    color: #fff;
    background: var(--c-accent);
}

.nma-results .results-choose-title {
    display: block;
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--c-ink);
}

.nma-results .results-choose-hint {
    display: block;
    font-size: 0.82em;
    color: var(--c-ink-muted);
}

.nma-results .results-controls .results-select {
    width: 19em;
}

.nma-results .results-downloads {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em 0.9em;
    flex: 1 1 100%;
    padding-top: 0.9em;
    border-top: 1px solid var(--c-border);
}

.nma-results .results-downloads-title {
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--c-ink-muted);
}

.nma-results .results-downloads .results-format-row {
    padding-left: 0;
    border-left: none;
}



/* ---------- table text follows the box width (bigger when the window is expanded) ---------- */
.nma-results #one-half-2,
.nma-results #one-half-3 {
    container-type: inline-size;
}

.nma-results .dash-spreadsheet-container .dash-spreadsheet-inner td {
    font-size: clamp(11px, 1.6cqi, 15px) !important;
}

.nma-results .dash-spreadsheet-container .dash-spreadsheet-inner th {
    font-size: clamp(11px, 1.55cqi, 14.5px) !important;
}

/* "Select outcome": wide enough for the outcome names */
.nma-results #_outcome_select {
    width: 12em !important;
    min-width: 12em;
}

/* the outcome dropdown passes its inline width to the inner control too */
.nma-results #_outcome_select .Select-control {
    width: 100% !important;
    height: auto !important;
}

/* "do something to see the results" note (same look as the prompts drawn inside empty graphs);
   also used on the NMA-KIT page */
:is(.nma-results, .nma-kt, .kt-trans-modal) .results-prompt {
    display: flex;
    align-items: center;
    gap: 0.7em;
    margin: 0.6em 0;
    padding: 0.8em 1em;
    font-size: 0.92em;
    line-height: 1.45;
    color: var(--c-ink);
    background: var(--c-accent-soft);
    border: 1.5px solid var(--c-accent);
    border-radius: var(--radius-md);
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-prompt .ui-note-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 1.5em;
    height: 1.5em;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, serif;
    color: #fff;
    background: var(--c-accent);
    border-radius: 50%;
}

/* prompt note placed over an empty graph */
:is(.nma-results, .nma-kt, .kt-trans-modal) .js-plotly-plot {
    position: relative;
}

:is(.nma-results, .nma-kt, .kt-trans-modal) .results-prompt.results-prompt-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    width: max-content;
    max-width: 85%;
    margin: 0;
    text-align: left;
}

/* Expand/Reduce window and Download: same box model everywhere (callbacks set display on some of them) */
:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action:not([style*="display: none"]) {
    display: inline-block !important;
    vertical-align: middle;
    line-height: 0;
}

:is(.nma-results, .nma-kt, .kt-trans-modal, .kt-window) .panel-action {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* edge info box before an edge is selected: a lighter hint */
.nma-results .results-network-selection:has(.results-network-selection-hint) {
    font-weight: 500;
    color: var(--c-ink-muted);
    background: var(--c-canvas);
    border: 1px dashed var(--c-border);
}

/* boxes set inline to "overflow: scroll": scrollbars only when there is more to see */
.nma-results [style*="overflow: scroll"] {
    overflow: auto !important;
}

/* "Node & edge size" in the network toolbar (Results and NMA-KIT) */
:is(.nma-results, .nma-kt) .network-scale-select {
    width: 6.5em;
    font-size: 0.9em;
}

/* "Upload CINeMA report" next to Download (league tables): same look as the other box buttons */
.nma-results .panel-action-upload .panel-action-glyph {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    color: var(--c-primary-dark);
    border-bottom: 2px solid var(--c-primary-dark);
}

.nma-results a.panel-action-upload {
    text-decoration: none !important;
}

/* league tables: the first column like the header row; the diagonal stands out */
.nma-results #league_table td[data-dash-column="Treatment"],
.nma-results #league_table_both td[data-dash-column="Treatment"],
.nma-results #modal_league_table_data td[data-dash-column="Treatment"] {
    background-color: var(--c-canvas) !important;
    color: var(--c-ink) !important;
    font-weight: 700 !important;
}

/* league table for two outcomes: choose the two outcomes */
.nma-results .league-both-select {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em 0.7em;
    margin: 0.6em 0 0.4em;
}

.nma-results .league-both-label {
    font-weight: 700;
    color: var(--c-ink);
}

.nma-results .league-both-and {
    color: var(--c-ink-muted);
}

.nma-results .league-both-dd {
    min-width: 11em;
}

.nma-results .league-both-status {
    font-size: 0.85em;
    color: #b8452d;
}

/* section tab names: the tab is as wide as its name, so a long name (e.g. "League Tables for two
   outcomes") stays inside the box when the box is reduced */
.nma-results .tab-container > .tab {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100%;
    white-space: normal;
    text-align: left;
}

.nma-results .league-both-field {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    margin-right: 1.2em;
}

/* league table colour legend: chips in a row, wrapping on narrow boxes */
.nma-results #league_table_legend,
.nma-results #league_table_legend_both,
.nma-results #modal_league_table_legend {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em;
}

/* ---------- publication year slider (Data): teal, a dot per year with studies, year always shown ---------- */
.nma-results .results-slider {
    padding: 2.1em 0.6em 0.4em !important;   /* room for the year above the handle and the labels below */
}

.nma-results .results-slider .rc-slider-rail {
    height: 6px;
    background: #e3e8ed;
    border-radius: 3px;
}

.nma-results .results-slider .rc-slider-track {
    height: 6px;
    background: var(--c-primary) !important;
    border-radius: 3px;
}

.nma-results .results-slider .rc-slider-dot {
    bottom: -1px;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    background: #ffffff;
    border: 1.5px solid #b9c6d1;
}

.nma-results .results-slider .rc-slider-dot-active {
    border-color: var(--c-primary);
}

.nma-results .results-slider .rc-slider-handle {
    width: 18px;
    height: 18px;
    margin-top: -6px;
    background: #ffffff;
    border: 3px solid var(--c-primary) !important;
    box-shadow: 0 1px 4px rgba(29, 43, 58, 0.25) !important;
    opacity: 1;
}

.nma-results .results-slider .rc-slider-handle:hover,
.nma-results .results-slider .rc-slider-handle:focus,
.nma-results .results-slider .rc-slider-handle-dragging {
    border-color: var(--c-primary-dark) !important;
    box-shadow: 0 0 0 5px rgba(31, 138, 138, 0.18) !important;
}

.nma-results .results-slider .rc-slider-mark-text {
    font-size: 11.5px;
    color: var(--c-ink-muted) !important;
    white-space: nowrap;
}

.nma-results .results-slider .rc-slider-tooltip-inner {
    min-width: 0;
    height: auto;
    padding: 2px 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: #ffffff;
    background: var(--c-primary-dark);
    border-radius: 6px;
    box-shadow: none;
}

.nma-results .results-slider .rc-slider-tooltip-arrow {
    border-top-color: var(--c-primary-dark) !important;
}

/* year dots: small and quiet (many years close together) */
.nma-results .results-slider .rc-slider-dot {
    bottom: 1px !important;
    width: 4px !important;
    height: 4px !important;
    margin-left: -2px !important;
    background: #9fb0bf !important;
    border: none !important;
}

.nma-results .results-slider .rc-slider-dot-active {
    background: #ffffff !important;
}

/* ---------- drag handle at the bottom of each box: make it shorter / taller (assets/box_resize.js) ---------- */
.nma-results #one-half-1,
.nma-results #one-half-2,
.nma-results #one-half-3 {
    position: relative;
    padding-bottom: 1.6em !important;
}

.nma-results .nma-box-resize {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    touch-action: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.nma-results .nma-box-resize span {
    width: 46px;
    height: 5px;
    background: #c9d3dc;
    border-radius: 3px;
    transition: background 0.15s ease, width 0.15s ease;
}

.nma-results .nma-box-resize:hover span,
.nma-results .nma-box-resize.is-dragging span {
    width: 64px;
    background: var(--c-primary);
}

.nma-results .nma-box-resize:hover {
    background: rgba(31, 138, 138, 0.06);
}

/* league tables: a gap between Download and "Upload CINeMA report" */
.nma-results a.panel-action-upload {
    margin-left: 0.6em !important;
}
