:root {
    --primary: #1a56db;
    --primary-hover: #1e429f;
    --error: #dc2626;
    --success: #166534;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --bg: #f8fafc;
    --card: #fff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --input-border: #cbd5e1;
    --input-focus: #3b82f6;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

main {
    max-width: 660px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    padding: 2rem;
}

h1 { font-size: 1.5rem; margin-bottom: .25rem; }

/* Site header (logo bar) */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    max-width: 660px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-logo {
    display: block;
    height: 41px;
    width: auto;
}

/* Page heading above the form card */
.page-heading {
    text-align: center;
    margin-bottom: 1.5rem;
}

.page-heading h1 {
    font-size: clamp(1.5rem, 5vw, 1.875rem);
    font-weight: 700;
    letter-spacing: -.015em;
    margin-bottom: .4rem;
}

.form-note {
    color: var(--text-muted);
    font-size: .85rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.subtitle { color: var(--text-muted); font-size: .95rem; }

fieldset { border: none; }

.form-group { margin-bottom: 1.25rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label, .label {
    display: block;
    font-weight: 500;
    margin-bottom: .375rem;
    font-size: .9rem;
}

.required::after { content: ' *'; color: var(--error); font-weight: 400; }

/* Label row with a text help toggle on the right */
.label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    margin-bottom: .375rem;
}

.label-row label, .label-row .label { margin-bottom: 0; }

.help-toggle {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--primary);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    transition: color .15s;
}

.help-toggle svg {
    width: 14px;
    height: 14px;
    flex: none;
    transition: transform .15s;
}

.help-toggle:hover { text-decoration: underline; }

.help-toggle:focus-visible {
    outline: 2px solid var(--input-focus);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Panel revealed by the help toggle */
.help-panel {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem .875rem;
    margin-bottom: .5rem;
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1.55;
}

.help-panel p { margin: 0 0 .5rem; }
.help-panel p:last-child { margin-bottom: 0; }
.help-panel ul { margin: 0 0 .5rem; padding-left: 1.15rem; }
.help-panel ul:last-child { margin-bottom: 0; }
.help-panel li { margin-bottom: .3rem; }
.help-panel li:last-child { margin-bottom: 0; }
.help-panel strong { color: var(--text); font-weight: 600; }

/* Short always-visible hint (used where the customer must not miss it) */
.field-hint {
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1.5;
    margin: -.125rem 0 .5rem;
}

.field-hint strong { color: var(--text); font-weight: 600; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: .625rem .75rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

textarea { min-height: 120px; resize: vertical; }

select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

input[type="date"] {
    cursor: pointer;
}

/* The whole date field opens the calendar (via showPicker() in form.js).
   Keep the native calendar icon visible and clickable as a clear affordance. */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* Toggle group (customer type) */
.toggle-group {
    display: flex;
    gap: .5rem;
}

.toggle-group input[type="radio"] { display: none; }

.toggle-group label {
    flex: 1;
    text-align: center;
    padding: .625rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: border-color .15s, background .15s;
}

.toggle-group input:checked + label {
    border-color: var(--primary);
    background: rgba(26,86,219,.05);
    color: var(--primary);
}

/* File upload */
.file-upload {
    border: 2px dashed var(--input-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    position: relative;
}

.file-upload:hover, .file-upload.dragover {
    border-color: var(--input-focus);
    background: rgba(59,130,246,.03);
}

.file-upload input { display: none; }

.file-upload-text { font-weight: 500; margin-bottom: .25rem; }
.text-muted { color: var(--text-muted); font-size: .85rem; }

.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem;
}

.file-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.file-preview-item img,
.file-preview-item video {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #000;
}

.file-preview-item .remove-file {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
}

/* Button */
.btn {
    display: block;
    width: 100%;
    padding: .875rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    margin-top: 1.5rem;
}

.btn:hover:not(:disabled) { background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Messages */
.message {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-top: 1.25rem;
    font-size: .95rem;
    line-height: 1.5;
}

.message.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.message.error {
    background: var(--error-bg);
    color: #991b1b;
    border: 1px solid var(--error-border);
}

/* Honeypot */
.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
}

/* Turnstile */
.turnstile-wrap {
    display: flex;
    justify-content: center;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: .5rem;
}

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

@media (max-width: 640px) {
    main { padding: 1rem .75rem; }
    .card { padding: 1.25rem; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .site-header-inner { padding: .875rem .75rem; }
    .site-logo { height: 34px; }
}

/* --- Article number autocomplete --- */
.autocomplete { position: relative; }
.autocomplete-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px rgba(15, 23, 42, .12);
}
.autocomplete-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: .4rem .5rem;
    border-radius: 6px;
    cursor: pointer;
}
.autocomplete-item.active,
.autocomplete-item:hover { background: var(--bg); }
.ac-thumb {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    border: 1px solid var(--border);
}
.ac-thumb-empty { background: var(--bg); }
.ac-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.ac-article {
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.ac-name {
    font-size: .85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Required-field error highlight --- */
input.input-error,
select.input-error,
textarea.input-error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

/* --- Upload overlay --- */
.upload-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .50);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: ov-fade .2s ease;
}
.upload-overlay-card {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    padding: 2.4rem 2rem 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    animation: ov-pop .28s cubic-bezier(.2, .8, .2, 1);
}
.upload-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.3rem;
    border: 3.5px solid #e8edf5;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.upload-overlay-title {
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 .5rem;
    letter-spacing: -.01em;
}
.upload-overlay-text {
    font-size: .93rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin: 0;
}
.upload-overlay-note {
    margin-top: 1.2rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
}
.upload-overlay-note svg { flex-shrink: 0; color: var(--primary); }
@keyframes ov-fade { from { opacity: 0; } }
@keyframes ov-pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }

/* Bundle label in the autocomplete list (L-/F-/LF- article variants) */
.ac-pkg {
    display: inline-block;
    align-self: flex-start;
    margin-top: .15rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Close (X) button injected into each help panel */
.help-panel {
    position: relative;
    padding-right: 2.25rem;
}
.help-close {
    position: absolute;
    top: .4rem;
    right: .4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.help-close:hover {
    background: #e2e8f0;
    color: var(--text);
}
.help-close svg {
    width: .9rem;
    height: .9rem;
}
