/* ============================================================
   Credit Calculator — изолированные стили (.cc-)
   Версия 1.0.0
============================================================ */

/* ----- Базовый виджет ----- */
.cc-widget {
    background: #0D1B2A;
    border-radius: 16px;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: #FFFFFF;
    max-width: 820px;
    margin: 0 auto;
    box-sizing: border-box;
    position: relative;
}
.cc-widget *,
.cc-widget *::before,
.cc-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ----- Вкладки ----- */
.cc-tabs {
    display: flex;
    gap: 4px;
    background: #131f2e;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}
.cc-tab {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: #B0BEC5;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .2s, color .2s;
    line-height: 1.3;
    text-align: center;
}
.cc-tab:hover:not(.cc-tab--active) {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.cc-tab--active {
    background: #1B2B3C;
    color: #2ECC71;
    font-weight: 600;
}

/* ----- Панели ----- */
.cc-panel {
    animation: cc-fade-in .22s ease;
}
@keyframes cc-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ----- Форма ----- */
.cc-form {
    margin-bottom: 20px;
}

/* ----- Поля ----- */
.cc-field {
    margin-bottom: 14px;
    position: relative;
}
.cc-field--row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}
.cc-field-inner {
    flex: 1;
    position: relative;
}
.cc-field-inner--pct {
    flex: 0 0 90px;
}
.cc-field--sm {
    margin-bottom: 0;
}

.cc-label {
    display: block;
    color: #B0BEC5;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    letter-spacing: .02em;
}
.cc-label--center {
    text-align: center;
    margin-bottom: 12px;
}

.cc-input {
    width: 100%;
    background: #131f2e;
    border: 1.5px solid #243447;
    border-radius: 10px;
    padding: 11px 44px 11px 14px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
    appearance: none;
}
.cc-input:focus {
    border-color: #2ECC71;
    box-shadow: 0 0 0 3px rgba(46,204,113,.15);
}
.cc-input.cc-error {
    border-color: #E74C3C;
    box-shadow: 0 0 0 3px rgba(231,76,60,.12);
}
.cc-input::-webkit-inner-spin-button,
.cc-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}
.cc-input[type="number"] { -moz-appearance: textfield; }

.cc-suffix {
    position: absolute;
    right: 13px;
    bottom: 12px;
    color: #B0BEC5;
    font-size: 12px;
    pointer-events: none;
    user-select: none;
}

/* ----- Input group (страховка с чекбоксом) ----- */
.cc-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cc-input-group .cc-input {
    flex: 1;
}

/* ----- Чекбокс ----- */
.cc-checkbox-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.cc-checkbox-wrap--full {
    width: 100%;
}
.cc-checkbox-wrap input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2ECC71;
    cursor: pointer;
    flex-shrink: 0;
}
.cc-checkbox-label {
    color: #B0BEC5;
    font-size: 13px;
}

/* ----- Сегментированные кнопки ----- */
.cc-segmented {
    display: inline-flex;
    background: #131f2e;
    border-radius: 10px;
    padding: 3px;
    flex-shrink: 0;
}
.cc-segmented--full {
    width: 100%;
}
.cc-segmented--sm {
    border-radius: 8px;
}
.cc-seg {
    flex: 1;
    padding: 7px 12px;
    background: transparent;
    border: none;
    color: #B0BEC5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .18s, color .18s;
    white-space: nowrap;
    text-align: center;
}
.cc-seg:hover:not(.cc-seg--active) {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.cc-seg--active {
    background: #2ECC71;
    color: #000;
    font-weight: 600;
}

/* ----- Кнопки ----- */
.cc-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}
.cc-actions .cc-btn { flex: 1; }

.cc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity .18s, transform .12s;
    text-decoration: none;
    line-height: 1;
}
.cc-btn:hover   { opacity: .88; }
.cc-btn:active  { transform: scale(.97); }

.cc-btn--primary { background: #2ECC71; color: #000; }
.cc-btn--outline {
    background: transparent;
    border: 1.5px solid #2A3B4D;
    color: #B0BEC5;
}
.cc-btn--outline:hover { border-color: #3a4f65; color: #fff; opacity: 1; }
.cc-btn--sm {
    padding: 6px 14px;
    font-size: 12px;
    background: #2ECC71;
    color: #000;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.cc-btn--full { width: 100%; margin-top: 10px; }

/* ----- Результаты ----- */
.cc-results { animation: cc-fade-in .25s ease; }

.cc-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* ----- Карточки ----- */
.cc-card {
    background: linear-gradient(135deg, #1B2B3C, #243447);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
}
.cc-card:last-child { margin-bottom: 0; }
.cc-card--main {
    text-align: center;
    padding: 20px 16px;
    margin-bottom: 0;
}
.cc-card--chart {
    text-align: center;
}
.cc-card--compare {
    margin-bottom: 12px;
}

/* ----- Суммы ----- */
.cc-amount {
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
    line-height: 1.1;
    letter-spacing: -.02em;
    word-break: break-word;
}
.cc-amount--green  { color: #2ECC71; }
.cc-amount--red    { color: #E74C3C; }
.cc-amount--yellow { color: #F39C12; }

/* ----- Строки результатов ----- */
.cc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
    gap: 12px;
}
.cc-row-label {
    color: #B0BEC5;
    flex-shrink: 0;
}
.cc-row > span:last-child {
    text-align: right;
    word-break: break-all;
}
.cc-red   { color: #E74C3C; }
.cc-green { color: #2ECC71; }
.cc-yellow{ color: #F39C12; }

.cc-divider {
    height: 1px;
    background: rgba(255,255,255,.07);
    margin: 0 -4px;
}

/* ----- Диаграмма ----- */
.cc-pie-wrap {
    display: flex;
    justify-content: center;
    margin: 4px 0 12px;
}
.cc-pie-wrap canvas {
    max-width: 200px;
    max-height: 200px;
}
.cc-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}
.cc-chart-header .cc-label { margin: 0; }

/* ----- Легенда ----- */
.cc-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 8px;
}
.cc-legend--inline {
    margin-top: 0;
    justify-content: flex-end;
}
.cc-legend-item {
    font-size: 12px;
    color: #B0BEC5;
    display: flex;
    align-items: center;
    gap: 5px;
}
.cc-legend-item::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.cc-legend-item--blue::before { background: #3498DB; }
.cc-legend-item--red::before  { background: #E74C3C; }

/* ----- Таблица ----- */
.cc-schedule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}
.cc-schedule-header .cc-label { margin: 0; }

.cc-filter-group {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.cc-filter {
    padding: 4px 12px;
    background: #1B2B3C;
    border: 1px solid #2A3B4D;
    color: #B0BEC5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.cc-filter:hover { background: #243447; color: #fff; }
.cc-filter--active { background: #2ECC71; color: #000; border-color: #2ECC71; }

.cc-table-wrap {
    overflow-x: auto;
    max-height: 380px;
    overflow-y: auto;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}
.cc-table-wrap::-webkit-scrollbar { width: 4px; height: 4px; }
.cc-table-wrap::-webkit-scrollbar-track { background: #1B2B3C; }
.cc-table-wrap::-webkit-scrollbar-thumb { background: #2A3B4D; border-radius: 4px; }

.cc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    min-width: 460px;
    table-layout: fixed;
}
.cc-thead th {
    background: #131f2e;
    color: #2ECC71;
    padding: 8px 6px;
    text-align: right;
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    border-bottom: 1px solid #2A3B4D;
}
.cc-thead th:first-child { text-align: left; }
.cc-table tbody tr:nth-child(even) { background: rgba(255,255,255,.03); }
.cc-table tbody tr:hover { background: rgba(255,255,255,.06); }
.cc-table td {
    padding: 6px 6px;
    text-align: right;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cc-table td:first-child  { text-align: left; color: #B0BEC5; }
.cc-table td:nth-child(5) { color: #E74C3C; }
.cc-table tfoot td {
    background: #131f2e;
    color: #2ECC71;
    font-weight: 700;
    padding: 8px 6px;
    position: sticky;
    bottom: 0;
    z-index: 2;
    border-top: 1px solid #2A3B4D;
    font-size: 11px;
}

/* ----- Сравнительная таблица (досрочное) ----- */
.cc-compare-head,
.cc-compare-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 7px 0;
    font-size: 12px;
}
.cc-compare-head {
    color: #B0BEC5;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.cc-compare-head span:not(:first-child),
.cc-compare-row span:not(:first-child) {
    text-align: right;
}
.cc-compare-row .cc-row-label { color: #B0BEC5; }

/* ----- Ипотека ----- */
.cc-early-payments { margin-bottom: 16px; }
.cc-early-payments > .cc-label { margin-bottom: 10px; }

.cc-early-row {
    background: #131f2e;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #243447;
}
.cc-early-row-inner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.cc-early-fields {
    display: flex;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
    min-width: 0;
}
.cc-early-fields .cc-field--sm {
    flex: 1 1 100px;
    min-width: 90px;
}
.cc-early-del {
    background: transparent;
    border: 1px solid #2A3B4D;
    color: #E74C3C;
    border-radius: 7px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 18px;
    transition: background .15s;
}
.cc-early-del:hover { background: rgba(231,76,60,.15); }

/* ----- Тултип ----- */
.cc-tooltip {
    position: fixed;
    background: #243447;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    pointer-events: none;
    z-index: 99999;
    white-space: nowrap;
    transform: translateX(-50%);
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    border: 1px solid rgba(255,255,255,.1);
}

/* ----- Тост ----- */
.cc-toast {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #243447;
    color: #2ECC71;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 100;
    white-space: nowrap;
    border: 1px solid rgba(46,204,113,.3);
}
.cc-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ----- Адаптив ----- */
@media (max-width: 600px) {
    .cc-widget { padding: 14px; border-radius: 12px; }

    .cc-tabs { margin-bottom: 16px; }
    .cc-tab  { font-size: 11px; padding: 8px 4px; }

    .cc-amount { font-size: 22px; }
    .cc-card--main { padding: 14px 12px; }

    .cc-results-grid { grid-template-columns: 1fr; }

    .cc-field--row { flex-direction: column; }
    .cc-field-inner--pct { flex: unset; width: 100%; }

    .cc-segmented--full .cc-seg { font-size: 12px; padding: 7px 8px; }

    .cc-compare-head,
    .cc-compare-row {
        grid-template-columns: 1.2fr 1fr 1fr;
        font-size: 11px;
    }

    .cc-pie-wrap canvas { max-width: 160px; max-height: 160px; }

    .cc-early-row-inner { flex-direction: column; }
    .cc-early-del { margin-top: 0; align-self: flex-end; }
}

@media (max-width: 380px) {
    .cc-widget { padding: 10px; }
    .cc-tab { font-size: 10px; }
    .cc-amount { font-size: 19px; }
    .cc-btn { font-size: 13px; padding: 10px 14px; }
}

/* ----- HiDPI canvas ----- */
.cc-pie-wrap canvas,
.cc-card canvas {
    display: block;
    max-width: 100%;
}
