:root {
    --primary: #E13135;
    --primary-light: #f87171;
    --primary-dark: #b91c1c;
    --secondary: #6b7280;
    --secondary-light: #9ca3af;
    --background: #fafafa;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--background);
    color: var(--gray-800);
    line-height: 1.5; /* Reduced from 1.6 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 1.5rem auto; /* Reduced from 2rem */
    padding: 0 1rem;
}

.form-header {
    text-align: center;
    margin-bottom: 2rem; /* Reduced from 2.5rem */
    padding: 1.5rem; /* Reduced from 2rem */
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: slideUp 0.6s ease-out;
}

.form-header h1 {
    color: var(--primary);
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem; /* Reduced from 0.5rem */
    letter-spacing: -0.025em;
}

.form-header p {
    color: var(--gray-600);
    font-size: 1.125rem;
    font-weight: 400;
}

.form-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem; /* Reduced from 1.5rem */
    overflow: hidden;
    transition: var(--transition);
    animation: slideUp 0.6s ease-out;
    animation-fill-mode: both;
}

.form-section:nth-child(2) { animation-delay: 0.1s; }
.form-section:nth-child(3) { animation-delay: 0.2s; }
.form-section:nth-child(4) { animation-delay: 0.3s; }
.form-section:nth-child(5) { animation-delay: 0.4s; }

.form-section:hover {
    box-shadow: var(--shadow-md);
}

.form-section.initially-hidden {
    display: none;
}

.section-title {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 1rem 1.25rem; /* Reduced from 1.25rem 1.5rem */
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    border: none;
}

.form-section > *:not(.section-title) {
    padding: 1.25rem; /* Reduced from 1.5rem */
}

.form-group {
    margin-bottom: 1rem; /* Reduced from 1.5rem */
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem; /* Reduced from 1.5rem */
}

label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem; /* Reduced from 0.5rem */
    font-size: 0.875rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.help-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--gray-400);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    cursor: help;
    transition: var(--transition);
    z-index: 10;
}

.help-icon:hover {
    background: var(--primary);
    transform: translateY(-50%) scale(1.05);
}

.tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--gray-900);
    color: var(--white);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: var(--transition);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 16px;
    border: 6px solid transparent;
    border-top-color: var(--gray-900);
}

.help-icon:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.875rem; /* Reduced from 0.75rem 1rem */
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--white);
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(225 49 53 / 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--gray-400);
}

textarea {
    resize: vertical;
    min-height: 80px; /* Reduced from 100px */
}

.search-help {
    margin-top: 0.375rem; /* Reduced from 0.5rem */
}

.search-help small {
    color: var(--gray-500);
    font-size: 0.75rem;
    font-style: italic;
}

.radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem; /* Reduced from 0.75rem */
    margin-top: 0.5rem; /* Reduced from 0.75rem */
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem; /* Reduced from 0.75rem 1rem */
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
}

.radio-option:hover {
    border-color: var(--primary-light);
    background: rgb(225 49 53 / 0.02);
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: rgb(225 49 53 / 0.05);
}

.radio-option input[type="radio"] {
    margin-right: 0.625rem; /* Reduced from 0.75rem */
    width: auto;
    accent-color: var(--primary);
}

.radio-option label {
    margin: 0;
    cursor: pointer;
    font-weight: 400;
    color: var(--gray-700);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem; /* Reduced from 0.75rem 1.5rem */
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
    transform: translateY(-1px);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0.5rem 0; /* Reduced from 0.75rem 0 */
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lookup-btn {
    width: 100%;
}

.submit-btn {
    width: 100%;
    padding: 0.875rem 1.25rem; /* Reduced from 1rem 1.5rem */
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.75rem; /* Reduced from 1rem */
}

.order-summary {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem; /* Reduced from 1.25rem */
    margin-bottom: 1rem; /* Reduced from 1.25rem */
}

.customer-verified {
    background: rgb(16 185 129 / 0.1);
    border: 1px solid rgb(16 185 129 / 0.2);
    color: var(--success);
    padding: 0.875rem 1rem; /* Reduced from 1rem 1.25rem */
    border-radius: var(--radius);
    margin-bottom: 1rem; /* Reduced from 1.25rem */
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.customer-verified .checkmark {
    font-size: 1.25rem;
    font-weight: 600;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem; /* Reduced from 1.25rem */
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.items-table th {
    background: var(--gray-100);
    color: var(--gray-700);
    text-align: left;
    padding: 0.75rem 0.625rem; /* Reduced from 1rem 0.75rem */
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-200);
}

.items-table td {
    padding: 0.75rem 0.625rem; /* Reduced from 1rem 0.75rem */
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.items-table tr:hover td {
    background: var(--gray-50);
}

.checkbox-cell {
    text-align: center;
    width: 60px;
}

.quantity-cell {
    width: 120px;
}

.quantity-cell input {
    width: 70px;
    padding: 0.375rem; /* Reduced from 0.5rem */
    text-align: center;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 120px auto;
    gap: 0.75rem; /* Reduced from 1rem */
    margin-bottom: 0.75rem; /* Reduced from 1rem */
    align-items: end;
}

.remove-item {
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    padding: 0.375rem 0.625rem; /* Reduced from 0.5rem 0.75rem */
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.remove-item:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--white);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.375rem; /* Reduced from 0.5rem */
    display: none;
    font-weight: 500;
}

.success-message {
    display: none;
    background: var(--success);
    color: var(--white);
    text-align: center;
    padding: 1.5rem; /* Reduced from 2rem */
    border-radius: var(--radius-lg);
    margin-top: 1.5rem; /* Reduced from 2rem */
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s ease-out;
}

.success-message h3 {
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    font-size: 1.5rem;
}

.terms {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: 1.5rem; /* Reduced from 2rem */
    padding: 1.25rem; /* Reduced from 1.5rem */
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.terms p {
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    font-weight: 500;
}

.terms ul {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
}

.terms li {
    margin-bottom: 0.375rem; /* Reduced from 0.5rem */
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        margin: 0.75rem auto; /* Reduced from 1rem */
        padding: 0 0.75rem;
    }

    .form-header {
        padding: 1.25rem; /* Reduced from 1.5rem */
        margin-bottom: 1.25rem; /* Reduced from 1.5rem */
    }

    .form-header h1 {
        font-size: 1.875rem;
    }

    .form-section > *:not(.section-title) {
        padding: 1rem; /* Reduced from 1.25rem */
    }

    .section-title {
        padding: 0.875rem 1rem; /* Reduced from 1rem 1.25rem */
        font-size: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem; /* Reduced from 1rem */
    }

    .radio-group {
        grid-template-columns: 1fr;
    }

    .item-row {
        grid-template-columns: 1fr;
        gap: 0.5rem; /* Reduced from 0.75rem */
    }

    .items-table {
        font-size: 0.875rem;
    }

    .items-table th,
    .items-table td {
        padding: 0.625rem 0.375rem; /* Reduced from 0.75rem 0.5rem */
    }

    .tooltip {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .tooltip::after {
        display: none;
    }
}