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

:root {
  --primary: #c5132b;
  --primary-dark: #8f0f20;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e0e3ea;
  --text: #2d3142;
  --muted: #6c757d;
  --radius: 10px;
  --surface: #f0f2f5;
  --accent: #e8475f;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ── */
header { background: linear-gradient(135deg, #e11d35 0%, #c5132b 55%, #8f0f20 100%); color: #fff; padding: 0 20px; box-shadow: 0 2px 8px rgba(143,15,32,.35); }
.header-inner { max-width: 1100px; margin: 0 auto; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 700; letter-spacing: .3px; }
.logo .logo-mark { width: 30px; height: 30px; display: block; }

.stats-bar { display: flex; gap: 16px; }
.stat { font-size: .85rem; background: rgba(255,255,255,.18); padding: 3px 10px; border-radius: 20px; }
.stat span { font-weight: 700; }
.stat.pending { background: rgba(243,156,18,.35); }
.stat.packed  { background: rgba(39,174,96,.35); }

/* ── Tabs ── */
.tabs { background: #fff; border-bottom: 2px solid var(--border); display: flex; max-width: 1100px; margin: 0 auto; }
.tab { flex: 1; max-width: 200px; padding: 14px 0; background: none; border: none; font-size: .95rem; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: color .2s, border-color .2s; font-weight: 500; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

/* ── Tab content ── */
.tab-content { display: none; max-width: 1100px; margin: 0 auto; padding: 24px 16px; gap: 20px; }
.tab-content.active { display: flex; flex-direction: column; }

/* ── Card ── */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.card h2 { font-size: 1.15rem; margin-bottom: 18px; color: var(--text); }
.card h3 { font-size: 1rem; margin-bottom: 14px; color: var(--text); }

/* ── Scan mode toggle ── */
.scan-mode-toggle { display: flex; gap: 8px; margin-bottom: 20px; }
.mode-btn { padding: 7px 18px; border-radius: 6px; border: 2px solid var(--border); background: #fff; color: var(--muted); cursor: pointer; font-size: .9rem; font-weight: 500; transition: all .2s; }
.mode-btn.active { border-color: var(--primary); color: var(--primary); background: #fff0f3; }

/* ── Camera reader ── */
#reader { border-radius: 8px; overflow: hidden; max-width: 500px; margin-bottom: 12px; }
#reader video { border-radius: 8px; }
.camera-controls { display: flex; gap: 10px; margin-bottom: 4px; }

/* ── Manual input ── */
.hint { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.input-row { display: flex; gap: 10px; }
.input-row input { flex: 1; padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px; font-size: 1rem; outline: none; transition: border-color .2s; }
.input-row input:focus { border-color: var(--primary); }

/* ── Buttons ── */
.btn { padding: 9px 20px; border-radius: 8px; border: none; cursor: pointer; font-size: .9rem; font-weight: 600; transition: all .15s; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-secondary { background: #eee; color: var(--text); }
.btn-secondary:hover { background: #ddd; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #219a52; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #c0392b; }
.btn-outline  { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover  { background: #fff0f3; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }

/* ── Result box ── */
.result-box { margin-top: 20px; border: 2px solid var(--success); border-radius: var(--radius); padding: 16px; background: #f0faf5; }
.result-box.error { border-color: var(--danger); background: #fff5f5; }
.result-header { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; margin-bottom: 12px; color: var(--success); }
.result-box.error .result-header { color: var(--danger); }
.result-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 14px; }
.result-table th { text-align: left; padding: 5px 10px 5px 0; color: var(--muted); width: 90px; font-weight: 600; }
.result-table td { padding: 5px 0; font-weight: 500; }
.result-actions { display: flex; gap: 8px; }
.hidden { display: none !important; }

/* ── Recent list ── (layout in section above) ── */
.badge { padding: 2px 8px; border-radius: 12px; font-size: .75rem; font-weight: 700; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-packed  { background: #d1e7dd; color: #0a5032; }

/* ── Items table ── */
.items-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.filter-row { display: flex; gap: 10px; align-items: center; }
.filter-row select { padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: .88rem; }
#items-table-wrap { overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.items-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.items-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.items-table tr:last-child td { border-bottom: none; }
.items-table tr:hover td { background: #fafafa; }
.items-table input.edit-field { border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font-size: .85rem; width: 100%; }
.mono { font-family: monospace; font-size: .85rem; }
.empty-msg { text-align: center; color: var(--muted); padding: 30px; }

/* ── Tracking tab ── */
.sub { color: var(--muted); font-size: .92rem; margin-bottom: 18px; }
.info-box { background: #fff8e1; border-left: 4px solid var(--warning); padding: 12px 16px; border-radius: 6px; font-size: .9rem; margin-bottom: 16px; color: #5d4037; }
.steps-list { padding-left: 20px; display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.steps-list li { padding: 10px 14px; background: #f8f9fa; border-radius: 8px; border: 1px solid var(--border); font-size: .9rem; line-height: 1.5; }
.steps-list li strong { color: var(--text); }

.explainer { margin-top: 28px; display: flex; flex-direction: column; gap: 18px; }
.explainer h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.barcode-types { display: flex; gap: 14px; flex-wrap: wrap; }
.btype { flex: 1; min-width: 220px; display: flex; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #fafafa; }
.btype-icon { font-size: 2rem; line-height: 1; }
.btype-info { display: flex; flex-direction: column; gap: 5px; }
.btype-info p { font-size: .85rem; color: var(--muted); line-height: 1.5; }
.btype-info code { font-size: .8rem; background: #eee; padding: 2px 6px; border-radius: 4px; color: var(--primary); }

.steps-visual { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.step-box { flex: 1; min-width: 150px; display: flex; align-items: flex-start; gap: 10px; padding: 12px; background: #fff0f3; border: 1px solid #f8c8d0; border-radius: 8px; font-size: .85rem; line-height: 1.5; }
.step-num { background: var(--primary); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.step-arrow { color: var(--primary); font-size: 1.4rem; font-weight: 700; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #2d3142; color: #fff; padding: 12px 24px; border-radius: 8px; font-size: .9rem; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 9999; transition: opacity .3s; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── Barcode card (tracking tab + OCR candidates) ── */
.barcode-card {
  border: 2px solid var(--success); border-radius: var(--radius);
  background: #f0faf5; padding: 18px; margin-top: 16px;
}
.barcode-card-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.barcode-ready-badge {
  background: var(--success); color: #fff; padding: 3px 12px;
  border-radius: 20px; font-size: .8rem; font-weight: 700;
}
.tracking-badge {
  background: #d1e7dd; color: #0a5032; padding: 2px 8px;
  border-radius: 10px; font-size: .75rem; font-weight: 700;
}
.barcode-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.barcode-code-label {
  font-family: monospace; font-size: 1rem; font-weight: 700;
  color: var(--text); margin-bottom: 10px; letter-spacing: 1px;
}
.barcode-img {
  display: block; max-width: 100%; height: auto;
  border-radius: 6px; background: #fff; padding: 8px;
  border: 1px solid var(--border);
}
.cand-barcode-img {
  display: block; max-width: 100%; max-height: 90px; margin-top: 10px;
  border-radius: 4px; background: #fff; padding: 6px;
  border: 1px solid var(--border);
}
.ocr-cand-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}

/* ── Live Auto-Detect ── */
.live-viewport {
  position: relative; width: 100%; max-width: 520px;
  border-radius: 10px; overflow: hidden; background: #000;
}
#live-video { width: 100%; display: block; border-radius: 10px; }
#live-region-canvas { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; border-radius:10px; }

.live-overlay {
  position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.scan-frame {
  width: 72%; aspect-ratio: 3/1.2; position: relative;
  border-radius: 6px;
}
.corner {
  position: absolute; width: 22px; height: 22px;
  border-color: #fff; border-style: solid; border-width: 0;
}
.corner.tl { top:0; left:0;  border-top-width:3px; border-left-width:3px;  border-top-left-radius:4px; }
.corner.tr { top:0; right:0; border-top-width:3px; border-right-width:3px; border-top-right-radius:4px; }
.corner.bl { bottom:0; left:0;  border-bottom-width:3px; border-left-width:3px;  border-bottom-left-radius:4px; }
.corner.br { bottom:0; right:0; border-bottom-width:3px; border-right-width:3px; border-bottom-right-radius:4px; }

.live-status {
  margin-top: 12px; background: rgba(0,0,0,.55); color: #fff;
  font-size: .82rem; padding: 4px 14px; border-radius: 20px;
  letter-spacing: .3px; white-space: nowrap;
}
.live-status.scanning { background: rgba(232,71,95,.75); animation: pulse-bg 1s ease infinite; }
.live-status.found    { background: rgba(39,174,96,.85); }

@keyframes pulse-bg { 0%,100%{opacity:1} 50%{opacity:.6} }

.live-pulse {
  position: absolute; inset: 0; border: 4px solid var(--success);
  border-radius: 10px; animation: pulse-border .5s ease-out forwards;
  pointer-events: none;
}
@keyframes pulse-border {
  0%   { opacity:1; transform:scale(1); }
  100% { opacity:0; transform:scale(1.04); }
}

.live-controls {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
  flex-wrap: wrap;
}
.live-toggle-wrap {
  display: flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--muted); cursor: pointer;
}

.live-results {
  margin-top: 16px; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.live-results-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #f8f9fa;
  border-bottom: 1px solid var(--border); font-size: .9rem;
}
.live-result-item {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  animation: slide-in .25s ease;
}
.live-result-item:last-child { border-bottom: none; }
@keyframes slide-in { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:none} }
.live-result-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.live-result-meta { display: flex; align-items: center; gap: 8px; }
.live-result-actions { display: flex; gap: 6px; }
.live-result-barcode { max-height: 70px; border-radius: 4px; background:#fff; padding:4px; border:1px solid var(--border); }
.live-source-badge {
  font-size:.7rem; padding:2px 7px; border-radius:10px; font-weight:700;
  background:#e8f4fd; color:#0c5460;
}
.live-source-badge.ocr { background:#fff3cd; color:#856404; }

.live-result-group { margin-bottom: 8px; }
.live-result-best {
  border-left: 4px solid var(--success);
  background: #f0faf5;
}
.best-badge {
  background: var(--success); color: #fff;
  font-size: .7rem; padding: 2px 8px; border-radius: 10px;
  font-weight: 700; flex-shrink: 0;
}

/* ── OCR Tab ── */
.ocr-source-toggle { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

.upload-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 32px 20px; border: 2px dashed var(--border); border-radius: 10px;
  cursor: pointer; background: #fafafa; transition: border-color .2s, background .2s;
  text-align: center; color: var(--muted); font-size: .9rem;
}
.upload-label:hover { border-color: var(--primary); background: #fff0f3; }
.upload-icon { font-size: 2.2rem; }
.upload-hint { font-size: .78rem; color: #aaa; }

#ocr-video { width: 100%; max-width: 480px; border-radius: 8px; background: #000; display: block; }

.ocr-preview-img { max-width: 100%; max-height: 320px; border-radius: 8px;
  border: 2px solid var(--border); display: block; object-fit: contain; }
.ocr-btn-row { display: flex; gap: 10px; margin-top: 12px; }

.ocr-loading { display: flex; align-items: center; gap: 14px; padding: 18px 0;
  color: var(--muted); font-size: .9rem; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.ocr-candidates { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.ocr-candidate {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; background: #f8f9fa;
}
.ocr-candidate .sku-val { font-family: monospace; font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.ocr-candidate .sku-type { font-size: .78rem; color: var(--muted); background: #eee;
  padding: 2px 8px; border-radius: 10px; }
.ocr-candidate-actions { display: flex; gap: 8px; }

.ocr-summary { cursor: pointer; color: var(--muted); font-size: .85rem;
  padding: 6px 0; user-select: none; }
.ocr-raw { font-family: monospace; font-size: .82rem; background: #f4f4f4;
  border-radius: 6px; padding: 10px 14px; margin-top: 8px; white-space: pre-wrap;
  word-break: break-all; color: var(--text); max-height: 160px; overflow-y: auto; }
.ocr-lines { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.ocr-line { display: flex; justify-content: space-between; gap: 12px;
  font-size: .82rem; padding: 4px 10px; background: #fafafa; border-radius: 4px; }
.ocr-line .conf { color: var(--muted); flex-shrink: 0; }
.ocr-line .conf.high { color: var(--success); }
.ocr-line .conf.low  { color: var(--danger); }

/* ── Product info card ── */
.pi-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin: 0;
}
.pi-img {
  width: 54px; height: 54px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
  flex-shrink: 0; background: #f0f0f0;
}
.pi-img-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; background: #e8e8e8;
}
.pi-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pi-name { font-weight: 700; font-size: .95rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-row { display: flex; align-items: center; gap: 6px; font-size: .82rem; }
.pi-label { color: var(--muted); min-width: 30px; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; }
.pi-val { font-weight: 600; color: var(--text); }
.pi-sku { font-family: monospace; font-size: .82rem; color: var(--primary); }

/* ── Products Tab ── */
.prod-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2); overflow: hidden;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; margin: 0; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.form-grid input, .form-grid textarea {
  padding: 8px 12px; border: 2px solid var(--border); border-radius: 7px;
  font-size: .9rem; outline: none; transition: border-color .2s; font-family: inherit;
}
.form-grid input:focus, .form-grid textarea:focus { border-color: var(--primary); }
.form-grid textarea { resize: vertical; min-height: 56px; }
.req { color: var(--primary); }

/* CSV import result message */
.import-ok  { color: var(--success); font-weight: 600; }
.import-err { color: var(--danger);  font-weight: 600; }

/* ── OCR Training Tab ── */
.train-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.train-canvas-card, .train-configs-card { height: fit-content; }

.train-upload-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

.train-canvas-wrap {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  min-height: 120px;
  cursor: crosshair;
}
#train-canvas { display: block; max-width: 100%; }
.train-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #888; font-size: .9rem; pointer-events: none;
}

.train-label-picker {
  margin-top: 12px; padding: 12px 14px;
  background: #fff8e1; border: 1px solid #ffe082; border-radius: 8px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .88rem;
}
.label-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.label-btn {
  padding: 5px 12px; border-radius: 6px; border: 2px solid var(--border);
  background: #fff; cursor: pointer; font-size: .82rem; font-weight: 600;
  transition: all .15s;
}
.label-btn:hover { border-color: var(--primary); color: var(--primary); background: #fff0f3; }
.label-btn[data-label="SKU"]           { border-color: #4caf50; color: #2e7d32; }
.label-btn[data-label="Shipment Code"] { border-color: #2196f3; color: #1565c0; }
.label-btn[data-label="Batch Barcode"] { border-color: #ff9800; color: #e65100; }
.label-btn[data-label="Tracking"]      { border-color: #9c27b0; color: #6a1b9a; }

.train-save-row { display: flex; gap: 10px; margin-top: 16px; }
.train-save-row input { flex: 1; padding: 9px 14px; border: 2px solid var(--border); border-radius: 8px; font-size: .9rem; }
.train-save-row input:focus { border-color: var(--primary); outline: none; }

/* Configs list */
.config-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 10px;
  transition: border-color .2s;
}
.config-item.active-config { border-color: var(--success); background: #f0faf5; }
.config-item-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.config-name { font-weight: 700; font-size: .95rem; }
.config-active-badge {
  background: var(--success); color: #fff;
  font-size: .7rem; padding: 2px 8px; border-radius: 10px; font-weight: 700;
}
.config-regions { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.region-chip {
  font-size: .75rem; padding: 2px 8px; border-radius: 10px;
  font-weight: 600; border: 1px solid;
}
.region-chip-SKU            { background:#e8f5e9; color:#2e7d32; border-color:#a5d6a7; }
.region-chip-Shipment\ Code { background:#e3f2fd; color:#1565c0; border-color:#90caf9; }
.region-chip-Batch\ Barcode { background:#fff3e0; color:#e65100; border-color:#ffcc80; }
.region-chip-Tracking       { background:#f3e5f5; color:#6a1b9a; border-color:#ce93d8; }
.region-chip-Any\ Text      { background:#f5f5f5; color:#424242; border-color:#bdbdbd; }
.config-actions { display: flex; gap: 6px; }
.cfg-preview-canvas {
  width: 100%; height: auto; border-radius: 6px;
  border: 1px solid var(--border); display: block; margin-bottom: 4px;
  background: #f0f0f0;
}

.ocr-config-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--success); font-weight: 600;
  background: #e8f5e9; padding: 3px 10px; border-radius: 10px; margin-bottom: 10px;
}

/* ── Scan session list (Scan tab) ── */
.scan-session-card { padding: 20px; }
.scan-session-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.scan-session-header h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.recent-count-badge {
  background: var(--primary); color: #fff;
  font-size: .72rem; padding: 1px 8px; border-radius: 10px; font-weight: 700;
}
#scan-session-list { display: flex; flex-direction: column; gap: 10px; max-height: 620px; overflow-y: auto; }
.scan-session-empty {
  text-align: center; color: var(--muted); font-size: .88rem;
  padding: 32px 16px; border: 2px dashed var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.scan-session-item {
  border-radius: 10px; border: 1px solid var(--border);
  overflow: hidden; animation: slide-in .22s ease;
  background: #fff;
}
.scan-item-new { border-color: #a5d6a7; }
.scan-item-dup { border-color: #ffe082; }
@keyframes scan-flash-bg {
  0%   { background: #fff9c4; }
  100% { background: transparent; }
}
.scan-item-flash { animation: scan-flash-bg 0.7s ease-out; }
.scan-item-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: #f8f9fa; border-bottom: 1px solid var(--border);
}
.scan-item-new .scan-item-header { background: #f1f8f2; }
.scan-item-dup .scan-item-header { background: #fffde7; }
.scan-item-num  { font-weight: 800; font-size: .85rem; color: var(--primary); min-width: 28px; }
.scan-item-time { font-size: .76rem; color: var(--muted); }
.status-new { background: #d1e7dd; color: #0a5032; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.status-dup { background: #fff3cd; color: #856404; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.scan-item-actions { margin-left: auto; display: flex; gap: 6px; }
.scan-item-body {
  padding: 10px 14px; display: flex; align-items: center;
  flex-wrap: wrap; gap: 8px; font-size: .88rem;
}
.scan-item-type { font-size: .75rem; color: var(--muted); background: #eee; padding: 1px 7px; border-radius: 8px; }
/* shared util */
.barcode-val { font-family: monospace; font-weight: 700; color: var(--primary); font-size: 1.3rem; }
.ri-sku  { font-size: .8rem; color: var(--muted); font-family: monospace; }
.ri-tag  { font-size: .75rem; background: #eee; padding: 1px 6px; border-radius: 8px; color: var(--muted); }
.ri-time { font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* ── Order products in scan result ── */
.op-order { padding: 10px 14px; border-top: 1px solid var(--border); }
.op-order-num { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.op-cid   { font-size: 22px; font-weight: 800; background: var(--primary); color: #fff; padding: 1px 7px; border-radius: 10px; }
.op-onum  { font-size: .78rem; font-weight: 700; color: var(--muted); }
.op-cname { font-size: .78rem; color: var(--muted); }
.op-items { display: flex; flex-wrap: wrap; gap: 8px; }
.op-item { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 90px; }
.op-item-scanned { outline: 2px solid var(--primary); border-radius: 8px; padding: 3px; background: #eef4ff; }
.op-img { width: 80px; height: 80px; object-fit: cover; border-radius: 7px; border: 1px solid var(--border); }
.op-img-ph { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; background: #f0f0f0; border-radius: 7px; font-size: 2rem; }
.op-sku { font-size: .78rem; font-family: monospace; color: var(--muted); text-align: center; word-break: break-all; max-width: 90px; font-weight: 600; }
.op-item-done { opacity: 0.55; }
.op-badge { font-size: .6rem; font-weight: 700; padding: 1px 5px; border-radius: 8px; }
.op-badge-new  { background: #d1e7dd; color: #0a5032; }
.op-badge-done { background: #e2e8f0; color: #64748b; }
.op-badge-link { background: #fde2e2; color: #8f0f20; }
.op-link { text-decoration: none; display: inline-block; cursor: pointer; transition: transform .12s; }
.op-link:hover { transform: translateY(-2px); }
.op-link:hover .op-img, .op-link:hover .op-img-ph { border-color: var(--primary); box-shadow: 0 2px 8px rgba(143,15,32,.25); }
.op-item-order { outline: 2px dashed var(--primary); border-radius: 8px; padding: 3px; }

/* ── OCR scan group (accumulated results) ── */
.ocr-scan-group {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  margin-bottom: 12px; animation: slide-in .25s ease;
}
.ocr-scan-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: #f0f2f5;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.ocr-scan-num  { font-weight: 800; font-size: .88rem; color: var(--primary); }
.ocr-scan-time { font-size: .78rem; color: var(--muted); }
.ocr-scan-found { font-size: .78rem; background: #d1e7dd; color: #0a5032; padding: 1px 8px; border-radius: 10px; font-weight: 600; }
.ocr-scan-none  { background: #f8d7da; color: #842029; }
.ocr-scan-group .ocr-candidates { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.ocr-scan-group-empty { border-color: #f0c0c5; }
.ocr-scan-group-empty .ocr-scan-group-header { background: #fff5f6; }
.ocr-raw-details { padding: 0 12px 10px; }
.ocr-no-result-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.ocr-no-result-text { font-size: .83rem; color: var(--muted); }
.ocr-no-result-label { font-weight: 700; color: var(--text); }
.ocr-no-result-hint {
  font-size: .82rem; background: #fff3cd; border: 1px solid #ffe082;
  border-radius: 7px; padding: 8px 12px; color: #856404;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}

/* ── Session bar (Scan tab top) ── */
.session-bar {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 14px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); flex-wrap: wrap;
}
.session-stat-box { text-align: center; min-width: 72px; }
.session-count { font-size: 2.4rem; font-weight: 800; color: var(--primary); line-height: 1; }
.session-count-label { font-size: .68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin-top: 3px; }
.session-divider { width: 1px; height: 52px; background: var(--border); flex-shrink: 0; }
.customer-panel { flex: 1; min-width: 180px; }
.customer-no-set { font-size: .88rem; color: var(--muted); font-style: italic; }
.customer-set { display: flex; align-items: center; gap: 12px; }
.customer-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 800; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(46,196,182,.35);
}
.customer-details { display: flex; flex-direction: column; gap: 1px; }
.customer-cid   { font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.customer-name  { font-size: .97rem; font-weight: 700; color: var(--text); }
.customer-phone { font-size: .8rem; color: var(--muted); }

/* ── Merged scanner two-column layout ── */
.scanner-two-col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; align-items: start;
}
/* Items list on left (visually first), scanner/OCR on right */
.scanner-left-col  { display: flex; flex-direction: column; gap: 16px; order: 2; }
.scanner-right-col { order: 1; position: sticky; top: 16px; }
.scanner-section-label {
  font-weight: 700; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
@media (max-width: 800px) {
  .scanner-two-col { grid-template-columns: 1fr; }
  .scanner-left-col  { order: 2; }
  .scanner-right-col { order: 1; position: static; }
}

/* ── Not-found scan card ── */
.scan-item-not-found { border-color: #f5c6cb; background: #fff5f5; }
.scan-item-not-found .scan-item-header { background: #fff0f2; }
.status-notfound {
  background: #f8d7da; color: #842029;
  font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 10px;
}
.scan-item-notfound-body {
  padding: 10px 14px; color: #842029; font-size: .88rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}

/* ── Order Status Panel ── */
#order-status-panel { margin-bottom: 4px; }
.order-status-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 10px; flex-wrap: wrap; gap: 8px;
}
.order-status-title {
  font-weight: 700; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
}
.order-select-all-wrap {
  display: flex; align-items: center; gap: 5px;
  font-size: .82rem; color: var(--muted); cursor: pointer;
}
#order-status-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.order-status-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fafafa;
  transition: background .15s, border-color .15s;
}
.order-status-row:hover { background: #f0faf9; border-color: var(--primary); }
.order-status-row.order-notified { background: #f0faf5; border-color: #a5d6a7; opacity: .85; }
.order-checkbox { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.order-status-info { flex: 1; min-width: 0; }
.order-status-num  { font-weight: 700; font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-status-customer { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-status-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 9px;
  border-radius: 10px; white-space: nowrap; flex-shrink: 0;
}
.order-status-badge.status-pending   { background: #fff3cd; color: #856404; }
.order-status-badge.status-delivered { background: #d1e7dd; color: #0a5032; }
.order-status-badge.status-cancelled { background: #f8d7da; color: #842029; }
.order-status-badge.status-scanned   { background: #cff4fc; color: #055160; }
.order-status-badge { background: #e9ecef; color: #495057; }
.order-status-count { font-size: .75rem; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.order-notified-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; background: #d1e7dd; color: #0a5032; flex-shrink: 0;
}
.order-status-divider { height: 1px; background: var(--border); margin: 4px 0 14px; }

/* ── OCR two-column layout ── */
.ocr-tab-header { margin-bottom: 18px; }
.ocr-two-col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; align-items: start;
}
.ocr-left-col { display: flex; flex-direction: column; gap: 14px; }
.ocr-right-col {
  display: flex; flex-direction: column; gap: 14px;
  border-left: 1px solid var(--border); padding-left: 22px;
  min-height: 340px;
}
.ocr-right-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.ocr-right-header h3 { margin: 0; font-size: 1rem; }
.ocr-results-label {
  font-size: .8rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.ocr-results-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; flex: 1; min-height: 260px;
  color: var(--muted); font-size: .88rem; text-align: center;
  border: 2px dashed var(--border); border-radius: 10px;
}
.ocr-results-placeholder div:first-child { font-size: 2.8rem; opacity: .6; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .train-layout { grid-template-columns: 1fr; }
  .ocr-two-col  { grid-template-columns: 1fr; }
  .ocr-right-col { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 18px; }
}

@media (max-width: 600px) {
  .header-inner { gap: 10px; }
  .stats-bar { gap: 8px; }
  .stat { font-size: .75rem; padding: 2px 8px; }
  .steps-visual { flex-direction: column; }
  .step-arrow { transform: rotate(90deg); }
  .session-bar { gap: 12px; padding: 12px 14px; }
  .session-count { font-size: 1.9rem; }
}

/* ── Order info cards (scan result) ── */
.oi-section { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.oi-title   { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.oi-row     { display: flex; gap: 10px; align-items: flex-start; padding: 8px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 8px; background: #fafafa; }
.oi-row:last-child { margin-bottom: 0; }
.oi-img     { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; border: 1px solid var(--border); }
.oi-img-placeholder { display: flex; align-items: center; justify-content: center; background: var(--surface); font-size: 1.4rem; }
.oi-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.oi-order-num { font-weight: 700; font-size: .9rem; color: var(--accent); }
.oi-sku     { font-family: monospace; font-size: .78rem; color: var(--primary); font-weight: 600; }
.oi-meta    { display: flex; flex-wrap: wrap; gap: 6px; font-size: .78rem; color: var(--muted); }
.oi-status  { font-size: .78rem; font-weight: 600; }
.oi-tracking { font-size: .74rem; color: var(--muted); font-family: monospace; }

/* ── Scan item meta (order / pallet tags) ── */
.scan-item-meta  { font-size: .78rem; color: var(--muted); margin: 3px 0 0; }
.sim-label       { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-weight: 600; margin-right: 4px; }

/* ── Scan context (Order No / Pallet No) ── */
.scan-context-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.sc-label         { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.sc-label input   { font-size: .88rem; padding: 7px 10px; border: 2px solid var(--border); border-radius: 7px; outline: none; transition: border-color .2s; font-family: inherit; width: 100%; }
.sc-label input:focus { border-color: var(--primary); }

/* ── Notify Sidebar ── */
.notify-sidebar { position: fixed; inset: 0; z-index: 2000; display: flex; justify-content: flex-end; }
.notify-sidebar.hidden { display: none; }
.notify-sidebar-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.notify-sidebar-panel {
  position: relative; width: 480px; max-width: 96vw;
  background: #fff; height: 100%; display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.18); animation: slide-from-right .25s ease;
}
@keyframes slide-from-right { from{transform:translateX(100%)} to{transform:none} }
.notify-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  background: var(--primary); color: #fff;
}
.notify-sidebar-header h3 { margin: 0; font-size: 1rem; }
.notify-sidebar-header .modal-close { color: #fff; opacity: .85; }
.notify-sidebar-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.notify-sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border); background: #f8f9fa;
  display: flex; flex-direction: column; gap: 10px;
}
.notify-footer-label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.notify-status-select {
  width: 100%; padding: 9px 12px; border: 2px solid var(--border);
  border-radius: 8px; font-size: .92rem; outline: none;
  transition: border-color .2s; background: #fff;
}
.notify-status-select:focus { border-color: var(--primary); }
.notify-footer-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Order summary card in sidebar */
.notify-order-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.notify-order-header {
  padding: 10px 14px; background: #f0faf9;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px;
}
.notify-order-num  { font-weight: 700; font-size: .95rem; color: var(--text); }
.notify-order-cust { font-size: .82rem; color: var(--muted); }
.notify-order-phone { font-size: .8rem; color: var(--primary); font-weight: 600; }
.notify-scan-progress {
  font-size: .78rem; font-weight: 700; padding: 3px 10px;
  border-radius: 10px; background: #d1faf5; color: #0a5032; flex-shrink: 0;
}
.notify-product-list { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.notify-product-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 7px; font-size: .82rem;
  border: 1px solid transparent;
}
.notify-product-row.scanned   { background: #f0faf5; border-color: #a5d6a7; }
.notify-product-row.unscanned { background: #fff5f5; border-color: #f5c6cb; }
.notify-product-img { width: 36px; height: 36px; object-fit: cover; border-radius: 5px; flex-shrink: 0; background: #f0f0f0; }
.notify-product-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notify-product-sku  { font-size: .72rem; color: var(--muted); font-family: monospace; }
.notify-scan-badge   { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 8px; flex-shrink: 0; }
.notify-scan-badge.yes { background: #d1e7dd; color: #0a5032; }
.notify-scan-badge.no  { background: #f8d7da; color: #842029; }
.notify-status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 10px;
}
.notify-loading { text-align: center; color: var(--muted); padding: 32px; font-size: .9rem; }

/* ── Orders Tab ── */
.orders-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.orders-search-input {
  padding: 8px 14px; border: 2px solid var(--border); border-radius: 8px;
  font-size: .9rem; outline: none; transition: border-color .2s; min-width: 220px;
}
.orders-search-input:focus { border-color: var(--primary); }

.order-scan-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--card); margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); transition: box-shadow .15s;
}
.order-scan-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.09); }
.order-scan-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 16px; background: #f8f9fa; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
}
.order-scan-info { display: flex; flex-direction: column; gap: 2px; }
.order-scan-num  { font-weight: 700; font-size: .95rem; color: var(--text); }
.order-scan-customer { font-size: .82rem; color: var(--muted); }
.order-scan-phone    { font-size: .78rem; color: var(--primary); font-weight: 600; }
.order-scan-city     { font-size: .78rem; color: var(--muted); }
.order-scan-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.order-scan-status {
  font-size: .78rem; font-weight: 700; padding: 4px 12px;
  border-radius: 20px; white-space: nowrap;
}
.order-scan-progress {
  font-size: .78rem; font-weight: 700; padding: 4px 12px;
  border-radius: 20px; background: #e9ecef; color: #495057; white-space: nowrap;
}
.order-scan-progress.complete { background: #d1e7dd; color: #0a5032; }
.order-scan-items { padding: 4px 16px 8px; }
.oi-row-scanned { background: #f0faf5 !important; border-color: #a5d6a7 !important; }

/* ── Product grid inside order cards ── */
.prod-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 12px 16px 14px;
}
.prod-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 90px; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px;
  background: #fafafa; transition: all .15s; cursor: pointer;
  position: relative;
}
.prod-tile:hover { border-color: var(--primary); background: #f0faf9; box-shadow: 0 2px 8px rgba(46,196,182,.15); }
.prod-tile.prod-tile-done { opacity: .6; }
.prod-tile-img-wrap { position: relative; width: 74px; height: 74px; flex-shrink: 0; }
.prod-tile-img-link { display: block; line-height: 0; border-radius: 6px; overflow: hidden; }
.prod-tile-img {
  width: 74px; height: 74px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); display: block;
  background: #f0f0f0;
}
.prod-tile-no-img {
  display: flex; align-items: center; justify-content: center;
  background: #f0f0f0; border-radius: 6px; font-size: 1.8rem;
}
.prod-tile-scanned-badge {
  position: absolute; bottom: 2px; right: 2px;
  background: var(--success); color: #fff;
  font-size: .62rem; font-weight: 700; padding: 1px 4px;
  border-radius: 4px; line-height: 1.4;
}
.prod-tile-sku {
  font-family: monospace; font-size: .7rem; font-weight: 700;
  color: var(--primary); text-align: center;
  word-break: break-all; max-width: 82px; line-height: 1.3;
}
.prod-tile-qty {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  background: #eee; padding: 1px 5px; border-radius: 8px;
}

/* ── Settings Tab ── */
.settings-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px; margin: 16px 0;
}
.settings-status-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 2px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: all .15s;
  user-select: none;
}
.settings-status-item:hover { border-color: var(--primary); background: #f0faf9; }
.settings-status-item:has(input:checked) { border-color: var(--primary); background: #eefaf8; }
.settings-status-item input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; cursor: pointer;
}
.settings-status-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.settings-status-name { font-size: .88rem; font-weight: 500; flex: 1; }
.settings-default-note {
  font-size: .82rem; color: var(--muted); font-style: italic;
  margin-bottom: 8px; padding: 8px 14px; background: #fff8e1;
  border-left: 3px solid var(--warning); border-radius: 4px;
}
