/* ============================================
   HYLA — страница оплаты договора
   ============================================ */

:root {
    --brand: #0B5ED7;
    --brand-dark: #0847a4;
    --brand-soft: #E8F0FD;
    --ok: #16A34A;
    --ok-soft: #E7F7EE;
    --danger: #E11D48;
    --danger-soft: #FEECF0;
    --warn: #B45309;
    --warn-soft: #FEF4E2;

    --bg: #F5F7FB;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --text: #101733;
    --muted: #6B7392;
    --border: #E4E8F1;

    --radius: 14px;
    --radius-lg: 22px;
    --shadow: 0 1px 2px rgba(16, 23, 51, .04), 0 8px 28px rgba(16, 23, 51, .06);
    --shadow-lg: 0 18px 48px rgba(11, 94, 215, .16);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ease: .28s cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
    --brand: #4D8FF5;
    --brand-dark: #3B7BE0;
    --brand-soft: #16233A;
    --ok: #34D07F;
    --ok-soft: #12271D;
    --danger: #FB6F8E;
    --danger-soft: #2A161C;
    --warn: #F0B860;
    --warn-soft: #2A2216;

    --bg: #0D1017;
    --surface: #151A23;
    --surface-2: #1B212C;
    --text: #E9EDF6;
    --muted: #949CB3;
    --border: #262D3B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
}

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

.pay-body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--ease), color var(--ease);
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
.icon { width: 20px; height: 20px; flex: none; }

.pay-container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 18px; }

/* ---------- шапка ---------- */

.pay-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.pay-header__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.pay-logo { display: flex; flex-direction: column; line-height: 1.1; }
.pay-logo__mark { font-weight: 700; font-size: 22px; letter-spacing: .14em; }
.pay-logo__sub { font-size: 11px; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; }
.pay-header__actions { display: flex; align-items: center; gap: 14px; }
.pay-header__phone { font-weight: 600; font-size: 15px; }
.theme-toggle {
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center;
    border: 1px solid var(--border); background: var(--surface-2);
    transition: background var(--ease), transform var(--ease);
}
.theme-toggle:hover { transform: rotate(-18deg); }
.theme-toggle .icon--moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon--sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon--moon { display: block; }

/* ---------- каркас ---------- */

.pay-main { flex: 1; padding: 34px 18px 64px; }
.pay-hero { text-align: center; margin-bottom: 28px; }
.pay-hero__title { font-size: clamp(28px, 6vw, 40px); font-weight: 700; letter-spacing: -.02em; }
.pay-hero__subtitle { color: var(--muted); margin-top: 8px; font-size: 16px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 26px;
    margin-bottom: 18px;
}
.card__title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 650; margin-bottom: 18px; }
.card__title .icon { color: var(--brand); }
.card__note { color: var(--muted); font-size: 13px; margin-top: 14px; }
.secure-note { display: flex; gap: 8px; align-items: flex-start; }
.secure-note .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--ok); }
.subtitle { font-size: 14px; font-weight: 600; color: var(--muted); margin: 22px 0 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* Автопрокрутка к найденному договору не должна заезжать под липкую шапку. */
#result { scroll-margin-top: 88px; }

.fade-in { animation: fadeIn .45s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } * { transition: none !important; } }

/* ---------- поля ---------- */

.search-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.search-form .btn { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field__input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.field__input:focus {
    outline: none;
    border-color: var(--brand);
    background: var(--surface);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}
.field__input.is-invalid { border-color: var(--danger); }
.field__error { font-size: 12.5px; color: var(--danger); min-height: 16px; }
.amount-input { position: relative; }
.field__input--amount { font-size: 24px; font-weight: 700; letter-spacing: -.01em; padding-right: 44px; }
.amount-input__currency { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 600; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
    padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
    border: 1.5px solid var(--border); background: var(--surface-2); color: var(--muted);
    transition: all var(--ease);
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- кнопки ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 15px 26px; border-radius: var(--radius);
    font-weight: 650; letter-spacing: .01em;
    transition: transform var(--ease), box-shadow var(--ease), background var(--ease), opacity var(--ease);
}
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(11, 94, 215, .28); }
.btn--primary:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn--primary:active { transform: translateY(0); }
.btn--lg { width: 100%; padding: 17px 26px; font-size: 16.5px; }
.btn--pay { margin-top: 22px; }
.btn--ghost { border: 1.5px solid var(--border); color: var(--muted); width: 100%; margin-top: 12px; }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn--outline { border: 1.5px solid var(--border); }
.btn--outline:hover { border-color: var(--brand); color: var(--brand); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.spinner {
    display: none; width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
.btn.is-loading .spinner { display: block; }
.btn.is-loading { pointer-events: none; opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- сообщения ---------- */

.form-alert {
    margin-top: 14px; padding: 13px 16px; border-radius: var(--radius);
    font-size: 14px; line-height: 1.45;
    animation: fadeIn .3s var(--ease) both;
}
.form-alert--error { background: var(--danger-soft); color: var(--danger); }
.form-alert--warn { background: var(--warn-soft); color: var(--warn); margin-top: 8px; }
.form-alert--info { background: var(--brand-soft); color: var(--brand); margin-top: 0; }
.form-alert--ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- карточка клиента ---------- */

.client__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.client__label { font-size: 13px; color: var(--muted); font-weight: 600; }
.client__name { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.badge {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 650;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--late { background: var(--danger-soft); color: var(--danger); }
.badge--closed { background: var(--brand-soft); color: var(--brand); }
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.progress { margin: 22px 0 4px; }
.progress__bar { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress__bar span {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, var(--brand), var(--ok));
    border-radius: 999px;
    transition: width .9s cubic-bezier(.2, .8, .2, 1);
}
.progress__meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 8px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 20px; }
.fact { background: var(--surface); padding: 14px 16px; }
.fact dt { font-size: 12.5px; color: var(--muted); }
.fact dd { font-size: 17px; font-weight: 650; margin-top: 2px; }
.dd--ok { color: var(--ok); }
.dd--accent { color: var(--brand); }
.pending-note { margin-top: 16px; font-size: 13.5px; color: var(--warn); background: var(--warn-soft); padding: 12px 15px; border-radius: var(--radius); }

/* ---------- выбор режима ---------- */

.switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch__item { position: relative; display: block; }
.switch__item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.switch__body {
    display: flex; flex-direction: column; gap: 3px;
    padding: 16px 18px 16px 46px;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    background: var(--surface-2);
    transition: all var(--ease);
    height: 100%;
}
.switch__body::before {
    content: ''; position: absolute; left: 17px; top: 20px;
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--surface);
    transition: all var(--ease);
}
.switch__item input:checked ~ .switch__body { border-color: var(--brand); background: var(--brand-soft); }
.switch__item input:checked ~ .switch__body::before { border-color: var(--brand); box-shadow: inset 0 0 0 4px var(--brand); }
.switch__item input:focus-visible ~ .switch__body { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.switch__title { font-weight: 650; font-size: 15px; }
.switch__sub { font-size: 13px; color: var(--muted); }
.mode-pane { margin-top: 22px; animation: fadeIn .3s var(--ease) both; }

.payoff { border: 1.5px solid var(--brand); border-radius: var(--radius); overflow: hidden; }
.promo {
    display: flex; align-items: center; gap: 9px;
    background: var(--brand); color: #fff; padding: 13px 18px; font-size: 14px; font-weight: 600;
}
.promo .icon { width: 18px; height: 18px; }
.payoff__row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 15px; }
.payoff__row b { font-weight: 650; }
.payoff__row--discount b { color: var(--ok); }
.payoff__row--total { border-bottom: 0; background: var(--brand-soft); font-size: 17px; }
.payoff__row--total b { font-size: 22px; color: var(--brand); }

/* ---------- способы оплаты ---------- */

.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.method {
    display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
    padding: 14px 16px; border-radius: var(--radius);
    border: 1.5px solid var(--border); background: var(--surface-2);
    transition: all var(--ease); text-align: left;
}
.method .icon { color: var(--muted); margin-bottom: 4px; }
.method span { font-weight: 600; font-size: 14.5px; }
.method small { color: var(--muted); font-size: 12px; }
.method:not(.is-disabled):hover { border-color: var(--brand); transform: translateY(-2px); }
.method.is-active { border-color: var(--brand); background: var(--brand-soft); }
.method.is-active .icon { color: var(--brand); }
.method.is-disabled { opacity: .5; cursor: not-allowed; }

/* ---------- история и график ---------- */

.history li, .schedule li {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px dashed var(--border); font-size: 14.5px;
}
.history li:last-child, .schedule li:last-child { border-bottom: 0; }
.history b, .schedule b { font-weight: 650; white-space: nowrap; }
.schedule__state { font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 999px; }
.state--paid { background: var(--ok-soft); color: var(--ok); }
.state--partial { background: var(--warn-soft); color: var(--warn); }
.state--overdue { background: var(--danger-soft); color: var(--danger); }
.state--planned { background: var(--surface-2); color: var(--muted); }
.history__date, .schedule__date { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }

/* ---------- подвал ---------- */

.pay-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 24px 0; color: var(--muted); font-size: 13.5px; }
.pay-footer__links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.pay-footer__links a:hover { color: var(--brand); }

/* ---------- результат оплаты ---------- */

.result-wrap { max-width: 540px; margin: 0 auto; text-align: center; }
.result-icon {
    width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 20px;
    display: grid; place-items: center;
    animation: pop .5s cubic-bezier(.2, 1.3, .4, 1) both;
}
.result-icon--ok { background: var(--ok-soft); color: var(--ok); }
.result-icon--fail { background: var(--danger-soft); color: var(--danger); }
.result-icon--wait { background: var(--warn-soft); color: var(--warn); }
.result-icon .icon { width: 44px; height: 44px; }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
.result-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.result-text { color: var(--muted); margin-top: 8px; }
.result-facts { margin-top: 24px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.result-facts div { display: flex; justify-content: space-between; gap: 14px; padding: 13px 17px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.result-facts div:last-child { border-bottom: 0; }
.result-facts span { color: var(--muted); }
.result-facts b { font-weight: 650; text-align: right; word-break: break-all; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }

/* ---------- чек ---------- */

.receipt { max-width: 620px; margin: 40px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow); }
.receipt__head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--text); padding-bottom: 16px; margin-bottom: 20px; }
.receipt__title { font-size: 20px; font-weight: 700; }
.receipt__rows div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 14.5px; }
.receipt__rows span { color: var(--muted); }
.receipt__total { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 16px; border-top: 2px solid var(--text); font-size: 19px; font-weight: 700; }
.receipt__note { margin-top: 20px; font-size: 12.5px; color: var(--muted); }
.receipt__actions { display: flex; gap: 12px; margin-top: 26px; }
.receipt__actions .btn { flex: 1; }
@media print {
    .pay-header, .pay-footer, .receipt__actions { display: none !important; }
    .pay-body { background: #fff; }
    .receipt { box-shadow: none; border: 0; margin: 0; padding: 0; }
}

/* ---------- мобильные ---------- */

@media (max-width: 640px) {
    .search-form, .switch, .facts, .grid-2, .result-actions { grid-template-columns: 1fr; }
    .card { padding: 20px 18px; border-radius: var(--radius); }
    .pay-main { padding-top: 24px; }
    .pay-header__phone { display: none; }
    .client__name { font-size: 19px; }
    .methods { grid-template-columns: 1fr 1fr; }
}
