* {
    box-sizing: border-box;
}

:root {
    --bg-1: #f8f3e9;
    --bg-2: #f2ece1;
    --card: rgba(255, 252, 246, 0.95);
    --card-strong: #ffffff;
    --text: #0b2149;
    --muted: #66748d;
    --line: #dbe3ef;
    --line-strong: #c7d3e4;
    --primary: #0b2149;
    --primary-2: #18366d;
    --accent: #d83a34;
    --accent-soft: rgba(216, 58, 52, 0.12);
    --success: #198754;
    --success-soft: rgba(25, 135, 84, 0.12);
    --error: #b42318;
    --error-soft: rgba(180, 35, 24, 0.12);
    --shadow-soft: 0 16px 40px rgba(11, 33, 73, 0.08);
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 16px;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Inter, Arial, Helvetica, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

body {
    position: relative;
}

.page-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(216, 58, 52, 0.10), transparent 26%),
        radial-gradient(circle at top right, rgba(11, 33, 73, 0.12), transparent 30%),
        radial-gradient(circle at bottom left, rgba(24, 54, 109, 0.08), transparent 24%);
    z-index: 0;
    pointer-events: none;
}

.shell {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
    padding: 22px 12px 40px;
}

.app-card {
    position: relative;
    overflow: hidden;
    background: var(--card);
    border: 1px solid rgba(11, 33, 73, 0.08);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
}

.top-accent {
    height: 8px;
    background: linear-gradient(90deg, #d83a34 0%, #b72d2d 22%, #0b2149 68%, #18366d 100%);
}

.brand-bar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    padding: 24px 24px 18px;
    border-bottom: 1px solid rgba(11, 33, 73, 0.08);
}

.brand-left {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.brand-badge {
    min-width: 108px;
    padding: 12px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff;
    text-align: center;
    font-weight: 800;
}

.brand-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
    color: var(--primary);
}

.brand-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 15px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.state-panel {
    margin: 22px 24px 24px;
    padding: 26px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.86);
    text-align: center;
}

.state-panel h2 {
    margin: 0;
    font-size: 24px;
    color: var(--primary);
}

.state-panel p {
    margin: 10px auto 0;
    max-width: 640px;
    color: var(--muted);
    line-height: 1.7;
}

.state-error h2 {
    color: var(--error);
}

.state-success h2 {
    color: var(--success);
}

.state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 24px;
}

.state-icon-loading {
    border: 4px solid rgba(11, 33, 73, 0.12);
    border-top-color: var(--primary);
    animation: spin 0.9s linear infinite;
}

.state-icon-error {
    background: var(--error-soft);
    color: var(--error);
}

.state-icon-success {
    background: var(--success-soft);
    color: var(--success);
}

.hero-card {
    margin: 22px 24px 0;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(11, 33, 73, 0.97) 0%, rgba(24, 54, 109, 0.98) 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.hero-kicker {
    margin: 0 0 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.72);
}

.hero-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}

.hero-text {
    margin: 12px 0 0;
    max-width: 700px;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.7;
}

.hero-amount {
    min-width: 210px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.10);
}

.hero-amount-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.70);
}

.hero-amount-value {
    display: block;
    margin-top: 10px;
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}

.section-card {
    margin: 20px 24px 0;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
}

.section-head {
    margin-bottom: 18px;
}

.section-head h3 {
    margin: 0;
    font-size: 21px;
    color: var(--primary);
}

.section-head p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.info-field-full {
    grid-column: 1 / -1;
}

.info-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.info-value {
    min-height: 50px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--card-strong);
    color: var(--text);
    line-height: 1.6;
}

.pdf-frame-wrap {
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--line-strong);
    background: #fff;
}

.pdf-frame {
    display: block;
    width: 100%;
    height: 720px;
    border: none;
    background: #fff;
}

.signature-box {
    overflow: hidden;
    border: 2px dashed #b9c8dc;
    border-radius: 18px;
    background: #fff;
}

canvas {
    display: block;
    width: 100%;
    height: 280px;
    background: #fff;
    touch-action: none;
}

.signature-footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-top: 16px;
}

.signature-note {
    color: var(--muted);
    line-height: 1.6;
}

.action-row {
    display: flex;
    gap: 12px;
}

.btn {
    border: none;
    border-radius: 14px;
    padding: 13px 18px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff;
}

.btn-secondary {
    background: #edf2fa;
    color: var(--primary);
}

.hidden {
    display: none !important;
}

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

@media (max-width: 900px) {
    .hero-card {
        flex-direction: column;
    }

    .hero-amount {
        width: 100%;
    }

    .signature-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .action-row {
        width: 100%;
    }

    .action-row .btn {
        flex: 1;
    }
}

@media (max-width: 720px) {
    .brand-bar {
        flex-direction: column;
        padding: 18px 16px 16px;
    }

    .brand-left {
        flex-direction: column;
    }

    .brand-title {
        font-size: 24px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-field-full {
        grid-column: auto;
    }

    .section-card,
    .hero-card,
    .state-panel {
        margin-left: 16px;
        margin-right: 16px;
        padding: 16px;
    }

    .pdf-frame {
        height: 430px;
    }

    .action-row {
        flex-direction: column;
    }

    .shell {
        padding: 14px 8px 28px;
    }

    canvas {
        height: 220px;
    }
}