.mortgage-calculator-page {
    background: #ffffff;
}

.mortgage-page {
    padding: 18px 0 58px;
}

.mortgage-calculator {
    color: #212937;
}

.mortgage-calculator__title,
.mortgage-results__title {
    margin: 0;
    color: #252b38;
    font-size: clamp(44px, 4.7vw, 64px);
    line-height: 0.98;
    font-weight: 700;
    letter-spacing: -0.06em;
}

.mortgage-calculator__shell {
    margin-top: 26px;
    padding: 0px 0px 24px 0px;
    border: 1px solid #d9e4f3;
    border-radius: 24px;
    background: #f5f8fe;
}

.mortgage-calculator__top {
    display: grid;
    grid-template-columns: 40% minmax(0, 1fr);
    gap: 46px;
    align-items: stretch;
}

.mortgage-panel {
    min-width: 0;
}

.mortgage-panel--form {
    display: flex;
    flex-direction: column;
    min-height: 470px;
    padding: 48px 0px 44px 44px;
}

.mortgage-panel--visual {
    min-height: 470px;
}

.mortgage-panel--visual img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 0 22px;
}

.mortgage-tabs {
    width: 100%;
    display: flex;
    padding: 4px;
    border: 1px solid #c9d6e7;
    border-radius: 11px;
    background: #ffffff;
}

.mortgage-tabs__button {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #566073;
    font-size: 12px;
    line-height: 1;
    font-weight: 500;
    padding: 0 10px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mortgage-tabs__button.is-active {
    background: #2E3A4D;
    color: #ffffff;
}

.mortgage-form {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    margin-top: 18px;
}

.mortgage-form__section {
    display: grid;
    gap: 13px;
}

.mortgage-divider {
    height: 1px;
    margin: 17px 0;
    background: #d6dfed;
}

.mortgage-divider--spaced {
    margin-top: 16px;
    margin-bottom: 17px;
}

.mortgage-field {
    display: grid;
    grid-template-columns: 136px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.mortgage-field--term {
    margin-bottom: 13px;
}

.mortgage-field__label,
.mortgage-payment-type__legend {
    margin: 0;
    color: #394250;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 400;
}

.mortgage-inline-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 84px;
    gap: 8px;
    align-items: center;
}

.mortgage-input,
.mortgage-select {
    position: relative;
    display: block;
}

.mortgage-input input,
.mortgage-select select {
    width: 100%;
    height: 38px;
    border: 1px solid #cbd8ea;
    border-radius: 8px;
    background: #ffffff;
    color: #2b3342;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mortgage-input input {
    padding: 0 36px 0 12px;
}

.mortgage-input:not(.mortgage-input--currency):not(.mortgage-input--percent) input {
    padding-right: 12px;
}

.mortgage-input input[readonly] {
    background: #ffffff;
    color: #354053;
}

.mortgage-input input:focus,
.mortgage-select select:focus {
    border-color: #90abdc;
    box-shadow: 0 0 0 3px rgba(144, 171, 220, 0.16);
}

.mortgage-input__suffix {
    position: absolute;
    top: 50%;
    right: 13px;
    transform: translateY(-50%);
    color: #2c3443;
    font-size: 14px;
    line-height: 1;
    pointer-events: none;
}

.mortgage-select::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 7px;
    height: 7px;
    margin-top: -5px;
    border-right: 1.5px solid #78839a;
    border-bottom: 1.5px solid #78839a;
    transform: rotate(45deg);
    pointer-events: none;
}

.mortgage-select select {
    appearance: none;
    padding: 0 30px 0 12px;
}

.mortgage-payment-type {
    display: grid;
    grid-template-columns: 136px minmax(0, 1fr);
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
}

.mortgage-payment-type__content {
    display: grid;
    gap: 14px;
    padding-top: 1px;
}

.mortgage-radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    color: #374052;
    font-size: 14px;
    line-height: 1.2;
}

.mortgage-radio input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mortgage-radio__mark {
    position: relative;
    width: 14px;
    height: 14px;
    border: 1px solid #a9b6c9;
    border-radius: 50%;
    background: #ffffff;
}

.mortgage-radio__mark::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: #4f79c8;
    opacity: 0;
}

.mortgage-radio input:checked + .mortgage-radio__mark {
    border-color: #4f79c8;
}

.mortgage-radio input:checked + .mortgage-radio__mark::after {
    opacity: 1;
}

.mortgage-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    outline: none;
}

.mortgage-tooltip__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border: 1px solid #aab7cb;
    border-radius: 50%;
    color: #7b879d;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
}

.mortgage-tooltip__content {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    width: 220px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #252d39;
    color: #ffffff;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    transform: translate(-50%, 4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 18px 32px rgba(37, 45, 57, 0.18);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.mortgage-tooltip:hover .mortgage-tooltip__content,
.mortgage-tooltip:focus-visible .mortgage-tooltip__content {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.mortgage-form__hint {
    min-height: 18px;
    margin: 14px 0 0;
    color: #9b3131;
    font-size: 12px;
    line-height: 1.25;
}

.mortgage-form__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 78px;
}

.mortgage-calculator__actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    margin-left: calc(398px + 156px);
}

.mortgage-button {
    height: 46px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    font-weight: 500;
    padding: 0 18px;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mortgage-button:hover {
    transform: translateY(-1px);
}

.mortgage-button--dark {
    background: #252d39;
    color: #ffffff;
}

.mortgage-button--light {
    background: #ffffff;
    border-color: #dce5f2;
    color: #384152;
}

.mortgage-button--ghost {
    min-width: 146px;
    height: 40px;
    padding: 0 15px;
    border-color: #d8e2f0;
    border-radius: 8px;
    background: #dfe8f7;
    color: #2f3746;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.01em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.mortgage-calculator__actions .mortgage-button--ghost:last-child {
    min-width: 93px;
    background: #ffffff;
}

.mortgage-calculator__actions .mortgage-button--ghost:hover {
    background: #d7e2f4;
}

.mortgage-calculator__actions .mortgage-button--ghost:last-child:hover {
    background: #f8fbff;
}

.mortgage-button[disabled] {
    opacity: 0.56;
    pointer-events: none;
}

.mortgage-results {
    margin-top: 58px;
}

.mortgage-results__summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.mortgage-summary-card {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 9px;
    background: #f6f9ff;
    color: #3a4353;
    font-size: 15px;
    line-height: 1.3;
    white-space: nowrap;
}

.mortgage-summary-card__value {
    color: #1e2735;
    font-weight: 700;
}

.mortgage-results__block-title {
    margin: 22px 0 14px;
    color: #232a36;
    font-size: 17px;
    line-height: 1.2;
    font-weight: 500;
}

.mortgage-results__block-title--table {
    margin: 0;
    padding: 0 16px 14px;
}

.mortgage-results__charts {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.mortgage-chart-card,
.mortgage-table-card {
    border: 1px solid #ccd8ea;
    border-radius: 16px;
    background: #ffffff;
}

.mortgage-chart-card {
    min-width: 0;
    position: relative;
}

.mortgage-chart-card--donut {
    aspect-ratio: 1 / 1;
    min-height: 252px;
    padding: 14px 16px 16px;
}

.mortgage-chart-card--bars {
    min-height: 252px;
    padding: 13px 16px 16px;
    width: stretch;
}

.mortgage-chart-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 20px;
    margin-bottom: 10px;
}

.mortgage-chart-card__head--end {
    justify-content: flex-end;
    padding-right: 25px;
}

.mortgage-section-title {
    margin: 0;
    color: #232a36;
    font-size: 17px;
    line-height: 1.2;
    font-weight: 500;
}

.mortgage-legend {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 11px;
    color: #3d4555;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
}

.mortgage-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mortgage-legend__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.mortgage-legend__dot--principal {
    background: #ffda24;
}

.mortgage-legend__dot--interest {
    background: #4e79c8;
}

.mortgage-donut {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100% - 30px);
}

.mortgage-donut svg {
    width: min(100%, 208px);
    height: auto;
    aspect-ratio: 1 / 1;
}

.mortgage-donut__track,
.mortgage-donut__segment {
    fill: none;
    stroke-linecap: round;
    stroke-width: 13;
}

.mortgage-donut__track {
    stroke: #eef3fb;
}

.mortgage-donut__segment {
    transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.mortgage-donut__segment--principal {
    stroke: #ffda24;
}

.mortgage-donut__segment--interest {
    stroke: #4e79c8;
}

.mortgage-bar-chart {
    height: calc(100% - 30px);
    min-height: 205px;
}

.mortgage-bar-chart svg {
    width: 100%;
    height: 100%;
    display: block;
}

.mortgage-bar-chart__axis {
    stroke: #d5dfed;
    stroke-width: 1;
}

.mortgage-bar-chart__grid {
    stroke: #e2e9f4;
    stroke-width: 1;
}

.mortgage-bar-chart__label {
    fill: #7f8ba3;
    font-size: 13px;
    font-family: "Geologica", "Segoe UI", sans-serif;
}

.mortgage-bar-chart__bar {
    transform-box: fill-box;
    transform-origin: center bottom;
    transform: scaleY(0.001);
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.mortgage-results.is-animated .mortgage-bar-chart__bar {
    transform: scaleY(1);
}

.mortgage-bar-chart__hitbox {
    fill: transparent;
    cursor: pointer;
}

.mortgage-chart-tooltip {
    position: absolute;
    z-index: 3;
    min-width: 168px;
    padding: 10px 12px;
    border: 1px solid #d6dfed;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 30px rgba(43, 53, 73, 0.16);
    color: #2b3443;
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 12px));
}

.mortgage-chart-tooltip__month {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.mortgage-chart-tooltip__row {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.mortgage-chart-tooltip__row + .mortgage-chart-tooltip__row {
    margin-top: 4px;
}

.mortgage-chart-tooltip__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: 0 0 7px;
}

.mortgage-chart-tooltip__dot--principal {
    background: #ffda24;
}

.mortgage-chart-tooltip__dot--interest {
    background: #4e79c8;
}

.mortgage-table-card {
    margin-top: 22px;
    overflow: hidden;
    padding: 18px 0 0;
}

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

.mortgage-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.mortgage-table th,
.mortgage-table td {
    padding: 14px 12px;
    border-top: 1px solid #d5deeb;
    border-right: 1px solid #d5deeb;
    color: #394352;
    font-size: 14px;
    line-height: 1.2;
    text-align: left;
}

.mortgage-table th:first-child,
.mortgage-table td:first-child {
    padding-left: 10px;
}

.mortgage-table th:last-child,
.mortgage-table td:last-child {
    border-right: 0;
}

.mortgage-table thead th {
    background: #eef4ff;
    font-weight: 400;
}

.mortgage-table-toggle {
    width: 100%;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    border: 0;
    border-top: 1px solid #d5deeb;
    background: transparent;
    padding: 0 16px;
    color: #232b39;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 500;
}

.mortgage-table-toggle__icon {
    width: 8px;
    height: 8px;
    border-right: 1.6px solid #394352;
    border-bottom: 1.6px solid #394352;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.mortgage-table-toggle.is-expanded .mortgage-table-toggle__icon {
    transform: rotate(-135deg);
}

.mortgage-history-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
}

.mortgage-history-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(25, 30, 42, 0.86);
}

.mortgage-history-dialog {
    position: relative;
    width: min(100% - 16px, 524px);
    min-height: 346px;
    margin: 12px auto;
    border-radius: 14px;
    background: #ffffff;
    padding: 20px 18px 16px;
}

.mortgage-history-dialog__header {
    padding-right: 44px;
}

.mortgage-history-dialog__title {
    margin: 0;
    color: #232833;
    font-size: 20px;
    line-height: 1.1;
    font-weight: 700;
}

.mortgage-history-dialog__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    padding: 0;
}

.mortgage-history-dialog__close span {
    position: absolute;
    left: 7px;
    top: 14px;
    width: 16px;
    height: 1.5px;
    background: #7f8aa1;
}

.mortgage-history-dialog__close span:first-child {
    transform: rotate(45deg);
}

.mortgage-history-dialog__close span:last-child {
    transform: rotate(-45deg);
}

.mortgage-history-list {
    margin-top: 22px;
}

.mortgage-history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid #dbe4f0;
}

.mortgage-history-item:first-child {
    border-top: 0;
    padding-top: 0;
}

.mortgage-history-item__date {
    color: #2b3240;
    font-size: 14px;
    line-height: 1.2;
}

.mortgage-history-item__amount {
    margin-top: 6px;
    color: #8f9ab0;
    font-size: 14px;
    line-height: 1.2;
}

.mortgage-history-item__button {
    min-width: 88px;
    height: 32px;
    border: 1px solid #ccd8ea;
    border-radius: 8px;
    background: #ffffff;
    color: #2d3543;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    padding: 0 14px;
}

.mortgage-history-item__remove {
    position: relative;
    width: 32px;
    height: 32px;
    border: 1px solid #ccd8ea;
    border-radius: 8px;
    background: #ffffff;
}

.mortgage-history-item__remove::before,
.mortgage-history-item__remove::after {
    content: "";
    position: absolute;
    left: 9px;
    top: 15px;
    width: 12px;
    height: 1.5px;
    background: #1f2735;
}

.mortgage-history-item__remove::before {
    transform: rotate(45deg);
}

.mortgage-history-item__remove::after {
    transform: rotate(-45deg);
}

@media (max-width: 1199.98px) {
    .mortgage-calculator__top {
        grid-template-columns: 360px minmax(0, 1fr);
        gap: 28px;
    }

    .mortgage-calculator__actions {
        margin-left: calc(360px + 28px);
    }

    .mortgage-panel--visual,
    .mortgage-panel--form {
        min-height: 430px;
    }
}

@media (max-width: 991.98px) {
    .mortgage-page {
        padding-top: 18px;
        padding-bottom: 44px;
    }

    .mortgage-calculator__shell {
        padding: 18px;
    }

    .mortgage-calculator__top {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .mortgage-results__charts,
    .mortgage-results__summary {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .mortgage-panel--form,
    .mortgage-panel--visual {
        min-height: 0;
        padding: 0;
    }

    .mortgage-form__actions {
        padding-top: 28px;
    }

    .mortgage-calculator__actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .mortgage-page {
        padding-top: 14px;
        padding-bottom: 32px;
    }

    .mortgage-calculator__title,
    .mortgage-results__title {
        font-size: 34px;
        line-height: 1;
    }

    .mortgage-calculator__shell {
        margin-top: 18px;
        padding: 14px;
        border-radius: 20px;
    }

    .mortgage-panel--visual img {
        min-height: 280px;
        border-radius: 16px;
    }

    .mortgage-field,
    .mortgage-payment-type {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .mortgage-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
    }

    .mortgage-tabs__button {
        font-size: 11px;
    }

    .mortgage-inline-fields {
        grid-template-columns: minmax(0, 1fr) 84px;
    }

    .mortgage-form__actions,
    .mortgage-calculator__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .mortgage-form__actions {
        padding-top: 18px;
    }

    .mortgage-calculator__actions .mortgage-button:last-child {
        grid-column: 1 / -1;
    }

    .mortgage-results {
        margin-top: 40px;
    }

    .mortgage-results__block-title {
        margin-top: 18px;
        margin-bottom: 12px;
    }

    .mortgage-summary-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 10px 12px;
    }

    .mortgage-chart-card__head,
    .mortgage-chart-card__head--end {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
    }

    .mortgage-legend {
        flex-wrap: wrap;
        white-space: normal;
    }

    .mortgage-table-card {
        padding-top: 14px;
    }

    .mortgage-table-toggle {
        padding-left: 12px;
        padding-right: 12px;
    }

    .mortgage-history-dialog {
        width: calc(100% - 16px);
        min-height: calc(100dvh - 24px);
    }

    .mortgage-history-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .mortgage-history-item__remove {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: center;
    }

    .mortgage-history-item__button {
        grid-column: 1;
        width: fit-content;
    }
}
