:root {
    color-scheme: light;
    --accent: #950f1c;
    --accent-dark: #740b15;
    --border: #ccd1d8;
    --text: #1e2329;
    --muted: #5f6875;
    --surface: #ffffff;
    --page-bg: #eef1f4;
    --danger: #b00020;
    --success: #137333;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--page-bg);
}

.app {
    width: min(100% - 24px, 1040px);
    margin: 24px auto 48px;
}

.brand {
    display: flex;
    justify-content: center;
    margin: 0 0 18px;
}

.brand img {
    display: block;
    width: min(360px, 72vw);
    height: auto;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    padding: 15px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .06);
}

.toolbar__text {
    width: 100%;
    line-height: 1.45;
    text-align: center;
}

.toolbar__text strong {
    display: block;
    margin-bottom: 0;
    font-size: 18px;
}

.toolbar__text small {
    color: var(--muted);
}

button {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 11px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}

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

.button-primary {
    color: #fff;
    background: var(--accent);
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-dark);
}

.button-secondary {
    color: var(--text);
    background: #fff;
    border-color: var(--border);
}

.button-secondary:hover:not(:disabled) {
    border-color: #9aa2ad;
    background: #f7f8fa;
}

.button-accent-outline {
    color: var(--accent);
    border-color: var(--accent);
}

.button-accent-outline:hover:not(:disabled) {
    color: #fff;
    background: var(--accent);
}

.pdf-page {
    position: relative;
    container-type: inline-size;
    width: min(100%, 900px);
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
    user-select: none;
}

.pdf-page > img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.pdf-input,
.signature-field {
    position: absolute;
    z-index: 2;
}

.pdf-input {
    border: 0;
    outline: 0;
    padding: 0 .65cqw;
    color: #111;
    background: transparent;
    font-family: Arial, Helvetica, sans-serif;
    font-size: clamp(10px, 1.55cqw, 16px);
    line-height: 1;
    user-select: text;
}

.pdf-input:focus {
    background: rgba(255, 255, 255, .94);
    box-shadow: inset 0 0 0 2px rgba(149, 15, 28, .8);
}

.pdf-input.is-invalid,
.signature-field.is-invalid {
    box-shadow: inset 0 0 0 2px var(--danger);
    background: rgba(255, 235, 235, .8);
}

#customerName {
    left: 20.1169%;
    top: 31.0736%;
    width: 25.3782%;
    height: 2.3753%;
}

#customerEmail {
    left: 65.6119%;
    top: 31.0736%;
    width: 25.6286%;
    height: 2.3753%;
}

#street {
    left: 20.1169%;
    top: 34.6365%;
    width: 25.3782%;
    height: 2.3753%;
}

#zipCity {
    left: 65.8623%;
    top: 34.6365%;
    width: 25.3782%;
    height: 2.3753%;
}

#vehicleType {
    left: 20.1169%;
    top: 38.1995%;
    width: 25.3782%;
    height: 2.3753%;
}

#vin {
    left: 65.8623%;
    top: 38.1995%;
    width: 25.3782%;
    height: 2.3753%;
    text-transform: uppercase;
}

#placeDate {
    left: 9.4318%;
    top: 86.3142%;
    width: 29.1346%;
    height: 3.7053%;
}

.signature-field {
    left: 57.2642%;
    top: 86.1963%;
    width: 33.6424%;
    height: 3.8232%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    padding: .15cqw .45cqw;
    color: #5c6570;
    background: transparent;
    font-size: clamp(8px, 1.15cqw, 12px);
    font-weight: 700;
    cursor: pointer;
}

.signature-field:hover,
.signature-field:focus-visible {
    outline: none;
    background: rgba(255, 255, 255, .94);
    box-shadow: inset 0 0 0 2px rgba(149, 15, 28, .8);
}

.signature-field img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.confirmation-box {
    width: min(100%, 900px);
    margin: 16px auto 0;
    padding: 15px 17px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.confirmation-label {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    line-height: 1.45;
    cursor: pointer;
}

.confirmation-label input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--accent);
}

.confirmation-label.is-invalid {
    color: var(--danger);
}

.legal-note {
    margin: 9px 0 0 28px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: min(100%, 900px);
    margin: 16px auto 0;
}

.status {
    min-height: 1.5em;
    margin: 14px auto 0;
    width: min(100%, 900px);
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.status[data-kind="error"] {
    color: var(--danger);
}

.status[data-kind="success"] {
    color: var(--success);
}

.status[data-kind="warning"] {
    color: #9a5b00;
}

.honeypot {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

dialog {
    width: min(760px, calc(100% - 24px));
    border: 0;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

dialog::backdrop {
    background: rgba(0, 0, 0, .58);
}

.dialog__header,
.dialog__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}

.dialog__header {
    border-bottom: 1px solid var(--border);
    border-top: 4px solid var(--accent);
}

.dialog__header h2 {
    margin: 0;
    font-size: 18px;
}

.dialog__footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.signature-wrap {
    padding: 16px;
}

#signatureCanvas {
    display: block;
    width: 100%;
    height: 240px;
    border: 1px solid #9da5af;
    border-radius: 7px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}

.signature-help {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 700px) {
    .app {
        width: 100%;
        margin-top: 16px;
    }

    .brand {
        padding: 0 12px;
    }

    .toolbar {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .pdf-page {
        box-shadow: none;
    }

    .confirmation-box {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .actions {
        padding: 0 12px;
    }

    .actions button {
        flex: 1 1 100%;
    }

    #signatureCanvas {
        height: 190px;
    }
}
