/* Sales Order Entry Page Styles */

/* Entry Point View */
.entry-point-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 2rem 1rem;
}

.entry-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 20rem;
}

.entry-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.entry-button-primary {
    background: var(--primary-green);
    color: white;
}

.entry-button-primary:hover {
    background: var(--primary-green-dark);
}

.entry-button-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.entry-button-secondary:hover {
    background: var(--surface-hover);
}

.draft-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    background: var(--primary-green);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.entry-button-secondary .draft-count-badge {
    background: #475569; /* slate-600 — good contrast with white in both light/dark modes */
}

/* Draft Info Card */
.draft-info-card {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface-hover);
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 20rem;
}

.draft-info-line {
    margin-bottom: 0.25rem;
}

.draft-info-line:last-child {
    margin-bottom: 0;
}

.draft-info-emphasis {
    color: var(--text-primary);
    font-weight: 500;
}

/* Recent Submitted Orders */
.recent-orders-section {
    margin-top: 1.5rem;
    max-width: 24rem;
}

.recent-orders-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.recent-orders-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: -0.5rem 0 0.75rem 0;
}

.recent-orders-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-order-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.recent-order-item:hover {
    background: var(--surface-hover);
}

.recent-order-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.75rem;
    padding: 0.75rem 1rem;
}

.recent-order-so {
    font-weight: 600;
    color: var(--primary-green);
    font-size: 0.875rem;
}

.recent-order-customer {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.recent-order-meta {
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.recent-order-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.recent-order-detail {
    padding: 0.5rem 1rem 0.75rem;
    border-top: 1px solid var(--border);
}

.recent-order-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.8125rem;
}

.recent-order-detail-row span:first-child {
    color: var(--text-secondary);
}

.recent-order-detail-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.recent-order-lines-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.recent-order-lines {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.recent-order-line {
    font-size: 0.8125rem;
    color: var(--text-primary);
    font-family: var(--font-mono, monospace);
}

.recent-order-line-empty {
    color: var(--text-secondary);
    font-style: italic;
    font-family: inherit;
}

/* View Header */
.view-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.view-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--primary-green);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem;
    transition: var(--transition);
}

.back-link:hover {
    opacity: 0.8;
}

/* Search Container - matches sales-brief.css exactly */
.search-container {
    position: relative;
}

.search-container input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--background);
    color: var(--text-primary);
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.search-button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.5rem;
}

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

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

/* FIX 1: Search Results - Ensure visible text */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    margin-top: 0.25rem;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    background: var(--background);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--surface-hover);
}

.search-result-item[data-id]:hover {
    background: var(--primary-green);
    color: white;
}

/* Search result states */
.search-result-item.searching,
.search-result-item.no-results {
    color: var(--text-secondary);
    cursor: default;
}

.search-result-item.searching:hover,
.search-result-item.no-results:hover {
    background: var(--background);
    color: var(--text-secondary);
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Drafts List */
.drafts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.no-drafts {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem 1rem;
}

.draft-item {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.draft-info {
    flex: 1;
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.draft-info:hover {
    background: var(--surface-hover);
}

.draft-customer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.draft-name {
    font-weight: 500;
    color: var(--text-primary);
}

.draft-age {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.draft-summary {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.draft-po-pill {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--surface-hover);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    margin-bottom: 0.25rem;
}

.draft-delete {
    padding: 1rem;
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.draft-delete:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error);
}

/* Customer Header */
.customer-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.customer-header-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    min-height: 0;
    flex-wrap: nowrap;
}

.customer-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    flex-wrap: nowrap;
}

.customer-name {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
    max-width: 200px;
}

.header-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.button-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Tier Badge */
.tier-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Tier badge in section header — right-aligned before chevron */
.section-header-badge {
    margin-left: auto;
    margin-right: 0.5rem;
}

/* Tier colors — match Customer Inquiry and Dealer Locator */
.tier-platinum {
    background-color: #000000;
    color: #FFD700;
}

.tier-gold {
    background-color: #FFD700;
    color: #000000;
}

.tier-silver {
    background-color: #c0c0c0;
    color: #1a1a1a;
}

.tier-bronze {
    background-color: #cd7f32;
    color: #ffffff;
}

.tier-standard {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

/* Mobile header - ensure single line on narrow screens */
@media (max-width: 768px) {
    .button-sm {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    .customer-name {
        max-width: 160px;
    }
}

@media (max-width: 480px) {
    .customer-header-top {
        gap: 0.375rem;
        padding: 0.5rem 0.75rem;
    }

    .customer-name {
        font-size: 0.875rem;
        max-width: 130px;
    }

    .tier-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
    }

    .button-sm {
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }

    .back-link {
        padding: 0.25rem;
        margin: -0.25rem;
    }

    .back-link svg {
        width: 16px;
        height: 16px;
    }
}

/* Narrow mobile (iPhone SE, ~375px) */
@media (max-width: 380px) {
    .customer-name {
        font-size: 0.8rem;
        max-width: 100px;
    }

    .tier-badge {
        font-size: 0.6rem;
        padding: 0.1rem 0.3rem;
    }

    .button-sm {
        padding: 0.2rem 0.35rem;
        font-size: 0.65rem;
    }

    .header-actions {
        gap: 0.25rem;
    }
}

/* PO Required Banner */
.po-required-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.15);
    border-top: 1px solid rgba(245, 158, 11, 0.3);
    color: #b45309;
    font-size: 0.875rem;
    font-weight: 500;
}

@media (prefers-color-scheme: dark) {
    .po-required-banner {
        background: rgba(245, 158, 11, 0.1);
        color: #fbbf24;
    }
}

body.theme-dark .po-required-banner {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.required-asterisk {
    color: var(--error);
    font-weight: bold;
}

/* Tabs */
.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.tab-button {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
}

.item-count {
    font-weight: 400;
    opacity: 0.8;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Collapsible Sections */
.collapsible-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
}

.section-header:hover {
    background: var(--surface-hover);
}

.section-title {
    flex: 1;
}

.chevron {
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

.collapsible-section.open .chevron {
    transform: rotate(180deg);
}

.section-content {
    display: none;
    padding: 0 1rem 1rem;
}

.collapsible-section.open .section-content {
    display: block;
}

/* Form Inputs */
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--background);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* Readonly Field */
.readonly-field {
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

/* Toggle Groups (for Hold Order, Ship Complete, Dropship) */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.toggle-group:last-of-type {
    border-bottom: none;
}

.toggle-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

/* Dropship Memo Group */
.dropship-memo-group {
    margin-left: 2rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}

/* Booking Order Group - match toggle row spacing */
.booking-order-group {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Custom Address Fields */
.custom-address-fields {
    margin-left: 1rem;
    padding: 1rem;
    border-left: 3px solid var(--primary-green);
    background: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

.form-group-city {
    flex: 2;
}

.form-group-state {
    flex: 1;
    min-width: 60px;
}

.form-group-zip {
    flex: 1.5;
    min-width: 80px;
}

/* Items Placeholder */
.items-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.items-placeholder h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.items-placeholder p {
    font-size: 0.875rem;
}

/* Attachments Placeholder */
.attachments-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.attachments-placeholder .placeholder-icon {
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.attachments-placeholder h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.attachments-placeholder p {
    font-size: 0.875rem;
    margin: 0;
}

/* Form Actions */
.form-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.button-full {
    width: 100%;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Mobile form adjustments */
@media (max-width: 480px) {
    .form-row {
        flex-wrap: wrap;
    }

    .form-group-city,
    .form-group-state,
    .form-group-zip {
        flex-basis: 100%;
    }

    .form-group-state {
        min-width: auto;
    }
}

/* ============================================
   ISLAND 2: Item Search + Line Items Styles
   ============================================ */

/* Add Item Section */
.add-item-section {
    margin-bottom: 1rem;
}

.item-search-bar {
    margin-bottom: 0.75rem;
}

.item-search-results {
    max-height: 250px;
}

/* Item Detail Panel */
.item-detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Detail Panel Row 1: SKU | Product Line | Close */
.detail-row1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.item-detail-sku {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: monospace;
}

.detail-chip-pl {
    margin-left: auto;
    flex-shrink: 0;
}

.item-detail-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    flex-shrink: 0;
    margin-left: 0.25rem;
}

.item-detail-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Detail Panel Row 2: Description (full width) */
.detail-row2 {
    margin-bottom: 0.5rem;
}

.item-detail-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Detail Panel Row 3: Avl | Case | Flags (force one row) */
.detail-row3 {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: nowrap;
    margin-bottom: 0.375rem;
    overflow-x: auto;
}

/* Detail Panel Row 4: MSRP | Cost (force one row) */
.detail-row4 {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: nowrap;
    margin-bottom: 0.75rem;
}

.detail-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.detail-cost,
.detail-msrp {
    font-family: monospace;
}

/* Item Flags in detail panel - now inline with chips */
.detail-flags-inline {
    display: contents;
}

.detail-flags-inline:empty {
    display: none;
}

.item-flag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

/* Quantity Breaks Indicator */
.qty-breaks-indicator {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    background: rgba(22, 163, 74, 0.08);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

/* Pricing Row */
.item-pricing-row {
    display: grid;
    grid-template-columns: 1fr 1fr 0.7fr 0.8fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: end;
}

.pricing-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.pricing-group select,
.pricing-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--background);
    color: var(--text-primary);
}

.pricing-group select:focus,
.pricing-group input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.rate-display, .total-display {
    padding: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: monospace;
    color: var(--text-primary);
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: right;
}

.custom-rate-input {
    text-align: right;
    font-family: monospace;
}

.qty-group input {
    text-align: center;
    font-weight: 600;
}

/* Qty Validation Message */
.qty-validation-msg {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

@media (prefers-color-scheme: dark) {
    .qty-validation-msg {
        background: rgba(245, 158, 11, 0.1);
        color: #fbbf24;
    }
}

body.theme-dark .qty-validation-msg {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.qty-validation-msg .suggestion-link {
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

/* Line Items Container */
.line-items-container {
    min-height: 3rem;
}

.line-items-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.line-items-empty .placeholder-icon {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.line-items-empty h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.line-items-empty p {
    font-size: 0.875rem;
}

/* Line Item Row (Compact) */
.line-item-row {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.375rem;
    overflow: hidden;
    transition: var(--transition);
}

.line-item-row.nla-row {
    opacity: 0.6;
    border-style: dashed;
}

.line-item-drag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    padding: 0.75rem 0;
    color: var(--text-secondary);
    cursor: grab;
    flex-shrink: 0;
    font-size: 1rem;
    user-select: none;
    touch-action: none;
}

.line-item-drag:active {
    cursor: grabbing;
}

.line-item-body {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.5rem;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
}

.line-item-sku {
    font-weight: 600;
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 5rem;
}

.line-item-nla-badge {
    font-size: 0.6rem;
    font-weight: 700;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.line-item-qty {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.line-item-pl {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.line-item-rate {
    font-size: 0.8rem;
    font-weight: 600;
    font-family: monospace;
    color: var(--text-primary);
    margin-left: auto;
    white-space: nowrap;
}

.line-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    padding: 0.75rem 0;
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.line-item-delete:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error);
}

/* Hide collapsed view elements when expanded (expanded section replaces them) */
.line-item-row.expanded .line-item-drag,
.line-item-row.expanded .line-item-body,
.line-item-row.expanded .line-item-delete {
    display: none;
}

/* Line Item Expanded View */
.line-item-expanded {
    display: none;
    padding: 0.75rem 1rem;
    background: var(--background);
    width: 100%;
}

.line-item-row.expanded .line-item-expanded {
    display: block;
}

/* When expanded, switch row to block layout for full-width expanded section */
.line-item-row.expanded {
    display: block;
}

/* Bug 17: Expanded controls bar with collapse and remove buttons */
.expanded-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.expanded-collapse-btn,
.expanded-remove-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.expanded-collapse-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--primary-green);
}

.expanded-remove-btn:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error);
    border-color: var(--error);
}

.expanded-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.expanded-field-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.expanded-field-value {
    color: var(--text-primary);
    font-weight: 500;
}

.expanded-edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr 0.7fr;
    gap: 0.5rem;
    align-items: end;
}

.expanded-edit-row label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.125rem;
}

.expanded-edit-row select,
.expanded-edit-row input {
    width: 100%;
    padding: 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    background: var(--background);
    color: var(--text-primary);
}

/* Line Items Footer */
.line-items-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.5rem;
    font-weight: 600;
}

.line-items-total {
    font-family: monospace;
    font-size: 1.125rem;
    color: var(--primary-green);
}

/* Drag and drop active state */
.line-item-row.dragging {
    opacity: 0.4;
    border: 1px dashed var(--primary-green);
}

.line-item-row.drag-over {
    border-top: 2px solid var(--primary-green);
}

/* Mobile adjustments for pricing row */
@media (max-width: 480px) {
    .item-pricing-row {
        grid-template-columns: 1fr 1fr;
    }

    .qty-group {
        grid-column: 1;
    }
}

/* ============================================
   Search Result Card Layout (Bug 11)
   ============================================ */

/* New card-based search result layout */
.search-result-card {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.625rem 0.75rem;
}

/* Row 1: SKU (bold) + Description (inline, truncate) */
.search-card-row1 {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
}

.search-card-sku {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.search-card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Row 2: Pills */
.search-card-row2 {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* Search Pills - compact inline style */
.search-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.search-pill-avail {
    background: rgba(22, 163, 74, 0.12);
    color: var(--primary-green);
}

.search-pill-avail.avail-zero {
    background: rgba(220, 38, 38, 0.12);
    color: var(--error);
}

.search-pill-flag {
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.search-pill-pl {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-pill-level {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-primary);
}

.search-pill-price {
    background: rgba(22, 163, 74, 0.15);
    color: var(--primary-green);
    font-family: monospace;
    font-weight: 600;
}

/* Dark mode: ensure all pills have readable contrast */
@media (prefers-color-scheme: dark) {
    .search-pill-pl {
        background: rgba(99, 102, 241, 0.25);
        color: #a5b4fc;
    }

    .search-pill-level {
        background: rgba(156, 163, 175, 0.2);
        color: #d1d5db;
    }

    .search-pill-price {
        background: rgba(34, 197, 94, 0.2);
        color: #4ade80;
    }
}

body.theme-dark .search-pill-pl {
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
}

body.theme-dark .search-pill-level {
    background: rgba(156, 163, 175, 0.2);
    color: #d1d5db;
}

body.theme-dark .search-pill-price {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

/* Typeahead dropdown: add spacing between card rows */
.ta-row .search-card-row2 {
    margin-top: 0.25rem;
}

/* Legacy flag ribbon (keep for backwards compat) */
.flag-ribbon {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-right: 0.25rem;
    white-space: nowrap;
}

.search-result-avail {
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: auto;
}

/* ============================================
   NLA Modal Enhancements
   ============================================ */

#nlaModal .modal-popup {
    max-width: 360px;
}

.modal-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.modal-message {
    font-size: 1rem;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.5;
}

.modal-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
    margin-top: 0.5rem;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
}

.modal-buttons .modal-button {
    min-width: 100px;
    min-height: 44px;
}

.modal-button-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.modal-button-secondary:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* ============================================
   Toast Notifications (Island 3 — Phase 1)
   ============================================ */

#toast-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    padding-top: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    max-width: calc(100vw - 2rem);
    pointer-events: auto;
    margin-bottom: 0.5rem;
    transform: translateY(-100%);
    opacity: 0;
    animation: toast-slide-in 0.3s ease forwards;
}

.toast.toast-dismissing {
    animation: toast-slide-out 0.3s ease forwards;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-dismiss {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0 0.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.toast-dismiss:hover {
    opacity: 1;
}

/* Variants */
.toast-success {
    background: #16a34a;
    color: white;
}

.toast-error {
    background: #dc2626;
    color: white;
}

.toast-warning {
    background: #d97706;
    color: white;
}

/* Slide animations */
@keyframes toast-slide-in {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* ============================================
   Delete Draft Modal
   ============================================ */

.delete-draft-modal {
    max-width: 340px;
}

.modal-icon-danger {
    filter: grayscale(100%) brightness(40%) sepia(100%) hue-rotate(-50deg) saturate(600%);
}

.delete-draft-info {
    text-align: left;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.delete-draft-customer {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.delete-draft-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.delete-draft-summary {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.delete-draft-po {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.delete-draft-buttons {
    gap: 1rem;
}

.modal-button-danger {
    background: var(--error);
    color: white;
    border: none;
}

.modal-button-danger:hover {
    background: #b91c1c;
}

/* PO Duplicate Check - inline status */
.po-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.po-input-wrapper input {
    flex: 1;
    padding-right: 2.2rem;
}

.po-check-status {
    position: absolute;
    right: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    pointer-events: none;
}

.po-check-ok {
    color: var(--primary-green);
    font-weight: 700;
    font-size: 1.1rem;
}

.po-spinner-inline {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Island 3: Submit Success Icon (Phase 4)
   ============================================ */

.submit-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #16a34a;
    color: white;
    font-size: 1.75rem;
    line-height: 1;
}

/* ============================================
   Island 3: Photo Capture UI (Phase 6)
   ============================================ */

.photo-capture-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    width: 100%;
    justify-content: center;
}

.photo-capture-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.photo-thumbnails {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.photo-thumbnails:empty {
    display: none;
}

.photo-thumb-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.photo-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    background: rgba(220, 38, 38, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
