/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #1a1a1a; background: #f5f5f5; line-height: 1.5; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar { display: flex; align-items: center; gap: 1rem; padding: 0.5rem 1rem; background: #1e293b; color: #fff; height: 52px; }
.nav-brand { display: flex; align-items: center; color: #fff; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.nav-brand img { display: block; height: 28px; width: auto; }
.nav-brand:hover { text-decoration: none; color: #93c5fd; }
.nav-logout { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-shrink: 0; }
.nav-user { font-size: 0.8rem; color: #94a3b8; }
.nav-logout button { padding: 0.3rem 0.75rem; background: #475569; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 0.8rem; transition: background 0.15s ease; }
.nav-logout button:hover { background: #64748b; }

/* === Breadcrumbs === */
.breadcrumbs { padding: 0.5rem 1.5rem; background: #fff; border-bottom: 1px solid #e2e8f0; font-size: 0.85rem; color: #64748b; }
.breadcrumbs a { color: #2563eb; }

/* === Content === */
.content { max-width: 1200px; margin: 1.5rem auto; padding: 0 1.5rem; }
h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }

/* === Tables === */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
thead { background: #f8fafc; }
th { text-align: left; padding: 0.75rem 1rem; font-weight: 600; font-size: 0.85rem; color: #475569; border-bottom: 2px solid #e2e8f0; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; }
tbody tr:hover { background: #f8fafc; }

/* === Badges === */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #e0e7ff; color: #3730a3; }
.badge-flag { background: #fef3c7; color: #92400e; }

/* === Pagination === */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1rem 0; }
.page-link { padding: 0.4rem 1rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 0.85rem; }
.page-link:hover { background: #f1f5f9; text-decoration: none; }
.page-info { font-size: 0.85rem; color: #64748b; }

/* === Filters === */
.filters { display: flex; align-items: end; gap: 0.75rem; padding: 1rem; background: #fff; border-radius: 8px; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); flex-wrap: wrap; }
.filter-field { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-field label { font-size: 0.75rem; font-weight: 600; color: #475569; }
.filter-field input, .filter-field select { padding: 0.4rem 0.75rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.85rem; }

/* === Buttons === */
.btn { display: inline-block; padding: 0.5rem 1rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.85rem; text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; text-decoration: none; }

/* === Detail Header === */
.detail-header { background: #fff; padding: 1.25rem; border-radius: 8px; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.detail-header h1 { margin-bottom: 0.75rem; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; font-size: 0.9rem; }
.meta dt { font-weight: 600; color: #475569; }
.meta dd { color: #1a1a1a; }

/* === Empty State === */
.empty-state { padding: 2rem; text-align: center; color: #64748b; background: #fff; border-radius: 8px; font-size: 0.95rem; }

/* === Login === */
.login-container { max-width: 360px; margin: 4rem auto; padding: 2rem; background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.login-container h1 { text-align: center; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 600; font-size: 0.85rem; color: #475569; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.9rem; }
.login-container .btn { width: 100%; padding: 0.65rem; font-size: 1rem; }
.error { padding: 0.75rem; margin-bottom: 1rem; background: #fee2e2; color: #991b1b; border-radius: 4px; font-size: 0.85rem; }

/* === Lot Detail === */
.lot-data { background: #fff; border-radius: 8px; padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.lot-data table { box-shadow: none; }
.lot-data th { width: 180px; }
.changed { background: #fef3c7; }
.images { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.images img { max-width: 200px; max-height: 200px; border-radius: 4px; border: 1px solid #e2e8f0; object-fit: cover; }

/* === Override Form === */
.override-form { background: #fff; border-radius: 8px; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.override-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 0.75rem; }
.override-form .form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.override-form .checkbox-group { display: flex; align-items: center; gap: 0.5rem; }
.override-form .checkbox-group input { width: auto; }


/* === SPA Shell Layout === */
.shell { display: grid; grid-template-columns: 250px 300px 1fr; grid-template-rows: 1fr; height: calc(100vh - 52px); }
.panel { overflow-y: auto; min-height: 0; background: #fff; position: relative; }
.panel-left1 { border-right: 1px solid #e2e8f0; }
.panel-left2 { border-right: 1px solid #e2e8f0; }
.panel-main { background: #f8fafc; }

/* === Panel Components === */
.panel-header { padding: 0.625rem 1rem; border-bottom: 1px solid #e2e8f0; background: #f8fafc; position: sticky; top: 0; z-index: 2; }
.panel-header h3 { font-size: 0.8rem; font-weight: 600; color: #475569; margin: 0; text-transform: uppercase; letter-spacing: 0.03em; }
.panel-header .panel-count { font-size: 0.75rem; font-weight: 400; color: #94a3b8; margin-left: 0.35rem; text-transform: none; letter-spacing: 0; }

/* === Panel Filter === */
.panel-filter { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.panel-filter-input { flex: 1; padding: 0.3rem 0.5rem; border: 1px solid transparent; border-radius: 4px; font-size: 0.75rem; background: transparent; color: #1e293b; min-width: 0; }
.panel-filter-input:focus { outline: none; border-color: #2563eb; background: #fff; }
.panel-filter-input::placeholder { color: #94a3b8; font-style: italic; }
.panel-filter .panel-count { flex-shrink: 0; }

.panel-list { list-style: none; margin: 0; padding: 0; }
.panel-item { display: block; padding: 0.5rem 0.75rem 0.5rem 1rem; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; border-left: 3px solid transparent; }
.panel-item:hover { background: #f1f5f9; }
.panel-item.active { background: #eff6ff; border-left-color: #2563eb; }
.panel-item-title { display: block; font-size: 0.8125rem; font-weight: 500; color: #1e293b; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-item-meta { display: flex; align-items: center; gap: 0.375rem; font-size: 0.6875rem; color: #64748b; margin-top: 0.125rem; }
.panel-item-id { font-size: 0.6875rem; color: #94a3b8; }
.panel-item .badge { font-size: 0.625rem; padding: 0.1rem 0.375rem; }

.panel-table { width: 100%; border-collapse: collapse; background: #fff; }
.panel-table thead { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
.panel-table th { text-align: left; padding: 0.5rem 1rem; font-weight: 600; font-size: 0.75rem; color: #475569; border-bottom: 2px solid #e2e8f0; text-transform: uppercase; letter-spacing: 0.03em; }
.panel-table td { padding: 0.4375rem 1rem; border-bottom: 1px solid #f1f5f9; font-size: 0.8125rem; }
.panel-table tbody tr:hover { background: #f8fafc; }
.panel-table td a { color: #2563eb; }
.panel-table td a:hover { text-decoration: underline; }

.panel-pagination { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border-top: 1px solid #e2e8f0; background: #f8fafc; font-size: 0.75rem; position: sticky; bottom: 0; flex-wrap: wrap; }
.panel-pagination a { padding: 0.2rem 0.625rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 0.75rem; color: #2563eb; cursor: pointer; text-decoration: none; transition: background 0.15s ease; }
.panel-pagination a:hover { background: #f1f5f9; text-decoration: none; }
.panel-pagination .page-info { color: #64748b; }
.panel-pagination .page-range { color: #64748b; font-size: 0.6875rem; }
.panel-pagination .page-jump { cursor: pointer; }
.panel-pagination .page-display { color: #2563eb; border-bottom: 1px dashed #2563eb; }
.panel-pagination .page-display:hover { color: #1d4ed8; }
.panel-pagination .page-input { width: 3.5em; padding: 0.1rem 0.25rem; border: 1px solid #2563eb; border-radius: 3px; font-size: 0.75rem; text-align: center; color: #1e293b; }
.panel-pagination .page-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.panel-pagination .page-size-select { padding: 0.15rem 0.25rem; border: 1px solid #e2e8f0; border-radius: 3px; font-size: 0.6875rem; color: #64748b; background: #fff; cursor: pointer; }
.panel-pagination .page-size-select:focus { outline: none; border-color: #2563eb; }

/* === Lots Table (Main Panel) === */
.lots-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 0.8125rem; }
.lots-table thead { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
.lots-table th { text-align: left; padding: 0.4rem 0.5rem; font-weight: 600; font-size: 0.6875rem; color: #475569; border-bottom: 2px solid #e2e8f0; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.lots-table td { padding: 0.3rem 0.5rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.lots-table tbody tr:hover { background: #f8fafc; }
.lot-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 3px; display: block; }
.lot-thumb-placeholder { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; background: #f1f5f9; border-radius: 3px; }
.lot-thumb-placeholder svg { width: 28px; height: 28px; opacity: 0.25; }
.lot-thumb-cell { width: 68px; position: relative; }
.lot-thumb-preview { display: none; position: absolute; z-index: 100; left: 68px; top: 50%; transform: translateY(-50%); width: 300px; height: auto; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); pointer-events: none; object-fit: contain; background: #fff; }
.lot-thumb-btn:hover .lot-thumb-preview { display: block; }
.lot-desc-cell { display: flex; flex-direction: column; gap: 0.125rem; }
.lot-desc-text { all: unset; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; width: 100%; text-align: left; font-size: 0.8125rem; font-weight: 500; color: #1e293b; line-height: 1.3; border-radius: 3px; padding: 0.125rem 0.25rem; }
.lot-desc-text:hover { background: #f1f5f9; }
.lot-desc-text:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
.lot-desc-notes { font-size: 0.75rem; color: #64748b; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; padding: 0 0.25rem; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; background: none; border-radius: 4px; color: #64748b; cursor: pointer; transition: color 0.15s ease; }
.btn-icon:hover { color: #2563eb; text-decoration: none; }
.override-btn.save-clean:hover { color: #15803d; }
.lot-input-missing { background: #fef2f2 !important; }
.lot-dims { display: flex; align-items: flex-end; gap: 0.125rem; flex-wrap: nowrap; }
.lot-dims-field { display: flex; flex-direction: column; align-items: center; gap: 0; }
.lot-dims-label { font-size: 0.5625rem; font-weight: 400; color: #94a3b8; line-height: 1; user-select: none; }
.lot-dims-input { width: 4.5ch; text-align: right; }
.lot-dims-wgt { width: 5.5ch; text-align: right; }
/* Hide native number spinners */
.lot-dims-input::-webkit-inner-spin-button,
.lot-dims-input::-webkit-outer-spin-button,
.lot-dims-wgt::-webkit-inner-spin-button,
.lot-dims-wgt::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.lot-dims-input, .lot-dims-wgt { -moz-appearance: textfield; }
.lot-dims-sep { flex-shrink: 0; user-select: none; color: #94a3b8; font-weight: 400; font-size: 0.625rem; align-self: flex-end; padding-bottom: 0.2rem; margin-bottom: 0; }
/* Grid alignment for dims with refs: labels row 1, inputs row 2, refs row 3 */
.lot-dims--refs { display: grid; grid-template-rows: auto auto auto; grid-auto-flow: column; grid-auto-columns: auto; column-gap: 0.125rem; }
.lot-dims--refs .lot-dims-field { display: grid; grid-row: 1 / -1; grid-template-rows: subgrid; justify-items: center; align-items: center; }
.lot-dims--refs .lot-dims-sep { grid-row: 2; align-self: end; margin-bottom: 0; }
/* Handling group (Fragility / Crate / DNT) — uses same subgrid as dims */
.lot-handling { justify-content: center; column-gap: 0.5rem; }
.lot-handling .lot-dims-field { align-items: center; }
.lot-handling select, .lot-handling input[type="checkbox"] { justify-self: center; }
.lots-table td { border: none; border-bottom: 1px solid #f1f5f9; }
.cpack-badge { font-family: 'Poppins', sans-serif; font-weight: 900; font-size: 0.75rem; letter-spacing: 0.02em; }
.cpack-nf { color: #16a34a; }
.cpack-lf { color: #2563eb; }
.cpack-f { color: #d97706; }
.cpack-vf { color: #dc2626; }
.cpack-pbo { color: #7c3aed; }
.lots-table input[type="text"],
.lots-table input[type="number"] { padding: 0.2rem 0.35rem; border: 1px solid transparent; border-radius: 3px; font-size: 0.8125rem; background: transparent; color: #1e293b; }
.lots-table input[type="text"]:focus,
.lots-table input[type="number"]:focus,
.lots-table select:focus { outline: none; border: 1px solid transparent; border-radius: 3px; background: #eff6ff; }
.lots-table select { padding: 0.2rem 0.35rem; border: none; background: transparent; font-size: 0.75rem; color: #1e293b; cursor: pointer; }
.lot-input-num { width: 52px; text-align: right; }

.lot-input-sm { font-size: 0.6875rem; color: #64748b; }
.lots-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.lots-table .htmx-indicator { display: none; }
.lots-table tr.htmx-request { opacity: 0.5; pointer-events: none; }

/* === Lot Cards (Main Panel) === */
.lot-cards { list-style: none; margin: 0; padding: 0; }
.lot-card { border-bottom: 1px solid #f1f5f9; }
.lot-card-link { display: flex; gap: 0.75rem; padding: 0.5rem 1rem; color: inherit; text-decoration: none; transition: background 0.15s ease; }
.lot-card-link:hover { background: #f1f5f9; text-decoration: none; }
.lot-card-thumb { flex-shrink: 0; width: 56px; height: 56px; border-radius: 4px; overflow: hidden; background: #f1f5f9; display: flex; align-items: center; justify-content: center; }
.lot-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lot-card-no-img { width: 28px; height: 28px; opacity: 0.25; }
.lot-card-no-img svg { width: 100%; height: 100%; }
.lot-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.lot-card-title { font-size: 0.8125rem; font-weight: 600; color: #1e293b; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lot-card-notes { font-size: 0.75rem; color: #64748b; line-height: 1.4; margin-top: 0.125rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lot-card-more { color: #2563eb; font-size: 0.6875rem; }

/* === Panel Empty States === */
.panel-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1.5rem; text-align: center; color: #94a3b8; min-height: 200px; }
.panel-empty-icon { width: 40px; height: 40px; margin-bottom: 0.75rem; opacity: 0.35; }
.panel-empty-icon svg { width: 100%; height: 100%; }
.panel-empty p { font-size: 0.8125rem; line-height: 1.4; margin: 0; }
.panel-empty .panel-empty-hint { font-size: 0.6875rem; margin-top: 0.25rem; color: #cbd5e1; }

/* === Panel Loading Indicators === */
.htmx-indicator { display: none; position: absolute; inset: 0; background: rgba(255,255,255,0.7); z-index: 10; }
.htmx-request .htmx-indicator { display: flex; align-items: center; justify-content: center; }
.htmx-request .panel-content { opacity: 0.5; pointer-events: none; transition: opacity 0.15s ease; }
.spinner { width: 22px; height: 22px; border: 2.5px solid #e2e8f0; border-top-color: #2563eb; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Panel Error State === */
.panel-error { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.5rem; text-align: center; color: #dc2626; min-height: 200px; }
.panel-error p { font-size: 0.8125rem; margin-bottom: 0.75rem; }
.panel-error button { padding: 0.35rem 0.875rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 0.75rem; color: #2563eb; cursor: pointer; transition: background 0.15s ease; }
.panel-error button:hover { background: #f1f5f9; }


/* === Dropzone === */
.dropzone {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border: 1.5px dashed #64748b;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.2s ease;
    white-space: nowrap;
}
.dropzone:hover {
    border-color: #93c5fd;
    color: #fff;
    transform: scale(1.05);
}
.dropzone.dragover {
    border-color: #3b82f6;
    background: rgba(59,130,246,0.15);
    color: #fff;
    transform: scale(1.05);
}
.dropzone.uploading {
    pointer-events: none;
    animation: dropzone-pulse 1.2s ease-in-out infinite;
}
@keyframes dropzone-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}
.dropzone input[type="file"] {
    display: none;
}

/* === Toast === */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast { padding: 0.75rem 1.25rem; border-radius: 6px; font-size: 0.85rem; color: #fff; pointer-events: auto; animation: toast-in 0.3s ease-out; max-width: 400px; word-break: break-word; }
.toast-error { background: #dc2626; }
.toast-success { background: #16a34a; }
.toast.fade-out { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* === Screen Reader Only === */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* === Skeleton Loading === */
.skeleton-loading { padding: 1.5rem 1rem; }
.skeleton-spinner { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.skeleton-list { list-style: none; margin: 0; padding: 0; }
.skeleton-item { padding: 0.5rem 0.75rem 0.5rem 1rem; border-bottom: 1px solid #f1f5f9; }
.skeleton-bar { border-radius: 4px; background: #e2e8f0; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-title { width: 60%; height: 0.8125rem; margin-bottom: 0.5rem; }
.skeleton-meta { width: 40%; height: 0.625rem; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.skeleton-table-row td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.skeleton-thumb { width: 56px; height: 56px; border-radius: 3px; background: #e2e8f0; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-dims { display: flex; gap: 0.25rem; }
.skeleton-dims-bar { width: 4ch; height: 1.25rem; }

/* === Mobile Back Button === */
.mobile-back-btn { display: none; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 0.8rem; color: #475569; cursor: pointer; position: fixed; top: 60px; left: 0.5rem; z-index: 20; }
.mobile-back-btn:hover { background: #e2e8f0; }

.lot-thumb-btn { all: unset; cursor: pointer; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.lot-thumb-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; border-radius: 4px; }

/* === Modal === */
dialog#lot-modal { max-width: 840px; width: 90vw; max-height: 85vh; border-radius: 8px; border: none; padding: 0; box-shadow: 0 8px 30px rgba(0,0,0,0.15); margin: auto; }
dialog#lot-modal::backdrop { background: rgba(0,0,0,0.5); }
.modal-container { display: flex; flex-direction: column; max-height: 85vh; position: relative; }
.modal-close { position: absolute; top: 0.5rem; right: 0.5rem; z-index: 10; background: rgba(255,255,255,0.85); border: none; font-size: 1.25rem; cursor: pointer; color: #64748b; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; line-height: 1; transition: background 0.15s, color 0.15s; }
.modal-close:hover { background: #f1f5f9; color: #1e293b; }
.modal-body { overflow-y: auto; flex: 1; }
.modal-loading { display: flex; align-items: center; justify-content: center; padding: 3rem; }

/* === Lot Modal Hero Layout === */
.lot-hero { display: grid; grid-template-columns: 45% 1fr; min-height: 260px; }
@media (max-width: 768px) { .lot-hero { grid-template-columns: 1fr; } }

.lot-gallery { background: #f1f5f9; display: flex; flex-direction: column; }
.lot-gallery-main { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 200px; }
.lot-gallery-main img { max-width: 100%; max-height: 240px; object-fit: contain; }
.lot-gallery-thumbs { display: flex; gap: 4px; padding: 6px 8px; background: #f8fafc; border-top: 1px solid #e2e8f0; overflow-x: auto; }
.lot-gallery-thumb { all: unset; cursor: pointer; flex-shrink: 0; width: 40px; height: 40px; border-radius: 4px; overflow: hidden; border: 2px solid transparent; opacity: 0.6; transition: opacity 0.15s, border-color 0.15s; }
.lot-gallery-thumb:hover { opacity: 0.85; }
.lot-gallery-thumb.active { border-color: #2563eb; opacity: 1; }
.lot-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lot-gallery-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; background: #f1f5f9; color: #94a3b8; gap: 0.5rem; min-height: 200px; }

.lot-info { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lot-desc-title { font-size: 0.9375rem; font-weight: 600; color: #1e293b; line-height: 1.4; }
.lot-info .lot-desc-notes { font-size: 0.8125rem; color: #64748b; line-height: 1.6; display: block; -webkit-line-clamp: unset; overflow: visible; }
.lot-info .lot-desc-notes[contenteditable] { cursor: text; border-radius: 4px; padding: 2px 4px; margin: -2px -4px; transition: outline-color 0.15s; outline: 1px solid transparent; min-height: 1.4em; }
.lot-info .lot-desc-notes[contenteditable]:hover { outline-color: #cbd5e1; }
.lot-info .lot-desc-notes[contenteditable]:focus { outline-color: #94a3b8; background: #f8fafc; }
.lot-info .lot-desc-notes[contenteditable]:empty::before { content: attr(data-placeholder); color: #94a3b8; font-style: italic; pointer-events: none; }

/* === Override Row (Modal + Table) === */
.override-row { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #e2e8f0; display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.override-row .lot-dims { flex: 0 0 auto; }
.override-row input[type="number"] { padding: 0.2rem 0.35rem; border: 1px solid transparent; border-radius: 3px; font-size: 0.8125rem; background: transparent; color: #1e293b; }
.override-row input[type="number"]:focus { outline: none; border: 1px solid transparent; border-radius: 3px; background: #eff6ff; }
.override-row select { padding: 0.2rem 0.35rem; border: none; background: transparent; font-size: 0.75rem; color: #1e293b; cursor: pointer; }
.override-row select:focus { outline: none; background: #eff6ff; }
.override-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.override-row .lot-dims-field input[type="checkbox"] { margin: 0; }
.override-actions { display: flex; flex-direction: column; gap: 0.125rem; margin-bottom: 0.625rem; }
.override-btn { display: none; }
.override-row.dirty .override-btn { display: inline-flex; color: #dc2626; }
tr[data-dirty="1"] .override-btn { display: inline-flex; color: #dc2626; }
.override-btn.save-clean { display: inline-flex; color: #16a34a; }
.initial-ref { font-size: 0.5625rem; color: #d9770666; font-weight: 400; text-align: center; min-height: 0.625rem; }
.initial-changed { color: #d97706; font-weight: 800; }

/* === Modal Sections === */
.modal-body .section { padding: 1rem 1.5rem; border-top: 1px solid #e2e8f0; }
.modal-body .section h3 { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-bottom: 0.625rem; }

/* === Quoter Cards (Recommendation Engine) === */
.quoter-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
@media (max-width: 600px) { .quoter-grid { grid-template-columns: 1fr; } }
.quoter-card { border: 1px solid #e2e8f0; border-radius: 6px; padding: 0.625rem; text-align: center; background: #fafbfc; }
.quoter-card.recommended { border-color: #3b82f6; background: #eff6ff; }
.quoter-card-label { font-size: 0.5625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-bottom: 0.25rem; }
.quoter-card.recommended .quoter-card-label { color: #3b82f6; }
.quoter-card-dims { font-size: 0.9375rem; font-weight: 600; color: #1e293b; }
.quoter-card-type { font-size: 0.6875rem; color: #64748b; }
.placeholder-badge { display: inline-flex; font-size: 0.5625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #92400e; background: #fef3c7; padding: 1px 6px; border-radius: 3px; margin-left: 0.375rem; }

/* === Card Stacks (Related Lots) === */
.stacks-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.stack-col-label { font-size: 0.5625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; text-align: center; margin-bottom: 0.375rem; display: flex; align-items: center; justify-content: center; gap: 0.375rem; }
.stack-col-label .tag { font-size: 0.5rem; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.q25-label { color: #16a34a; }
.q25-label .tag { color: #16a34a; background: #f0fdf4; }
.q50-label { color: #2563eb; }
.q50-label .tag { color: #2563eb; background: #eff6ff; }
.q75-label { color: #d97706; }
.q75-label .tag { color: #d97706; background: #fffbeb; }
.card-stack { position: relative; height: 200px; }
.stack-card { position: absolute; left: 0; right: 0; border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; background: white; transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease; }
.stack-card[data-pos="0"] { z-index: 3; transform: translateY(0); opacity: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.stack-card[data-pos="1"] { z-index: 2; transform: translateY(6px) scale(0.97); opacity: 0.7; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stack-card[data-pos="2"] { z-index: 1; transform: translateY(12px) scale(0.94); opacity: 0.4; }
.stack-card[data-pos="hidden"] { z-index: 0; transform: translateY(16px) scale(0.91); opacity: 0; pointer-events: none; }
.stack-card:hover[data-pos="0"] { border-color: #93c5fd; }
.stack-card-img { height: 68px; background: #f1f5f9; overflow: hidden; }
.stack-card-img img { width: 100%; height: 100%; object-fit: cover; }
.stack-card-body { padding: 0.375rem 0.5rem; }
.stack-card-lot { font-size: 0.625rem; font-weight: 600; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack-card-dims { font-size: 0.6875rem; color: #1e293b; margin-top: 0.125rem; }
.stack-card-meta { display: flex; align-items: center; gap: 0.375rem; margin: 0.125rem 0 0.25rem; }
.stack-card-wgt { font-size: 0.625rem; color: #94a3b8; }
.cpack-pill { font-size: 0.5625rem; font-weight: 600; padding: 1px 5px; border-radius: 3px; }
.cpack-pill-nf { color: #16a34a; background: #f0fdf4; }
.cpack-pill-lf { color: #2563eb; background: #eff6ff; }
.cpack-pill-f { color: #d97706; background: #fffbeb; }
.cpack-pill-vf { color: #dc2626; background: #fef2f2; }
.stack-card-accept { display: block; width: 100%; padding: 0.1875rem; border: 1px solid #e2e8f0; border-radius: 3px; background: white; color: #3b82f6; font-size: 0.6875rem; font-weight: 500; cursor: pointer; font-family: inherit; transition: background 0.15s; }
.stack-card-accept:hover { background: #eff6ff; border-color: #93c5fd; }
.stack-nav { display: flex; justify-content: center; gap: 0.25rem; margin-top: 0.375rem; }
.stack-nav-btn { width: 20px; height: 20px; border: 1px solid #e2e8f0; border-radius: 4px; background: white; color: #94a3b8; font-size: 0.5625rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color 0.15s, color 0.15s; padding: 0; line-height: 1; }
.stack-nav-btn:hover { border-color: #93c5fd; color: #3b82f6; }
.stack-nav-btn:disabled { opacity: 0.3; cursor: default; }
.stack-counter { font-size: 0.5rem; color: #94a3b8; display: flex; align-items: center; padding: 0 0.125rem; }
.future-badge { display: inline-flex; font-size: 0.5625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #7e22ce; background: #f3e8ff; padding: 1px 6px; border-radius: 3px; margin-left: 0.375rem; }

/* === Recovery Page === */
.recovery-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.recovery-table th {
    text-align: left;
    padding: 0.625rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
}
.recovery-table td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
    vertical-align: middle;
}
.recovery-row.success {
    background: #f0fdf4;
}
.recovery-row.error {
    background: #fef2f2;
}
.recovery-row.warning {
    background: #fffbeb;
}
.recovery-status.found {
    color: #16a34a;
    font-weight: 500;
    font-size: 0.8rem;
}
.recovery-status.missing {
    color: #dc2626;
    font-weight: 500;
    font-size: 0.8rem;
}

/* === Navbar Search === */
.nav-search {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.search-input {
    padding: 0.3rem 0.5rem;
    border: 1px solid #475569;
    border-radius: 4px;
    font-size: 0.8rem;
    background: #334155;
    color: #fff;
    width: 120px;
    transition: border-color 0.15s ease, width 0.15s ease;
}
.search-input::placeholder {
    color: #94a3b8;
}
.search-input:focus {
    outline: none;
    border-color: #93c5fd;
    width: 160px;
}
.nav-search button {
    padding: 0.3rem 0.5rem;
    background: #475569;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.15s ease;
}
.nav-search button:hover {
    background: #64748b;
}

/* === Lot Active Highlight === */
.lot-active {
    background: #eff6ff !important;
    border-left: 3px solid #3b82f6;
}

/* === Mobile/Narrow Viewport === */
@media (max-width: 767px) {
    .shell { grid-template-columns: 1fr; }
    .panel { display: none; border-right: none; }
    .shell[data-mobile-panel="sellers"] [data-panel="sellers"] { display: block; }
    .shell[data-mobile-panel="events"] [data-panel="events"] { display: block; }
    .shell[data-mobile-panel="lots"] [data-panel="lots"] { display: block; }
    .mobile-back-btn[hidden] { display: none !important; }
    .mobile-back-btn:not([hidden]) { display: flex; }
}
