/* wspolne/style.css: shared theme (purples) for all calculators: dark by default, light on request.
   Calculator-specific styles live in that calculator's own folder.
   Colours are variables: the dark set below is the original look; [data-theme="light"] replaces them.
   The theme switch is in nav.js. Purple A (#6d4aff), the A/B badges and the money-flow colours read well in both. */

:root {
    --bg: #13111f;
    --panel: #1c1a26;
    --panel-deep: #17151f;
    --panel-grad: #252335;
    --panel-grad-hi: #2f2a4a;
    --input: #26233a;
    --border: #2c2942;
    --border-strong: #3b3852;
    --text-faint: #4a4660;
    --text-disabled: #5c5873;
    --text-muted: #807b96;
    --text-soft: #b8b3c7;
    --text-2: #d4d1dd;
    --text: #e4e2ea;
    --text-strong: #ffffff;
    --accent-text: #8d7bff;
    --accent-soft: #a48fff;
    --green: #6cd0a5;
    --orange: #ff9f6e;
    --pink: #f08fa3;
    --tag-text: #d6d0f0;
    --series-filter: none;          /* chart lines keep their colours on the dark background */
}

:root[data-theme="light"] {
    --bg: #f6f5fa;
    --panel: #ffffff;
    --panel-deep: #fbfaff;
    --panel-grad: #f4f2fb;
    --panel-grad-hi: #ece7ff;
    --input: #f1eff8;
    --border: #e2deef;
    --border-strong: #cdc7e2;
    --text-faint: #b5b0c8;
    --text-disabled: #a19cb5;
    --text-muted: #6b6680;
    --text-soft: #4d485f;
    --text-2: #2f2b3d;
    --text: #1d1a29;
    --text-strong: #13111f;
    --accent-text: #5a3fd6;
    --accent-soft: #5a3fd6;
    --green: #13885a;
    --orange: #c4561c;
    --pink: #c2334f;
    --tag-text: #3f3a55;
    --series-filter: brightness(0.72) saturate(1.4);   /* pale chart colours darkened for a white background */
}

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 24px;
}

h1 {
    font-size: 22px;
    margin: 0 0 24px;
    color: var(--accent-text);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 16px;
}

h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-text);
    margin: 0 0 14px;
    font-weight: 600;
}

/* === TWO-COLUMN LAYOUT: settings + results === */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-left,
.panel-right {
    min-width: 0;
}

/* === Parameter sections === */
.param-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.param-section:last-of-type {
    border-bottom: none;
}

.param-section h3 {
    color: #6d4aff;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.section-desc {
    color: var(--text-muted);
    font-size: 12px;
    margin: -8px 0 14px;
    line-height: 1.4;
}

/* Collapsible form section ("Opcje dodatkowe"): the heading looks like a section heading with an arrow,
   the line under it says what is switched on */
.param-details summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
}

.param-details summary::-webkit-details-marker {
    display: none;
}

.param-details .details-title {
    color: #6d4aff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.param-details .details-title::before {
    content: '▸ ';
}

.param-details[open] .details-title::before {
    content: '▾ ';
}

.param-details .details-desc {
    color: var(--text-muted);
    font-size: 12px;
}

.param-details[open] summary {
    margin-bottom: 14px;
}

.param-details summary:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 2px;
}

.param {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.param-label-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.param-label-container label {
    flex: 1;
    color: var(--text-soft);
    font-size: 13px;
    text-align: right;
}

.param-help {
    border: none;
    padding: 0;
    font-family: inherit;
    background: #6d4aff;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 11px;
    cursor: help;
    font-weight: bold;
    flex-shrink: 0;
}

.param input[type="number"] {
    width: 120px;
    min-width: 120px;
    background: var(--input);
    color: var(--text-strong);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    text-align: right;
}

.param input[type="number"]:focus {
    outline: none;
    border-color: #6d4aff;
    box-shadow: 0 0 0 2px rgba(109, 74, 255, 0.25);
}

.param-note {
    grid-column: 1 / -1;
    text-align: right;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: -6px;
}

.param .unit {
    color: var(--text-muted);
    font-size: 12px;
    min-width: 50px;
    text-align: left;
}

/* === KPI cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.kpi-card {
    background: var(--input);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.kpi-card .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-text);
    margin-bottom: 6px;
}

.kpi-card .label {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

.kpi-card .hint {
    font-size: 11px;
    margin-top: 6px;
    color: var(--text-muted);
}

.kpi-card.win .value {
    color: var(--green);
}

.kpi-card.highlight {
    border-color: #6d4aff;
    background: linear-gradient(135deg, var(--input) 0%, var(--panel-grad-hi) 100%);
}

/* === Quick buttons under a field (e.g. inflation: NBP target, latest GUS reading): inflacja, oszczedzanie === */
.presets {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

.preset {
    background: var(--input);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text-soft);
    font: inherit;
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
}

.preset.active {
    border-color: #6d4aff;
    color: var(--text);
}

.preset:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 2px;
}

/* === Where the data comes from (under the lead) === */
.data-note {
    font-size: 12px;
    color: var(--text-muted);
    margin: -8px 0 22px;
    line-height: 1.5;
}

.data-note a {
    color: var(--accent-soft);
}

/* === Insight box === */
.insight-box {
    background: linear-gradient(135deg, var(--panel) 0%, var(--panel-grad) 100%);
    border-left: 4px solid #6d4aff;
    padding: 15px 18px;
    border-radius: 0 8px 8px 0;
    margin-top: 20px;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.6;
}

.insight-box.warning {
    border-left-color: var(--orange);
}

.insight-box strong {
    color: var(--text);
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
}

.insight-box p {
    margin: 6px 0;
}

.hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 10px;
    font-style: italic;
}

/* === Responsive: on phones everything stacks === */
@media (max-width: 900px) {
    .layout-grid {
        grid-template-columns: 1fr;
    }

    .panel-left,
    .panel-right {
        order: 1;
    }

    .panel-right {
        order: 2;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .layout-grid {
        gap: 12px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

}

/* Phones: label on its own line, input + unit below, so all inputs line up */
@media (max-width: 560px) {
    .param {
        grid-template-columns: 1fr auto;
        gap: 4px 10px;
    }

    .param-label-container {
        grid-column: 1 / -1;
    }

    .param-label-container label {
        flex: 0 1 auto;
        text-align: left;
    }

    .param input[type="number"] {
        width: 100%;
        min-width: 0;
    }

    .param .unit {
        min-width: 56px;
    }
}
/* Tooltip with data sources */
.real-tooltip {
    position: fixed;
    background: var(--panel);
    border: 1px solid #6d4aff;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-2);
    max-width: 300px;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    cursor: auto;   /* normal cursor, not the text one */
}

.real-tooltip a {
    color: var(--accent-soft);
    text-decoration: underline;
    overflow-wrap: anywhere;   /* wrap a link only when it does not fit, never in the middle of every word */
}

.real-tooltip a:hover {
    color: #6d4aff;
}

/* select styled like the number inputs */
.param select {
    width: 220px;
    background: var(--input);
    color: var(--text-strong);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    grid-column: 2 / -1;
}

@media (max-width: 560px) {
    .param select {
        width: 100%;
        grid-column: 1 / -1;
    }
}

/* Links inside results and descriptions (sources, hints): readable on the dark background */
.hint a,
.insight-box a,
.section-desc a {
    color: var(--accent-soft);
}

/* === Segmented buttons (a choice between a few options) === */
.segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}

.segment {
    flex: 1 1 auto;
    background: var(--input);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    padding: 8px 10px;
    cursor: pointer;
}

.segment.active {
    background: #6d4aff;
    border-color: #6d4aff;
    color: #ffffff;
    font-weight: 600;
}

.segment:disabled {
    cursor: default;
    color: var(--text-disabled);
}

.segmented.small .segment {
    font-size: 12px;
    padding: 6px 8px;
}

.segment:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 2px;
}

/* Link from one calculator to another with the user's numbers (e.g. salary → inflation) */
.cross-link {
    display: inline-block;
    margin: 0 0 18px;
    color: var(--accent-soft);
    font-size: 13px;
    font-weight: 600;
}

/* === Navigation bar at the top (wspolne/nav.js); phones: one row that scrolls sideways === */
/* "w budowie" tag after a calculator that is still being finished (inProgress in nav.js) */
.nav-wip {
    margin-left: 6px;
    padding: 1px 5px;
    border: 1px solid var(--orange);
    border-radius: 4px;
    color: var(--orange);
    font-size: 10px;
    font-weight: 600;
    vertical-align: 1px;
}

/* the same note at the top of such a calculator */
.wip-note {
    border: 1px dashed var(--orange);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--text-soft);
}

.wip-note b {
    color: var(--orange);
}

.wip-note a {
    color: var(--accent-soft);
}

/* the bar + the theme switch (nav.js wraps them in .site-top) */
.site-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -8px 0 18px;
    border-bottom: 1px solid var(--border);
}

.site-nav {
    display: flex;
    gap: 4px;
    margin: -8px 0 18px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.site-top .site-nav {
    flex: 1;
    min-width: 0;
    margin: 0;
    border-bottom: none;
}

.site-nav::-webkit-scrollbar {
    display: none;
}

.site-nav.more {
    mask-image: linear-gradient(to right, #000 80%, transparent);
}

.site-nav a {
    flex-shrink: 0;
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    padding: 10px 12px;
    border-bottom: 3px solid transparent;
}

.site-nav a:first-child {
    padding-left: 0;
}

.site-nav a:hover {
    color: var(--text);
}

.site-nav a.active {
    color: var(--text);
    border-bottom-color: #6d4aff;
}

/* Light / dark switch next to the navigation bar: Ciemny [knob] Jasny (knob left = dark, right = light);
   the word of the current theme is brighter */
.theme-switch {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 4px 2px;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.theme-switch[aria-checked="false"] .theme-dark,
.theme-switch[aria-checked="true"] .theme-light {
    color: var(--text);
    font-weight: 600;
}

.theme-track {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--input);
    border: 1px solid var(--border-strong);
    transition: background 0.2s;
}

.theme-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #6d4aff;
    transition: left 0.2s;
}

.theme-switch[aria-checked="true"] .theme-knob {
    left: 18px;
}

.theme-switch:hover .theme-label {
    color: var(--text);
}

.theme-switch:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 2px;
    border-radius: 6px;
}

/* chart lines and their legend samples: darker on the light background */
.chart-svg polyline,
.legend-line {
    filter: var(--series-filter);
}

.site-nav a:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: -2px;
}

/* === Link back to the calculator (end of the methodology pages) === */
.nav-back {
    display: inline-block;
    color: var(--accent-soft);
    font-size: 13px;
    text-decoration: none;
    margin-bottom: 12px;
}

.nav-back:hover {
    color: var(--text-2);
}

/* === Start page: calculator tiles === */
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.hub-tile {
    display: block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    color: inherit;
    text-decoration: none;
}

a.hub-tile:hover,
a.hub-tile:focus-visible {
    border-color: #6d4aff;
    outline: none;
}

.hub-tile h2 {
    margin-bottom: 8px;
}

.hub-tile p {
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.hub-tile.coming-soon {
    opacity: 0.55;
}

.hub-tile .status {
    display: inline-block;
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Start page: a heading over a group of tiles (e.g. "Kalkulatory finansowe") */
.hub-group-title {
    font-size: 18px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    margin: 8px 0 14px;
}

/* Start page: "Dlaczego te kalkulatory są inne" under the tiles */
.hub-lead {
    font-size: 15px;
    max-width: 760px;
}

.hub-lead b {
    color: var(--text);
}

.hub-about {
    margin-top: 40px;
}

.hub-about-title {
    font-size: 18px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    margin: 0 0 14px;
}

.hub-why {                     /* the same columns as the tiles above, so the edges line up */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.hub-why-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
}

.hub-why-icon {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: var(--accent-soft);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-bottom: 10px;
}

.hub-why-card h3 {
    font-size: 15px;
    color: var(--text);
    margin: 0 0 6px;
}

.hub-why-card p {
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

/* folding sections in the start page footer: "Więcej o tym", "Dla ciekawskich", "Zasady" */
/* links to the "informacje" pages, side by side above the e-mail (start page and those pages) */
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 22px;
    margin-bottom: 10px;
}

.site-footer .footer-links a {
    white-space: normal;
}

/* === Footer with contact (all pages) === */
.site-footer {
    margin-top: 32px;
    padding: 16px 0 8px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    line-height: 1.6;
}

.site-footer a {
    color: var(--accent-soft);
    white-space: nowrap;   /* never break the e-mail address in the middle */
}

.param-help:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 2px;
}

/* ===== Shared result blocks, toggles and options (used by all calculators) ===== */
/* === Results: "housing cost" and "what if" tables === */
.results-block {
    margin-top: 20px;
}

.results-h3 {
    color: var(--accent-text);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px;
}

.table-wrap {
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table th,
.results-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}

.results-table th:first-child,
.results-table td:first-child {
    text-align: left;
    white-space: normal;
    color: var(--text-soft);
}

.results-table th {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-table tr.total td {
    font-weight: 700;
    color: var(--text);
    border-top: 1px solid var(--border-strong);
}

.results-note {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.5;
    margin: 8px 0 0;
}

/* === Intro under the title === */
.lead {
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.6;
    max-width: 900px;
    margin: -12px 0 20px;
}

.lead a,
.results-note a {
    color: var(--accent-soft);
}

.results-table .none {
    color: var(--text-faint);
}

.param-note.param-note-bad {
    color: var(--orange);
}

/* === Toggles: advanced mode === */
.toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 10px 12px;
    background: var(--input);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    margin-bottom: 16px;
}

.toggle input {
    accent-color: #6d4aff;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    flex-shrink: 0;
}

.toggle-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: var(--text);
}

.toggle-text span {
    color: var(--text-muted);
    font-size: 12px;
}

/* Option inside a section (e.g. "living with parents"): a plain one-line checkbox, no frame */
.param-option {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin: 0 0 12px;
    padding-right: 62px;   /* aligned with the number inputs (room for the unit) */
    font-size: 13px;
    color: var(--text-soft);
}

.param-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.param-option input {
    accent-color: #6d4aff;
    width: 16px;
    height: 16px;
    margin: 0;
}

@media (max-width: 560px) {   /* same breakpoint as the stacked form fields */
    .param-option {
        justify-content: flex-start;
        padding-right: 0;
    }
}


.param-zeroed input {
    opacity: 0.5;
}

.hidden-assumptions {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
    margin: 0;
    padding-top: 4px;
}

/* === Key conclusions === */
.insight-box.key-points ul {
    margin: 0;
    padding-left: 18px;
}

.insight-box.key-points li {
    margin: 6px 0;
}

/* ===== Methodology pages ("Jak to liczymy"): readable text, formulas, symbol tables ===== */
.doc { max-width: 860px; line-height: 1.7; color: var(--text-2); font-size: 15px; }
.doc h2 { margin-top: 36px; font-size: 14px; }
.doc h3 { color: var(--accent-soft); font-size: 15px; margin: 24px 0 8px; }
.doc p, .doc li { color: var(--text-2); }
.doc a { color: var(--accent-soft); }
.doc code { background: var(--input); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.formula {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid #6d4aff;
  border-radius: 0 6px 6px 0; padding: 10px 14px; margin: 10px 0;
  font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace; font-size: 14px;
  overflow-x: auto; white-space: pre; line-height: 1.8; color: var(--text);
}
.formula.b { border-left-color: var(--green); }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 10px 0; }
.doc th, .doc td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.doc table.symbols td:first-child { font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace; white-space: nowrap; color: var(--text); }
.doc .table-wrap { overflow-x: auto; }
@media (max-width: 600px) {
  .formula { white-space: pre-wrap; font-size: 12.5px; line-height: 1.7; }
}
.note-box { border-left: 3px solid var(--orange); padding: 8px 14px; background: var(--panel); border-radius: 0 6px 6px 0; }

/* === Line chart (wspolne/chart.js) === */
.panel.chart-panel {
    position: relative;   /* value tooltip is positioned relative to the panel */
}

.chart-box {
    width: 100%;
}

.chart-svg {
    display: block;
    max-width: 100%;
    height: auto;
    background: var(--panel-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    touch-action: pan-y;  /* horizontal swipe = read values, vertical = page scroll */
}

/* Legend: three groups (A / B / shared), each series with a short description */
.chart-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin: 6px 0 14px;
}

.legend-group {
    background: var(--input);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 10px 12px;
}


.legend-title {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-soft);
    margin-bottom: 8px;
    min-height: 24px;
}


.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
}

.legend-item input {
    accent-color: #6d4aff;
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
}

/* Line sample in the series colour (dashed for helper series) */
.legend-line {
    display: inline-block;
    width: 18px;
    height: 0;
    border-top: 3px solid var(--color);
    margin-top: 8px;
    flex-shrink: 0;
}

.legend-line.dashed {
    border-top-style: dashed;
}

.legend-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.legend-label {
    color: var(--text);
    font-size: 13px;
}

/* Short text after a series name in the legend, e.g. the change over the period */
/* extra line under a series in the chart readout (e.g. what the pay buys), indented under the label */
.readout-note {
    margin: -2px 0 4px 18px;
    color: var(--text-soft);
    font-size: 12px;
}

.legend-note {
    color: var(--text-soft);
    font-weight: 600;
    white-space: nowrap;
}

/* Compact legend group (many short series): chips side by side, the whole width of the legend */
.legend-group.legend-compact {
    grid-column: 1 / -1;
}

.legend-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.legend-chip input {
    accent-color: #6d4aff;
    margin: 0;
}

.legend-chip .legend-line {
    margin-top: 0;
    width: 14px;
}

.legend-desc {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

/* Values in a given month: floating tooltip (desktop) and box under the chart (phone) */
.chart-tip,
.chart-readout {
    background: var(--panel);
    border: 1px solid #6d4aff;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
}

.chart-tip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    max-width: min(360px, calc(100% - 16px));
}

.chart-readout {
    margin-top: 10px;
}

.readout-head {
    font-weight: 600;
    margin-bottom: 4px;
}

.readout-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.readout-row .legend-line {
    margin-top: 0;
    width: 12px;
}

.readout-label {
    color: var(--text-soft);
    flex: 1;
    min-width: 0;
}

.readout-value {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .panel.chart-panel {
        padding: 12px;
    }
}
