/* ============================================
   kalkulator-finansowy.pl – light financial workbench
   Trust-focused, compact, accessible contrast
   ============================================ */

:root {
    --bg-root:              #F6F8FB;
    --bg-panel:             #FFFFFF;
    --bg-card:              #FFFFFF;
    --bg-card-hover:        #F8FAFC;
    --bg-input:             #F8FAFC;
    --bg-input-focus:       #FFFFFF;
    --bg-tag:               #EEF2F6;
    --bg-table-stripe:      rgba(15,23,42,0.018);
    --bg-table-hover:       rgba(15,118,110,0.06);
    --bg-overpayment:       #F8FAFC;
    --bg-chart-area:        rgba(15,118,110,0.04);

    --border:               #DDE5EE;
    --border-light:         #EDF2F7;
    --border-accent:        rgba(15,118,110,0.24);

    --accent:               #0F766E;
    --accent-hover:         #0D9488;
    --accent-light:         rgba(15,118,110,0.10);
    --accent-glow:          rgba(15,118,110,0.14);

    --green:                #16A34A;
    --green-light:          rgba(22,163,74,0.10);
    --green-glow:           rgba(22,163,74,0.10);

    --red:                  #DC2626;
    --red-light:            rgba(220,38,38,0.10);

    --orange:               #D97706;
    --orange-light:         rgba(217,119,6,0.11);

    --text-primary:         #0F172A;
    --text-secondary:       #475569;
    --text-muted:           #7C8796;
    --text-accent:          #0F766E;
    --text-green:           #16A34A;
    --text-red:             #DC2626;

    --shadow-card:          0 1px 2px rgba(15,23,42,0.04);
    --shadow-elevated:      0 16px 34px rgba(15,23,42,0.10);
    --shadow-glow-accent:   0 0 0 3px rgba(15,118,110,0.10);

    --radius-sm:            4px;
    --radius:               6px;
    --radius-md:            8px;
    --radius-lg:            10px;

    --font-body:            14px;
    --font-small:           12px;
    --font-micro:           11px;
    --font-title:           16px;
    --font-heading:         22px;
    --font-metric:          24px;

    --top-bar-height:       68px;
    --category-bar-height:  48px;

    --transition-fast:      0.12s ease;
    --transition-base:      0.18s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-root);
    color: var(--text-primary);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: var(--font-body);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

::selection {
    background: var(--accent-light);
    color: var(--accent);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   TOP BAR
   ============================================ */

.top-bar {
    background:
        linear-gradient(180deg, rgba(15,118,110,0.035), transparent 72%),
        var(--bg-panel);
    border-bottom: 1px solid var(--border);
    height: var(--top-bar-height);
    display: flex;
    align-items: center;
    z-index: 100;
    position: sticky;
    top: 0;
    box-shadow: 0 1px 0 rgba(15,23,42,0.02);
}

.top-bar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 24px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    min-width: 0;
}

.brand-mark {
    position: relative;
    width: 42px;
    height: 42px;
    overflow: hidden;
    background:
        linear-gradient(135deg, #0F766E, #0D9488);
    color: #FFFFFF;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 10px 24px rgba(15,118,110,0.16);
}

.brand-calculator {
    display: grid;
    grid-template-columns: repeat(3, 5px);
    grid-auto-rows: 5px;
    gap: 3px;
    width: 21px;
}

.calc-screen {
    grid-column: 1 / -1;
    height: 6px;
    background: rgba(255,255,255,0.92);
    border-radius: 2px;
}

.calc-key {
    width: 5px;
    height: 5px;
    background: rgba(255,255,255,0.70);
    border-radius: 1px;
}

.calc-key-wide {
    grid-column: span 2;
    width: 13px;
}

.calc-key-accent {
    background: #D1FAE5;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-kicker {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.brand-title {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.15;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar-link {
    font-size: var(--font-small);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-weight: 600;
    background: transparent;
    border: 1px solid transparent;
    font-family: inherit;
}

.top-bar-link:hover {
    color: var(--text-primary);
    border-color: var(--border);
    background: var(--bg-card-hover);
}

/* ============================================
   CATEGORY BAR (sub-header badges)
   ============================================ */

.category-bar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--top-bar-height);
    z-index: 99;
    overflow: hidden;
}

.category-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 10px 20px;
    max-width: 1360px;
    margin: 0 auto;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: var(--font-small);
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.01em;
    transition: all var(--transition-base);
}

.category-badge:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-card-hover);
}

.category-badge.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow-accent);
}

.badge-icon {
    font-size: 13px;
    line-height: 1;
}

.badge-count {
    font-size: var(--font-micro);
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-tag);
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    margin-left: 2px;
}

.category-badge.active .badge-count {
    color: #fff;
    background: rgba(255,255,255,0.20);
}

/* ============================================
   DUAL-PANE LAYOUT
   ============================================ */

.main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 0;
    flex: 1;
    max-width: 1360px;
    margin: 0 auto;
    width: 100%;
}

.feed-pane {
    padding: 24px 24px 72px;
    overflow-y: auto;
    min-height: 0;
}

.detail-pane {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 24px 24px 72px;
    position: sticky;
    top: calc(var(--top-bar-height) + var(--category-bar-height));
    height: calc(100vh - var(--top-bar-height) - var(--category-bar-height));
    overflow-y: auto;
}

@media (max-width: 960px) {
    :root {
        --top-bar-height: 64px;
    }

    .top-bar-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        padding: 0 16px;
    }

    .main-layout {
        grid-template-columns: 1fr;
    }

    .loan-preview {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-pane {
        display: none;
    }

    .detail-pane.mobile-visible {
        display: block;
        position: static;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

/* ============================================
   TAB PANELS
   ============================================ */

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeSlideIn 0.15s ease-out;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
    margin-bottom: 14px;
}

.page-title {
    font-size: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.page-subtitle {
    font-size: var(--font-body);
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 600px;
}

/* ============================================
   FEED CARD
   ============================================ */

.feed-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 8px;
    transition: all var(--transition-base);
    position: relative;
    cursor: default;
}

.feed-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--accent);
    border-radius: var(--radius) 0 0 var(--radius);
    transition: width var(--transition-base);
}

.feed-card.hoverable:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
}

.feed-card.hoverable:hover::before {
    width: 2px;
}

.feed-card.interactive {
    cursor: pointer;
}

.feed-card.interactive:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-elevated);
}

.feed-card.interactive:hover::before {
    width: 2px;
}

.card-header-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.card-icon-slot {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.card-body {
    flex: 1;
    min-width: 0;
}

.card-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 3px;
}

.card-title {
    font-size: var(--font-title);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.card-subtitle {
    font-size: var(--font-body);
    color: var(--text-secondary);
    font-weight: 500;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.card-salary {
    font-size: var(--font-metric);
    font-weight: 800;
    color: var(--text-green);
    letter-spacing: -0.02em;
    white-space: nowrap;
    text-align: right;
    flex-shrink: 0;
}

.card-salary-label {
    font-size: var(--font-micro);
    font-weight: 500;
    color: var(--text-muted);
    display: block;
    line-height: 1;
    margin-bottom: 1px;
}

/* ── Micro Tags / Badges ── */

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--font-micro);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tag);
    border: 1px solid var(--border-light);
    border-radius: 3px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.tag-accent {
    color: var(--accent);
    background: var(--accent-light);
    border-color: transparent;
}

.tag-green {
    color: var(--text-green);
    background: var(--green-light);
    border-color: transparent;
}

.tag-red {
    color: var(--text-red);
    background: var(--red-light);
    border-color: transparent;
}

.tag-orange {
    color: var(--orange);
    background: var(--orange-light);
    border-color: transparent;
}

/* ============================================
   SECTION HEADINGS
   ============================================ */

.section-title {
    font-size: var(--font-micro);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.subsection-title {
    font-size: var(--font-small);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   LIVE LOAN PREVIEW
   ============================================ */

.loan-preview {
    display: grid;
    grid-template-columns: minmax(190px, 1.35fr) repeat(3, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.preview-metric {
    min-width: 0;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.preview-primary {
    background: var(--accent-light);
    border-color: var(--border-accent);
}

.preview-label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-metric strong {
    display: block;
    color: var(--text-primary);
    font-size: var(--font-metric);
    line-height: 1.1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.preview-primary strong {
    color: var(--text-green);
}

.preview-metric span:last-child {
    display: block;
    color: var(--text-muted);
    font-size: var(--font-micro);
    margin-top: 3px;
}

.loan-preview[data-state="good"] #mPreviewLtv,
.loan-preview[data-state="good"] #mPreviewDownPayment {
    color: var(--text-green);
}

.loan-preview[data-state="warn"] #mPreviewLtv,
.loan-preview[data-state="warn"] #mPreviewDownPayment {
    color: var(--orange);
}

.loan-preview[data-state="danger"] #mPreviewLtv,
.loan-preview[data-state="danger"] #mPreviewDownPayment {
    color: var(--text-red);
}

/* ============================================
   INPUT GRID
   ============================================ */

.input-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

@media (max-width: 640px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-label {
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input {
    width: 100%;
    min-height: 40px;
    padding: 8px 46px 8px 12px;
    font-size: var(--font-body);
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    -moz-appearance: textfield;
    caret-color: var(--accent);
    transition: all var(--transition-fast);
}

.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input:hover {
    border-color: var(--text-muted);
}

.input:focus {
    border-color: var(--accent);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.input[aria-invalid="true"] {
    border-color: var(--red);
    box-shadow: 0 0 0 2px var(--red-light);
}

.input-suffix {
    position: absolute;
    right: 10px;
    font-size: var(--font-small);
    font-weight: 500;
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Range Slider ── */

.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin-top: 6px;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: transform var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-micro);
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

/* ── Toggle Group ── */

.toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    background: var(--bg-toggle-track);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.toggle-group-three {
    grid-template-columns: repeat(3, 1fr);
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 36px;
    padding: 8px 12px;
    font-size: var(--font-small);
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-btn:hover {
    color: var(--text-primary);
}

.toggle-btn.active {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-icon {
    font-size: 12px;
}

.input-group.is-hidden {
    display: none;
}

/* ============================================
   TOOLTIP
   ============================================ */

.tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 9px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 50%;
    cursor: help;
    position: relative;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.tooltip:hover {
    background: var(--accent);
    color: #fff;
}

.tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    padding: 10px 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--font-small);
    font-weight: 400;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-elevated);
    z-index: 200;
    pointer-events: none;
    white-space: normal;
}

.tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
    z-index: 200;
}

/* ============================================
   OVERPAYMENTS
   ============================================ */

.overpayments-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-bottom: 14px;
}

.overpayments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.section-option {
    margin-bottom: 10px;
}

.overpayment-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-overpayment);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.overpayment-row .input-group {
    flex: 1;
    min-width: 120px;
}

.overpayment-row .input-group-wide {
    flex: 1.6;
    min-width: 180px;
}

.overpayment-row .input {
    font-size: var(--font-body);
    padding: 7px 66px 7px 10px;
}

.costs-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cost-card {
    min-width: 0;
    padding: 12px;
    background: var(--bg-overpayment);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.cost-card-wide {
    grid-column: 1 / -1;
}

.cost-card-title {
    margin: 0 0 10px;
    color: var(--text-primary);
    font-size: var(--font-small);
    font-weight: 800;
}

.cost-input-row {
    min-width: 0;
    margin-bottom: 8px;
}

.cost-input-row:last-child {
    margin-bottom: 0;
}

.cost-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(100px, 0.58fr);
    gap: 8px;
}

.cost-card .input {
    padding-top: 7px;
    padding-bottom: 7px;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: var(--font-small);
    font-weight: 600;
}

.checkline input {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.overpayment-planner {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
    gap: 10px;
}

.overpay-card {
    min-width: 0;
    padding: 12px;
    background: var(--bg-overpayment);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.overpay-card-wide {
    grid-row: span 2;
}

.overpay-frequency-list {
    display: grid;
    gap: 8px;
}

.overpay-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(90px, 0.6fr) auto auto minmax(70px, 0.45fr) auto minmax(70px, 0.45fr);
    gap: 7px;
    align-items: center;
    color: var(--text-secondary);
    font-size: var(--font-small);
    font-weight: 600;
}

.overpay-row .input {
    padding-top: 7px;
    padding-bottom: 7px;
}

.overpay-unit {
    color: var(--text-muted);
    font-size: var(--font-small);
    font-weight: 700;
}

.btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-red);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.btn-remove:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.costs-timeline {
    display: grid;
    gap: 8px;
}

.costs-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.cost-category-pill {
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.cost-category-pill span {
    display: block;
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cost-category-pill strong {
    display: block;
    margin-top: 2px;
    color: var(--text-primary);
    font-size: var(--font-small);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.mini-section-title {
    margin: 4px 0 8px;
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cost-timeline-item {
    display: grid;
    grid-template-columns: minmax(80px, 0.5fr) minmax(160px, 1fr) minmax(120px, auto);
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.cost-timeline-month,
.cost-timeline-category {
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cost-timeline-name {
    color: var(--text-primary);
    font-size: var(--font-small);
    font-weight: 700;
}

.cost-timeline-amount {
    color: var(--text-red);
    font-size: var(--font-small);
    font-weight: 800;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 16px;
    font-size: var(--font-small);
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 3px 8px var(--accent-glow);
    transform: translateY(-1px);
}

.btn:disabled,
.btn:disabled:hover {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-secondary:hover {
    background: var(--accent-light);
}

.btn-small {
    padding: 5px 12px;
    font-size: var(--font-small);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.btn-small:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-small:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-small:disabled:hover {
    border-color: var(--border);
    color: var(--text-secondary);
    background: var(--bg-card);
}

.btn-calculate {
    width: 100%;
    padding: 13px 20px;
    font-size: var(--font-body);
    margin-top: 4px;
    border-radius: var(--radius);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-feedback {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: var(--font-small);
    font-weight: 600;
}

.form-feedback:empty {
    display: none;
}

.form-feedback.is-error {
    color: var(--text-red);
    background: var(--red-light);
    border-color: rgba(248,113,113,0.35);
}

.form-feedback.is-warning {
    color: var(--orange);
    background: var(--orange-light);
    border-color: rgba(251,191,36,0.35);
}

.form-feedback.is-success {
    color: var(--text-green);
    background: var(--green-light);
    border-color: rgba(22,163,74,0.30);
}

/* ============================================
   SUMMARY GRID
   ============================================ */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    margin-bottom: 12px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    position: relative;
    overflow: hidden;
}

.summary-card.accent-red {
    border-left: 3px solid var(--red);
}

.summary-card.accent-orange {
    border-left: 3px solid var(--orange);
}

.summary-card.accent-green {
    border-left: 3px solid var(--green);
}

.summary-icon {
    display: none;
}

.summary-label {
    font-size: var(--font-micro);
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.summary-card.accent-green .summary-value {
    color: var(--text-green);
}

.summary-card.accent-red .summary-value {
    color: var(--text-red);
}

.summary-detail {
    font-size: var(--font-micro);
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

/* ============================================
   SCENARIO COMPARISON
   ============================================ */

.scenario-card {
    padding-bottom: 18px;
}

.scenario-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.scenario-header .section-title {
    flex: 1;
    margin-bottom: 0;
}

.scenario-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.scenario-empty {
    padding: 16px;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    font-size: var(--font-small);
    font-weight: 600;
    text-align: center;
}

.scenario-empty.is-hidden {
    display: none;
}

.scenario-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.scenario-item {
    min-width: 0;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.scenario-item.best-cost {
    border-color: rgba(22,163,74,0.36);
    box-shadow: inset 3px 0 0 var(--green);
}

.scenario-item.best-payment {
    border-color: rgba(15,118,110,0.34);
}

.scenario-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.scenario-title {
    color: var(--text-primary);
    font-size: var(--font-body);
    font-weight: 800;
    line-height: 1.25;
}

.scenario-subtitle {
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 600;
    margin-top: 2px;
}

.icon-button.scenario-remove {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
}

.scenario-metrics {
    display: grid;
    gap: 6px;
}

.scenario-metric {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
}

.scenario-metric:first-child {
    border-top: 0;
    padding-top: 0;
}

.scenario-metric span {
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scenario-metric strong {
    color: var(--text-primary);
    font-size: var(--font-small);
    font-weight: 800;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.scenario-metric .positive {
    color: var(--text-green);
}

.scenario-metric .warning {
    color: var(--orange);
}

/* ============================================
   CHARTS
   ============================================ */

.payment-overview-card {
    padding-bottom: 18px;
}

.payment-overview {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.45fr);
    gap: 28px;
    align-items: center;
}

.payment-donut-panel {
    display: grid;
    justify-items: center;
    gap: 4px;
}

.payment-percent-label,
.payment-percent-sub {
    color: var(--text-secondary);
    font-size: var(--font-small);
    font-weight: 600;
}

.payment-percent {
    color: var(--text-primary);
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.payment-donut-wrap {
    width: min(240px, 100%);
    aspect-ratio: 1;
    margin: 10px auto 8px;
}

.payment-donut-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.payment-breakdown {
    min-width: 0;
}

.payment-breakdown-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: baseline;
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: var(--font-body);
    font-weight: 700;
    border-top: 1px solid var(--border-light);
}

.payment-breakdown-row:first-child {
    border-top: 0;
}

.payment-breakdown-total {
    color: var(--text-primary);
    font-size: 17px;
    padding-top: 0;
}

.payment-breakdown-row strong,
.payment-cost-row strong {
    color: var(--text-primary);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.legend-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 10px;
    border-radius: 50%;
    vertical-align: -1px;
}

.dot-interest {
    background: #F97316;
}

.dot-costs {
    background: #E11D48;
}

.dot-capital {
    background: #57518F;
}

.dot-overpayment {
    background: #0F766E;
}

.payment-cost-details {
    display: grid;
    gap: 6px;
    padding: 2px 0 10px 30px;
}

.payment-cost-details.is-hidden {
    display: none;
}

.payment-cost-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    color: var(--text-secondary);
    font-size: var(--font-small);
    font-weight: 500;
}

.payment-cost-row.muted {
    color: var(--text-muted);
}

.chart-card {
    padding-bottom: 18px;
}

.chart-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.chart-container.chart-tall {
    max-width: 100%;
    aspect-ratio: 16 / 7;
    min-height: 260px;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-small);
    font-weight: 500;
    color: var(--text-secondary);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ============================================
   TABLE
   ============================================ */

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.table-summary {
    font-size: var(--font-small);
    color: var(--text-muted);
    font-weight: 500;
}

.table-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-small);
    color: var(--text-secondary);
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.schedule-table {
    width: 100%;
    min-width: 920px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--font-body);
    font-family: inherit;
}

.schedule-table th {
    padding: 13px 12px;
    text-align: right;
    font-weight: 800;
    font-size: var(--font-small);
    color: #FFFFFF;
    line-height: 1.25;
    letter-spacing: 0;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,0.45);
    border-right: 1px solid rgba(255,255,255,0.20);
}

.schedule-table th:last-child {
    border-right: 0;
}

.schedule-table th:first-child {
    text-align: left;
    border-top-left-radius: var(--radius);
}

.schedule-table th:last-child {
    border-top-right-radius: var(--radius);
}

.schedule-table .col-date-header {
    color: var(--text-primary);
    background: #F1F5F9;
}

.schedule-table .col-payment-header {
    color: #334155;
    background: #CBD0D6;
}

.schedule-table .col-interest-header {
    background: #F97316;
}

.schedule-table .col-capital-header {
    background: #57518F;
}

.schedule-table .col-overpayment-header {
    background: #0F766E;
}

.schedule-table .col-balance-header {
    background: #292866;
}

.schedule-table .col-costs-header {
    background: #E11D48;
}

.schedule-table td {
    padding: 9px 12px;
    text-align: right;
    border-bottom: 1px solid rgba(255,255,255,0.55);
    border-right: 1px solid rgba(255,255,255,0.35);
    white-space: nowrap;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.schedule-table td:last-child {
    border-right: 0;
}

.schedule-table td:first-child {
    text-align: left;
}

.schedule-table tbody tr {
    transition: background var(--transition-fast);
}

.schedule-table tbody tr:hover td {
    background: rgba(15,118,110,0.08);
}

.schedule-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: var(--radius);
}

.schedule-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: var(--radius);
}

.schedule-year-row td {
    background: #FFFFFF;
    color: var(--text-primary);
    font-size: var(--font-body);
    font-weight: 800;
    border-bottom: 1px dashed var(--border);
}

.schedule-month-row td {
    background: #EEF0F2;
    color: #4B5563;
    font-size: var(--font-body);
    font-weight: 500;
    border-bottom-color: rgba(255,255,255,0.38);
}

.schedule-date-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.schedule-year-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    color: var(--text-primary);
    background: #FFFFFF;
    border: 2px solid #111827;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
}

.schedule-year-toggle:hover {
    color: #FFFFFF;
    background: var(--accent);
    border-color: var(--accent);
}

.schedule-month-row td:first-child {
    padding-left: 48px;
    font-weight: 700;
}

/* ============================================
   DETAIL PANE (right sidebar)
   ============================================ */

.detail-pane-title {
    font-size: var(--font-small);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.detail-empty-icon {
    font-size: 36px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.detail-empty h4 {
    font-size: var(--font-body);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-empty p {
    font-size: var(--font-small);
    max-width: 220px;
    line-height: 1.5;
}

.detail-metric {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 6px;
}

.detail-metric-label {
    font-size: var(--font-micro);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.detail-metric-value {
    font-size: var(--font-metric);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.detail-metric-value.green {
    color: var(--text-green);
}

.detail-metric-value.red {
    color: var(--text-red);
}

.detail-metric-sub {
    font-size: var(--font-micro);
    color: var(--text-muted);
    margin-top: 1px;
    font-weight: 500;
}

/* ============================================
   PLACEHOLDER TABS
   ============================================ */

.placeholder-card {
    text-align: center;
    padding: 36px 20px;
}

.placeholder-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.placeholder-card h3 {
    font-size: var(--font-title);
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.placeholder-card > p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: var(--font-body);
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

.feature-list {
    display: inline-flex;
    flex-direction: column;
    text-align: left;
    list-style: none;
    padding: 0;
    gap: 3px;
}

.feature-list li {
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: var(--font-body);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.feature-list li::before {
    content: '✓';
    color: var(--accent);
    font-weight: 700;
    font-size: 10px;
    width: 18px;
    height: 18px;
    background: var(--accent-light);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    width: min(520px, calc(100vw - 32px));
    padding: 0;
    color: var(--text-primary);
    background: transparent;
    border: 0;
}

.modal::backdrop {
    background: rgba(0,0,0,0.58);
    backdrop-filter: blur(2px);
}

.modal-panel {
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elevated);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.modal-header h2 {
    font-size: var(--font-title);
    font-weight: 800;
}

.modal-panel p {
    color: var(--text-secondary);
    font-size: var(--font-body);
    line-height: 1.55;
}

.modal-panel p + p {
    margin-top: 10px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
    font-size: 20px;
    line-height: 1;
    transition: all var(--transition-fast);
}

.icon-button:hover {
    color: var(--text-primary);
    border-color: var(--border-accent);
    background: var(--bg-card-hover);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 12px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-micro);
    font-weight: 500;
    letter-spacing: 0.03em;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    body {
        background: #fff;
        color: #000;
        --text-primary: #000;
        --text-secondary: #555;
    }

    .top-bar,
    .category-bar,
    .detail-pane,
    .btn {
        display: none !important;
    }

    .main-layout {
        display: block !important;
    }

    .feed-card {
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .schedule-table {
        font-size: 10px;
    }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 960px) {
    .loan-preview {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .costs-form-grid {
        grid-template-columns: 1fr;
    }

    .payment-overview {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .overpayment-planner {
        grid-template-columns: 1fr;
    }

    .overpay-card-wide {
        grid-row: auto;
    }

    .overpay-row {
        grid-template-columns: minmax(130px, 1fr) minmax(90px, 0.7fr) auto auto minmax(70px, 0.5fr) auto minmax(70px, 0.5fr);
    }
}

@media (max-width: 640px) {
    .brand-mark {
        width: 36px;
        height: 36px;
    }

    .brand-kicker {
        display: none;
    }

    .brand-title {
        font-size: 17px;
    }

    .top-bar-actions {
        gap: 6px;
    }

    .top-bar-link {
        padding-left: 9px;
        padding-right: 9px;
    }

    .main-layout {
        display: block;
    }

    .feed-pane {
        padding: 14px 12px 48px;
    }

    .detail-pane {
        display: none;
    }

    .detail-pane.mobile-visible {
        display: block;
    }

    .page-title {
        font-size: 16px;
    }

    .feed-card {
        padding: 14px;
        border-radius: var(--radius-sm);
    }

    .loan-preview {
        grid-template-columns: 1fr;
    }

    .preview-metric strong {
        font-size: 21px;
    }

    .payment-breakdown-row,
    .payment-cost-row {
        gap: 10px;
    }

    .payment-cost-details {
        padding-left: 18px;
    }

    .card-title-row {
        flex-direction: column;
        gap: 2px;
    }

    .card-salary {
        text-align: left;
    }

    .category-badge {
        font-size: var(--font-micro);
        padding: 4px 10px;
    }

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

    .toggle-group-three {
        grid-template-columns: 1fr;
    }

    .scenario-header {
        flex-direction: column;
    }

    .scenario-actions {
        width: 100%;
        justify-content: stretch;
    }

    .scenario-actions .btn {
        flex: 1;
    }

    .cost-timeline-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .cost-timeline-amount {
        text-align: left;
    }

    .cost-pair {
        grid-template-columns: 1fr;
    }

    .overpay-row {
        grid-template-columns: 1fr 1fr auto;
    }

    .overpay-row span:nth-of-type(2),
    .overpay-row span:nth-of-type(3) {
        text-align: left;
    }

    .table-nav {
        width: 100%;
        justify-content: space-between;
    }
}
