.credit-calculator {
    width: 100%;
}

.credit-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
    gap: 24px;
    align-items: start;
}

.credit-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #ffffff;
    padding: 22px;
}

.credit-card-title {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.credit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.credit-error {
    margin-top: 14px;
    color: #dc2626;
    font-weight: 600;
    font-size: 14px;
    min-height: 20px;
}

.credit-result-card {
    position: static;
    align-self: start;
}

.credit-result-main {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 12px;
    background: #f8fafc;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    color: #111827;
}

.credit-result-list {
    display: grid;
    gap: 10px;
}

.credit-result-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #eef1f5;
}

.credit-result-row span {
    color: #6b7280;
}

.credit-result-row strong {
    text-align: right;
    color: #111827;
    font-weight: 800;
}

.credit-result-row-accent strong {
    color: #dc2626;
}

.credit-formula {
    margin-top: 16px;
    padding: 12px;
    border-radius: 10px;
    background: #f8fafc;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
}

.credit-schedule-card {
    grid-column: 1 / -1;
}

.credit-schedule-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.credit-schedule-summary {
    color: #6b7280;
    font-size: 14px;
    text-align: right;
}

.credit-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.credit-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 14px;
}

.credit-table th,
.credit-table td {
    padding: 10px 12px;
    border: 1px solid #eef1f5;
    text-align: right;
    white-space: nowrap;
}

.credit-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #111827;
}

.credit-table th:first-child,
.credit-table td:first-child {
    text-align: center;
}

.credit-table th:nth-child(2),
.credit-table td:nth-child(2) {
    text-align: left;
}

.credit-empty-row {
    text-align: center !important;
    color: #6b7280;
}

.credit-disclaimer {
    margin-top: 12px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 991px) {
    .credit-layout {
        grid-template-columns: 1fr;
    }

    .credit-result-card {
        position: static;
    }
}

@media (max-width: 767px) {
    .credit-layout {
        gap: 18px;
    }

    .credit-card {
        padding: 18px;
    }

    .credit-schedule-header {
        display: block;
    }

    .credit-schedule-summary {
        display: block;
        margin-top: 4px;
        text-align: left;
    }

    .credit-table {
        min-width: 680px;
        font-size: 13px;
    }

    .credit-table th,
    .credit-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 575px) {
    .credit-card {
        padding: 16px;
        border-radius: 14px;
    }

    .credit-card-title {
        font-size: 17px;
        margin-bottom: 16px;
    }

    .credit-result-main {
        font-size: 17px;
        padding: 13px;
    }

    .credit-result-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
        padding: 10px 0;
    }

    .credit-result-row strong {
        text-align: left;
    }

    .credit-actions {
        flex-direction: column;
    }

    .credit-actions .btn {
        width: 100%;
    }

    .credit-formula {
        font-size: 13px;
    }

    .credit-schedule-card {
        padding-left: 12px;
        padding-right: 12px;
    }

    .credit-table-wrap {
        margin-left: -4px;
        margin-right: -4px;
        padding-bottom: 6px;
    }

    .credit-table {
        min-width: 640px;
        font-size: 12px;
    }

    .credit-table th,
    .credit-table td {
        padding: 7px 8px;
    }

    .credit-disclaimer {
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .credit-card {
        padding: 14px;
    }

    .credit-result-main {
        font-size: 16px;
    }

    .credit-table {
        min-width: 610px;
    }
}

/* ===== CREDIT MOBILE FIX ===== */

.credit-calculator,
.credit-calculator * {
    box-sizing: border-box;
}

.credit-calculator {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.credit-layout,
.credit-card,
.credit-schedule-card,
.credit-table-wrap {
    min-width: 0;
    max-width: 100%;
}

.credit-layout > * {
    min-width: 0;
}

.credit-card {
    width: 100%;
}

.credit-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Планшеты и телефоны */
@media (max-width: 991px) {
    .credit-layout {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 18px;
    }

    .credit-result-card {
        position: static !important;
    }

    .credit-schedule-card {
        grid-column: auto !important;
    }
}

/* Телефоны */
@media (max-width: 575px) {
    .credit-card {
        padding: 15px !important;
        border-radius: 12px;
    }

    .credit-card-title {
        font-size: 16px;
        margin-bottom: 14px;
    }

    .credit-result-main {
        font-size: 16px;
        padding: 12px;
        word-break: break-word;
    }

    .credit-result-row {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        padding: 10px 0;
    }

    .credit-result-row strong {
        text-align: left;
        word-break: break-word;
    }

    .credit-actions {
        flex-direction: column;
    }

    .credit-actions .btn {
        width: 100%;
    }

    .credit-schedule-header {
        display: block;
    }

    .credit-schedule-summary {
        display: block;
        margin-top: 4px;
        text-align: left;
    }

    /*
      На телефоне таблица превращается в карточки.
      Так график не ломает ширину страницы.
    */
    .credit-table-wrap {
        overflow-x: visible !important;
    }

    .credit-table {
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: separate;
        border-spacing: 0 10px;
        font-size: 13px;
    }

    .credit-table thead {
        display: none;
    }

    .credit-table,
    .credit-table tbody,
    .credit-table tr,
    .credit-table td {
        display: block;
        width: 100%;
    }

    .credit-table tr {
        border: 1px solid #eef1f5;
        border-radius: 12px;
        background: #ffffff;
        padding: 10px 12px;
    }

    .credit-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 7px 0 !important;
        border: 0 !important;
        text-align: right !important;
        white-space: normal !important;
    }

    .credit-table td::before {
        flex: 0 0 auto;
        color: #6b7280;
        font-weight: 600;
        text-align: left;
    }

    .credit-table td:nth-child(1)::before {
        content: "№";
    }

    .credit-table td:nth-child(2)::before {
        content: "Дата платежа";
    }

    .credit-table td:nth-child(3)::before {
        content: "Платёж";
    }

    .credit-table td:nth-child(4)::before {
        content: "Основной долг";
    }

    .credit-table td:nth-child(5)::before {
        content: "Проценты";
    }

    .credit-table td:nth-child(6)::before {
        content: "Остаток долга";
    }

    .credit-empty-row {
        display: block !important;
        text-align: center !important;
        padding: 14px 0 !important;
    }

    .credit-empty-row::before {
        content: "" !important;
    }

    .credit-disclaimer {
        font-size: 12px;
    }
}

/* Очень узкие экраны */
@media (max-width: 420px) {
    .credit-card {
        padding: 13px !important;
    }

    .credit-table tr {
        padding: 9px 10px;
    }

    .credit-table td {
        font-size: 12px;
    }

    .credit-table td::before {
        max-width: 45%;
    }
}