:root {
    --bg: #f6f8fb;
    --card: rgba(255, 255, 255, 0.92);
    --card-strong: #ffffff;
    --text: #172033;
    --muted: #68758b;
    --line: rgba(20, 38, 70, 0.1);
    --primary: #2063cd;
    --primary-2: #1de2c1;
    --danger: #d92d20;
    --warning: #b7791f;
    --success: #067647;
    --shadow: 0 18px 48px rgba(22, 43, 84, 0.12);
    --radius: 22px;
    --gradient: linear-gradient(270deg, #1de2c1, #2063cd 100%);
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: transparent;
}

html { height: 100%; }

body {
    padding: 18px;
    min-height: 100vh;          /* растягиваем body на всю высоту iframe Bitrix24 */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.refund-widget {
    flex: 1;                    /* растягиваемся на остаток body */
    display: flex;
    flex-direction: column;
    min-height: 260px;          /* запасной минимум на случай микро-iframe */
}

.install-page { min-height: 260px; }

.widget-shell {
    position: relative;
    flex: 1;                    /* растягиваемся на всю высоту .refund-widget */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at 20% 0%, rgba(29, 226, 193, 0.18), transparent 34%),
        radial-gradient(circle at 90% 10%, rgba(32, 99, 205, 0.16), transparent 28%),
        var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.widget-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: start;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--line);
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.kicker-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--gradient);
}

h1,
h2,
h3,
p { margin: 0; }

.widget-title {
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.widget-subtitle {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.amount-badge {
    min-width: 164px;
    padding: 13px 16px;
    border-radius: 18px;
    color: #fff;
    background: var(--gradient);
    box-shadow: 0 12px 28px rgba(32, 99, 205, 0.22);
    text-align: right;
}

.amount-label {
    font-size: 11px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.amount-value {
    margin-top: 3px;
    font-size: 22px;
    font-weight: 900;
}

.widget-body {
    flex: 1;                    /* заполнить пространство ниже header */
    display: flex;
    flex-direction: column;
    padding: 20px 24px 24px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.info-cell {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.info-label {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
}

.info-value {
    margin-top: 4px;
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border: 1px solid rgba(32, 99, 205, 0.14);
    border-radius: 18px;
    background: rgba(32, 99, 205, 0.07);
    color: #1d3763;
    font-size: 14px;
    line-height: 1.45;
}

.notice.warning {
    border-color: rgba(183, 121, 31, 0.2);
    background: rgba(255, 247, 237, 0.82);
    color: #744210;
}

.notice.danger {
    border-color: rgba(217, 45, 32, 0.16);
    background: rgba(254, 243, 242, 0.9);
    color: #912018;
}

.notice.success {
    border-color: rgba(6, 118, 71, 0.16);
    background: rgba(236, 253, 243, 0.9);
    color: #05603a;
}

.notice-icon {
    display: inline-grid;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    font-weight: 900;
}

.errors-list {
    margin: 12px 0 0;
    padding-left: 18px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: auto;            /* прижать кнопки к низу .widget-body */
    padding-top: 18px;
}

.button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.button.primary {
    color: #fff;
    background: var(--gradient);
    box-shadow: 0 12px 24px rgba(32, 99, 205, 0.22);
}

.button.secondary {
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(255, 255, 255, 0.86);
}

.button.danger {
    color: #fff;
    background: linear-gradient(135deg, #e5484d, #b42318);
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(32, 99, 205, 0.2);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.loading-card,
.install-card {
    display: flex;
    gap: 14px;
    align-items: center;
    max-width: 760px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}

.install-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background: var(--bg);
}

.install-card {
    flex-direction: column;
    text-align: center;
}

.install-card h1 {
    font-size: 24px;
}

.install-card p {
    max-width: 560px;
    color: var(--muted);
    line-height: 1.5;
}

.status-icon {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    font-size: 26px;
    font-weight: 900;
}

.status-icon.success { background: var(--gradient); }
.status-icon.danger { background: linear-gradient(135deg, #e5484d, #b42318); }

.loader {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(32, 99, 205, 0.14);
    border-top-color: var(--primary);
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

.loading-title {
    font-size: 15px;
    font-weight: 850;
}

.loading-text {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(10, 20, 35, 0.36);
    backdrop-filter: blur(8px);
}

.modal {
    width: min(560px, 100%);
    border: 1px solid rgba(255, 255, 255, 0.52);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 26px 70px rgba(12, 20, 38, 0.28);
    overflow: hidden;
}

.modal-header {
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--line);
}

.modal-title {
    font-size: 21px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.modal-text {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.modal-body {
    padding: 18px 22px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 20px;
    border-top: 1px solid var(--line);
}

.modal-error {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 0 22px 4px;
    padding: 12px 14px;
    border: 1px solid rgba(217, 45, 32, 0.16);
    border-radius: 14px;
    background: rgba(254, 243, 242, 0.9);
    color: #912018;
    font-size: 13px;
    line-height: 1.45;
}

.modal-error .notice-icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #fff;
    color: var(--danger);
    font-weight: 900;
}

.option-grid {
    display: grid;
    gap: 10px;
}

.option-card {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(246, 248, 251, 0.74);
    cursor: pointer;
}

.option-card input { margin-top: 2px; }

.option-title {
    font-size: 14px;
    font-weight: 850;
}

.option-desc {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.file-field {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border: 1px dashed rgba(32, 99, 205, 0.34);
    border-radius: 18px;
    background: rgba(32, 99, 205, 0.05);
}

.file-field.visible { display: block; }

.file-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 850;
}

.file-field input {
    width: 100%;
    color: var(--muted);
}

@media (max-width: 720px) {
    body { padding: 12px; }
    .widget-header { grid-template-columns: 1fr; }
    .amount-badge { text-align: left; }
    .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .modal-footer { flex-direction: column-reverse; }
    .button { width: 100%; }
}

@media (max-width: 460px) {
    .info-grid { grid-template-columns: 1fr; }
    .widget-title { font-size: 20px; }
}

.form-stack {
    display: grid;
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 850;
}

.form-field input,
.form-field select {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 650;
}

.form-field input[type="file"] {
    min-height: auto;
    padding: 11px 12px;
    color: var(--muted);
    font-weight: 650;
}

.form-field input:focus,
.form-field select:focus {
    border-color: rgba(32, 99, 205, 0.42);
    box-shadow: 0 0 0 4px rgba(32, 99, 205, 0.09);
}

.method-panel {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(246, 248, 251, 0.78);
}

.method-panel.hidden,
.hidden {
    display: none !important;
}

.panel-title {
    font-size: 14px;
    font-weight: 900;
}

.panel-text {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.file-control {
    margin-top: 13px;
}

.two-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 13px;
}

.hint-box {
    margin-top: 13px;
    padding: 11px 12px;
    border: 1px solid rgba(32, 99, 205, 0.16);
    border-radius: 14px;
    background: rgba(32, 99, 205, 0.06);
    color: #1d3763;
    font-size: 13px;
    line-height: 1.45;
}

.callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-top: 13px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
}

.callout-info {
    border: 1px solid rgba(183, 121, 31, 0.28);
    background: linear-gradient(135deg, rgba(255, 247, 237, 0.95), rgba(254, 243, 199, 0.6));
    color: #744210;
}

.callout strong { font-weight: 800; }

.callout-icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #fff;
    color: var(--warning);
    font-weight: 900;
}

.optional-mark {
    color: var(--muted);
    font-weight: 650;
    font-size: 12px;
}

.confirm-summary {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(246, 248, 251, 0.9);
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
}

.errors-list.compact {
    margin-top: 10px;
    color: #912018;
    font-size: 13px;
}

@media (max-width: 720px) {
    .two-fields { grid-template-columns: 1fr; }
}
