* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: linear-gradient(135deg, #2c1f0f 0%, #1a1209 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: #2c1f0f;
}

.page-container {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

.container {
    background: linear-gradient(135deg, #f4d03f 0%, #f9e79f 100%);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(255, 255, 255, 0.3);
    padding: 28px;
    max-width: 550px;
    width: 100%;
    border: 3px solid #d4a600;
    position: relative;
}

h1 {
    color: #6b4423;
    margin-bottom: 5px;
    font-size: 32px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
}

.subtitle {
    color: #7a5028;
    margin-bottom: 14px;
    font-size: 14px;
    font-style: italic;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    border-bottom: 2px solid #d4a600;
}

.tab-button {
    padding: 10px 15px;
    background: transparent;
    border: none;
    color: #7a5028;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-button.active {
    color: #6b4423;
    border-bottom-color: #6b4423;
}

.tab-button:hover {
    color: #6b4423;
}

.tab-content {
    display: none;
}

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

.form-group {
    margin-bottom: 13px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #6b4423;
    font-weight: 600;
    font-size: 14px;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid #d4a600;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: #2c1f0f;
    transition: all 0.3s;
    font-family: 'Arial', sans-serif;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #8b5a2b;
    background: white;
    box-shadow: 0 0 10px rgba(139, 90, 43, 0.3);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e5c158;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #8b5a2b;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #8b5a2b;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
}

.currency {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    border: 2px solid #d4a600;
    font-weight: 500;
    color: #8b5a2b;
}

.slider-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.slider-container input[type="range"] {
    flex: 1;
}

.slider-value {
    color: #7a5028;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.input-hint {
    font-size: 11px;
    color: #7a5028;
    margin-top: 4px;
    font-style: italic;
    line-height: 1.4;
}

.results {
    background: rgba(255, 255, 255, 0.7);
    padding: 18px;
    border-radius: 10px;
    margin-top: 30px;
    display: none;
    border: 2px solid #d4a600;
}

.results.show {
    display: block;
}

.results.calculating {
    opacity: 0.55;
    transition: opacity 0.15s;
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d4a600;
}

.result-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.result-label {
    color: #8b5a2b;
    font-size: 14px;
    font-weight: 500;
}

.result-value {
    font-weight: 700;
    color: #6b4423;
    font-size: 14px;
}

.total-invested {
    color: #8b5a2b;
}

.interest-earned {
    color: #8b6d00;
}

.taxes {
    color: #c41e3a;
}

.net-value {
    color: #2d5016;
}

.final-value {
    background: linear-gradient(135deg, #e5c158 0%, #f4d03f 100%);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 2px solid #d4a600;
}

.final-value .result-label {
    font-size: 15px;
    font-weight: 600;
}

.final-value .result-value {
    font-size: 24px;
    color: #6b4423;
}

button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #8b5a2b 0%, #6b4423 100%);
    color: #f4d03f;
    border: 2px solid #d4a600;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
    font-family: 'Georgia', serif;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(107, 68, 35, 0.6);
    background: linear-gradient(135deg, #6b4423 0%, #4a2f1a 100%);
}

button:active {
    transform: translateY(0);
}

.info-box {
    background: rgba(255, 255, 255, 0.8);
    border-left: 4px solid #8b5a2b;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #6b4423;
}

/* ── Ränta-på-ränta-ruta ──────────────────────────────── */
.rpr-panel {
    margin-bottom: 12px;
}
.rpr-toggle {
    width: 100%;
    background: linear-gradient(135deg, #8b5a2b 0%, #6b4423 100%);
    color: #f9e79f;
    border: none;
    border-radius: 10px;
    padding: 13px 18px;
    font-family: 'Georgia', serif;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    transition: opacity 0.2s;
}
.rpr-toggle:hover { opacity: 0.88; transform: none; box-shadow: none; }
.rpr-toggle .rpr-arrow {
    font-size: 11px;
    transition: transform 0.25s;
    flex-shrink: 0;
}
.rpr-toggle.open .rpr-arrow { transform: rotate(180deg); }

.rpr-body {
    display: none;
    background: rgba(255,255,255,0.82);
    border: 1px solid #d4a600;
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 20px;
    color: #3a2510;
    font-size: 13.5px;
    line-height: 1.7;
}
.rpr-body.open { display: block; }

.rpr-body h3 {
    font-size: 15px;
    color: #6b4423;
    margin-bottom: 10px;
}
.rpr-example {
    background: #fff8e8;
    border-left: 4px solid #d4a600;
    border-radius: 6px;
    padding: 14px 16px;
    margin: 14px 0;
    font-size: 13px;
}
.rpr-example strong { color: #6b4423; }
.rpr-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 8px 0;
}
.rpr-bar-row { display: flex; flex-direction: column; gap: 3px; }
.rpr-bar-label { font-size: 12px; color: #6b4423; font-weight: 600; }
.rpr-bar-track {
    background: #e8d9b8;
    border-radius: 6px;
    height: 28px;
    position: relative;
    overflow: hidden;
}
.rpr-bar-fill {
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    transition: width 0.6s ease;
}
.rpr-bar-insatt { background: #8b5a2b; }
.rpr-bar-vanlig { background: #b07d3a; }
.rpr-bar-rpr    { background: #2d6a2d; }
.rpr-bar-value {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 700;
    color: #3a2510;
}
.rpr-takeaway {
    background: linear-gradient(135deg, #2d5016 0%, #1a3a0a 100%);
    color: #c8f0a0;
    border-radius: 8px;
    padding: 13px 16px;
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.6;
}
.rpr-takeaway strong { color: #e8ffd0; }


.breakdown {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #d4a600;
}

.breakdown-title {
    font-weight: 600;
    color: #6b4423;
    margin-bottom: 12px;
    font-size: 14px;
}

.chart-container {
    margin-top: 15px;
    height: 40px;
    background: #e5c158;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    border: 2px solid #d4a600;
}

.chart-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.chart-invested {
    background: #8b5a2b;
}

.chart-interest {
    background: #d4a600;
}

.chart-taxes {
    background: #c41e3a;
}

.chart-net {
    background: #2d5016;
}

.chart-fees {
    background: #e07b00;
}

.legend {
    font-size: 12px;
    margin-top: 12px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.table-container {
    margin-top: 20px;
    overflow-x: auto;
    border-radius: 8px;
    border: 2px solid #d4a600;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

table thead {
    background: #8b5a2b;
    color: #f4d03f;
}

table th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
}

table td {
    padding: 8px 10px;
    border-bottom: 1px solid #d4a600;
    color: #6b4423;
}

table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.5);
}

.success {
    color: #2d5016;
}

.warning {
    color: #c41e3a;
}

.error-message {
    color: #c41e3a;
    font-size: 12px;
    margin-top: 4px;
    display: none;
    font-weight: 600;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 8px;
    background: #8b5a2b;
    color: #f4d03f;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-family: 'Georgia', serif;
    font-weight: 600;
    font-size: 14px;
    z-index: 1000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

.error-message.show {
    display: block;
}

.amount-hint {
    font-size: 12px;
    color: #6b4423;
    margin-top: 3px;
    min-height: 16px;
    font-style: italic;
    opacity: 0.8;
}

/* ── Tooltips ─────────────────────────────────────────── */
.field-label {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    background: #c8a84b;
    color: #2c1f0f;
    border-radius: 50%;
    font-size: 10px;
    font-style: normal;
    font-weight: bold;
    cursor: help;
    margin-left: 7px;
    position: relative;
    vertical-align: middle;
    flex-shrink: 0;
    user-select: none;
    font-family: 'Arial', sans-serif;
}
.info-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #2c1f0f;
    color: #f9e79f;
    font-size: 12px;
    line-height: 1.6;
    padding: 10px 13px;
    border-radius: 8px;
    white-space: pre-wrap;
    width: 240px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
    font-weight: normal;
    font-family: 'Arial', sans-serif;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    left: auto;
    right: -8px;
    transform: none;
}
.info-tip:hover::after,
.info-tip:focus::after { opacity: 1; }

.warning-message {
    background: #fff3cd;
    border: 2px solid #ffc107;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
}

/* ─── Footer ──────────────────────────────────────────── */
.footer {
    flex-basis: 100%;
    width: 100%;
    max-width: 550px;
    margin: 10px auto 10px;
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.license-line {
    color: #d4a600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Georgia', serif;
    flex-wrap: wrap;
    justify-content: center;
}

.license-badge {
    background: rgba(244, 208, 63, 0.12);
    color: #f4d03f;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #d4a600;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Arial', sans-serif;
    text-decoration: none;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.license-badge:hover {
    background: rgba(244, 208, 63, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 166, 0, 0.3);
}

.github-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #2c1f0f 0%, #1a1209 100%);
    color: #f4d03f;
    padding: 11px 26px;
    border-radius: 50px;
    border: 2px solid #d4a600;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.2s;
    font-family: 'Georgia', serif;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.github-button:hover {
    background: linear-gradient(135deg, #1a1209 0%, #0a0604 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(212, 166, 0, 0.4);
    border-color: #f4d03f;
}

.github-button svg {
    width: 18px;
    height: 18px;
    fill: #f4d03f;
}

.updated-date {
    color: #b8860b;
    font-size: 11px;
    opacity: 0.7;
    font-style: italic;
}

@media (max-width: 768px) {
    .page-container {
        flex-direction: column;
    }

    h1 {
        font-size: 24px;
    }
}

/* ── Tvåkolumnslayout (widescreen) ───────────────────── */
.tab-layout {
    display: block;
}

.tab-results .results {
    margin-top: 0;
}

@media (min-width: 900px) {
    .container {
        max-width: 1180px;
    }

    .footer {
        max-width: 1180px;
    }

    .tab-layout {
        display: grid;
        grid-template-columns: 290px minmax(260px, 340px) 1fr;
        gap: 24px;
        align-items: start;
    }

    .tab-summary .results,
    .tab-timeline .results {
        display: block;
    }
}

/* ── Sidhuvud med titel + explainer horisontellt ─────── */
.page-header {
    margin-bottom: 16px;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.header-title {
    flex: 1;
    min-width: 160px;
}

.header-title h1 { margin-bottom: 2px; }
.header-title .subtitle { margin-bottom: 0; }

.header-extras {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Explainer-knappen ska inte ta full bredd i header-läge */
.header-extras .rpr-toggle {
    width: auto;
    padding: 10px 16px;
}

/* Info-boxen utan margin i header-läge */
.header-extras .info-box {
    margin-bottom: 0;
    white-space: nowrap;
}

/* Rpr-body spänner full bredd under header-raden */
.page-header .rpr-body {
    border-radius: 0 0 10px 10px;
}

@media (max-width: 768px) {
    .header-extras { width: 100%; }
    .header-extras .rpr-toggle { width: 100%; }
    .header-extras .info-box { white-space: normal; }
}
.col-header {
    font-size: 10px;
    font-weight: 700;
    color: #8b5a2b;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 7px;
    border-bottom: 2px solid #d4a600;
    opacity: 0.75;
}

/* ── Checkbox-label ──────────────────────────────────────── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
}
.checkbox-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #8b5a2b;
    flex-shrink: 0;
}
