@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=Josefin+Sans:wght@400;500;600;700&display=swap');

/* Värimaailma 2026: syvä siniharmaa, teal-aksentti (EV/tech), violetit korostukset, slate-äänet */
:root {
    --color-bg-canvas: #080c10;
    --color-panel: rgba(14, 22, 30, 0.9);
    --color-panel-soft: rgba(20, 30, 40, 0.8);
    --color-panel-border: rgba(255, 255, 255, 0.09);
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-accent: #14b8a6;
    --color-accent-hover: #2dd4bf;
    --color-accent-active: #0f766e;
    --color-secondary: #8b7cf8;
    --color-secondary-hover: #a78bfa;
    --color-success: #4ade80;
    --color-success-hover: #22c55e;
    --color-magenta: #fb7185;
    --color-magenta-hover: #f43f5e;
    --color-compare: #818cf8;
    --color-compare-hover: #a5b4fc;
    /* Hillitty CTA (Automerkit): läpinäkymätön slate */
    --color-cta-muted-bg: #334155;
    --color-cta-muted-bg-hover: #475569;
    --color-danger: #fb7185;
    --color-danger-hover: #f43f5e;
    --color-result-pill: rgba(15, 118, 110, 0.5);
    --color-focus-ring: #5eead4;
    --color-bar-muted: #64748b;
    --color-overlay-gradient: linear-gradient(
        165deg,
        rgba(6, 14, 20, 0.55) 0%,
        rgba(8, 22, 28, 0.7) 48%,
        rgba(4, 12, 18, 0.82) 100%
    );
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 10px 32px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.35);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --space-xs: 6px;
    --space-sm: 12px;
    --space-md: 20px;
    --space-lg: 28px;
    --font-display: 'Josefin Sans', ui-sans-serif, system-ui, sans-serif;
    --font-body: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
    /* Työpöytä/kokonäyttö (aiemmin 800px); ≤768px: .container max-width 100% */
    --container-max: 1120px;
    --secondary-color: rgba(20, 184, 166, 0.32);
    --line-prose: 1.65;
    --text-base: 1rem;
    --text-lead: clamp(1.05rem, 2.5vw, 1.125rem);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Body Styles */
body {
    font-family: var(--font-body);
    background-color: var(--color-bg-canvas);
    margin: 0;
    padding: clamp(80px, 18vh, 220px) var(--space-md) var(--space-md);
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    color: var(--color-text);
    line-height: 1.5;
    position: relative;
    isolation: isolate;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--color-overlay-gradient);
}

body .container,
body > footer.footer {
    position: relative;
    z-index: 1;
}

body.brand-page {
    font-family: var(--font-body);
    background-color: var(--color-bg-canvas);
    margin: 0;
    padding: var(--space-md);
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    color: var(--color-text);
    line-height: 1.5;
    position: relative;
    isolation: isolate;
}

body.brand-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--color-overlay-gradient);
}

body.brand-page .container,
body.brand-page > footer.footer {
    position: relative;
    z-index: 1;
}

body > .blog-container,
body > .terms-container {
    position: relative;
    z-index: 1;
}

/* Body Styles for screens 770px or smaller */
@media (max-width: 770px) {
    body,
    body.brand-page {
        padding: var(--space-md);
        background-attachment: scroll;
    }
}

h1,
h2,
h3,
h4,
h2.domain,
h2.inline-h2,
h2.blog {
    font-family: var(--font-display);
}

h1 {
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 600;
    line-height: 1.25;
}

/* Container */
.container {
    max-width: var(--container-max);
    margin: auto;
    background-color: var(--color-panel);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    color: var(--color-text);
    border: 1px solid var(--color-panel-border);
}

@supports (backdrop-filter: blur(10px)) {
    .container {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

.result-paragraph {
    background-color: var(--color-result-pill);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}



/* Table Styles */
.form-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border: 0px solid white; /* Lisää 2px valkoinen reunus */
    table-layout: fixed; /* Varmistaa, että sarakkeet ovat yhtä leveitä */
}

.form-table td {
    padding: 10px;
    vertical-align: top;
    color: #fff;
    border: 0px solid white; /* Lisää 2px valkoinen reunus */
}

/* Form Field Styles */
select,
input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-sm);
    color: #1a1f26;
    background-color: #fff;
    font-family: var(--font-body);
    font-size: var(--text-base, 1rem);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
    border-color: var(--color-accent);
}

button:focus-visible,
.tab:focus-visible,
.accordion:focus-visible,
.expand-button:focus-visible,
a.expand-button:focus-visible,
.fin-chip:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 3px;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Result Section */
.result {
    margin-top: var(--space-md);
    font-size: var(--text-lead, 1.125rem);
    line-height: var(--line-prose);
    color: var(--color-text);
    font-family: var(--font-body);
}

/* Saved Results Styles */
/* Container Flexbox Setup */
/* Automaattinen sarakeleveys: kortit leveämpiä kuin kiinteä 1/3-rivi */
.saved-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: var(--space-sm);
    transition: all 0.5s ease;
}

.saved-results-export {
    display: none;
    margin-top: var(--space-md);
}

.saved-results-export.is-visible {
    display: block;
}

.saved-results-export #exportCompareCsv {
    background: var(--color-panel-soft);
    color: var(--color-text);
    border: 1px solid var(--color-panel-border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.saved-results-export #exportCompareCsv:hover {
    background: rgba(51, 65, 85, 0.95);
    border-color: rgba(139, 124, 248, 0.35);
    transform: translateY(-1px);
}

.saved-results-export #exportCompareCsv:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

/* Fade-in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Fade-out animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
}

/* Vertailukortit: sama henkisyys kuin rahoitusvertailun fin-result-box */
.result-card {
    background: var(--color-result-pill);
    color: var(--color-text);
    padding: var(--space-md);
    padding-top: calc(var(--space-md) + 4px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-panel-border);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    position: relative;
    opacity: 0;
    transform: scale(0.9);
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s ease;
    z-index: 1;
    font-family: var(--font-body);
}

.result-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-md);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Kun kortti poistetaan */
.result-card.removing {
    animation: fadeOut 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.9);
}

.result-card .card-content {
    font-size: 0.9rem;
    padding-right: 28px;
    line-height: 1.45;
}

.result-card .compare-card-lead {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 var(--space-sm);
    color: var(--color-text);
    line-height: 1.35;
}

.result-card .compare-spec-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.result-card .compare-spec-table td {
    padding: 8px 0;
    vertical-align: top;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.result-card .compare-spec-table tr:last-child td {
    border-bottom: none;
}

.result-card .compare-spec-table td:first-child {
    color: var(--color-text-muted);
    width: 58%;
    padding-right: 8px;
}

.result-card .compare-spec-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
}

.result-card .compare-spec-section td {
    border-bottom: none;
    padding-top: var(--space-sm);
    padding-bottom: 4px;
    text-align: left;
}

.result-card .compare-section-label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--color-text);
    font-family: var(--font-display);
    text-align: left;
}

.result-card .compare-spec-total td {
    font-weight: 600;
    color: var(--color-text);
    padding-top: 10px;
    border-bottom: none;
}

.result-card .compare-spec-total td:first-child {
    color: var(--color-text);
}

.result-card .remove-button {
    position: absolute;
    top: 8px;
    right: 10px;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-danger);
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

/* Poistoruksin hover-tila */
.result-card .remove-button:hover {
    color: var(--color-danger-hover);
    transform: scale(1.2) rotate(90deg);
}

/* Mobile Responsive Layout */
@media screen and (max-width: 768px) {
    .form-table td {
        display: block;
        width: 100%;
    }

    .container {
        max-width: 100%;
    }

    .button-container {
        flex-direction: column;
    }

    .result-card {
        width: 100%;
        max-width: 100%;
        flex: 1 1 100%;
        margin-bottom: 15px;
        transform: scale(0.95);
    }

    .result-card:hover {
        transform: translateY(-3px) scale(0.98);
    }
}


/* Button Styles */
/* Button Container (Flexbox) */
.button-container {
    display: flex;
    gap: 10px; /* Space between buttons */
    flex-wrap: nowrap; /* Prevent wrapping */
    justify-content: flex-start; /* Align buttons to the left */
    align-items: center; /* Vertically center buttons */
}

/* General Button Styles */
button {
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    display: inline-block;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-body);
    box-shadow: var(--shadow-sm);
    text-align: center;
    white-space: nowrap;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

button:hover:not(:disabled) {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Active effect (painallus) */
button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Calculate Button Specific Styles */
button#calculateButton {
    flex-grow: 1; /* Allow the calculate button to take up the remaining space */
}

/* Clear Button Specific Styles */

button#calculateButton {
    background: var(--color-success) !important;
    color: #fff !important;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: auto;
    box-shadow: var(--shadow-sm);
}

button#calculateButton:hover:not(:disabled) {
    background: var(--color-success-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button#clearButton {
    background: var(--color-magenta) !important;
    color: #fff !important;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: auto;
    box-shadow: var(--shadow-sm);
	display: none;
}

button#clearButton:hover:not(:disabled) {
    background: var(--color-magenta-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Add to Compare Button */
#addToCompareButton {
    background: var(--color-compare);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 10px;
    width: auto;
    box-shadow: var(--shadow-sm);
    display: none;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#addToCompareButton:hover:not(:disabled) {
    background: var(--color-compare-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#addToCompareButton:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Tabs container */
.tabs {
    display: flex;
    position: relative; /* For glider positioning */
    margin-bottom: 10px;
    border-bottom: 3px solid var(--color-panel-border);
    width: 100%; /* Full width for tabs */
    overflow: hidden; /* Prevent overflow during resizing */
}

/* Individual tabs */
.tab {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
    cursor: pointer;
    background-color: var(--color-accent);
    color: #fff;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, flex-grow 0.25s ease;
    flex: 1; /* Default width for equal spacing */
	
}

.tab:hover {
    background-color: var(--color-accent-hover);
}

.tab.active {
    background-color: var(--color-accent-active);
    z-index: 2; /* Ensure it stays above the glider */
    flex-grow: 1.5; /* Highlight active tab by growing it */
	
}

/* Glider for transition effect */
.glider {
    position: absolute;
    height: 54px;
    width: 0; /* Default width, adjusted dynamically */
    background-color: var(--secondary-color);
    border-radius: 99px; /* Pill effect */
    z-index: 1;
    transition: transform 0.25s ease-out, width 0.25s ease-out;
}

/* Radio button behavior */
input[type="radio"] {
    display: none; /* Hide radio buttons */
}

input[id="tab-1"]:checked ~ .glider {
    transform: translateX(0); /* First tab position */
}

input[id="tab-2"]:checked ~ .glider {
    transform: translateX(100%); /* Second tab position */
}

.tab-content.active {
    display: block;
}


/* Tyylit otsikon painikkeelle */
.accordion {
    cursor: pointer;
    padding: 10px;
    width: 100%;
    text-align: left;
    border: none;
    font-size: 1rem;
    font-family: var(--font-body);
    font-weight: 500;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text);
    transition: background-color 0.2s ease;
}

.accordion:hover {
    background-color: var(--color-accent-hover);
}

.accordion.active::after {
    content: "▲"; /* Vaihda nuolen suunta ylös */
}

.accordion::after {
    content: "▼"; /* Nuolen suunta alas */
    float: right;
    margin-left: 10px;
}

/* Piilotetun sisällön tyylit, käytetään max-height smoothiin avautumiseen */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
    padding: 0 18px;
    margin-top: 5px;
    border-radius: 4px;
}

/* Kun accordion on aktiivinen ja näytetään sisältö */
.accordion-content.show {
    max-height: 500px; /* Riittävän suuri sisältöä varten */
    transition: max-height 0.5s ease-in;
}

/* Varmista, että "Kulutustiedot" on oletuksena auki */
#showNewVsOld .accordion.active + .accordion-content {
    display: block;
    max-height: 500px;
}
/* Kohdistus vain #introContainerin sisäiseen taulukkoon */
#introContainer table {
    width: 100%;
    border-collapse: collapse;
    margin: 5px 0;
    border: 1px solid rgba(27, 38, 49, 0.2);
    table-layout: fixed; /* Tasaa sarakkeiden leveydet */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Taulukon varjo */
    transition: box-shadow 0.3s ease; /* Smooth shadow change */
    border-radius: 4px; /* Kulmien pyöristys */
    overflow: hidden; /* Estää sisällön ylityksen pyöristyksen sisällä */
}

#introContainer th, #introContainer td {
	padding: 10px 4px 10px 4px; 
    border: 1px solid rgba(27, 38, 49, 0.2);
    text-align: center; /* Tekstit keskitetään vaakasuunnassa */
    vertical-align: middle; /* Tekstit keskitetään pystysuunnassa */
    transition: transform 0.2s ease, background-color 0.3s ease, border-radius 0.3s ease; /* Hover animation */
}

#introContainer th {
    background-color: var(--color-secondary);
    color: #fff;
    font-weight: 600;
    font-family: var(--font-display);
}

#introContainer td {
    /* background-color: #fff; */
	/* text-align: left; */
}

/* Hover: otsikot sama sävy kuin secondary-nappi hoverissa */
#introContainer th:hover, #introContainer td:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

#introContainer th:hover {
    background-color: var(--color-secondary-hover);
}

#introContainer td:hover {
    background-color: rgba(27, 38, 49, 1);
}

/* Optional: Table shadow on hover */
#introContainer table:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); /* Increase shadow intensity */
}

/* Etusivu: hero-tyyppinen intro (tuloslaatikko + infokortit, hiottu hierarkia) */
#pageReset {
    margin-bottom: var(--space-sm);
}

#introContainer.intro-fin-wrap {
    background: var(--color-result-pill);
    border-radius: var(--radius-lg);
    padding: clamp(var(--space-md), 4vw, var(--space-lg));
    margin: var(--space-md) 0 var(--space-lg);
    border: 1px solid var(--color-panel-border);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

#introContainer.intro-fin-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#introContainer.intro-fin-wrap .intro-fin-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(12px, 2.5vw, 18px);
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

@media (max-width: 720px) {
    #introContainer.intro-fin-wrap .intro-fin-cards {
        grid-template-columns: 1fr;
        max-width: 420px;
        margin-left: auto;
        margin-right: auto;
    }
}

#introContainer.intro-fin-wrap .intro-fin-card {
    text-align: center;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100%;
    padding: clamp(14px, 3vw, 20px) clamp(12px, 2vw, 16px);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

#introContainer.intro-fin-wrap .intro-fin-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

@media (prefers-reduced-motion: reduce) {
    #introContainer.intro-fin-wrap .intro-fin-card {
        transition: none;
    }

    #introContainer.intro-fin-wrap .intro-fin-card:hover {
        transform: none;
    }
}

#introContainer.intro-fin-wrap .intro-fin-card > p.intro-fin-emoji {
    margin: 0 0 10px;
    font-size: clamp(1.5rem, 4.5vw, 1.9rem);
    line-height: 1;
    color: var(--color-text);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

#introContainer.intro-fin-wrap .intro-fin-card h3 {
    font-size: clamp(0.68rem, 1.85vw, 0.78rem);
    letter-spacing: 0.09em;
    line-height: 1.35;
    margin: 0 0 10px;
    max-width: 20rem;
    color: rgba(226, 232, 240, 0.92);
}

#introContainer.intro-fin-wrap .intro-fin-card > p:not(.intro-fin-emoji) {
    margin: 0;
    font-size: clamp(0.88rem, 2.2vw, 0.95rem);
    line-height: 1.5;
    max-width: 19rem;
    color: rgba(241, 245, 249, 0.78);
    flex-grow: 1;
}

/* Erottimen täysi leveys: border ei saa jakaa max-widthia nappien kanssa (aiheutti „vajaan” viivan). */
#introContainer.intro-fin-wrap .intro-cta-row {
    margin-top: 0;
    margin-bottom: 0;
    margin-left: 0;
    margin-right: 0;
    padding-top: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: none;
    position: relative;
    z-index: 1;
    display: block;
    box-sizing: border-box;
}

#introContainer.intro-fin-wrap .intro-cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    max-width: 52rem;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 770px) {
    #introContainer.intro-fin-wrap .intro-cta-buttons {
        flex-direction: column;
    }
}

/* Layerin oletustila (piilotettu) */
#comparisonLayer {
    position: fixed;
    top: 50%;
    right: -400px; /* Piilotettuna näytön ulkopuolella */
    width: min(100vw - 24px, 360px);
    box-sizing: border-box;
    background-color: var(--color-panel);
    color: var(--color-text);
    padding: 12px 14px 14px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-panel-border);
    transform: translateY(-50%); /* Keskitetty pystysuunnassa */
    transition: right 0.5s ease-in-out; /* Sulava siirtymä */
    z-index: 1000; /* Layer näkyy päällä */
    text-align: left;
}

/* Piilotettu tila */
#comparisonLayer.hidden {
    right: -440px; /* Piilossa oikealla */
}

/* Näkyvä tila: liuku sisään */
#comparisonLayer.slide-in {
    right: 0px; /* Näkyvissä näytöllä */
}

#comparisonLayer .close-button {
    position: absolute;
    top: 2px; /* Etäisyys layerin yläreunasta */
    right: 2px; /* Etäisyys layerin oikeasta reunasta */
    cursor: pointer;
    font-size: 24px; /* Ruksin koko */
    color: var(--color-danger);
    font-weight: bold; /* Vahva fontti */
    background: none; /* Ei taustaväriä */
    border: none; /* Ei reunuksia */
    z-index: 1100; /* Varmistaa, että se näkyy päällä */
    transition: transform 0.3s ease, color 0.3s ease; /* Sulava hover-siirtymä */
    box-shadow: none; /* Poistaa hoverilla näkyvän varjon */
}

#comparisonLayer .close-button:hover {
    color: var(--color-danger-hover);
    transform: scale(1.2); /* Suurentaa hoverilla */
}

/* Toast: nappi omalle rivilleen — välttää inline-napin ja tekstin päällekkäisyyden */
#comparisonLayer p {
    margin: 32px 0 0;
    padding-right: 36px; /* ei alle sulkupainikkeen */
    line-height: 1.5;
    text-align: left;
}

#comparisonLayer #compareButton {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 10px;
    padding: 12px 16px;
    font-size: 1rem;
}



/* Sama tyyli domain-otsikolle */
h2.domain {
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-md);
    display: inline-block;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

/* Inline-h2-tyyli, jotta se tulee samalle riville */
h2.inline-h2 {
    display: inline-block; /* Pitää elementin samalla rivillä */
    font-size: clamp(1.05rem, 2.8vw, 1.35rem);
    margin-left: 10px; /* Pieni väli ensimmäisen osan jälkeen */
    font-weight: 500;
    color: var(--color-text);
}

/* Media query näytöille alle 685px */
@media screen and (max-width: 685px) {
    h2.domain {
        margin-bottom: -5px; /* Lisää väliä domain-otsikon alapuolelle */
    }

    h2.inline-h2 {
        display: block; /* Vaihtaa otsikon allekkain-asetteluun */
        font-size: 13px; /* Puolitetaan fonttikoko */
        margin-left: 0; /* Poistetaan marginaali, koska ne ovat allekkain */
		/* font-weight: bold; */
    }
}

/* Styling for buttons */
.expand-button {
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
    border: none;
    padding: 15px 30px;
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    font-weight: 600;
    font-family: var(--font-body);
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.expand-button:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.expand-button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Add ripple effect */
button::after,
.expand-button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 1s;
}

button:active::after,
.expand-button:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* Smooth transition for the form display */
#formContainer {
    transition: all 0.5s ease-in-out;
    opacity: 0;
}

#formContainer.show {
    opacity: 1;
}

/* Etusivun CTA-rivi: Vertaa tästä + rahoitusvertailu */
.intro-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

a.expand-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
}

.expand-button--secondary {
    background: var(--color-secondary);
}

.expand-button--secondary:hover {
    background: var(--color-secondary-hover);
}

.expand-button--tertiary {
    background: var(--color-cta-muted-bg);
    color: #f1f5f9;
    border: none;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}

.expand-button--tertiary:hover {
    background: var(--color-cta-muted-bg-hover);
    color: #fff;
}

@media (max-width: 770px) {
    .intro-cta-row {
        flex-direction: column;
    }

    .intro-cta-row .expand-button,
    .intro-cta-row a.expand-button {
        width: 100%;
        max-width: 320px;
    }
}

#mainButton {
    margin-bottom: 0;
}

/* Rahoitusvertailu (rahoitusvertailu.html) */
.fin-page h1 {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 3.5vw, 1.45rem);
    font-weight: 600;
    margin: 0 0 8px;
    line-height: 1.3;
}

.fin-back {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.fin-back:hover {
    color: var(--color-text);
    text-decoration: underline;
}

/* Automerkit-luettelo (automerkkit.html) */
.brand-index-page .brand-index-lead {
    margin: 0 0 var(--space-md);
    font-size: var(--text-lead);
    line-height: var(--line-prose);
    color: var(--color-text-muted);
    max-width: 40rem;
}

.brand-index-page .brand-index-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    gap: 10px 14px;
}

.brand-index-page .brand-index-list li {
    margin: 0;
}

.brand-index-page .brand-index-list a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-panel-border);
    background: rgba(0, 0, 0, 0.18);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.brand-index-page .brand-index-list a:hover {
    border-color: rgba(20, 184, 166, 0.45);
    background: rgba(20, 184, 166, 0.12);
    color: var(--color-accent-hover);
}

.fin-field {
    margin-bottom: 18px;
}

.fin-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.fin-stepper {
    display: flex;
    align-items: stretch;
    gap: 0;
    max-width: 100%;
}

/* Sama aksentti kuin expand-button--secondary (violetti), ei yleinen teal-button-hover */
.fin-stepper > button {
    flex: 0 0 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: #e2e8f0;
    color: #0f172a;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: none;
    border-radius: 0;
    white-space: nowrap;
}

.fin-stepper > button:hover:not(:disabled) {
    background: var(--color-secondary);
    color: #fff;
    border-color: var(--color-secondary);
    transform: none;
    box-shadow: none;
}

.fin-stepper > button:active:not(:disabled) {
    background: var(--color-secondary-hover);
    border-color: var(--color-secondary-hover);
    transform: scale(0.98);
    box-shadow: none;
}

.fin-stepper > button:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.fin-stepper > button::after {
    display: none;
}

.fin-stepper > button:first-child {
    border-radius: 4px 0 0 4px;
}

.fin-stepper > button:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.fin-stepper input[type="number"] {
    flex: 1;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    text-align: center;
    min-width: 0;
}

.fin-result-box {
    background: var(--color-result-pill);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    border: 1px solid var(--color-panel-border);
}

.fin-result-box h2 {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0 0 10px;
    color: var(--color-text-muted);
    font-weight: 600;
    font-family: var(--font-display);
}

.fin-result-lead {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px;
}

.fin-result-sub {
    font-size: 0.95rem;
    margin: 0 0 8px;
    color: var(--color-text-muted);
}

.fin-result-breakeven {
    font-size: 0.95rem;
    margin: 0;
    color: var(--color-text);
}

/* Päälaskuri (#result): tuloslistat sama hierarkia kuin rahoitusvertailun infolaatikossa */
.result .fin-result-box ul.calc-result-list {
    list-style: disc;
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}

.result .fin-result-box ul.calc-result-list li {
    margin: 0.4em 0;
}

.result .fin-result-box ul.calc-result-list li:first-child {
    margin-top: 0;
}

.result .fin-result-box ul.calc-result-list li:last-child {
    margin-bottom: 0;
}

.fin-bars {
    margin: 18px 0;
}

.fin-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.fin-bar-label {
    flex: 0 0 72px;
    font-size: 0.9rem;
}

.fin-bar-track {
    flex: 1;
    height: 28px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.fin-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.35s ease;
    min-width: 2px;
}

.fin-bar-fill--new {
    background: var(--color-secondary);
}

.fin-bar-fill--used {
    background: var(--color-bar-muted);
}

.fin-bar-value {
    flex: 0 0 88px;
    text-align: right;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.fin-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

@media (max-width: 600px) {
    .fin-cards {
        grid-template-columns: 1fr;
    }
}

.fin-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.fin-card h3 {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 8px;
    color: var(--color-text-muted);
    font-family: var(--font-display);
}

.fin-card .fin-card-total {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 6px;
}

.fin-card p {
    margin: 4px 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.fin-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.fin-chip {
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: transparent;
    color: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.fin-chip:hover {
    background: rgba(255, 255, 255, 0.1);
}

.fin-chip.is-active {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
}

.fin-disclaimer {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 24px;
    line-height: 1.45;
}

.fin-advanced .accordion-content {
    color: #fff;
}

.fin-advanced .accordion-content label {
    color: #fff;
}

.fin-advanced .accordion-content input {
    color: #000;
}

.fin-advanced-inner {
    margin-top: 12px;
}

.fin-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
    align-items: start;
}

.fin-advanced .fin-settings-grid .fin-field {
    margin-bottom: 0;
}

.fin-advanced .fin-settings-grid .fin-field input[type='number'] {
    margin-top: 6px;
    margin-bottom: 0;
}

.fin-settings-full {
    margin-top: var(--space-md);
}

.fin-settings-full > label {
    display: block;
    margin-bottom: 6px;
}

@media (max-width: 560px) {
    .fin-settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Oletusarvo: Footer kiinteä suuremmilla näytöillä */
.footer {
    background-color: var(--color-panel-soft);
    color: var(--color-text);
    text-align: center;
    padding: var(--space-md) var(--space-sm);
    position: relative; /* Kiinteä alareunassa oletuksena */
    bottom: 0;
    left: 0;
    margin: 350px auto 0; /* Keskittää footerin ja lisää marginaalin ylhäältä */
    max-width: var(--container-max);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-panel-border);
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}


/* Mobiilinäkymässä footer mukautuu sisältöön */
@media (max-width: 1000px) {
    .footer {
        position: relative; /* Poistaa kiinteän alareunan asetuksen */
        margin-top: 400px; /* Lisää reilu marginaali sisällön jälkeen */
        margin-left: auto; /* Siirtää footerin oikealle */
        border-radius: 4; /* Poista pyöristykset mobiilissa */
        box-shadow: none; /* Poista varjo mobiilissa */
        background-color: var(--color-panel-soft);
    }
}


.footer-links a {
    color: var(--color-text);
    text-decoration: none;
    display: inline-block;
    margin: 5px 0;
    font-size: 0.9rem;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.footer-links a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Separator styling */
.separator {
    color: var(--color-text-muted);
    display: inline; /* Default */
}

/* Responsive adjustments */
@media (max-width: 770px) {
    .footer-links a {
        display: block; /* Stack links */
        margin: 5px 0; /* Spacing for readability */
    }
    .separator {
        display: none; /* Hide separators on mobile */
    }
}

/* Blog Container Styles */
.blog-container {
    max-width: var(--container-max);
    margin: auto;
    background-color: rgba(252, 253, 255, 0.96);
    color: #1a1f26;
    padding: var(--space-lg) var(--space-md);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease;
}

.blog-container p,
.blog-container li {
    max-width: 65ch;
    line-height: var(--line-prose);
    font-family: var(--font-body);
}

.blog-container h4 {
    font-family: var(--font-display);
    font-size: clamp(1.05rem, 2.5vw, 1.2rem);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: #141a22;
}

h2.blog {
    display: inline-block; /* Pitää elementin samalla rivillä */
    font-size: clamp(1.05rem, 2.8vw, 1.35rem);
    margin-left: 10px;
    font-weight: 500;
    color: #1a1f26;
}


/* Optional: Media Query for Responsiveness */
@media screen and (max-width: 768px) {
    .blog-container {
        padding: 15px; /* Adjust padding for smaller screens */
        max-width: 100%; /* Allow full width on mobile */
    }
}

.table-terms {
    width: 100%;
    border-collapse: collapse;
}

.table-terms th, 
.table-terms td {
    text-align: left; /* Asettaa tekstin vasempaan reunaan */
    padding: 15px;   /* Lisää väliä solujen välillä */
    border: 1px solid #ddd; /* Lisää raja soluille */
    color: black; /* Tekstin väri mustaksi */
}

.table-terms th {
    background-color: #f2f2f2; /* Taustaväri otsikoille */
}

.table-terms tr:nth-child(even) {
    background-color: #f9f9f9; /* Vaihteleva taustaväri riveille */
}

.table-terms tr:nth-child(odd) {
    background-color: #e0e0e0; /* Vaihteleva taustaväri riveille */
}

.terms-container {
    max-width: var(--container-max);
    margin: auto;
    background-color: var(--color-panel);
    color: var(--color-text);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-panel-border);
    transition: box-shadow 0.2s ease;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content {
    background: var(--color-panel);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: var(--shadow-lg);
    margin: auto;
    border: 1px solid var(--color-panel-border);
    color: var(--color-text);
}

@supports (backdrop-filter: blur(10px)) {
    .modal-content {
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
}

.close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: rotate(90deg);
}

.fuel-settings-grid {
    display: grid;
    gap: 10px;
    width: 100%;
}

.grid-header {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.grid-header .type-price,
.grid-header .share {
    font-weight: 600;
    color: #fff;
    font-size: 15px;
    padding-bottom: 8px;
}

.grid-header .share {
    padding-left: 10px;
}

.grid-row {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
    align-items: center;
}

.type-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

.type-price .label {
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    width: 220px;
}

.share {
    display: flex;
    justify-content: flex-start;
}

.type-price input[type="number"],
.share input[type="number"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #000;
    background-color: #fff;
    font-family: var(--font-body);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.type-price input[type="number"] {
    width: 80px;
}

.share input[type="number"] {
    width: 60px;
}

.type-price input[type="number"]:focus-visible,
.share input[type="number"]:focus-visible {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(159, 212, 255, 0.35);
    outline: none;
}

/* Webkit autofill styles */
input[type="number"]:-webkit-autofill,
input[type="number"]:-webkit-autofill:hover,
input[type="number"]:-webkit-autofill:focus {
    -webkit-text-fill-color: #000;
    -webkit-box-shadow: 0 0 0px 1000px #fff inset;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: #000;
}

.fuel-setting-group {
    background: var(--color-panel-soft);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-panel-border);
    transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.fuel-setting-group:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    background: var(--color-panel);
}

.fuel-setting-group h3 {
    cursor: default;
    padding: 10px;
    width: 100%;
    text-align: left;
    border: none;
    font-size: 1rem;
    font-family: var(--font-display);
    border-radius: var(--radius-sm);
    transition: background-color 0.3s ease;
    background: var(--color-accent);
    color: white;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.fuel-setting-group h3:hover {
    background-color: var(--color-accent-hover);
}

.fuel-setting {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.fuel-setting label {
    font-weight: 500;
    color: #444;
    flex: 1;
}

.fuel-setting input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    width: 100px;
}

.fuel-setting:last-child {
    margin-bottom: 0;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-body);
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--color-accent);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.modal-buttons button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--color-accent-hover);
}

.settings-icon {
    position: absolute;
    top: 0;
    right: 0;
    padding: 10px 14px;
    background: var(--color-accent);
    border-radius: 0 0 0 var(--radius-md);
    color: #fff;
    font-size: 1.5em;
    z-index: 1000;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.25s ease;
}

.settings-icon:hover {
    background: var(--color-accent-hover);
    transform: rotate(90deg);
}

.fuel-setting-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
}

.fuel-setting-row .fuel-setting {
    flex: 1;
}

.fuel-setting input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.fuel-setting label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

.fuel-settings-table {
    width: 100%;
}

.fuel-settings-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
    padding: 0 10px;
}

.fuel-price-column {
    flex: 2;
}

.fuel-share-column {
    flex: 1;
    text-align: center;
}

.fuel-setting-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
}

.fuel-setting-row .fuel-setting:first-child {
    flex: 2;
}

.fuel-setting-row .fuel-setting:last-child {
    flex: 1;
}

.fuel-setting input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

/* Mobiiliresponsiivisuus polttoaineasetuksille */
@media screen and (max-width: 768px) {
    .modal {
        align-items: flex-start;
        padding: 10px;
    }

    .modal-content {
        width: 100%;
        margin: 0;
        padding: 15px;
        border-radius: 8px;
        max-height: 95vh;
        overflow-y: auto;
    }

    /* Säilytetään grid-rakenne myös mobiilissa */
    .grid-header, .grid-row {
        grid-template-columns: 2fr 1fr; /* Säilytetään kaksi saraketta */
        gap: 10px;
        align-items: center;
    }

    .type-price {
        flex-direction: row; /* Pidetään elementit rivissä */
        align-items: center;
        gap: 8px;
    }

    .type-price .label {
        width: auto;
        margin-bottom: 0;
        font-size: 12px;
        flex: 1;
        white-space: normal; /* Sallitaan tekstin rivittyminen */
    }

    .type-price input[type="number"] {
        width: 70px; /* Kiinteä leveys numerolle */
        min-width: 70px;
    }

    .share input[type="number"] {
        width: 50px; /* Pienempi leveys prosenttikentälle */
        min-width: 50px;
    }

    .share {
        margin-top: 0;
        width: auto;
        justify-content: flex-end;
    }

    .grid-header .share {
        padding-left: 0;
        text-align: center;
    }

    /* Optimoidaan otsikot */
    .fuel-setting-group h3 {
        font-size: 14px;
        padding: 8px;
        margin-bottom: 10px;
    }

    /* Optimoidaan syöttökentät */
    .fuel-setting input {
        font-size: 14px;
        padding: 8px;
    }

    /* Muut mobiilioptimoidut tyylit */
    .modal-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .modal-buttons button {
        width: 100%;
        padding: 12px;
    }

    .close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 28px;
    }

    /* Vierityspalkin tyylit */
    .modal-content::-webkit-scrollbar {
        width: 6px;
    }

    .modal-content::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 3px;
    }

    .modal-content::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }

    /* Vierityksen indikaattorit */
    .modal-content::after {
        content: '';
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 20px;
        background: linear-gradient(to top, rgba(27, 38, 49, 0.7), transparent);
        pointer-events: none;
    }

    .modal-content::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 20px;
        background: linear-gradient(to bottom, rgba(27, 38, 49, 0.7), transparent);
        pointer-events: none;
        z-index: 1;
    }

    /* Lisätään apuviivat taulukon selkeyttämiseksi */
    .grid-row {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 8px 0;
    }

    .grid-row:last-child {
        border-bottom: none;
    }
}

/* Tablet-optimointi */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .modal-content {
        width: 90%;
        max-width: 600px;
    }

    .type-price input[type="number"] {
        width: 100px;
    }

    .share input[type="number"] {
        width: 80px;
    }
}

/* --- Markkinaviite 2.0 (aggregoitu ilmoitusdata) --- */
.market-reference {
    margin: var(--space-md) 0;
    padding: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-panel-border);
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-sm);
}

.market-reference--hidden {
    display: none;
}

.market-reference__inner {
    padding: var(--space-md) var(--space-lg);
}

.market-reference__title {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 1.15rem;
    margin: 0 0 var(--space-sm);
    color: var(--color-accent);
}

.market-reference__lead {
    margin: 0 0 var(--space-sm);
    color: var(--color-text);
    line-height: 1.5;
}

.market-reference__stats {
    margin: var(--space-sm) 0;
    padding-left: 1.25rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.market-reference__compare {
    margin: var(--space-sm) 0 0;
    color: var(--color-text);
}

.market-reference__meta {
    margin: var(--space-md) 0 0;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.45;
}

.market-reference__loading {
    padding: var(--space-md) var(--space-lg);
    color: var(--color-text-muted);
    margin: 0;
}

.market-brand-insight {
    margin: 0 0 var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-panel-border);
    background: rgba(20, 30, 40, 0.65);
}

.market-brand-insight__title {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 1.2rem;
    margin: 0 0 var(--space-sm);
    color: var(--color-secondary);
}

.market-brand-insight__lead {
    margin: 0 0 var(--space-sm);
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.market-brand-insight__list {
    margin: var(--space-sm) 0;
    padding-left: 1.25rem;
    color: var(--color-text);
    line-height: 1.65;
}

.market-brand-insight__list--interactive {
    list-style: decimal;
    padding-left: 1.5rem;
}

.market-brand-insight__item {
    margin: 0 0 var(--space-xs);
    padding-left: 0.25rem;
}

.market-brand-insight__row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.35rem;
}

.market-brand-insight__row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: var(--space-sm) var(--space-sm);
    text-align: left;
    font: inherit;
    color: inherit;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-panel-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.market-brand-insight__row:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(139, 124, 248, 0.35);
}

.market-brand-insight__row:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

.market-brand-insight__row[aria-expanded='true'] {
    border-color: rgba(139, 124, 248, 0.55);
    background: rgba(139, 124, 248, 0.08);
}

.market-brand-insight__chevron {
    flex-shrink: 0;
    width: 0.55em;
    height: 0.55em;
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    position: relative;
    top: -0.15em;
}

.market-brand-insight__row[aria-expanded='true'] .market-brand-insight__chevron {
    transform: rotate(-135deg);
    top: 0.1em;
}

.market-brand-insight__year-panel {
    margin: var(--space-xs) 0 var(--space-sm);
    padding: 0 0 0 var(--space-sm);
}

.market-brand-insight__year-panel[hidden] {
    display: none !important;
}

.market-brand-insight__table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-panel-border);
    background: rgba(8, 12, 16, 0.5);
}

.market-brand-insight__year-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    color: var(--color-text);
}

.market-brand-insight__year-table th,
.market-brand-insight__year-table td {
    padding: 0.5rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--color-panel-border);
}

.market-brand-insight__year-table th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
}

.market-brand-insight__year-table tbody tr:last-child td {
    border-bottom: none;
}

.market-brand-insight__year-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

.market-brand-insight__year-empty {
    margin: var(--space-sm) 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.market-brand-insight__model {
    font-weight: 600;
    color: var(--color-text);
}

.market-brand-insight__prices {
    color: var(--color-text-muted);
    font-weight: 400;
}

.market-brand-insight__count {
    color: var(--color-text-muted);
    font-size: 0.92em;
}

.market-brand-insight__meta {
    margin: var(--space-md) 0 0;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    line-height: 1.45;
}

.market-brand-insight__loading {
    color: var(--color-text-muted);
    margin: 0;
}

.market-brand-insight__chart-block {
    margin: var(--space-md) 0 0;
    padding: var(--space-md) 0 0;
    border-top: 1px solid var(--color-panel-border);
}

.market-brand-insight__chart-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 var(--space-xs);
    color: var(--color-text);
}

.market-brand-insight__chart-ai-note {
    margin: -4px 0 var(--space-sm);
    font-size: 0.82rem;
    font-style: italic;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.market-brand-insight__chart-fieldset {
    border: none;
    margin: 0 0 var(--space-sm);
    padding: 0;
    min-width: 0;
}

.market-brand-insight__chart-legend {
    float: none;
    padding: 0;
    margin: 0 0 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.market-brand-insight__chart-checkgrid,
.market-brand-insight__chart-fuel-checkgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 6px 12px;
    overflow-y: auto;
    padding: 4px 2px;
    margin-bottom: var(--space-xs);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-panel-border);
    background: rgba(15, 23, 42, 0.5);
}

.market-brand-insight__chart-checkgrid {
    max-height: min(280px, 42vh);
}

.market-brand-insight__chart-check--select-all {
    grid-column: 1 / -1;
    padding-bottom: 4px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    font-weight: 500;
}

.market-brand-insight__chart-fuel-checkgrid {
    max-height: 140px;
    margin-bottom: var(--space-sm);
}

.market-brand-insight__chart-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--color-text);
    margin: 0;
    font-weight: 400;
}

.market-brand-insight__chart-check input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-focus-ring, #8b7cf8);
    flex-shrink: 0;
}

.market-brand-insight__chart-check input:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

.market-brand-insight__chart-check span {
    min-width: 0;
    flex: 1 1 auto;
}

.market-brand-insight__row-main > .market-brand-insight__model,
.market-brand-insight__row-main > .market-brand-insight__prices,
.market-brand-insight__row-main > .market-brand-insight__count {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.market-brand-insight__show-more-models {
    display: block;
    width: 100%;
    max-width: 22rem;
    margin: var(--space-sm) 0 var(--space-md);
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--color-panel-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
}

.market-brand-insight__show-more-models:hover {
    background: rgba(51, 65, 85, 0.95);
}

.market-brand-insight__show-more-models:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

.market-brand-insight__chart-fuel-extra-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 12px;
    margin-top: 2px;
    padding-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    align-items: start;
}

.market-brand-insight__chart-fuel-extra-row .market-brand-insight__chart-check {
    align-items: flex-start;
}

.market-brand-insight__chart-fuel-extra-row .market-brand-insight__chart-check span {
    min-width: 0;
    line-height: 1.35;
}

.market-brand-insight__chart-check--km,
.market-brand-insight__chart-check--aggregate {
    margin: 0;
}

.market-brand-insight__chart-canvas-wrap {
    position: relative;
    height: min(320px, 55vw);
    max-height: 360px;
    margin-top: var(--space-xs);
}

.market-brand-insight__chart-empty {
    margin: var(--space-sm) 0 0;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

/* Merkkisivut (body.brand-page): kapea näyttö — täysleveys, tilastotaulukko, kuvaaja, insight */
@media (max-width: 640px) {
    body.brand-page {
        padding: var(--space-xs) 0;
    }

    body.brand-page .container {
        max-width: none;
        width: 100%;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 10px var(--space-sm);
        box-sizing: border-box;
    }

    body.brand-page > footer.footer {
        max-width: none;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-sizing: border-box;
    }

    body.brand-page > footer.footer .footer-links a {
        font-size: 0.82rem;
    }

    body.brand-page main section h2 {
        font-size: clamp(0.9rem, 3.8vw, 1.05rem);
        line-height: 1.28;
    }

    body.brand-page main section p,
    body.brand-page main section li {
        font-size: 0.85rem;
        line-height: 1.55;
    }

    body.brand-page main section ul {
        overflow-wrap: break-word;
        word-break: break-word;
        padding-right: 2px;
    }

    body.brand-page main section ul li {
        white-space: normal;
    }

    body.brand-page #pageReset h2.domain,
    body.brand-page #pageReset h2.inline-h2 {
        font-size: clamp(1rem, 4.5vw, 1.2rem);
    }

    /* Yläosan 3 saraketta → pinottu korttirivi (ei ahtaita minisarakkeita) */
    body.brand-page #introContainer table {
        display: block;
        width: 100%;
        border: none;
        box-shadow: none;
        border-radius: 0;
        background: transparent;
        overflow: visible;
    }

    body.brand-page #introContainer thead {
        display: none;
    }

    body.brand-page #introContainer tbody {
        display: block;
        width: 100%;
    }

    body.brand-page #introContainer tbody tr {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
    }

    body.brand-page #introContainer td {
        display: block;
        width: 100%;
        box-sizing: border-box;
        text-align: left;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-sm);
        border: 1px solid rgba(139, 124, 248, 0.28);
        background: rgba(15, 23, 42, 0.55);
        font-size: 0.84rem;
        line-height: 1.55;
    }

    body.brand-page #introContainer td:nth-child(1)::before {
        content: '💸 Keskimääräinen arvonalenema';
        display: block;
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--color-secondary-hover);
        margin-bottom: var(--space-xs);
        letter-spacing: 0.02em;
    }

    body.brand-page #introContainer td:nth-child(2)::before {
        content: '⌛ 3 vuoden jälkeen';
        display: block;
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--color-secondary-hover);
        margin-bottom: var(--space-xs);
        letter-spacing: 0.02em;
    }

    body.brand-page #introContainer td:nth-child(3)::before {
        content: '✅ Keskimääräinen kulutus';
        display: block;
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--color-secondary-hover);
        margin-bottom: var(--space-xs);
        letter-spacing: 0.02em;
    }

    body.brand-page #introContainer td:hover {
        transform: none;
        box-shadow: none;
    }

    .market-brand-insight {
        padding: 10px var(--space-sm);
        margin-bottom: var(--space-md);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .market-brand-insight__title {
        font-size: 0.92rem;
        line-height: 1.28;
    }

    .market-brand-insight__lead {
        font-size: 0.78rem;
        line-height: 1.45;
    }

    .market-brand-insight__list {
        font-size: 0.78rem;
        line-height: 1.55;
        padding-left: 1.35rem;
    }

    .market-brand-insight__list--interactive {
        padding-left: 1.45rem;
    }

    .market-brand-insight__list--interactive .market-brand-insight__item {
        min-width: 0;
        max-width: 100%;
    }

    .market-brand-insight__model {
        font-size: 0.84rem;
    }

    .market-brand-insight__prices {
        font-size: 0.76rem;
        line-height: 1.4;
    }

    .market-brand-insight__count {
        font-size: 0.72rem;
    }

    .market-brand-insight__row-main > .market-brand-insight__model,
    .market-brand-insight__row-main > .market-brand-insight__prices,
    .market-brand-insight__row-main > .market-brand-insight__count {
        display: block;
        width: 100%;
    }

    .market-brand-insight__row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
    }

    .market-brand-insight__row-main {
        flex-direction: column;
        align-items: flex-start;
        align-self: stretch;
        gap: 0.15rem 0;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .market-brand-insight__chart-title {
        font-size: 0.88rem;
    }

    .market-brand-insight__chart-ai-note {
        font-size: 0.72rem;
    }

    /* Poltto/sähkö + mallit: yksi sarake, ei kapeaa kaksisaraketta */
    .market-brand-insight__chart-fuel-checkgrid,
    .market-brand-insight__chart-checkgrid {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px 10px;
        padding: 8px 10px;
    }

    .market-brand-insight__chart-fuel-checkgrid {
        max-height: min(320px, 50vh);
    }

    .market-brand-insight__chart-fuel-extra-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px 0;
    }

    .market-brand-insight__chart-fuel-extra-row .market-brand-insight__chart-check {
        align-items: flex-start;
    }

    .market-brand-insight__chart-check {
        font-size: 0.78rem;
        line-height: 1.4;
    }

    /* Kuvaaja: enemmän korkeutta kapealla, jotta akselit erottuvat */
    .market-brand-insight__chart-canvas-wrap {
        height: clamp(260px, 48vh, 340px);
        min-height: 260px;
        max-height: none;
        margin-top: var(--space-sm);
    }

    .market-brand-insight__year-table {
        font-size: 0.78rem;
    }

    .market-brand-insight__year-table th,
    .market-brand-insight__year-table td {
        padding: 0.4rem 0.4rem;
        white-space: normal;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .market-brand-insight__year-table th {
        font-size: 0.72rem;
    }

    .market-brand-insight__show-more-models {
        max-width: none;
    }
}
