* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4a6cf7;
    --primary-dark: #3a56d4;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --dark: #1a1a2e;
    --text: #212529;
    --text-light: #6c757d;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --border: #dee2e6;
    --shadow: 0 2px 12px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 80px;
    min-height: 100vh;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
}

header h1 { font-size: 1.5rem; font-weight: 700; color: var(--dark); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: auto;
    padding: 6px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.icon-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 8px; border-radius: 50%; transition: background 0.2s; line-height: 1; }
.icon-btn:hover { background: rgba(0,0,0,0.05); }

/* ===== Hero Card (Homepage) ===== */
.hero-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-top: 8px;
}

.hero-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.hero-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-card-header .btn {
    width: auto;
    padding: 6px 12px;
    font-size: 0.8rem;
}

#heroAuctionInfo {
    margin-bottom: 20px;
}

.hero-auction-key {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 4px;
}
/* The auction name doubles as a button that enters the lot page. */
.hero-auction-key-link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.hero-auction-key-link:hover,
.hero-auction-key-link:focus-visible {
    color: var(--primary);
    text-decoration: underline;
}

.hero-auction-dates {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 2px;
}

.hero-auction-lot-range {
    font-size: 0.85rem;
    color: var(--text-light);
}

.hero-cta {
    margin-top: 0;
}

.home-actions {
    margin-top: 16px;
}

/* ===== Form Page Header ===== */
.form-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
}

.form-back-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.form-page-auction-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.form-auction-key {
    font-weight: 700;
    font-size: 1rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-auction-dates {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== Auction Selector Modal ===== */
.auction-selector-item {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auction-selector-item:hover {
    border-color: var(--primary);
    background: #f8f9ff;
}

.auction-selector-item.selected {
    border-color: var(--primary);
    background: #eef1ff;
}

.auction-selector-item .sel-info {
    flex: 1;
    min-width: 0;
}

.auction-selector-item .sel-key {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--dark);
}

.auction-selector-item .sel-dates {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

.auction-selector-item .sel-lot-range {
    font-size: 0.8rem;
    color: var(--text-light);
}

.auction-selector-item .sel-check {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: bold;
    margin-left: 12px;
    flex-shrink: 0;
}

/* ===== General Form Styles ===== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; color: var(--text); }
.form-group small { display: block; color: var(--text-light); font-size: 0.8rem; margin-top: 4px; }

input[type="number"], input[type="text"], input[type="password"], textarea, select {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius-sm);
    font-size: 1rem; font-family: inherit; transition: border-color 0.2s; background: var(--card-bg); color: var(--text);
}
input[type="number"]:focus, input[type="text"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary);
}

/* Compact x Bid / As-Is / Taxable row */
.lot-flags { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.flag-field { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.flag-field > .flag-label,
.flag-field > label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--text); margin: 0; }
.flag-xbid { align-items: flex-start; }
.count-input { display: flex; align-items: center; gap: 4px; }
.count-input input { width: 52px; padding: 8px 6px; text-align: center; }
.flag-lot .count-input input { width: 76px; }
.count-btn { width: 34px; height: 38px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text); font-size: 1.1rem; font-weight: 700; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; line-height: 1; transition: background 0.15s; }
.count-btn:active { background: var(--border); }
textarea { resize: vertical; min-height: 80px; }

.checkbox-group { margin-bottom: 20px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; padding: 8px 0; }
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
    width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 4px;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0;
}
.checkbox-label input:checked + .checkbox-custom { background: var(--primary); border-color: var(--primary); }
.checkbox-label input:checked + .checkbox-custom::after { content: '✓'; color: white; font-size: 16px; font-weight: bold; }
.checkbox-text { font-weight: 600; font-size: 1rem; color: var(--danger); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; width: 100%; font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; width: auto; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover:not(:disabled) { background: #5a6268; }
.btn-submit {
    background: linear-gradient(135deg, var(--primary), #6c63ff); color: white;
    padding: 16px; font-size: 1.1rem; border-radius: var(--radius); margin-top: 8px;
}
.btn-submit:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(74,108,247,0.4); }
.btn-success { background: var(--success); color: white; margin-top: 12px; }
.btn-success:hover:not(:disabled) { background: #218838; }

/* Inline busy state for buttons (Save Lot / Save Changes / Save Lot Number):
   a small white spinner + the button is disabled while the request runs. */
.btn.is-saving { pointer-events: none; }
.btn.is-saving::before {
    content: '';
    width: 16px; height: 16px; flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.camera-controls { display: flex; gap: 10px; margin-bottom: 12px; }
.camera-controls .btn { flex: 1; padding: 10px 16px; font-size: 0.9rem; }

.photo-gallery { display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px; }
.photo-gallery .photo-item {
    position: relative; width: calc(33.33% - 6px); aspect-ratio: 1;
    border-radius: var(--radius-sm); overflow: hidden; border: 2px solid var(--border);
}
.photo-gallery .photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-gallery .photo-item .delete-photo {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
    background: rgba(220,53,69,0.9); color: white; border: none; border-radius: 50%;
    font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1;
    z-index: 2;
}
.photo-gallery .photo-item .photo-include-label {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.92); padding: 4px 6px;
    font-size: 0.68rem; line-height: 1.1; cursor: pointer; z-index: 2;
}
.photo-gallery .photo-item .photo-include-label input { flex-shrink: 0; margin: 0; }
.photo-gallery .photo-item.photo-excluded { border-color: var(--danger); }
.photo-gallery .photo-item.photo-excluded img { opacity: 0.35; filter: grayscale(0.7); }
.photo-gallery .photo-item.photo-excluded .photo-include-label { background: rgba(255,235,235,0.95); color: var(--danger); }

.loading { text-align: center; padding: 40px 0; }
.loading p { margin-top: 12px; color: var(--text-light); }
.spinner {
    width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-container { background: var(--card-bg); border-radius: var(--radius); padding: 20px; margin-top: 20px; box-shadow: var(--shadow); }
.result-container h3 { margin-bottom: 12px; color: var(--dark); }
.result-content { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.7; color: var(--text); }
.result-line { margin-bottom: 3px; }
.result-label { font-weight: 700; color: var(--dark); }
.result-hint { font-size: 0.8rem; color: var(--text-light); margin: 0 0 14px; }
.result-field { margin-bottom: 12px; }
.result-field label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--dark); margin-bottom: 4px; }

/* View-lot tabs */
.view-lot-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.view-tab-btn {
    flex: 1;
    padding: 8px 0;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.view-tab-btn:active { transform: scale(0.97); }
.view-tab-btn.active { background: var(--primary); color: #fff; }
.view-tab-pane { min-height: 60px; }

/* View-lot carousel */
.lot-carousel {
    position: relative;
    background: var(--dark);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.carousel-stage { position: relative; width: 100%; aspect-ratio: 4 / 3; }

.carousel-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.carousel-slide.active { opacity: 1; z-index: 1; }
.carousel-slide img { max-width: 100%; max-height: 100%; }
.carousel-slide.excluded img { opacity: 0.45; filter: grayscale(0.75); }

.carousel-badge {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 4px;
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
}

.carousel-badge.main {
    position: absolute;
    top: 8px;
    left: 8px;
    right: auto;
    bottom: auto;
    background: rgba(255, 193, 7, 0.95);
    color: #1a1a2e;
}

.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(26, 26, 46, 0.85);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

.carousel-counter {
    position: absolute;
    top: 8px;
    right: 12px;
    background: rgba(26, 26, 46, 0.85);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 2;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 6px 0 2px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}

.carousel-dot.active { background: #fff; transform: scale(1.25); }
.carousel-dot.main { box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.9); }
.carousel-dot.main.active { background: #ffc107; }
.carousel-empty { padding: 24px 0; }

/* Edit-mode rotate controls (rotate the photo currently shown in the carousel) */
.carousel-rotate-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 8px 10px;
    background: rgba(0, 0, 0, 0.35);
}
.carousel-rotate-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.72rem;
    font-weight: 600;
}
.carousel-rotate-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}
.carousel-rotate-btn:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.25); }
.carousel-rotate-btn:disabled { opacity: 0.5; cursor: default; }

/* View-lot public fields (Lot Number / Title / Description) */
.view-lot-meta { margin-top: 0; }

.view-lot-field {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}

.view-lot-field .field-label {
    flex-shrink: 0;
    min-width: 112px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
}

.view-lot-field .field-value {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.view-lot-field .field-value.muted { color: var(--text-light); font-style: italic; }

/* View-lot internal detail rows */
.view-lot-detail { margin-bottom: 10px; }

.detail-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.detail-value { font-size: 0.95rem; color: var(--text); }
.detail-value.as-is { color: var(--danger); font-weight: 600; }
.detail-value.non-taxable { color: var(--danger); font-weight: 600; }

.detail-value.ai-analysis {
    white-space: pre-wrap;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-top: 4px;
}

.detail-value.photo-manifest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.photo-chip {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--success);
    color: #fff;
}

.photo-chip-excluded { background: var(--danger); }

.local-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--warning);
    color: #856404;
    font-weight: 500;
}

/* View-lot edit mode */
.modal-header-actions { display: flex; align-items: center; gap: 8px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
    z-index: 1;
}

.edit-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    margin-top: 2px;
}

.edit-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    resize: vertical;
    margin-top: 2px;
}

.view-edit-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }

.edit-photo-item {
    position: relative;
    width: calc(33.33% - 6px);
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.edit-photo-item img { width: 100%; height: 100%; object-fit: cover; }
.edit-photo-item.photo-excluded { border-color: var(--danger); }
.edit-photo-item.photo-excluded img { opacity: 0.4; filter: grayscale(0.8); }

.edit-photo-item .edit-main-radio {
    position: absolute;
    top: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(26, 26, 46, 0.85);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 2;
}
.edit-photo-item .edit-main-radio input { margin: 0; accent-color: var(--primary); flex-shrink: 0; }

.edit-photo-item .edit-include-check {
    position: absolute;
    bottom: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(26, 26, 46, 0.85);
    color: #ddd;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 2;
}
.edit-photo-item .edit-include-check input { margin: 0; flex-shrink: 0; }

.edit-photo-item .edit-photo-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    z-index: 3;
}

/* Edit-mode "add photos" row (camera / gallery) */
.view-edit-add-photos {
    display: flex;
    gap: 8px;
    margin: 14px 0 4px;
}
.view-edit-add-photos .btn { flex: 1; }

.edit-checkline { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.edit-checkline input { width: auto; accent-color: var(--primary); }

/* Form gallery "main photo" selector */
.photo-main-label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
}
.photo-main-label input { margin: 0; accent-color: var(--primary); flex-shrink: 0; }

.saved-lots-section { margin-top: 32px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-header h2 { font-size: 1.2rem; color: var(--dark); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.sync-status { font-size: 0.75rem; color: var(--text-light); font-style: italic; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-bar select { flex: 1; min-width: 0; padding: 8px 12px; font-size: 0.9rem; border-radius: var(--radius-sm); border: 2px solid var(--border); background: var(--card-bg); }
#lotPageSize { flex: 0 0 auto; margin-left: auto; }
.empty-state { text-align: center; color: var(--text-light); padding: 24px; font-style: italic; }
.lots-footer { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 2px; }
.page-summary { font-size: 0.8rem; color: var(--text-light); padding: 2px 0; }
.pagination { display: flex; align-items: center; gap: 6px; }
.pagination.hidden { display: none; }
.pagination-btn { min-width: 34px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); border: 2px solid var(--border); background: var(--card-bg); color: var(--text); font-size: 0.9rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background 0.2s, border-color 0.2s; }
.pagination-btn:hover:not(:disabled) { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btn:disabled { opacity: 0.4; cursor: default; }
.page-numbers { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.page-num { min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--radius-sm); border: 2px solid var(--border); background: var(--card-bg); color: var(--text); font-size: 0.9rem; cursor: pointer; }
.page-num.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.page-num:hover:not(.active) { border-color: var(--primary); }
.page-ellipsis { padding: 0 2px; color: var(--text-light); }

.saved-lot-item {
    background: var(--card-bg); border-radius: var(--radius-sm); padding: 12px 16px;
    margin-bottom: 8px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: transform 0.2s;
}
.saved-lot-item:hover { transform: translateX(4px); }
.saved-lot-item .lot-info { flex: 1; min-width: 0; }
.saved-lot-item .lot-number { font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-lot-item .lot-title { font-size: 0.9rem; color: var(--text); font-weight: 500; margin-top: 2px; }
.saved-lot-item .lot-auction { font-size: 0.8rem; color: var(--primary); font-weight: 500; }
.saved-lot-item .lot-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.saved-lot-item .lot-badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 12px; background: var(--warning); color: #856404; font-weight: 600; margin-left: 8px; flex-shrink: 0; }
.saved-lot-item .synced-badge { font-size: 0.7rem; padding: 1px 6px; border-radius: 10px; background: var(--success); color: #fff; font-weight: 500; }
.saved-lot-item .delete-lot { background: none; border: none; color: var(--danger); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; flex-shrink: 0; }

.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; z-index: 1000; padding: 16px; }
.modal.hidden { display: none !important; }
.modal-content { background: var(--card-bg); border-radius: var(--radius); width: 100%; max-width: 480px; max-height: 90vh; margin: auto; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-bg); z-index: 1; }
.modal-header h2 { font-size: 1.2rem; }
.modal-body { padding: 20px; }

/* Change Lot Number modal */
.change-lot-info { display: flex; gap: 12px; align-items: flex-start; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px; }
.change-lot-thumb { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--border); flex-shrink: 0; }
.change-lot-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 0.72rem; color: var(--text-light); text-align: center; padding: 4px; }
.change-lot-title { font-weight: 600; font-size: 0.95rem; line-height: 1.35; }
.change-lot-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.change-lot-actions { position: static; display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding: 12px 0 0; border-top: 1px solid var(--border); }

#cameraModal { padding: 0; }
#cameraModal.modal { align-items: flex-end; background: rgba(0,0,0,0.85); }
.camera-modal-content { background: #000; width: 100%; max-width: none; height: 100vh; height: 100dvh; max-height: 100vh; position: relative; overflow: hidden; border-radius: 0; box-shadow: none; }

/* Viewfinder fills the entire camera screen; the controls float over it. */
.camera-viewfinder { position: absolute; inset: 0; overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; }
.camera-viewfinder video { width: 100%; height: 100%; object-fit: contain; }
.camera-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.camera-frame { width: 86%; height: 80%; border: 1px solid rgba(255,255,255,0.22); border-radius: 10px; }

/* Top overlay: back / title / count + Done. */
.camera-modal-header { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; color: #fff; background: linear-gradient(180deg, rgba(0,0,0,0.65), rgba(0,0,0,0)); }
.camera-modal-header .icon-btn { color: #fff; font-size: 1.3rem; }
.camera-modal-header .btn { width: auto; }
.camera-header-right { display: flex; align-items: center; gap: 10px; }
.camera-title { font-weight: 600; font-size: 1rem; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.camera-count { font-size: 0.85rem; color: #ddd; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }

/* Right-side vertical zoom overlay (transparent over the preview). */
.camera-zoom { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); z-index: 3; display: flex; flex-direction: column; gap: 10px; margin: 0; }
.zoom-btn { width: 52px; height: 38px; border-radius: 19px; border: 2px solid rgba(255,255,255,0.45); background: rgba(0,0,0,0.35); color: #fff; font-size: 0.95rem; font-weight: 600; font-family: inherit; cursor: pointer; transition: background 0.2s, border-color 0.2s; backdrop-filter: blur(2px); }
.zoom-btn.active { background: var(--primary); border-color: var(--primary); }

/* Bottom-left thumbnails overlay. */
.camera-thumbnails { position: absolute; left: 12px; bottom: 12px; right: 120px; z-index: 3; display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.camera-thumbnails .cam-thumb { width: 72px; border-radius: 6px; overflow: hidden; border: 2px solid rgba(255,255,255,0.5); flex-shrink: 0; position: relative; background: #111; }
.camera-thumbnails .cam-thumb img { width: 100%; height: 56px; object-fit: cover; display: block; }
.camera-thumbnails .cam-thumb.cam-thumb-excluded { border-color: #dc3545; }
.camera-thumbnails .cam-thumb.cam-thumb-excluded img { opacity: 0.35; filter: grayscale(0.7); }
.camera-thumbnails .cam-thumb .cam-thumb-del { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; background: rgba(220,53,69,0.9); color: white; border: none; border-radius: 50%; font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0; z-index: 2; }
.camera-thumbnails .cam-thumb .cam-thumb-rot { position: absolute; bottom: 2px; left: 2px; width: 18px; height: 18px; background: rgba(0,0,0,0.65); color: white; border: 1px solid rgba(255,255,255,0.5); border-radius: 50%; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0; z-index: 2; }
.camera-thumbnails .cam-thumb .cam-thumb-include { display: flex; align-items: center; gap: 3px; padding: 3px 4px; font-size: 0.6rem; line-height: 1.1; color: #ddd; cursor: pointer; background: rgba(0,0,0,0.55); }
.camera-thumbnails .cam-thumb .cam-thumb-include input { flex-shrink: 0; margin: 0; }
.camera-thumbnails .cam-thumb.cam-thumb-excluded .cam-thumb-include { color: #ff9a9a; background: #3a1216; }

/* Bottom-right overlay: Done stack directly above the capture (shutter) button. */
.camera-actions { position: absolute; right: 20px; bottom: 24px; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.camera-done-btn { width: auto; padding: 8px 14px; font-size: 0.9rem; box-shadow: 0 2px 10px rgba(0,0,0,0.55); }
.camera-cancel-btn { width: auto; padding: 8px 14px; font-size: 0.85rem; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.5); color: #fff; }
.btn-capture-btn { width: 72px; height: 72px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.9); background: rgba(0,0,0,0.25); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: transform 0.15s; }
.btn-capture-btn:active { transform: scale(0.92); }
.capture-circle { width: 56px; height: 56px; border-radius: 50%; background: #fff; display: block; }

/* Landscape: compact the overlays so the preview stays dominant. */
@media (orientation: landscape) and (max-height: 520px) {
    .camera-modal-header { padding: 6px 10px; }
    .camera-title { display: none; }
    .camera-zoom { right: 8px; gap: 8px; }
    .zoom-btn { width: 44px; height: 34px; font-size: 0.85rem; }
    .camera-actions { right: 16px; bottom: 12px; gap: 8px; }
    .camera-done-btn { padding: 6px 10px; font-size: 0.78rem; }
    .camera-cancel-btn { padding: 6px 10px; font-size: 0.78rem; }
    .btn-capture-btn { width: 60px; height: 60px; border-width: 3px; }
    .capture-circle { width: 46px; height: 46px; }
    .camera-thumbnails { left: 10px; bottom: 10px; right: 100px; }
    .camera-thumbnails .cam-thumb { width: 62px; }
    .camera-thumbnails .cam-thumb img { height: 46px; }
}

/* Settings modal extras */
.prompt-actions { margin-top: 8px; }
.settings-note { margin-top: 8px; font-size: 0.8rem; color: var(--danger); font-weight: 500; }
.model-cooldown { display: block; margin-top: 6px; font-size: 0.78rem; color: #b8860b; font-weight: 600; }

/* Admin model list editor */
.models-admin { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.models-admin-header { margin-bottom: 6px; }
.models-admin-title { font-weight: 600; font-size: 0.85rem; color: var(--dark); }
#modelsAdminList { margin-bottom: 8px; }
.model-admin-row { display: flex; gap: 6px; margin-bottom: 6px; }
.model-admin-row input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 0.8rem; border-radius: var(--radius-sm); border: 2px solid var(--border); }
.model-remove-btn { width: 30px; height: 30px; flex-shrink: 0; background: rgba(220,53,69,0.9); color: white; border: none; border-radius: 50%; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; align-self: center; }
.models-admin small { display: block; margin-top: 6px; }

#cameraModal.modal.hidden { display: none; }

/* Hidden utility */
.hidden { display: none !important; }

/* ===== Login Screen ===== */
body.auth-locked > #app > header,
body.auth-locked > #app > #homePage,
body.auth-locked > #app > #auctionFormPage {
    display: none !important;
}

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-title {
    margin: 0 0 4px;
    font-size: 24px;
    text-align: center;
    color: #1a1a2e;
}

.login-subtitle {
    margin: 0 0 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 14px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.login-form input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d0d8;
    border-radius: 10px;
    font-size: 15px;
    box-sizing: border-box;
}

.login-form input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

.btn-block {
    width: 100%;
    margin-top: 4px;
}

.login-toggle {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
}

.login-toggle a {
    color: #4f46e5;
    text-decoration: none;
}

.login-toggle a:hover {
    text-decoration: underline;
}

.login-about { margin-top: 10px; text-align: center; font-size: 12px; }
.login-about a { color: #8a8a99; text-decoration: none; }
.login-about a:hover { text-decoration: underline; }

/* About modal */
.about-app { margin-bottom: 16px; }
.about-name { font-size: 1.1rem; font-weight: 700; color: var(--dark); }
.about-desc { font-size: 0.9rem; color: var(--text-light); margin-top: 2px; }

/* AI model picker (edit-page "Analyze with AI") */
.model-picker-hint { font-size: 0.85rem; color: var(--text-light); margin: 0 0 12px; }
.model-pick-list { margin-bottom: 16px; }
.model-pick-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.model-pick-item:hover:not(:disabled) { border-color: var(--primary); background: #f8f9ff; }
.model-pick-item:active:not(:disabled) { transform: scale(0.985); }
.model-pick-item.cooling { opacity: 0.55; cursor: not-allowed; }
.model-pick-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.model-pick-label { font-weight: 700; font-size: 0.98rem; color: var(--dark); }
.model-pick-value { font-size: 0.78rem; color: var(--text-light); word-break: break-all; }
.model-pick-badge {
    font-size: 0.68rem; font-weight: 600; padding: 1px 7px; border-radius: 10px;
    background: rgba(74, 108, 247, 0.12); color: var(--primary); margin-top: 3px;
}
.model-pick-badge.cooling { background: rgba(255, 165, 0, 0.15); color: #b26a00; }
.model-pick-go { font-size: 1.2rem; color: var(--primary); margin-left: 12px; flex-shrink: 0; }

.auth-message {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
}

.auth-message.auth-error {
    background: #fdecea;
    color: #c0392b;
}

.auth-message.auth-success {
    background: #e8f6ef;
    color: #1e7e4f;
}

/* ===== Users modal ===== */
.users-list {
    margin-bottom: 8px;
}

.users-divider {
    border: none;
    border-top: 1px solid #e5e5ec;
    margin: 18px 0;
}

.user-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #ececf2;
    border-radius: 10px;
    margin-bottom: 8px;
}

.user-name {
    font-weight: 600;
    color: #1a1a2e;
}

.user-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.role-admin { background: #eef0ff; color: #4f46e5; }
.role-user { background: #eef2f5; color: #5b6b7b; }

.user-created {
    font-size: 12px;
    color: #888;
}
