* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f5f5f5; }
.app { min-height: 100vh; }

.auth-screen {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.auth-card {
  background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); max-width: 400px; width: 100%;
}
.auth-card h1 { margin: 0 0 8px; font-size: 1.5rem; }
.auth-subtitle { color: #666; margin: 0 0 24px; font-size: 0.9rem; }
.auth-form input {
  display: block; width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem;
}
.auth-form button {
  width: 100%; padding: 12px; background: #2563eb; color: #fff; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer;
}
.auth-form button:hover { background: #1d4ed8; }
.auth-error { color: #dc2626; font-size: 0.9rem; margin-top: 12px; }
.auth-footer { margin-top: 16px; text-align: center; }
.auth-footer a { color: #2563eb; }
.hidden { display: none !important; }

.main-screen { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: #fff; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-email { font-size: 0.85rem; color: #666; }
.main { flex: 1; padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }
.main-grid-page { max-width: none; padding: 12px 16px; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab {
  padding: 10px 18px; border: 1px solid #ddd; background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}
.tab:hover { background: #f9fafb; }
.tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-toolbar { margin-bottom: 12px; }
.search-input {
  width: 100%; max-width: 400px; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem;
}
.list {
  background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden;
}
.list-item {
  padding: 14px 16px; border-bottom: 1px solid #eee; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #f9fafb; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 0.85rem; color: #666; }
.batch-completed { opacity: 0.7; background: #f0fdf4; }
.batch-completed:hover { background: #dcfce7; }
.list-item .btn { padding: 6px 12px; font-size: 0.9rem; border-radius: 6px; cursor: pointer; border: 1px solid #ddd; background: #fff; }
.list-item .btn:hover { background: #f3f4f6; }
.list-item .btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.list-item .btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn-delete { background: #dc2626 !important; color: #fff !important; border-color: #dc2626 !important; }
.btn-delete:hover { background: #b91c1c !important; }
.reason-tag { font-size: 0.8rem; color: #666; }
.empty { padding: 40px; text-align: center; color: #666; }

.hint { font-size: 0.85rem; color: #666; margin-top: 12px; }

.btn { padding: 8px 16px; border-radius: 8px; font-size: 0.95rem; cursor: pointer; border: 1px solid #ddd; background: #fff; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.secondary { background: transparent; }

.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: 100%; left: 0; margin-top: 4px; background: #fff; border: 1px solid #ddd; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12); min-width: 200px; z-index: 100; overflow: hidden;
}
.dropdown-item {
  display: block; width: 100%; padding: 10px 16px; background: #fff; border: none; text-align: left;
  font-size: 0.9rem; cursor: pointer; border-bottom: 1px solid #f0f0f0;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #f3f4f6; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-content {
  background: #fff; border-radius: 12px; max-width: 560px; width: 100%; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #eee; }
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; padding: 0 4px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid #eee; }
.order-detail-table { width: 100%; border-collapse: collapse; }
.order-detail-table th, .order-detail-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; }
.order-detail-table th { font-weight: 600; color: #374151; }

.loading { padding: 24px; text-align: center; color: #666; }

/* Draft items in drafts modal */
.draft-item {
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #f9fafb;
}

.draft-item h3 {
  margin: 0 0 8px 0;
  font-size: 1rem;
  color: #111827;
}

.draft-item p {
  margin: 4px 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.draft-item button {
  margin-top: 8px;
  margin-right: 8px;
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
}

.draft-item button:hover {
  background: #f3f4f6;
}

.draft-item button:first-of-type {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.draft-item button:first-of-type:hover {
  background: #2563eb;
}

/* Batch view - always visible on grid page */
.batch-view { padding-top: 0; }
.batch-view-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.batch-view-toolbar select { padding: 8px 12px; border-radius: 6px; border: 1px solid #ddd; min-width: 180px; }
.batch-center-content { display: block; }
.batch-center-content.hidden { display: none !important; }

.batch-main-grid { display: grid; grid-template-columns: 300px 1fr 260px; gap: 16px; margin-top: 12px; min-height: 400px; margin-left: auto; }
.batch-left-panel { background: #f9fafb; border-radius: 10px; padding: 10px; border: 1px solid #e5e7eb; }
.batch-left-panel h3 { margin: 0 0 8px; font-size: 1rem; }
.menu-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.menu-btn { padding: 10px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600; text-align: left; }
.menu-btn:hover { background: #f3f4f6; border-color: #2563eb; }
.list-panel { margin-top: 8px; }
.list-panel .search-input { width: 100%; padding: 8px 10px; margin-bottom: 8px; border-radius: 6px; border: 1px solid #ddd; font-size: 0.9rem; }
.list-panel .list { max-height: 320px; overflow-y: auto; }
.list-panel .list-item { padding: 10px 12px; cursor: pointer; }
.list-panel .list-item:hover { background: #eff6ff; }
/* Keep enough of the name visible to be readable; below that the buttons
   drop to their own line rather than being pushed out of the panel. */
.customer-list-row .customer-list-row-main { flex: 1 1 120px; min-width: 120px; }
.customer-list-row .customer-list-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.customer-list-row .customer-edit-btn { font-size: 0.85rem; padding: 4px 10px; }
.customer-list-row .customer-use-btn { font-size: 0.85rem; padding: 4px 10px; }
.customer-list-row .customer-invite-btn { font-size: 0.85rem; padding: 4px 10px; }
.customer-form .form-row { margin-bottom: 12px; }
.customer-form .form-row label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: #374151; }
.customer-form .form-row input, .customer-form .form-row select, .customer-form .form-row textarea { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 0.9rem; }
.customer-form .form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.customer-form .form-row.actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-content-wide { max-width: 560px; }
#order-analysis-modal .modal-content-wide { max-width: min(920px, 96vw); }
.batch-center-empty { display: flex; align-items: center; justify-content: center; min-height: 360px; color: #6b7280; font-size: 1rem; text-align: center; padding: 24px; }
.batch-view-header { display: flex; align-items: center; justify-content: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.draft-badge { font-size: 0.7em; background: #f59e0b; color: white; padding: 2px 8px; border-radius: 4px; margin-left: 8px; font-weight: 600; }
.batch-center-panel { min-width: 0; display: flex; flex-direction: column; }
.batch-page-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.batch-page-tab { padding: 10px 16px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.95rem; }
.batch-page-tab:hover { background: #f3f4f6; }
.batch-page-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.batch-tab-content { display: none; flex: 1; }
.batch-tab-content.active { display: block; }

/* Stand column = 1fr so it expands right to fill middle gap (grid stays fixed on right); stand image same size, aligned right so it sits next to grid */
.review-grid-wrap { display: grid; grid-template-columns: 1fr 660px; gap: 16px; }
.stand-image-wrap { display: flex; flex-direction: column; align-items: flex-end; }
.stand-image-wrap .side-header { font-weight: 600; margin-bottom: 8px; font-size: 0.95rem; }
.batch-stand-image-wrap { background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 10px; min-height: 480px; display: flex; align-items: center; justify-content: center; overflow: hidden; max-width: 420px; }
.batch-stand-image { max-width: 100%; max-height: 540px; width: 100%; object-fit: contain; display: none; }
.batch-stand-image.loaded { display: block; }

/* Batch Notes Panel (in override sidebar) */
.batch-notes-panel {
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  margin: 8px;
}
.batch-notes-panel .batch-notes-content {
  font-size: 0.9rem;
  color: #78350f;
  white-space: pre-wrap;
  line-height: 1.4;
}
.batch-notes-panel .batch-notes-empty {
  color: #92400e;
  font-style: italic;
  font-size: 0.9rem;
}
.grid-tabs-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; align-items: flex-end; }
.grid-side-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.grid-side-tab { padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.grid-side-tab:hover { background: #f9fafb; }
.grid-side-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.batch-grid-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.batch-grid-actions .btn { margin: 0; }
.batch-grid-area { overflow-x: auto; display: flex; justify-content: flex-end; }
.batch-order-actions-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.batch-order-actions-inline input[type="date"] { padding: 8px; border-radius: 6px; border: 1px solid #ddd; }

.batch-section { margin-bottom: 24px; }
.batch-section h3 { margin: 0 0 12px; font-size: 1rem; color: #374151; }
.side-header { font-weight: 600; font-size: 0.95rem; color: #374151; margin-bottom: 6px; }
.batch-grid-wrap { overflow-x: auto; margin-bottom: 16px; margin-left: auto; }
/* Grid: cap column width; aligned right so closer to override sidebar */
.batch-cell-grid { display: grid; gap: 2px; max-width: 660px; }
.batch-cell { border: 1px solid #e8eaed; border-radius: 3px; overflow: hidden; background: #fff; padding: 1px; cursor: pointer; min-width: 0; }
.batch-cell:hover { border-color: #93c5fd; }
.batch-cell-img-wrap { width: 100%; height: 116px; background: #fafafa; border-radius: 2px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.batch-cell-img { width: 100%; height: 100%; object-fit: contain; }
.batch-cell-img.loaded { }
.batch-cell.matrix-mismatch .batch-cell-img-wrap { background: #1d4ed8; } /* navy blue for mismatched position */
.batch-cell.dup-product .batch-cell-img-wrap { background: #b91c1c; }      /* cherry red for duplicate products */
.batch-cell-label { font-size: 0.8rem; font-weight: 600; margin-top: 2px; }
.batch-cell-qty { font-size: 0.75rem; margin-top: 1px; }
.batch-cell-qty input.qty-edit { width: 42px; padding: 2px 4px; text-align: center; border-radius: 4px; border: 1px solid #d1d5db; font-size: 0.8rem; }
.qty-controls { display: flex; gap: 4px; align-items: center; justify-content: center; }
.qty-mode-toggle { padding: 2px 6px; font-size: 11px; border: 1px solid #ccc; background: #fff; cursor: pointer; border-radius: 3px; min-width: 32px; transition: all 0.2s; }
.qty-mode-toggle[data-mode="stk"] { background: #4a90e2; color: white; border-color: #357abd; }
.qty-mode-toggle:hover { opacity: 0.8; }
.batch-grid-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.batch-grid-table th, .batch-grid-table td { padding: 6px 10px; text-align: left; border: 1px solid #eee; }
.batch-grid-table th { background: #f9fafb; font-weight: 600; }
.batch-grid-table input.qty-edit { width: 56px; padding: 4px; text-align: center; }
.order-summary { font-size: 0.9rem; color: #666; margin: 0 0 8px; }
.batch-order-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.batch-order-table th, .batch-order-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; }
.batch-order-table th { font-weight: 600; }
.add-override-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.add-override-row input[type="text"] { width: 120px; padding: 8px; border-radius: 6px; border: 1px solid #ddd; }
.add-override-row input[type="number"] { width: 70px; padding: 8px; border-radius: 6px; border: 1px solid #ddd; }
.batch-order-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.batch-order-actions input[type="date"] { padding: 8px; border-radius: 6px; border: 1px solid #ddd; }
.batch-item-clickable { cursor: pointer; }
.batch-item-clickable:hover { background: #eff6ff; }
.batch-item-clickable.batch-completed:hover { background: #dcfce7; }

.batch-override-sidebar { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; }
.batch-override-sidebar h3 { margin: 0 0 10px; font-size: 1rem; }
.override-selected { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.override-crop-wrap { width: 80px; height: 80px; flex-shrink: 0; background: #e5e7eb; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.override-selected-crop { max-width: 100%; max-height: 100%; object-fit: contain; display: none; }
.override-selected-crop.loaded { display: block; }
.override-selected-text { font-size: 0.9rem; color: #374151; }
.override-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.override-tab { padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.override-tab:hover { background: #f3f4f6; }
.override-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.override-tab-content { display: none; max-height: 320px; overflow-y: auto; }
.override-tab-content.active { display: block; }
.product-filter-row { display: flex; gap: 8px; margin-bottom: 8px; }
.product-filter-row .filter-btn { flex: 1; padding: 6px 12px; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; color: #374151; cursor: pointer; font-size: 12px; }
.product-filter-row .filter-btn:hover { background: #f3f4f6; }
.product-filter-row .filter-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.override-tab-hint { font-size: 0.8rem; color: #6b7280; margin: 0 0 8px; }
.override-tab-hint .override-error { color: #dc2626; font-size: 0.75rem; }
.override-load-status { font-size: 0.75rem; color: #dc2626; margin: 0 0 8px; }
.override-search { width: 100%; padding: 8px 10px; margin-bottom: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.9rem; }
.override-product-list { display: flex; flex-direction: column; gap: 6px; }
.override-product-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer; }
.override-product-item:hover { border-color: #2563eb; background: #eff6ff; }
.override-product-item.correct-for-cell { background: #dcfce7; border-color: #22c55e; }
.override-product-item .override-item-img { width: 48px; height: 48px; object-fit: contain; background: #f3f4f6; border-radius: 6px; flex-shrink: 0; }
.override-product-item .override-item-code { font-weight: 600; font-size: 0.9rem; }
.batch-cell.selected { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3); }

/* Dashboard (same as Hook Detector) */
.order-header { margin-bottom: 16px; }
.order-header.dashboard-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.order-header h3 { margin: 0; font-size: 1.1rem; }
.order-analysis-hint { margin: 0 0 14px; font-size: 0.85rem; color: #6b7280; line-height: 1.4; }
.order-analysis-filters { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.order-analysis-zones-panel {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
}
.order-analysis-zones-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.order-analysis-zones-heading { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.order-analysis-zones-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #475569; }
.order-analysis-zones-status { font-size: 0.85rem; color: #64748b; }
.order-analysis-zone-actions { display: flex; gap: 8px; flex-shrink: 0; }
.zone-action-btn {
  padding: 6px 12px; font-size: 0.8rem; font-weight: 600; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #fff; color: #334155; cursor: pointer;
}
.zone-action-btn:hover { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.order-analysis-zone-chips {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%;
}
.zone-chip { position: relative; display: inline-flex; margin: 0; cursor: pointer; user-select: none; }
.zone-chip-input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.zone-chip-label {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 16px; border-radius: 999px;
  font-size: 0.875rem; font-weight: 600; letter-spacing: 0.02em;
  border: 1.5px solid #cbd5e1; background: #fff; color: #334155;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.zone-chip:hover .zone-chip-label { border-color: #60a5fa; background: #f8fafc; }
.zone-chip-input:focus-visible + .zone-chip-label {
  outline: 2px solid #2563eb; outline-offset: 2px;
}
.zone-chip-input:checked + .zone-chip-label {
  background: #2563eb; border-color: #1d4ed8; color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.zone-chip-input:checked + .zone-chip-label:hover { background: #1d4ed8; }
.order-analysis-zone-chips .stat-note { font-size: 0.85rem; color: #94a3b8; padding: 4px 0; }
.order-analysis-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding-top: 4px; border-top: 1px solid #e5e7eb;
}
.order-analysis-view-toggle { display: flex; align-items: flex-end; }
.order-analysis-view-toggle .filter-btn {
  padding: 8px 14px; font-size: 0.85rem; white-space: nowrap;
  border-radius: 8px; border: 1px solid #d1d5db; background: #fff; color: #374151; cursor: pointer;
}
.order-analysis-view-toggle .filter-btn:hover { background: #f3f4f6; }
.order-analysis-view-toggle .filter-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.order-analysis-toolbar label {
  display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; font-weight: 500; color: #374151;
}
.order-analysis-customer-field { flex: 1 1 200px; min-width: 180px; }
.batch-customer-field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.customer-combobox { position: relative; width: 100%; }
.combobox-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}
.combobox-trigger:hover { border-color: #9ca3af; }
.combobox-trigger-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-chevron { color: #6b7280; font-size: 0.75rem; flex-shrink: 0; }
.combobox-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.combobox-panel.hidden { display: none; }
.combobox-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
  box-sizing: border-box;
  outline: none;
}
.combobox-options { max-height: 240px; overflow-y: auto; }
.combobox-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.88rem;
  cursor: pointer;
  color: #111827;
}
.combobox-option:hover,
.combobox-option:focus { background: #eff6ff; outline: none; }
.combobox-empty-msg { padding: 12px; color: #6b7280; font-size: 0.85rem; text-align: center; }
.combobox-native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.order-analysis-customer-field .customer-combobox { min-width: 180px; }
.batch-customer-field .combobox-trigger { min-width: 200px; }
.modal .combobox-panel { z-index: 1200; }
.order-analysis-toolbar select,
.order-analysis-toolbar input[type="number"] {
  min-width: 100px; padding: 8px 10px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 0.9rem; background: #fff;
}
.order-analysis-apply-btn { align-self: flex-end; padding: 8px 18px; min-height: 38px; }
.order-analysis-summary {
  font-size: 0.85rem; color: #6b7280; margin-bottom: 8px; padding: 8px 12px;
  background: #f9fafb; border-radius: 8px; border: 1px solid #f3f4f6;
}
.order-analysis-list { max-height: min(60vh, 480px); overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
.order-analysis-list .stat-row { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; align-items: center; gap: 8px; }
.order-analysis-list .stat-row:last-child { border-bottom: none; }
.order-analysis-list .order-analysis-meta { font-size: 0.8rem; color: #6b7280; display: block; margin-top: 2px; }
.order-analysis-list .btn { flex-shrink: 0; }

/* Product sales analysis */
#product-sales-modal .modal-content-wide { max-width: min(1100px, 98vw); }
.product-sales-toolbar label { font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; }
.product-sales-toolbar input[type="date"],
.product-sales-toolbar input[type="text"],
.product-sales-toolbar input[type="number"],
.product-sales-toolbar select { padding: 6px 8px; border-radius: 6px; border: 1px solid #d1d5db; min-height: 36px; }
.product-sales-rank-field { font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; min-width: 72px; }
.product-sales-rank-field input { width: 4.5rem; }
.product-sales-rank { text-align: right; font-weight: 600; color: #6b7280; font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; width: 2.5rem; }
.product-sales-list { max-height: min(65vh, 560px); overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
.product-sales-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.product-sales-table th,
.product-sales-table td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; text-align: left; vertical-align: middle; }
.product-sales-table th { background: #f9fafb; font-size: 0.8rem; color: #6b7280; position: sticky; top: 0; z-index: 1; }
.product-sales-table tr.product-sales-row { cursor: pointer; }
.product-sales-table tr.product-sales-row:hover { background: #f9fafb; }
.product-sales-table tr.product-sales-row.expanded { background: #eff6ff; }
.product-sales-img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: #f3f4f6; border: 1px solid #e5e7eb; }
.product-sales-img.placeholder { opacity: 0.35; }
.product-sales-code { font-weight: 600; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.product-sales-name { color: #374151; font-size: 0.85rem; max-width: 220px; }
.product-sales-num { text-align: right; white-space: nowrap; }
.product-sales-detail td { background: #f8fafc; padding: 0; }
.product-sales-detail-inner { padding: 10px 12px 12px 56px; font-size: 0.82rem; }
.product-sales-detail-table { width: 100%; border-collapse: collapse; }
.product-sales-detail-table th,
.product-sales-detail-table td { padding: 4px 8px; border-bottom: 1px solid #e5e7eb; }
.product-sales-detail-table th { color: #6b7280; font-weight: 600; text-align: left; }
.product-sales-loading { padding: 16px; color: #6b7280; text-align: center; }
.product-sales-stand-swap-wrap { margin: 8px 0 4px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.stand-swap-period-field { font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; color: #374151; }
.stand-swap-period-inputs { display: flex; align-items: center; gap: 6px; }
.stand-swap-period-field input[type="number"] {
  width: 4rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  min-height: 36px;
  font-size: 0.9rem;
}
.stand-swap-period-suffix { color: #6b7280; font-size: 0.85rem; }
.product-sales-stand-swap-panel { margin: 12px 0 16px; padding: 12px 14px; border: 1px solid #dbeafe; border-radius: 8px; background: #f8fafc; }
.product-sales-stand-swap-title { margin: 0 0 6px; font-size: 1rem; color: #1e3a8a; }
.product-sales-stand-swap-list { max-height: min(40vh, 360px); overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
.stand-swap-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.stand-swap-table th,
.stand-swap-table td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; text-align: left; vertical-align: middle; }
.stand-swap-table th { background: #f9fafb; font-size: 0.78rem; color: #6b7280; position: sticky; top: 0; z-index: 1; }
.stand-swap-table tr.stand-swap-row.expanded { background: #eff6ff; }
.stand-swap-product-clickable { cursor: pointer; border-radius: 6px; }
.stand-swap-product-clickable:hover { background: #f0f9ff; }
.stand-swap-detail td { background: #f8fafc; padding: 0; }
.stand-swap-detail-inner { padding: 10px 12px 12px; font-size: 0.82rem; }
.stand-swap-history-summary { margin-bottom: 8px; color: #374151; line-height: 1.4; }
.stand-swap-history-empty { color: #6b7280; padding: 8px 0; }
.stand-swap-history-table { width: 100%; border-collapse: collapse; }
.stand-swap-history-table th,
.stand-swap-history-table td { padding: 4px 8px; border-bottom: 1px solid #e5e7eb; text-align: left; }
.stand-swap-history-table th { color: #6b7280; font-weight: 600; font-size: 0.78rem; }
.stand-swap-product { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stand-swap-product-meta { min-width: 0; }
.stand-swap-arrow { color: #6b7280; font-size: 1.1rem; text-align: center; }
.stand-swap-reason { color: #4b5563; font-size: 0.8rem; line-height: 1.35; max-width: 220px; }
.stand-swap-side { text-transform: capitalize; font-weight: 600; color: #374151; }
.stand-swap-num { text-align: right; white-space: nowrap; }

.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.stat-label { font-size: 0.8rem; color: #6b7280; margin-bottom: 4px; }
.stat-value { font-size: 1.25rem; font-weight: 700; color: #111; }
.stat-sub { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
.dashboard-custom-dates { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dashboard-custom-dates label { font-size: 0.85rem; display: flex; align-items: center; gap: 4px; }
.dashboard-custom-dates input[type="date"] { padding: 4px 8px; border-radius: 6px; border: 1px solid #d1d5db; }
.dashboard-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .dashboard-extra { grid-template-columns: 1fr; } }
.stat-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; }
.stat-section h4 { margin: 0 0 10px; font-size: 0.95rem; }
.stat-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; }
.stat-row span { color: #6b7280; }
.top-customers-list { max-height: 200px; overflow-y: auto; font-size: 0.9rem; }
.top-customers-list .stat-row { padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
.small-btn { padding: 6px 12px; font-size: 0.85rem; }

/* Products view in review tab */
.products-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 70vh;
  background: #f9fafb;
}

.products-toolbar {
  padding: 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.products-toolbar .search-input {
  width: 100%;
  max-width: 400px;
  margin-bottom: 12px;
}

.category-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-btn {
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.category-btn:hover {
  background: #f3f4f6;
}

.category-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.products-grid-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-height: 400px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  max-width: 1400px;
}

.product-tile {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s ease;
}

.product-tile:hover {
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.product-tile img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  margin-bottom: 8px;
  background: #fafafa;
  border-radius: 6px;
}

.product-code {
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: #111;
}

.product-name {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.4em;
}

.product-price {
  font-size: 0.9rem;
  color: #333;
  margin-bottom: 8px;
  font-weight: 600;
}

.product-qty-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.qty-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  color: #374151;
  transition: all 0.15s ease;
}

.qty-btn:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.qty-display {
  min-width: 35px;
  text-align: center;
  font-weight: bold;
  font-size: 0.95rem;
  color: #111;
}


.menu-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* Product Edit Modal - iOS Style */
.modal-product-edit { max-width: 480px; }
.product-edit-body { padding: 0; }

.pe-section {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.pe-section:last-of-type { border-bottom: none; }

.pe-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
}

.pe-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}
.pe-info-row:last-child { border-bottom: none; }

.pe-label {
  font-weight: 500;
  color: #374151;
  font-size: 0.9rem;
}
.pe-value {
  color: #111827;
  font-size: 0.9rem;
}

.pe-field { margin-bottom: 16px; }
.pe-field:last-child { margin-bottom: 0; }

.pe-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.pe-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #f97316;
  background: rgba(249, 115, 22, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.pe-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.pe-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.pe-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pe-currency {
  font-weight: 500;
  color: #374151;
  font-size: 1rem;
}
.pe-price-input { flex: 1; }
.pe-clear-btn {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}
.pe-clear-btn:hover { color: #dc2626; }

.pe-price-info {
  font-size: 0.8rem;
  text-align: right;
  line-height: 1.4;
}
.pe-price-info .using { color: #22c55e; font-weight: 600; display: block; }
.pe-price-info .default { color: #6b7280; display: block; }

.pe-hint {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 4px;
}

.pe-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}
.pe-toggle input[type="checkbox"] {
  margin-top: 4px;
  transform: scale(1.2);
  accent-color: #ef4444;
}
.pe-toggle-text { flex: 1; }
.pe-toggle-title { font-weight: 500; display: block; color: #111827; }
.pe-toggle-subtitle { font-size: 0.85rem; color: #6b7280; display: block; margin-top: 2px; }

.pe-disable-warning {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #f97316;
  padding: 8px 12px;
  background: rgba(249, 115, 22, 0.08);
  border-radius: 6px;
}

.pe-footer {
  padding: 16px 20px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}
.pe-footer-hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 0 0 12px;
}
.pe-footer-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Show Discontinued button */
.discontinued-btn {
  border-color: #f97316;
  color: #f97316;
}
.discontinued-btn:hover {
  background: rgba(249, 115, 22, 0.1);
}
.discontinued-btn.active {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
}

/* Image Zoom Modal */
.image-zoom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-zoom-modal.hidden {
  display: none;
}

.image-zoom-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.image-zoom-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  z-index: 10001;
}

.image-zoom-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  display: block;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  cursor: grab;
  transition: transform 0.1s ease-out;
  user-select: none;
}

.image-zoom-img.dragging {
  cursor: grabbing;
}

.image-zoom-img.zoomed {
  cursor: move;
}

.image-zoom-close {
  position: absolute;
  top: -45px;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #111;
  font-size: 32px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.2s;
}

.image-zoom-close:hover {
  background: #fff;
}

.image-zoom-reset {
  position: absolute;
  top: -45px;
  right: 50px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #111;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.image-zoom-reset:hover {
  background: #fff;
}

.image-zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.image-zoom-controls button {
  background: #fff;
  border: 1px solid #ddd;
  color: #111;
  font-size: 18px;
  font-weight: bold;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.image-zoom-controls button:hover {
  background: #f3f4f6;
  border-color: #999;
}

.zoom-level {
  font-size: 13px;
  font-weight: 600;
  color: #111;
  min-width: 50px;
  text-align: center;
}

/* Clickable cursor on stand image */
.batch-stand-image.loaded {
  cursor: zoom-in;
}

/* Assign Side Modal */
.assign-side-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.assign-side-btn {
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
}

#assign-side-skip {
  width: 100%;
  margin-top: 8px;
}

.list-item-void {
  opacity: 0.55;
  background: #f3f4f6;
}

.list-item-void .list-item-title,
.list-item-void .list-item-subtitle {
  color: #6b7280;
}

.order-void-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #6b7280;
  background: #e5e7eb;
  border-radius: 4px;
  vertical-align: middle;
}
