/**
 * SKOR Mobile-First Stylesheet
 * 
 * White/near-white surfaces, dark text, restrained Go APE orange,
 * large touch targets, image-led design.
 */

/* ============================================================================
   Variables & Reset
   ============================================================================ */
:root {
    /* SKOR Brand Colors */
    --skor-money-green: #1F6B2A;
    --skor-forest-green: #11461B;
    --skor-emerald-accent: #2E8F3E;
    --skor-mint-tint: #DDF3DB;
    --skor-jet-black: #0B0B0B;
    --skor-graphite: #1E1F21;
    --skor-soft-ash: #A7ADA8;
    --skor-off-white: #F7F8F4;
    
    /* Light Theme Tokens (default) */
    --color-bg: #F7F8F4;
    --color-surface: #FFFFFF;
    --color-text: #0B0B0B;
    --color-text-secondary: #4A4F4B;
    --color-border: #D9DEDB;
    --color-primary: #1F6B2A;
    --color-primary-dark: #11461B;
    --color-primary-hover: #11461B;
    --color-secondary-btn: #E8EFE6;
    --color-accent: #2E8F3E;
    --color-success: #3AA34C;
    --color-warning: #FFC107;
    --color-error: #DC3545;
    
    --spacing-unit: 8px;
    --border-radius: 8px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    color-scheme: light;
}

/* Dark Theme Tokens */
[data-theme="dark"] {
    --color-bg: #0B0B0B;
    --color-surface: #151715;
    --color-text: #F7F8F4;
    --color-text-secondary: #B8BEB9;
    --color-border: #2B312C;
    --color-primary: #1F6B2A;
    --color-primary-dark: #2E8F3E;
    --color-primary-hover: #2E8F3E;
    --color-secondary-btn: #222724;
    --color-accent: #5BC46B;
    --color-success: #6ED37B;
    
    color-scheme: dark;
}

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

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   Layout
   ============================================================================ */
.main-content {
    padding-bottom: calc(60px + env(safe-area-inset-bottom)); /* Space for bottom nav */
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) * 2);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.page-header .header-logo {
    max-width: 180px;
    width: auto;
    height: 32px;
    margin-right: calc(var(--spacing-unit) * 2);
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: var(--spacing-unit);
    align-items: center;
}

/* ============================================================================
   Theme Switcher
   ============================================================================ */
.theme-switcher {
    display: flex;
    gap: calc(var(--spacing-unit) / 2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 2px;
}

.theme-btn {
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 1.5);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: calc(var(--border-radius) - 2px);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.theme-btn:hover {
    background: var(--color-border);
}

.theme-btn:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

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

/* ============================================================================
   Bottom Navigation
   ============================================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: calc(var(--spacing-unit) * 1.5);
    text-decoration: none;
    color: var(--color-text-secondary);
    transition: color 0.2s;
    min-height: 60px;
}

.nav-item:active {
    background: var(--color-surface);
}

.nav-item.active {
    color: var(--color-primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: calc(var(--spacing-unit) / 2);
}

.nav-label {
    font-size: 12px;
    font-weight: 500;
}

/* ============================================================================
   Forms & Inputs
   ============================================================================ */
.form-group {
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: calc(var(--spacing-unit) / 2);
    color: var(--color-text);
}

.form-control {
    width: 100%;
    padding: calc(var(--spacing-unit) * 1.5);
    font-size: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Prevent Safari auto-zoom on input focus */
input,
textarea,
select {
    font-size: 16px;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-prefix {
    display: flex;
    align-items: center;
    padding: 0 calc(var(--spacing-unit) * 1.5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-right: none;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    font-weight: 500;
}

.input-group .form-control {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 3);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px; /* Large touch target */
}

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

.btn-primary:hover,
.btn-primary:active {
    background: var(--color-primary-hover);
}

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

.btn-secondary:active {
    background: var(--color-border);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 2);
    font-size: 14px;
    min-height: 36px;
}

.btn-icon {
    padding: calc(var(--spacing-unit) * 1);
    min-width: 40px;
    min-height: 40px;
}

/* Pass 07 Button Enhancements */
.btn-primary {
    /* Override to ensure explicit text color (no Safari blue inheritance) */
    color: #ffffff !important;
}

.btn-lg {
    min-height: 48px;
    padding: 14px 28px;
    font-size: 18px;
}

.btn-danger {
    background-color: var(--error-bg);
    color: var(--error-color);
}

.btn-danger:hover:not(:disabled) {
    opacity: 0.9;
}

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

/* Confidence badges */
.confidence-badge {
    display: inline-flex;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Responsive button stacking on narrow screens */
@media (max-width: 480px) {
    .btn-block-mobile {
        width: 100%;
    }
}

/* ============================================================================
   Cards
   ============================================================================ */
.product-card,
.show-list-card,
.sell-queue-card {
    display: flex;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    margin-bottom: calc(var(--spacing-unit) * 2);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.product-card:active {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-image,
.show-list-card-image {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img,
.show-list-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image {
    color: var(--color-text-secondary);
    font-size: 14px;
}

.product-info {
    flex: 1;
    padding: calc(var(--spacing-unit) * 2);
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) / 2);
}

.product-number {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.product-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.product-brand {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.product-financial {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
    font-size: 14px;
}

.cost {
    font-weight: 600;
}

.value-range {
    color: var(--color-success);
    font-weight: 500;
}

/* P01-R1: qualification shown beside a resale range that rests on an unverified candidate */
.value-range-qualifier {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    font-style: italic;
}

.resale-range-qualification,
.research-single-observation {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}

.applied-price-reference {
    margin: 8px 0 12px;
    padding: 8px 10px;
    border-left: 3px solid var(--color-border, #ccc);
}

.applied-price-reference-amount {
    font-weight: 600;
}

.applied-price-reference-source,
.applied-price-reference-note {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}

.product-actions {
    display: flex;
    align-items: center;
    padding: calc(var(--spacing-unit) * 2);
    border-left: 1px solid var(--color-border);
}

/* ============================================================================
   Sell Queue mobile spacing (scoped: Inventory / Shows share .product-* classes)
   ============================================================================ */
.sell-container {
    box-sizing: border-box;
    padding: 0 calc(var(--spacing-unit) * 2); /* 16px page gutter */
}

.sell-header {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 1.5);
    padding: calc(var(--spacing-unit) * 2) 0;
}

.sell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
}

.sell-actions .btn {
    min-height: 44px;
}

/* Destructive: the same solid red used for Delete Show */
.sell-actions .btn-danger {
    background: var(--error-color, #dc2626);
    color: #ffffff;
    border: none;
}

.export-note {
    box-sizing: border-box;
    padding: 0 calc(var(--spacing-unit) * 2);
    margin: calc(var(--spacing-unit) * 2) 0;
    overflow-wrap: anywhere;
}

.data-exports {
    box-sizing: border-box;
    margin: calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 2);
    padding-top: calc(var(--spacing-unit) * 2);
    border-top: 1px solid var(--border-color);
    min-width: 0;
}

.data-exports-title {
    margin: 0 0 calc(var(--spacing-unit) / 2);
    font-size: 0.95rem;
    color: var(--text-primary);
}

.data-exports-help {
    margin: 0 0 calc(var(--spacing-unit) * 1.5);
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.data-exports-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
}

.data-exports-actions .btn {
    flex: 1 1 14rem;
    min-width: 0;
    white-space: normal;
}

.sell-queue-card {
    min-width: 0;
}

/* Checkbox: native control, 24px, in a 44px tap zone (a <label>, so the whole zone toggles it) */
.sell-queue-card .product-select {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sell-queue-card .queue-item-checkbox {
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.sell-queue-card .product-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 480px) {
    /* Room for the details: smaller image, and Remove drops to its own row inside the card */
    .sell-queue-card {
        flex-wrap: wrap;
    }

    .sell-queue-card .product-image {
        width: 88px;
        height: 88px;
        align-self: center;
    }

    .sell-queue-card .product-info {
        flex: 1 1 0;
        padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 1.5);
    }

    .sell-queue-card .product-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        border-left: 0;
        border-top: 1px solid var(--color-border);
        padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5);
    }

    .sell-queue-card .product-actions .btn {
        min-height: 44px;
    }
}

/* ============================================================================
   Badges
   ============================================================================ */
.badge {
    display: inline-block;
    padding: calc(var(--spacing-unit) / 2) var(--spacing-unit);
    font-size: 12px;
    font-weight: 600;
    border-radius: calc(var(--border-radius) / 2);
}

.badge-available {
    background: #E7F5EC;
    color: var(--color-success);
}

.badge-sold {
    background: #F8D7DA;
    color: var(--color-error);
}

.badge-warning {
    background: #FFF3CD;
    color: #856404;
}

.badge-unsold {
    background: var(--color-surface);
    color: var(--color-text-secondary);
}

/* ============================================================================
   Shows list card: information full width above a 2-column action grid
   ============================================================================ */
.show-list-card {
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2);
    padding: calc(var(--spacing-unit) * 2);
}

.show-list-card .show-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
}

.show-list-card .show-name {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.show-list-card .show-meta {
    font-size: 15px;
    color: var(--color-text-secondary);
}

.show-list-card .show-meta-sep {
    margin: 0 calc(var(--spacing-unit) / 2);
}

.show-list-card .show-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
}

.show-list-card .show-badges .show-status {
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

/* Sold badge: darker red text so the count is readable on its pink pill in both themes */
.show-list-card .show-badges .badge-sold {
    color: #842029;
}

.show-list-card .show-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-unit);
}

.show-list-card .show-actions .btn {
    min-width: 0;
    min-height: 48px;
    padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5);
    text-align: center;
    line-height: 1.2;
}

/* Destructive: the existing solid red used for other destructive actions */
.show-list-card .show-actions .btn-danger,
.show-delete-dialog .btn-danger {
    background: var(--error-color, #dc2626);
    color: #ffffff;
    border: none;
}

/* Shows page: "+ New Show" gets the same inset as the card contents (mobile only; desktop unchanged) */
@media (max-width: 767px) {
    .shows-header {
        padding: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 2 + 1px);
    }
}

/* Extremely narrow screens: stack the actions */
@media (max-width: 299px) {
    .show-list-card .show-actions {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Desktop: information on the left, actions on the right */
@media (min-width: 768px) {
    .show-list-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .show-list-card .show-info {
        flex: 1 1 auto;
    }

    .show-list-card .show-actions {
        flex: 0 0 auto;
        grid-template-columns: repeat(4, auto);
    }

    .show-list-card .show-actions .btn {
        white-space: nowrap;
    }
}

/* Delete Show confirmation (reuses .confirm-overlay / .confirm-dialog) */
.show-delete-dialog h3 {
    margin: 0 0 12px 0;
    font-size: 1.125rem;
    color: var(--color-text);
}

.show-delete-dialog p {
    margin: 0 0 20px 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

.show-delete-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
    justify-content: flex-end;
}

.show-delete-buttons .btn {
    min-width: 80px;
}

/* Show date modal (reuses .confirm-overlay / .show-delete-dialog) + Manage page date controls */
.show-date-label {
    display: block;
    margin: 0 0 calc(var(--spacing-unit) / 2) 0;
    font-weight: 500;
    color: var(--color-text);
}

/* The WRAPPER is the visible field box (border, radius, background, focus ring) and simply fills the dialog's content
   width, like the title and label. The native date input inside is a borderless, transparent control, so iOS's own
   border geometry no longer decides where the visible box sits. */
.show-date-field-wrap {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0 0 calc(var(--spacing-unit) * 2) 0;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-bg);
    overflow: hidden;
    transition: border-color 0.2s;
}

.show-date-field-wrap[hidden],
.show-date-label[hidden] {
    display: none;
}

.show-date-field-wrap:focus-within {
    border-color: var(--color-primary);
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.show-date-input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0 calc(var(--spacing-unit) * 1.5);
    color: var(--color-text);
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    text-align: left;
}

.show-date-input:focus {
    outline: none;
}

.show-date-input::-webkit-date-and-time-value {
    display: block;
    min-height: 1.4em;
    margin: 0;
    padding: 0;
    text-align: left;
}

.show-date-input::-webkit-datetime-edit {
    padding: 0;
}

.show-date-dialog .show-date-error {
    margin: calc(var(--spacing-unit) * -1) 0 calc(var(--spacing-unit) * 2) 0;
    color: var(--color-error);
    font-size: 0.9375rem;
}

[data-theme="dark"] .show-date-dialog .show-date-error {
    color: #FF8A94;
}

.show-date-dialog {
    box-sizing: border-box;
    min-width: 0;
}

.show-date-dialog .show-date-saved-text {
    margin: 0 0 calc(var(--spacing-unit) * 2) 0;
    font-size: 1rem;
    color: var(--color-text);
}

.show-date-dialog:focus {
    outline: none;
}

.show-date-dialog .btn-primary {
    color: #ffffff;
}

.show-date-controls .show-date-text {
    margin: 0 0 var(--spacing-unit) 0;
}

.show-date-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
}

.show-date-actions .btn[hidden] {
    display: none;
}

/* ============================================================================
   Manage page: lineup editing (toolbar above the Show Items list)
   Normal:  [ + Add Products ] [ Remove Products ]
   Editing: [ + Add Products ] [ Remove Selected (N) ]  /  [ Cancel ] [ Save Changes ]
   ============================================================================ */
.show-lineup {
    min-width: 0;
}

.show-lineup .lineup-title {
    margin-bottom: var(--spacing-unit);
}

.lineup-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.lineup-toolbar .lineup-btn {
    min-height: 44px;
    min-width: 0;
    max-width: 100%;
    padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5);
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

.lineup-toolbar .lineup-btn[hidden] {
    display: none;
}

/* Destructive: the same solid red used for Delete Show */
.lineup-toolbar .lineup-btn.is-destructive {
    background: var(--error-color, #dc2626);
    color: #ffffff;
    border: none;
}

.lineup-toolbar .lineup-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.lineup-items {
    min-width: 0;
}

/* Editing: a checkbox tap zone (a <label>, 44px) beside the existing card, thumbnail and title intact */
.product-card.lineup-item {
    min-width: 0;
}

.product-card.lineup-item .lineup-select {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.product-card.lineup-item .lineup-select-input {
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.product-card.lineup-item .product-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

.product-card.lineup-item .lineup-item-note {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.product-card.lineup-item .lineup-item-flags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-unit);
}

/* Pending states: subtle, never alarming */
.product-card.lineup-item .badge-pending-add {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.product-card.lineup-item .badge-pending-remove {
    background: var(--color-surface);
    color: #B02A37;
    border: 1px solid #B02A37;
}

[data-theme="dark"] .product-card.lineup-item .badge-pending-add {
    color: var(--color-success);
    border-color: var(--color-success);
}

[data-theme="dark"] .product-card.lineup-item .badge-pending-remove {
    color: #FF8A94;
    border-color: #FF8A94;
}

.product-card.lineup-item.is-pending-remove .product-image,
.product-card.lineup-item.is-pending-remove .product-info > :not(.lineup-item-flags) {
    opacity: 0.55;
}

.product-card.lineup-item.is-pending-add {
    border-color: var(--color-primary);
}

[data-theme="dark"] .product-card.lineup-item.is-pending-add {
    border-color: var(--color-success);
}

.product-card.lineup-item .lineup-undo-btn {
    min-height: 44px;
    padding: 0 var(--spacing-unit);
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

[data-theme="dark"] .product-card.lineup-item .lineup-undo-btn {
    color: var(--color-accent);
}

/* SHOW-REORDER-R1: Reorder Products mode. The button takes its own row so the toolbar wraps cleanly on phones. */
.lineup-toolbar #lineup-reorder-btn {
    grid-column: 1 / -1;
}

.lineup-reorder-hint {
    margin: calc(var(--spacing-unit) * -1) 0 calc(var(--spacing-unit) * 2);
    font-size: 14px;
    color: var(--color-text-secondary);
}

.lineup-reorder-hint[hidden] {
    display: none;
}

/* The drag handle: a 44px touch target. Only the handle claims the gesture (touch-action: none); swiping anywhere else still scrolls. */
.product-card.lineup-item .lineup-handle {
    /* SHOW-REORDER-R2: a full-height grab bar inset 8px from the card's top, bottom and left edges, 10px clear of the thumbnail */
    flex: 0 0 52px;
    width: 52px;
    min-width: 48px;
    min-height: 48px;
    align-self: stretch;
    margin: 8px 10px 8px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-secondary);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.product-card.lineup-item .lineup-handle:hover {
    border-color: var(--color-primary);
}

.product-card.lineup-item .lineup-handle:active {
    background: var(--color-border);
    border-color: var(--color-primary);
    color: var(--color-primary);
    cursor: grabbing;
}

.product-card.lineup-item .lineup-handle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.show-lineup.is-reordering .product-card.lineup-item {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.show-lineup.is-reordering .product-card.lineup-item img {
    pointer-events: none;
    -webkit-user-drag: none;
}

/* While dragging: the real card stays in the list as the card-height insertion space (its contents hidden); a floating copy follows the pointer */
.show-lineup.is-drag-active,
.show-lineup.is-drag-active * {
    cursor: grabbing;
}

.product-card.lineup-item.is-drag-placeholder {
    background: var(--color-surface);
    border: 1px dashed var(--color-primary);
    box-shadow: inset 0 0 0 1px var(--color-primary);
}

.product-card.lineup-item.is-drag-placeholder > * {
    visibility: hidden;
}

.product-card.lineup-item.lineup-slide {
    transition: transform 0.18s ease;
}

.product-card.lineup-item.lineup-drag-preview {
    position: fixed;
    top: 0;
    margin: 0;
    z-index: 1000;
    pointer-events: none;
    background: var(--color-bg);
    border-color: var(--color-primary);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3), 0 0 0 2px var(--color-primary);
    will-change: transform;
}

.product-card.lineup-item.lineup-drag-preview.is-settling {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 0 2px var(--color-primary);
}

.product-card.lineup-item.lineup-drag-preview * {
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .product-card.lineup-item.lineup-slide,
    .product-card.lineup-item.lineup-drag-preview.is-settling {
        transition: none;
    }
}

@media (max-width: 480px) {
    .show-lineup.is-reordering .product-card.lineup-item .product-image,
    .show-lineup.is-editing .product-card.lineup-item .product-image {
        width: 88px;
        height: 88px;
        align-self: center;
    }
}

/* ============================================================================
   Scan Page
   ============================================================================ */
.scan-container {
    padding: calc(var(--spacing-unit) * 2);
    max-width: 600px;
    margin: 0 auto;
}

.scan-mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.mode-btn {
    padding: calc(var(--spacing-unit) * 2);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

.mode-btn strong {
    display: block;
    margin-bottom: calc(var(--spacing-unit) / 2);
}

.mode-btn small {
    font-size: 14px;
    opacity: 0.9;
}

.photo-capture {
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.photo-buttons {
    display: flex;
    gap: var(--spacing-unit);
    margin-bottom: var(--spacing-unit);
}

.photo-buttons .btn-camera {
    flex: 1;
}

.btn-camera {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
    padding: calc(var(--spacing-unit) * 3);
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--border-radius);
    min-height: auto;
}

.photo-action-icon {
    width: 40px;
    height: 40px;
    display: block;
    margin: 0 auto 12px;
    color: currentColor;
    flex: 0 0 auto;
}

@media (max-width: 480px) {
    .photo-action-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
    }
}

.photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--spacing-unit);
    margin-top: calc(var(--spacing-unit) * 2);
}

.photo-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.photo-preview-add {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-more {
    width: 60px;
    height: 60px;
    border: 2px dashed var(--color-border);
    background: var(--color-surface);
    border-radius: var(--border-radius);
    font-size: 32px;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.help-text {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
    margin-top: var(--spacing-unit);
}

/* Scan Loading - Enhanced */
.scan-loading {
    padding: 2rem 1rem;
}

.loading-card {
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-thumbnail {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-surface);
}

.loading-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loading-card .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .loading-card .spinner {
        animation-duration: 2s;
    }
}

.loading-card #loading-status {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.loading-card .loading-detail {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.loading-card .draft-saved {
    font-size: 0.875rem;
    color: var(--color-primary);
    margin: 0;
}

.loading-card .loading-time {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin: 0;
}

/* Spinner animation */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-surface);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto calc(var(--spacing-unit) * 2);
}

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

/* AI Context Field */
.ai-context-field {
    margin: 1rem 0;
}

.ai-context-field .form-control {
    width: 100%;
    padding: 0.75rem;
    font-size: 16px; /* Prevent iOS zoom */
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: inherit;
    resize: vertical;
}

.ai-context-field .form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

/* Confidence SKOR Display */
.confidence-skor {
    margin: 1rem 0;
    padding: 0.75rem;
    background: var(--color-surface);
    border-radius: 8px;
}

.confidence-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0.25rem;
}

.confidence-high {
    background: rgba(34, 139, 34, 0.15);
    color: var(--color-primary);
}

.confidence-medium {
    background: rgba(255, 193, 7, 0.15);
    color: #f59e0b;
}

.confidence-low {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.confidence-note {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

/* Additional color tokens for UI components */
:root {
    --bg-primary: var(--color-surface);
    --bg-secondary: var(--color-bg);
    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-secondary);
    --border-color: var(--color-border);
    --primary-color: var(--color-primary);
    --link-color: var(--color-primary);
    --success-bg: rgba(34, 139, 34, 0.1);
    --success-color: var(--color-success);
    --warning-bg: rgba(255, 193, 7, 0.15);
    --warning-color: #f59e0b;
    --error-bg: rgba(220, 53, 69, 0.1);
    --error-color: var(--color-error);
}

[data-theme="dark"] {
    --bg-primary: var(--color-surface);
    --bg-secondary: var(--color-bg);
    --link-color: var(--color-accent);
}

/* Research Section in Product Modal */
.research-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.research-section h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.research-section a {
    color: var(--link-color);
    text-decoration: none;
}

.research-section a:hover {
    text-decoration: underline;
}

/* Insufficient Pricing Notice */
.insufficient-notice {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--warning-bg);
    border-left: 4px solid var(--warning-color);
    border-radius: 4px;
}

.insufficient-notice div:first-child {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.insufficient-notice div:last-child {
    font-size: 0.875rem;
}

/* Product Modal Enhancements */
.product-modal .modal-content {
    background-color: var(--bg-primary);
}

/* Product Info dialog layout: a bounded column (header, scrolling body, action footer).
   The overlay is as tall as the visible viewport (dvh, with a plain fallback), and the
   dialog never exceeds it, so the footer cannot fall behind a browser toolbar.
   If the screen is too short for header + footer + a usable body, the dialog keeps its
   natural height and the overlay scrolls instead of clipping the actions. */
.product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding: max(12px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

@supports (height: 100dvh) {
    .product-modal {
        height: 100dvh;
    }
}

.product-modal .modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    max-height: 100%;
    margin: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
}

.product-modal .modal-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
}

.product-modal .modal-body {
    flex: 1 1 auto;
    min-height: 7rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    color: var(--text-primary);
}

.product-modal .modal-footer {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 12px 12px;
}

.product-modal .modal-footer .btn {
    max-width: 100%;
}

@media (max-width: 480px) {
    .product-modal .modal-header {
        padding: 12px 16px;
    }

    .product-modal .modal-body {
        padding: 16px;
    }

    .product-modal .modal-footer {
        padding: 12px 16px;
    }

    .product-modal .modal-footer .btn {
        flex: 1 1 auto;
    }
}

.product-image-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.product-image-strip > div {
    flex: 0 0 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
}

.product-number-display {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.current-value-display {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.confidence-skor-display {
    margin-bottom: 1.25rem;
}

/* Operation waiting indicator */
.operation-waiting {
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Operation spinner */
.operation-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: operation-spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .operation-spinner {
        animation: none;
        /* Show a static pulse instead */
        opacity: 0.8;
    }
}

.operation-status-text {
    flex: 1 0 auto;
    text-align: center;
}

/* Persistent feedback messages */
.persistent-feedback-message {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 8px;
    font-size: 0.9375rem;
    line-height: 1.5;
    border-width: 1px;
    border-style: solid;
}

.persistent-feedback-error {
    background: var(--error-bg, #fef2f2);
    color: var(--error-color, #dc2626);
    border-color: var(--error-color, #dc2626);
}

.persistent-feedback-warning {
    background: var(--warning-bg, #fffbeb);
    color: var(--warning-color, #d97706);
    border-color: var(--warning-color, #d97706);
}

.persistent-feedback-info {
    background: var(--info-bg, #eff6ff);
    color: var(--info-color, #2563eb);
    border-color: var(--info-color, #2563eb);
}

/* Inventory page spacing */
.inventory-container {
    padding: 0 16px;
    max-width: 100%;
}

.inventory-controls {
    margin-top: 12px;
    margin-bottom: 12px;
}

.inventory-controls .search-box {
    margin-bottom: 12px;
}

.product-feed {
    margin-bottom: 16px;
}

/* Draft cleanup (Inventory > Filters > Draft only) */
/* Filters on the left, "\2190 All Inventory" on the right of the same row (wraps only on extremely narrow screens) */
.inventory-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-unit);
}

.inventory-action-row .btn {
    min-height: 44px;
    max-width: 100%;
    min-width: 0;
}

.inventory-filter-bar {
    margin: 0 0 0 auto;
    max-width: 100%;
}

.inventory-filter-bar[hidden] {
    display: none;
}

.draft-cleanup-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
    margin-bottom: 12px;
}

.draft-cleanup-bar[hidden] {
    display: none;
}

.draft-cleanup-bar .btn {
    min-height: 44px;
    max-width: 100%;
    min-width: 0;
}

/* Destructive: the same solid red used for Delete Show */
.draft-cleanup-bar .btn-danger,
.discard-draft-btn {
    background: var(--error-color, #dc2626);
    color: #ffffff;
    border: none;
}

.draft-cleanup-bar .btn-danger:disabled {
    opacity: 0.5;
}

/* Checkbox: native control, 24px, in a 44px tap zone (a <label>, so the whole zone toggles it) */
.product-card.draft-selectable,
.product-card.remove-selectable,
.product-card.show-pick-selectable {
    min-width: 0;
}

.product-card.draft-selectable .draft-select,
.product-card.remove-selectable .remove-select,
.product-card.show-pick-selectable .show-pick-select {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.product-card.draft-selectable .draft-select-input,
.product-card.remove-selectable .remove-select-input,
.product-card.show-pick-selectable .show-pick-select-input {
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.product-card.draft-selectable .product-info,
.product-card.remove-selectable .product-info,
.product-card.show-pick-selectable .product-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 480px) {
    .product-card.draft-selectable .product-image,
    .product-card.remove-selectable .product-image,
    .product-card.show-pick-selectable .product-image {
        width: 88px;
        height: 88px;
        align-self: center;
    }

    .product-card.draft-selectable .product-actions,
    .product-card.remove-selectable .product-actions,
    .product-card.show-pick-selectable .product-actions {
        padding: var(--spacing-unit);
    }
}

/* Remove Products (Inventory list): the Shows pattern. Normal: [Remove Products]; selecting: red [Remove Selected (N)] + [Cancel] */
.inventory-action-row .inventory-remove-btn[hidden] {
    display: none;
}

.inventory-action-row .inventory-remove-btn.is-destructive {
    background: var(--error-color, #dc2626);
    color: #ffffff;
    border: none;
}

.inventory-action-row .inventory-remove-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Selection mode replaces the Draft cleanup checkbox (a card never shows two), and a selected card is clearly marked */
.product-feed.is-removing .draft-select {
    display: none;
}

.product-card.remove-selectable.is-remove-selected {
    border-color: var(--error-color, #dc2626);
    box-shadow: 0 0 0 1px var(--error-color, #dc2626);
}

/* Add to Show (Inventory -> Show): a selected card is marked in the brand green, never the destructive red */
.product-card.show-pick-selectable.is-show-pick-selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.product-feed.is-picking .draft-select {
    display: none;
}

.add-to-show-dialog {
    max-width: 440px;
}

.add-to-show-dialog .add-to-show-select {
    width: 100%;
    margin: 0 0 calc(var(--spacing-unit) * 2) 0;
}

.add-to-show-dialog .add-to-show-error {
    color: var(--color-error);
    font-weight: 600;
}

.add-to-show-dialog .add-to-show-error[hidden] {
    display: none;
}

.confirm-dialog .discard-confirm-note {
    margin-top: -8px;
    font-weight: 500;
}

.load-more-container {
    text-align: center;
    padding: 20px 0;
}

@media (min-width: 768px) {
    .inventory-container {
        padding: 0 24px;
    }
}

/* Product image strip with removal controls */
.product-image-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

.saved-image-wrapper {
    flex: 0 0 100px;
    position: relative;
}

.saved-image-thumbnail {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--color-border);
}

.saved-image-thumbnail.is-primary {
    border: 3px solid var(--primary-color);
}

.saved-image-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.btn-remove-saved-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Expand touch target to 44px using pseudo-element */
.btn-remove-saved-image::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.btn-remove-saved-image:hover {
    background: rgba(0, 0, 0, 0.95);
    transform: scale(1.05);
}

.btn-remove-saved-image:active {
    background: rgba(220, 38, 38, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

.btn-remove-saved-image svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    pointer-events: none;
}

.btn-remove-saved-image:disabled,
.pending-photo-remove:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.5);
}

/* Pending preview wrapper (existing uploads) */
.pending-preview-wrapper {
    flex: 0 0 100px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Photo removal confirmation dialog */
.photo-removal-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.photo-removal-confirm-dialog {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.photo-removal-confirm-dialog h3 {
    margin: 0 0 16px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.photo-removal-preview {
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.photo-removal-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-removal-message {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.photo-removal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.photo-removal-actions .btn {
    flex: 1;
}

.photo-removal-actions .btn-destructive {
    background: var(--error-color, #dc2626);
    color: white;
    border: none;
}

.photo-removal-actions .btn-destructive:active {
    opacity: 0.8;
}

/* Confirm dialog overlay */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-dialog {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Result card improvements */
.result-success {
    background: rgba(34, 139, 34, 0.1);
    color: var(--color-primary);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
}

.value-range {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0.75rem 0;
}

.insufficient-notice {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin: 0.75rem 0;
}

.valuation-note {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0.5rem 0;
    font-style: italic;
}

.result-sources {
    margin: 1rem 0;
    padding: 0.75rem;
    background: var(--color-surface);
    border-radius: 8px;
    font-size: 0.875rem;
}

.result-sources a {
    color: var(--color-primary);
    text-decoration: none;
    word-break: break-all;
}

.result-sources a:hover {
    text-decoration: underline;
}

/* Scan result layout adjustments */
#scan-result {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

#result-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.result-field {
    margin: 0.5rem 0;
}

/* Button spacing in results */
#result-details .btn {
    margin-top: 0.5rem;
}

/* Result action buttons (Scan Another, View Inventory) */
.result-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}

.result-actions .btn {
    flex: 1;
    margin: 0;
}

/* ============================================================================
   Show Mode (Swipe Interface)
   ============================================================================ */
.show-mode-container {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    z-index: 2000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.show-mode-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--spacing-unit) * 2);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.btn-exit {
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 2);
    text-decoration: none;
    color: var(--color-text);
    font-weight: 600;
}

.show-mode-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
}

.show-progress {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.show-deck {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.show-mode-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    overflow-y: auto;
}

.lot-number {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 600;
    margin-bottom: calc(var(--spacing-unit) / 2);
}

/* ---- Show Mode product workstation ------------------------------------------------
   One column by default (phones, iPad portrait). Two columns only on landscape screens
   at least 1024px wide (iPad landscape, laptops) or on very wide windows (>= 1280px). */
.sm-layout {
    --sm-pad: 16px;
    flex: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "gallery"
        "summary"
        "sale"
        "content";
    align-items: start;
    padding-bottom: calc(var(--spacing-unit) * 4 + env(safe-area-inset-bottom, 0px));
}

.sm-gallery { grid-area: gallery; min-width: 0; }
.sm-summary { grid-area: summary; min-width: 0; }
.sm-side    { grid-area: sale; min-width: 0; }
.sm-sale    { min-width: 0; }
.sm-content { grid-area: content; min-width: 0; }

.sm-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: clamp(200px, 38vh, 520px);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--color-surface);
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

.sm-photo-empty {
    cursor: default;
}

.sm-photo:focus-visible,
.sm-thumb:focus-visible,
.sm-lightbox button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.sm-photo-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sm-thumbs {
    display: flex;
    gap: var(--spacing-unit);
    padding: calc(var(--spacing-unit) * 1.5) var(--sm-pad);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.sm-thumbs[hidden] { display: none; }

.sm-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-surface);
    overflow: hidden;
    cursor: pointer;
    opacity: 0.75;
    -webkit-tap-highlight-color: transparent;
}

.sm-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sm-thumb.is-active {
    border-color: var(--color-primary);
    opacity: 1;
}

[data-theme="dark"] .sm-thumb.is-active {
    border-color: var(--color-accent);
}

.sm-summary {
    padding: calc(var(--spacing-unit) * 2) var(--sm-pad) var(--spacing-unit);
}

.sm-summary h2 {
    font-size: 22px;
    line-height: 1.25;
    margin: 0 0 var(--spacing-unit);
    overflow-wrap: anywhere;
}

.sm-byline {
    font-size: 15px;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.sm-k {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    margin-right: 4px;
}

.sm-summary .value-range {
    font-size: 1.25rem;
    font-weight: 700;
    margin: var(--spacing-unit) 0 0;
    color: var(--color-primary);
}

[data-theme="dark"] .sm-summary .value-range {
    color: var(--color-accent);
}

.sm-summary .value-range .sm-k {
    color: inherit;
    font-size: 14px;
    font-weight: 600;
}

.sm-section-title {
    margin: 0 0 var(--spacing-unit);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.sm-sale {
    padding: calc(var(--spacing-unit) * 2) var(--sm-pad);
    margin-top: var(--spacing-unit);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.sm-facts,
.sm-data-list {
    margin: 0;
    padding: 0;
}

.sm-fact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-unit);
    padding: 6px 0;
    min-height: 36px;
}

.sm-fact dt {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.sm-fact dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

/* The summary right above already shows the range on one-column layouts. */
.sm-fact-range { display: none; }

.sm-empty {
    color: var(--color-text-secondary);
    font-weight: 400;
}

.sm-sale .result-status {
    text-align: right;
    padding: 0;
    margin: 0;
    font-size: 14px;
}

.sm-sale .result-status span {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 700;
    border: 1px solid transparent;
}

.sm-sale .status-pending { background: #FFF3CD; color: #5C4400; border-color: #F0DC9A; }
.sm-sale .status-sold    { background: #E3F2E5; color: #11461B; border-color: #B9DEBF; }
.sm-sale .status-unsold  { background: #EEF0EE; color: #4A4F4B; border-color: #D9DEDB; }

[data-theme="dark"] .sm-sale .status-pending { background: rgba(255, 193, 7, 0.16); color: #FFD65A; border-color: rgba(255, 193, 7, 0.4); }
[data-theme="dark"] .sm-sale .status-sold    { background: #1D3A22; color: #8FE39B; border-color: #2E5B36; }
[data-theme="dark"] .sm-sale .status-unsold  { background: #222724; color: #B8BEB9; border-color: #2B312C; }

.sm-sale .amount-input {
    margin: var(--spacing-unit) 0 calc(var(--spacing-unit) * 2);
}

.sm-sale .amount-input label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
}

.sm-content {
    padding: 0 var(--sm-pad);
}

.sm-section {
    padding: calc(var(--spacing-unit) * 2) 0;
    border-bottom: 1px solid var(--color-border);
}

.sm-section:last-child {
    border-bottom: 0;
}

.sm-text {
    margin: 0;
    line-height: 1.5;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.sm-feature-list {
    margin: 0;
    padding-left: 22px;
    line-height: 1.5;
}

.sm-feature-list li {
    margin: 2px 0;
    overflow-wrap: anywhere;
}

.sm-row {
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: var(--spacing-unit);
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 15px;
}

.sm-row:last-child {
    border-bottom: 0;
}

.sm-row dt {
    color: var(--color-text-secondary);
}

.sm-row dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 360px) {
    .sm-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }
}

/* Two columns: landscape >= 1024px (iPad landscape, laptops) or any window >= 1280px wide.
   Phones (incl. landscape, < 1024px) and iPad portrait (< 1024px or portrait) stay one column. */
@media (min-width: 1024px) and (orientation: landscape), (min-width: 1280px) {
    .sm-layout {
        --sm-pad: 0px;
        grid-template-columns: minmax(0, 6fr) minmax(0, 4fr);
        grid-template-areas:
            "gallery sale"
            "summary sale"
            "content sale";
        column-gap: calc(var(--spacing-unit) * 4);
        padding: calc(var(--spacing-unit) * 2) 72px calc(var(--spacing-unit) * 4);
    }

    .sm-photo {
        height: clamp(240px, 52vh, 560px);
        border-radius: var(--border-radius);
    }

    .sm-thumbs {
        padding-left: 0;
        padding-right: 0;
    }

    .sm-side {
        position: sticky;
        top: calc(var(--spacing-unit) * 2);
        align-self: start;
        /* if the right column is ever taller than the screen, it scrolls itself instead of being cut off */
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
    }

    .sm-sale {
        margin-top: 0;
        padding: calc(var(--spacing-unit) * 2.5);
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius);
    }

    .sm-fact-range { display: flex; }
}

/* Wider than a phone: keep content clear of the side navigation arrows. */
@media (min-width: 768px) and (max-width: 1023.98px), (min-width: 768px) and (orientation: portrait) and (max-width: 1279.98px) {
    .sm-layout {
        --sm-pad: 0px;
        padding-left: 72px;
        padding-right: 72px;
    }

    .sm-photo {
        border-radius: var(--border-radius);
    }
}

/* Coming Up Next: passive glance at the following lot (never clickable) */
.coming-up-next {
    padding: calc(var(--spacing-unit) * 1.5) var(--sm-pad) calc(var(--spacing-unit) * 2);
    border-bottom: 1px solid var(--color-border);
    cursor: default;
}

.coming-up-next .sm-section-title {
    margin-bottom: var(--spacing-unit);
}

.cun-row {
    display: flex;
    align-items: flex-start;
    gap: calc(var(--spacing-unit) * 1.5);
}

.cun-thumb {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: var(--border-radius);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    overflow: hidden;
    text-align: center;
}

.cun-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cun-thumb .no-image {
    font-size: 12px;
    line-height: 1.2;
    padding: 0 4px;
}

.cun-body {
    flex: 1 1 auto;
    min-width: 0;
}

.cun-lot {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}

.cun-title {
    margin: 2px 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.cun-desc {
    margin: 0 0 4px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--color-text-secondary);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.cun-est {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary);
}

[data-theme="dark"] .cun-est {
    color: var(--color-accent);
}

@media (min-width: 768px) {
    .cun-thumb {
        width: 88px;
        height: 88px;
    }
}

@media (min-width: 1024px) and (orientation: landscape), (min-width: 1280px) {
    .coming-up-next {
        margin-top: calc(var(--spacing-unit) * 2);
        padding: calc(var(--spacing-unit) * 2);
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius);
    }
}

/* Coming Up Next: visual polish. A soft green wash + a dark green pill so the live-selling
   assist reads apart from the product content, while staying quieter than the Sale panel. */
.coming-up-next {
    background: #EAF4EC;
    border-top: 1px solid #BFDCC5;
    border-bottom-color: #BFDCC5;
}

@media (min-width: 1024px) and (orientation: landscape), (min-width: 1280px) {
    .coming-up-next {
        border: 1px solid #BFDCC5;
    }
}

.coming-up-next .sm-section-title {
    display: inline-block;
    margin: 0 0 var(--spacing-unit);
    padding: 3px 10px;
    border-radius: 999px;
    background: #11461B;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.coming-up-next .cun-thumb {
    background: #FFFFFF;
    border-color: #BFDCC5;
}

[data-theme="dark"] .coming-up-next {
    background: #142A19;
    border-top-color: #2E5B36;
    border-bottom-color: #2E5B36;
}

@media (min-width: 1024px) and (orientation: landscape), (min-width: 1280px) {
    [data-theme="dark"] .coming-up-next {
        border-color: #2E5B36;
    }
}

[data-theme="dark"] .coming-up-next .sm-section-title {
    background: #1F6B2A;
    color: #FFFFFF;
    box-shadow: 0 0 0 1px #3E7A48;
}

[data-theme="dark"] .coming-up-next .cun-thumb {
    background: var(--color-surface);
    border-color: #2E5B36;
}

.sm-lightbox {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
}

.sm-lightbox[hidden] { display: none; }

.sm-lb-img {
    max-width: calc(100% - 16px);
    max-height: calc(100% - 96px);
    object-fit: contain;
}

.sm-lightbox button {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

.sm-lightbox button[hidden] { display: none; }

.sm-lb-close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
}

.sm-lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.sm-lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

.sm-lb-count {
    position: absolute;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    text-align: center;
    color: #ffffff;
    font-weight: 600;
}

.sm-lb-count[hidden] { display: none; }

.status-sold {
    color: var(--color-success);
}

.status-unsold {
    color: var(--color-text-secondary);
}

.status-pending {
    color: var(--color-warning);
}

.amount-input {
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.result-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.btn-sold {
    background: var(--color-success);
    color: white;
    font-weight: 700;
    font-size: 18px;
    padding: calc(var(--spacing-unit) * 2);
}

.btn-unsold {
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border);
    font-weight: 700;
    font-size: 18px;
    padding: calc(var(--spacing-unit) * 2);
}

.nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 32px;
    cursor: pointer;
    z-index: 100;
}

.nav-left {
    left: calc(var(--spacing-unit) * 2);
}

.nav-right {
    right: calc(var(--spacing-unit) * 2);
}

/* ---- Show Mode Items drawer (navigation only) ------------------------------------ */
.btn-items {
    flex: 0 0 auto;
    min-height: 44px;
    margin: 0 calc(var(--spacing-unit) * 1.5);
    padding: 0 calc(var(--spacing-unit) * 2.5);
    border: 0;
    border-radius: var(--border-radius);
    background: var(--color-primary);
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn-items:hover,
.btn-items:active {
    background: var(--color-primary-dark);
}

.btn-items:focus-visible,
.sm-drawer-close:focus-visible,
.sm-drawer-clear:focus-visible,
.sm-drawer-row:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: -3px;
}

.sm-drawer {
    position: absolute;
    inset: 0;
    z-index: 300;
    display: flex;
    justify-content: flex-end;
}

.sm-drawer[hidden] { display: none; }

.sm-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    touch-action: none;
}

.sm-drawer-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    touch-action: pan-y;
    animation: sm-drawer-in 0.18s ease-out;
}

.sm-drawer-panel:focus { outline: none; }

@keyframes sm-drawer-in {
    from { transform: translateX(32px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.sm-drawer-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 4px 16px;
}

.sm-drawer-head h2 {
    font-size: 20px;
    margin: 0;
}

.sm-drawer-close {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--color-secondary-btn);
    color: var(--color-text);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.sm-drawer-searchbar {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 4px 16px 4px;
}

.sm-drawer-search {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    font-size: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-bg);
    color: var(--color-text);
}

.sm-drawer-search:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-accent);
}

.sm-drawer-clear {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-secondary-btn);
    color: var(--color-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.sm-drawer-clear[hidden] { display: none; }

.sm-drawer-count {
    flex: 0 0 auto;
    padding: 4px 16px 6px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.sm-drawer-saving {
    flex: 0 0 auto;
    margin: 0 16px 6px;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    background: #FFF3CD;
    color: #5C4400;
    font-size: 14px;
    font-weight: 600;
}

.sm-drawer-saving[hidden] { display: none; }

[data-theme="dark"] .sm-drawer-saving { background: rgba(255, 193, 7, 0.16); color: #FFD65A; }

.sm-drawer-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    border-top: 1px solid var(--color-border);
}

.sm-drawer-list[hidden] { display: none; }

.sm-drawer-list li {
    border-bottom: 1px solid var(--color-border);
}

.sm-drawer-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 8px 16px;
    border: 0;
    border-left: 4px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.sm-drawer-row:hover { background: var(--color-bg); }

.sm-drawer-row.is-active {
    border-left-color: var(--color-accent);
    background: var(--skor-mint-tint);
    color: #0B0B0B;
}

[data-theme="dark"] .sm-drawer-row.is-active { background: #1D3A22; color: #F7F8F4; }

.sm-drawer-row[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

.sm-drawer-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
}

.sm-drawer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sm-drawer-thumb-empty {
    font-size: 9px;
    line-height: 1.1;
    text-align: center;
    color: var(--color-text-secondary);
}

.sm-drawer-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.sm-drawer-lot {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-secondary);
}

.sm-drawer-row.is-active .sm-drawer-lot,
.sm-drawer-row.is-active .sm-drawer-sub { color: inherit; }

.sm-drawer-title {
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

.sm-drawer-sub {
    font-size: 12px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sm-drawer-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.sm-drawer-now {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-primary-dark);
}

.sm-drawer-now[hidden] { display: none; }

[data-theme="dark"] .sm-drawer-now { color: var(--color-accent); }

.sm-drawer-status {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.sm-drawer-status.is-upcoming { background: #FFF3CD; color: #5C4400; border-color: #F0DC9A; }
.sm-drawer-status.is-sold { background: #E3F2E5; color: #11461B; border-color: #B9DEBF; }
.sm-drawer-status.is-unsold { background: #EEF0EE; color: #4A4F4B; border-color: #D9DEDB; }

[data-theme="dark"] .sm-drawer-status.is-upcoming { background: rgba(255, 193, 7, 0.16); color: #FFD65A; border-color: rgba(255, 193, 7, 0.4); }
[data-theme="dark"] .sm-drawer-status.is-sold { background: #1D3A22; color: #8FE39B; border-color: #2E5B36; }
[data-theme="dark"] .sm-drawer-status.is-unsold { background: #222724; color: #B8BEB9; border-color: #2B312C; }

.sm-drawer-empty {
    flex: 1 1 auto;
    padding: 32px 16px;
    text-align: center;
    color: var(--color-text-secondary);
}

.sm-drawer-empty[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
    .sm-drawer-panel { animation: none; }
}

.save-status {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
}

.save-status.saving .saving {
    display: inline;
    color: var(--color-text-secondary);
}

.save-status.saved .saved {
    display: inline;
    color: var(--color-success);
}

.save-status.error .error {
    display: inline;
    color: var(--color-error);
}

.save-status span {
    display: none;
}

/* ============================================================================
   Bottom Sheet (Filters, etc.)
   ============================================================================ */
.bottom-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: none;
    align-items: flex-end;
}

.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) * 2);
    border-bottom: 1px solid var(--color-border);
}

.bottom-sheet-content {
    background: var(--color-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    max-height: 80vh;
    overflow-y: auto;
    padding: calc(var(--spacing-unit) * 2);
    width: 100%;
}

.btn-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
}

/* Filters sheet: one opaque panel holding the header and the controls.
   Scoped to --filters so any other bottom sheet keeps the rules above. */
.bottom-sheet--filters {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 100%;
    padding-top: env(safe-area-inset-top);
    box-sizing: border-box;
}

@supports (height: 100dvh) {
    .bottom-sheet--filters {
        height: 100dvh;
    }
}

.bottom-sheet--filters[hidden] {
    display: none;
}

.bottom-sheet--filters .bottom-sheet-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    max-height: 100%;
    box-sizing: border-box;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-sheet--filters .bottom-sheet-header {
    flex: 0 0 auto;
    background: transparent;
    color: var(--color-text);
}

.bottom-sheet--filters .bottom-sheet-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--color-text);
}

.bottom-sheet--filters .btn-close {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    color: var(--color-text);
}

.bottom-sheet--filters .btn-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--border-radius);
}

.bottom-sheet--filters .bottom-sheet-content {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: transparent;
    border-radius: 0;
}

/* ============================================================================
   Alerts & Toasts
   ============================================================================ */
.alert {
    padding: calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.alert-error {
    background: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
}

.alert-warning {
    background: #FFF3CD;
    color: #856404;
    border: 1px solid #FFEAA7;
}

.alert-info {
    background: #D1ECF1;
    color: #0C5460;
    border: 1px solid #BEE5EB;
}

/* Toast surface: a paired background and foreground per theme, so the text stays
   readable in both. Variants only add an accent edge. */
:root {
    --toast-bg: #1E1F21;
    --toast-fg: #F7F8F4;
    --toast-border: #4A4F4B;
}

[data-theme="dark"] {
    --toast-bg: #262C28;
    --toast-fg: #F7F8F4;
    --toast-border: #55605A;
}

.toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: calc(var(--spacing-unit) * 2);
    background: var(--toast-bg);
    color: var(--toast-fg);
    border: 1px solid var(--toast-border);
    border-left-width: 4px;
    border-radius: var(--border-radius);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s;
    width: max-content;
    max-width: min(90vw, 420px);
    box-sizing: border-box;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

.toast-info {
    border-left-color: var(--color-accent);
}

.toast-success {
    border-left-color: var(--color-success);
}

.toast-warning {
    border-left-color: var(--color-warning);
}

.toast-error {
    border-left-color: var(--color-error);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================================
   Login Page
   ============================================================================ */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-surface);
    position: relative;
}

.login-theme-switcher {
    position: absolute;
    top: calc(var(--spacing-unit) * 2);
    right: calc(var(--spacing-unit) * 2);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: calc(var(--spacing-unit) * 2);
}

.login-card {
    background: var(--color-bg);
    padding: calc(var(--spacing-unit) * 4);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.logo {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.logo img {
    max-width: 224px;
    width: 100%;
    height: auto;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

/* Tagline: outside and directly below the card, the same width as the card (both fill .login-container), one line */
.login-tagline {
    margin: 28px 0 0;
    text-align: center;
    white-space: nowrap;
    font-size: clamp(24px, 6.4vw, 32px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--color-text);
}

.logo h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: calc(var(--spacing-unit) / 2);
}

/* ============================================================================
   Empty States
   ============================================================================ */
.empty-state {
    text-align: center;
    padding: calc(var(--spacing-unit) * 6) calc(var(--spacing-unit) * 2);
    color: var(--color-text-secondary);
}

.empty-state p {
    margin-bottom: calc(var(--spacing-unit) * 2);
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (min-width: 768px) {
    .product-feed,
    .shows-list,
    .sell-queue {
        max-width: 800px;
        margin: 0 auto;
    }
}

/* ============================================================================
   Product Selector Modals
   ============================================================================ */
.product-selector-modal,
.inventory-selector-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.product-selector-modal.show,
.inventory-selector-modal.show {
    display: flex;
}

.product-selector-modal .modal-content,
.inventory-selector-modal .modal-content {
    background: var(--color-bg);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    flex-direction: column;
    margin-bottom: calc(60px + env(safe-area-inset-bottom)); /* Above bottom nav */
}

.product-selector-modal .modal-header,
.inventory-selector-modal .modal-header {
    padding: calc(var(--spacing-unit) * 2);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.product-selector-modal .modal-header h2,
.inventory-selector-modal .modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.product-selector-modal .modal-body,
.inventory-selector-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(var(--spacing-unit) * 2);
}

.product-selector-modal .modal-footer,
.inventory-selector-modal .modal-footer {
    padding: calc(var(--spacing-unit) * 2);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: calc(var(--spacing-unit) * 2);
    justify-content: flex-end;
    flex-shrink: 0;
    background: var(--color-bg);
}

.product-selector-list,
.selector-item {
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.selector-item {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
    padding: calc(var(--spacing-unit) * 2);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-surface);
}

.selector-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-width: 24px;
    cursor: pointer;
}

.selector-item label {
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) / 2);
}

.selector-item label strong {
    font-weight: 600;
    color: var(--color-text);
}

.selector-item .value {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-left: calc(var(--spacing-unit));
}

.product-selector-modal .selector-item input[type="checkbox"],
.inventory-selector-modal .selector-item input[type="checkbox"] {
    flex-shrink: 0;
}

.product-selector-modal .selector-item label,
.inventory-selector-modal .selector-item label {
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1.5);
}

/* Square thumbnail (same /image/ source as Inventory); never distorts the picture */
.product-selector-modal .selector-thumb,
.inventory-selector-modal .selector-thumb {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    box-sizing: border-box;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-selector-modal .selector-thumb img,
.inventory-selector-modal .selector-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-selector-modal .selector-thumb .selector-thumb-empty,
.inventory-selector-modal .selector-thumb .selector-thumb-empty {
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
}

.product-selector-modal .selector-details,
.inventory-selector-modal .selector-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) / 2);
}

.product-selector-modal .selector-title,
.inventory-selector-modal .selector-title {
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.product-selector-modal .selector-item .value,
.inventory-selector-modal .selector-item .value {
    margin-left: 0;
}

@media (min-width: 768px) {
    .product-selector-modal .modal-content,
    .inventory-selector-modal .modal-content {
        max-height: 70vh;
        border-radius: var(--border-radius);
        margin-bottom: 0;
    }
}

/* Research Details Disclosure */
.research-details-toggle {
    padding: 12px;
    background-color: var(--bg-secondary);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    width: 100%;
    border: none;
    text-align: left;
    color: var(--text-primary);
    font-size: 1rem;
}

.research-details-toggle:hover {
    background-color: var(--bg-primary);
}

.research-details-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Image Lightbox Viewer */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.image-lightbox-img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    user-select: none;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .image-lightbox {
        transition: none;
    }
    .image-lightbox-img {
        transition: none;
    }
}

.image-lightbox-close {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 32px;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-lightbox-close:hover,
.image-lightbox-close:focus {
    background: rgba(255, 255, 255, 0.2);
    outline: none;
}

.image-lightbox-counter {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10001;
    pointer-events: none;
}

.image-lightbox-prev,
.image-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 32px;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-lightbox-prev {
    left: max(16px, env(safe-area-inset-left));
}

.image-lightbox-next {
    right: max(16px, env(safe-area-inset-right));
}

.image-lightbox-prev:hover,
.image-lightbox-prev:focus,
.image-lightbox-next:hover,
.image-lightbox-next:focus {
    background: rgba(255, 255, 255, 0.2);
    outline: none;
}

/* Compact Source Links */
.source-link {
    color: var(--link-color);
    text-decoration: none;
}

.source-link:hover {
    text-decoration: underline;
}

.source-toggle-btn {
    background: none;
    border: none;
    color: var(--link-color);
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 4px;
}

.source-toggle-btn:hover {
    text-decoration: underline;
}

.source-toggle-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Image Error State */
.image-lightbox-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

.image-lightbox-error-message {
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
}

.image-lightbox-retry {
    padding: 10px 24px;
    background: var(--primary-color, #007bff);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    transition: background 0.2s;
}

.image-lightbox-retry:hover,
.image-lightbox-retry:focus {
    background: var(--primary-color-dark, #0056b3);
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Product Info Form Typography */
#product-edit-form input[type="text"],
#product-edit-form input[type="number"],
#product-edit-form select,
#product-edit-form textarea {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

/* Product Photo Upload Section */
.product-photo-section {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.photo-section-header {
    margin-bottom: 12px;
}

.photo-counter {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
}

.photo-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.photo-action-btn {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.photo-action-btn svg {
    flex-shrink: 0;
}

.pending-photos-area {
    margin-bottom: 12px;
}

.pending-photos-label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.pending-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.pending-photo-preview {
    position: relative;
    padding-top: 100%;
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--bg-tertiary, #f5f5f5);
    border: 2px solid var(--border-color);
}

.pending-photo-preview img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pending-photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s;
}

.pending-photo-remove:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.pending-photo-remove:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pending-photo-failed {
    border-color: var(--error-color, #c00);
    opacity: 0.7;
}

.pending-photo-uncertain {
    border-color: var(--warning-color, #f90);
    border-style: dashed;
}

.upload-photos-btn {
    width: 100%;
}

.photo-status-area {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
    animation: fadeIn 0.3s;
}

.photo-status-info {
    background-color: var(--info-bg, #e3f2fd);
    color: var(--info-color, #0277bd);
}

.photo-status-success {
    background-color: var(--success-bg, #e8f5e9);
    color: var(--success-color, #2e7d32);
}

.photo-status-error {
    background-color: var(--error-bg, #ffebee);
    color: var(--error-color, #c62828);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================================================
   Recognition matches (scan page, scan-recognition.js)
   ============================================================================ */
.recognition [hidden],
.recognition[hidden] {
    display: none !important;
}

.recognition {
    margin-top: calc(var(--spacing-unit) * 1);
    min-width: 0;
}

.recognition-heading {
    font-size: 20px;
    margin: 0 0 calc(var(--spacing-unit) * 1);
    color: var(--color-text);
}

.recognition-heading:focus {
    outline: none;
}

.recognition-subheading {
    font-size: 16px;
    margin: calc(var(--spacing-unit) * 3) 0 calc(var(--spacing-unit) * 1);
    color: var(--color-text-secondary);
}

.recognition-status {
    margin: 0 0 calc(var(--spacing-unit) * 1);
    color: var(--color-text-secondary);
    font-size: 15px;
}

.recognition-status:empty {
    display: none;
}

.recognition--notice .recognition-status {
    padding: calc(var(--spacing-unit) * 2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text);
}

.recognition-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    min-width: 0;
    overflow-wrap: anywhere;
}

.recognition-card--best {
    display: flex;
    flex-direction: column;
    border: 2px solid var(--color-primary);
}

.recognition-media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.recognition-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.recognition-media-fallback {
    color: var(--color-text-secondary);
    font-size: 14px;
}

.recognition-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
    padding: calc(var(--spacing-unit) * 2);
    min-width: 0;
}

.recognition-identity {
    min-width: 0;
}

.recognition-brand {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.recognition-model {
    margin: 2px 0 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.recognition-card--best .recognition-model {
    font-size: 22px;
}

.recognition-variant {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.recognition-score {
    align-self: flex-start;
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--border-radius);
    background: var(--skor-mint-tint);
    color: var(--skor-forest-green);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.03em;
    white-space: normal;
}

.recognition-card--best .recognition-score {
    font-size: 20px;
    padding: 6px 14px;
}

.recognition-score-note {
    margin: 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.recognition-score--none {
    background: var(--color-secondary-btn);
    color: var(--color-text-secondary);
}

.recognition-features {
    margin: 0;
    padding-left: 18px;
    font-size: 14px;
    color: var(--color-text);
}

.recognition-features li {
    margin-bottom: 2px;
}

.recognition-why-not {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.recognition-why-not summary {
    cursor: pointer;
    padding: 6px 0;
    min-height: 32px;
}

.recognition-why-not-list {
    margin: 4px 0 0;
    padding-left: 18px;
}

.recognition-use-btn {
    width: 100%;
    margin-top: auto;
}

.recognition-alternatives {
    display: flex;
    gap: calc(var(--spacing-unit) * 1.5);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--spacing-unit);
    max-width: 100%;
}

.recognition-card--alt {
    flex: 0 0 72%;
    max-width: 260px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
    padding-bottom: calc(var(--spacing-unit) * 1.5);
}

.recognition-card--alt > :not(.recognition-media) {
    margin-left: calc(var(--spacing-unit) * 1.5);
    margin-right: calc(var(--spacing-unit) * 1.5);
}

.recognition-card--alt .recognition-use-btn {
    width: auto;
}

.recognition-actions {
    display: grid;
    gap: var(--spacing-unit);
    margin-top: calc(var(--spacing-unit) * 3);
}

.recognition .btn:focus-visible,
.recognition-why-not summary:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

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

.recognition--deciding .recognition-card {
    opacity: 0.8;
}

@media (min-width: 700px) {
    .recognition-card--best {
        flex-direction: row;
    }

    .recognition-card--best .recognition-media {
        flex: 0 0 44%;
        aspect-ratio: auto;
        min-height: 280px;
    }

    .recognition-alternatives {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow-x: visible;
    }

    .recognition-card--alt {
        max-width: none;
    }

    .recognition-actions {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 699px) {
    .recognition-card--best .recognition-score {
        order: -1;
    }
}

@media (min-width: 900px) {
    .scan-container:has(> .recognition:not([hidden])) {
        max-width: 960px;
    }
}

/* ============================================================================
   Research modes: chosen-match summary, research chooser, Find Matches Again
   ============================================================================ */
.recognition-selected[hidden],
.research-match-overlay[hidden],
.research-match-progress[hidden] {
    display: none !important;
}

.recognition-selected {
    margin-bottom: calc(var(--spacing-unit) * 2);
    text-align: left;
}

.recognition-selected-card {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1.5);
    padding: var(--spacing-unit);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    min-width: 0;
    overflow-wrap: anywhere;
}

.recognition-selected-card .recognition-media {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    aspect-ratio: auto;
    border-radius: calc(var(--border-radius) / 2);
    overflow: hidden;
}

.recognition-selected-body {
    min-width: 0;
}

.recognition-selected-label {
    margin: 0 0 2px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.recognition-selected-body .recognition-brand,
.recognition-selected-body .recognition-model {
    margin: 0;
    font-size: 15px;
}

/* Research continues from the chosen match: hide scan-phase details */
.scan-loading--continuing .loading-thumbnail,
.scan-loading--continuing .loading-detail,
.scan-loading--continuing .draft-saved {
    display: none !important;
}

.research-mode-overlay,
.research-match-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.research-mode-dialog,
.research-match-panel {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.research-mode-dialog {
    max-width: 440px;
    padding: 24px;
    display: grid;
    gap: 12px;
}

.research-mode-title {
    margin: 0 0 4px;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.research-mode-choice {
    display: grid;
    gap: 4px;
    width: 100%;
    min-height: 44px;
    padding: 14px 16px;
    text-align: left;
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
}

.research-mode-choice:hover {
    border-color: var(--primary-color);
}

.research-mode-choice:focus-visible,
.research-mode-actions .btn:focus-visible,
.research-match-panel .btn:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.research-mode-choice-label {
    font-weight: 600;
    font-size: 1rem;
}

.research-mode-choice-text {
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.research-mode-note {
    margin: 0;
    padding: 10px 12px;
    font-size: 0.875rem;
    background: var(--warning-bg);
    border-left: 4px solid var(--warning-color);
    border-radius: 4px;
}

.research-mode-actions {
    display: flex;
    justify-content: flex-end;
}

.research-ready-text {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.research-ready-actions {
    flex-wrap: wrap;
    gap: 8px;
}

.research-mode-actions .btn {
    min-width: 96px;
    min-height: 44px;
}

.research-match-panel {
    max-width: 960px;
    padding: 20px;
}

.research-match-title {
    margin: 0 0 4px;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.research-match-title:focus {
    outline: none;
}

.research-match-intro {
    margin: 0 0 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.research-match-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
}

.research-match-progress .spinner {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin: 0;
}

.research-match-progress-text {
    margin: 0;
    color: var(--text-primary);
}

.research-match-footer {
    margin-top: var(--spacing-unit);
}

.research-match-footer .btn,
.research-match-panel .recognition-actions .btn {
    min-height: 44px;
}

.research-match-overlay--researching .research-match-footer {
    display: none;
}

body.research-match-open {
    overflow: hidden;
}

/* CURRENT SAVED ITEM vs NEW RESEARCH PROPOSAL */
.research-identity {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.research-identity--different {
    border-left: 4px solid var(--warning-color);
}

.research-identity-verdict {
    margin: 0 0 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.research-identity-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.research-identity-col {
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    min-width: 0;
}

.research-identity-col--proposed {
    border-color: var(--primary-color);
}

.research-identity-heading {
    margin: 0 0 6px;
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.research-identity-title {
    margin: 0 0 2px;
    font-weight: 600;
    color: var(--text-primary);
}

.research-identity-brand {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.research-identity-origin,
.research-identity-note {
    margin: 10px 0 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.research-identity-note {
    font-style: italic;
}

@media (max-width: 480px) {
    .research-identity-grid {
        grid-template-columns: 1fr;
    }

    .research-match-panel,
    .research-mode-dialog {
        padding: 16px;
    }

    .research-ready-actions .btn {
        flex: 1 1 100%;
    }
}

/* ---------------------------------------------------------------------------
   Research evidence (Pass 2): field evidence, identification strength, source roles.
   Theme variables only, so light and dark both follow the theme.
   --------------------------------------------------------------------------- */
.research-identity-withheld {
    margin: 10px 0 0;
    font-size: 0.8125rem;
    color: var(--text-primary);
    font-weight: 600;
}

.research-change-row {
    margin-bottom: 6px;
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}

.research-change-current {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.research-change-proposed {
    color: var(--primary-color);
    font-weight: bold;
}

.research-change-row--kept .research-change-proposed,
.research-change-row--info .research-change-proposed {
    color: var(--text-primary);
    font-weight: 600;
}

.research-change-note {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.research-evidence {
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.research-evidence-heading {
    font-weight: bold;
    margin-bottom: 6px;
}

.research-evidence-subheading {
    margin: 10px 0 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

.research-evidence-warning,
.research-evidence-conflict {
    margin: 0 0 8px;
    padding: 8px 10px;
    font-size: 0.8125rem;
    background: var(--warning-bg);
    border-left: 4px solid var(--warning-color);
    border-radius: 4px;
    color: var(--text-primary);
}

.research-evidence-price {
    margin: 0;
    font-size: 0.875rem;
}

.research-evidence-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.research-evidence-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    min-width: 0;
}

.research-evidence-item:last-child {
    border-bottom: 0;
}

.research-evidence-field {
    font-weight: 600;
    margin-right: 8px;
}

.research-evidence-status,
.research-evidence-basis,
.research-comp-role {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 8px;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.research-evidence-item--supported .research-evidence-status {
    border-color: var(--success-color);
    color: var(--success-color);
}

.research-evidence-item--conflicting .research-evidence-status {
    border-color: var(--warning-color);
    color: var(--text-primary);
    background: var(--warning-bg);
    font-weight: 600;
}

.research-evidence-item--unknown .research-evidence-field {
    color: var(--text-secondary);
    font-weight: 500;
}

.research-evidence-value {
    margin-top: 2px;
    color: var(--text-primary);
}

.research-evidence-note {
    margin-top: 2px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.research-source-title {
    font-size: 0.8125rem;
}

.research-comp-evidence {
    margin-top: 2px;
    font-size: 0.8125rem;
}

.research-comp-title {
    color: var(--text-secondary);
}

/* ---------------------------------------------------------------------------
   Product Info form: grouped sections (Product Field Alignment V1)
   Uses the existing theme variables, so light and dark both follow the theme.
   --------------------------------------------------------------------------- */
.product-form-section {
    margin: 0 0 8px 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.product-form-section-title {
    margin: 22px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.product-form-section:first-of-type .product-form-section-title {
    margin-top: 4px;
}

.product-range-group {
    margin: 0 0 15px 0;
}

.product-range-title {
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.product-range-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.product-field-help {
    margin-top: 4px;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.product-field-quiet {
    margin-top: 4px;
    font-size: 0.75rem;
    font-style: italic;
    color: var(--text-secondary);
}

/* OP01-R1: saved original price (amount/range + basis) as the main value of the Estimated Original Price / MSRP group */
.original-price-display {
    margin: 0 0 12px 0;
    padding: 10px 12px;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
}

.original-price-main {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.original-price-main-empty {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.original-price-basis {
    margin-top: 4px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.form-readonly-value {
    padding: 10px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.form-readonly-value.is-multiline {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Show Mode: saved Markings keep their line breaks */
.sm-multiline {
    white-space: pre-line;
}
