:root {
  --ink: #1d2b4a;
  --ink-2: #26375c;
  --accent: #c98a1b;
  --accent-soft: #fbf1dd;
  --surface: #f5f6f8;
  --line: #e3e6eb;
  --bs-primary: #2c4a86;
  --bs-primary-rgb: 44, 74, 134;
  --bs-link-color: #2c4a86;
  --bs-link-color-rgb: 44, 74, 134;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}
body { background: var(--surface); font-size: .95rem; }
.btn-primary { --bs-btn-bg: #2c4a86; --bs-btn-border-color: #2c4a86; --bs-btn-hover-bg: #233d70; --bs-btn-hover-border-color: #233d70; --bs-btn-active-bg: #1d335e; }
.btn-outline-primary { --bs-btn-color: #2c4a86; --bs-btn-border-color: #2c4a86; --bs-btn-hover-bg: #2c4a86; --bs-btn-hover-border-color: #2c4a86; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: 0 0 248px; background: var(--ink); color: #c9d2e3; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-offcanvas { background: var(--ink); color: #c9d2e3; width: 270px !important; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; font-weight: 650; font-size: 1.05rem; text-decoration: none; letter-spacing: .01em; }
.brand i { color: #f2b84b; font-size: 1.35rem; }
.brand:hover { color: #fff; }
.side-nav { padding: .25rem .6rem 1rem; }
.side-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: #c9d2e3; padding: .52rem .75rem; border-radius: .45rem; font-size: .92rem; }
.side-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.side-nav .nav-link:hover { background: var(--ink-2); color: #fff; }
.side-nav .nav-link.active { background: #f2b84b; color: var(--ink); font-weight: 600; }
.side-nav .nav-link.disabled { color: #6f7d99; cursor: default; }
.side-nav .nav-link.disabled .badge { background: #2f4069; color: #9aa7c2; font-weight: 500; font-size: .66rem; }
.sidebar-foot { margin-top: auto; padding: .8rem 1.25rem; color: #6f7d99; }
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 1.15rem; font-weight: 650; margin: 0; flex: 1 1 auto; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { position: relative; align-items: center; width: 280px; }
.topbar-search i { position: absolute; left: .6rem; color: #8a94a6; font-size: .85rem; }
.topbar-search input { padding-left: 1.8rem; background: var(--surface); }
.content { padding: 1.25rem; max-width: 1400px; width: 100%; }
@media (max-width: 575.98px) { .content { padding: .85rem; } .topbar { padding: .6rem .85rem; } }

.card { border: 1px solid var(--line); border-radius: .6rem; box-shadow: 0 1px 2px rgba(20, 30, 50, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--ink); }
.stat-card { padding: 1rem 1.1rem; height: 100%; }
.stat-card .stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6a7488; font-weight: 600; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--ink); line-height: 1.15; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat-card .stat-sub { font-size: .8rem; color: #6a7488; }
.stat-card .stat-icon { font-size: 1.4rem; color: var(--accent); }
.stat-card.highlight { background: var(--accent-soft); border-color: #f0dcb2; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .55rem .7rem; }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #6a7488; font-weight: 600; background: #fafbfc; border-bottom-width: 1px; white-space: nowrap; }
.table-hover tbody tr:hover { --bs-table-bg-state: #f6f8fc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.code-pill { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: #eef1f6; color: var(--ink); padding: .1rem .4rem; border-radius: .3rem; white-space: nowrap; text-decoration: none; }
a.code-pill:hover { background: #dfe5ef; }
.qty-big { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.text-available { color: #1f7a45; }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: #6a7488; }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .4rem; color: #a3acbd; }
.form-label { font-weight: 600; font-size: .85rem; color: #39445a; }
.required::after { content: " *"; color: #c0392b; }

/* Search results */
.result-card { border-left: 4px solid #2c4a86; }
.result-card.out { border-left-color: #adb5bd; }
.copy-row { display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.copy-row:last-child { border-bottom: 0; }
.box-chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--accent-soft); border: 1px solid #f0dcb2; color: #7a5410; border-radius: 2rem; padding: .1rem .6rem; font-size: .82rem; font-weight: 600; white-space: nowrap; }

/* Receive lines */
.receive-line { background: #fff; border: 1px solid var(--line); border-radius: .6rem; padding: 1rem; position: relative; }
.receive-line + .receive-line { margin-top: .8rem; }
.receive-line .line-no { position: absolute; top: -.6rem; left: .8rem; background: var(--ink); color: #fff; border-radius: 1rem; font-size: .72rem; padding: .05rem .55rem; font-weight: 600; }
.suggest-box { position: absolute; z-index: 1050; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: .5rem; box-shadow: 0 8px 24px rgba(20, 30, 50, .12); max-height: 320px; overflow-y: auto; }
.suggest-box button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .5rem .75rem; border-bottom: 1px solid #f1f3f6; }
.suggest-box button:hover, .suggest-box button:focus { background: #f2f6fd; outline: none; }
.selected-title { background: #eef6f0; border: 1px solid #cfe7d6; border-radius: .5rem; padding: .5rem .75rem; }

/* Barcode previews */
.barcode-svg { display: block; width: 100%; height: 100%; }
.barcode-inline { width: 220px; height: 60px; }
.label-sheet-wrap { overflow-x: auto; background: #e9ecef; padding: 1rem; border-radius: .5rem; }
.label-sheet { width: 210mm; height: 297mm; background: #fff; position: relative; margin: 0 auto 1rem; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.label { position: absolute; overflow: hidden; display: flex; flex-direction: column; align-items: stretch; color: #000; }
.label.bordered { outline: .1mm solid #bbb; }
.label .lbl-title { font: 700 8pt/1.15 Arial, "Noto Sans", sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .lbl-bars { flex: 1 1 auto; min-height: 0; margin: 1.2mm auto; }
.label .lbl-code { font: 700 11pt/1 "Courier New", Courier, monospace; text-align: center; }
.label.box-label .lbl-big { font: 700 26pt/1 Arial, sans-serif; text-align: center; }
.label.box-label .lbl-name { font: 9pt/1.1 Arial, sans-serif; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .alert, .offcanvas, .toast-container { display: none !important; }
  .content { padding: 0 !important; max-width: none; }
  .label-sheet-wrap { padding: 0; background: none; overflow: visible; }
  .label-sheet { box-shadow: none; margin: 0; page-break-after: always; break-after: page; }
  .label-sheet:last-child { page-break-after: auto; break-after: auto; }
}

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, #1d2b4a 0%, #2c4a86 100%); }
.login-card { width: 100%; max-width: 400px; border-radius: .9rem; border: 0; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand { color: var(--ink); justify-content: center; padding: 0 0 .5rem; font-size: 1.2rem; }
.login-card .brand i { color: var(--accent); }
.btn-loading { pointer-events: none; opacity: .75; }

/* ---------------- Scanner (Part 2) ---------------- */
.scan-app { max-width: 560px; }
.scan-steps { display: flex; gap: .3rem; list-style: none; padding: 0; margin: 0 0 .6rem; counter-reset: s; }
.scan-steps li { flex: 1 1 0; font-size: .74rem; color: #6a7488; text-align: center; border-top: 4px solid #dfe3ea; padding-top: .3rem; line-height: 1.15; }
.scan-steps li span { display: none; }
.scan-steps li.current { color: var(--ink); font-weight: 700; border-top-color: #f2b84b; }
.scan-steps li.done { color: #1f7a45; border-top-color: #1f7a45; }
.scan-camera { position: relative; background: #111; border-radius: .7rem; overflow: hidden; aspect-ratio: 4 / 3; max-height: 46vh; width: 100%; }
.scan-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide { position: absolute; left: 6%; right: 6%; top: 25%; bottom: 25%; border: 3px solid rgba(255,255,255,.85); border-radius: .6rem; box-shadow: 0 0 0 999px rgba(0,0,0,.28); pointer-events: none; display: none; }
.scan-guide span { position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: #ff4d4d; box-shadow: 0 0 6px #ff4d4d; animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 0%,100% { transform: translateY(-28px); } 50% { transform: translateY(28px); } }
@media (prefers-reduced-motion: reduce) { .scan-guide span { animation: none; } }
.scan-camera.live .scan-guide { display: block; }
.scan-camera.busy .scan-guide { border-color: #f2b84b; }
.cam-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #fff; padding: 1rem; font-size: .92rem; background: rgba(17,17,17,.85); }
.cam-msg.d-none { display: none !important; }
.cam-paused-msg { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: #fff; background: rgba(17,17,17,.6); font-weight: 600; }
.scan-camera.paused.live .cam-paused-msg { display: flex; }
.scan-camera.paused .scan-guide { display: none; }
.cam-tools { position: absolute; top: .5rem; right: .5rem; display: flex; gap: .35rem; }
.cam-tools .btn { opacity: .85; }
.cam-torch.active { background: #f2b84b; color: #000; border-color: #f2b84b; opacity: 1; }
.cam-engine { position: absolute; left: .5rem; bottom: .35rem; color: rgba(255,255,255,.55); font-size: .66rem; }
.scan-step-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); margin: .4rem 0 .35rem; }
.scan-manual { margin-bottom: .6rem; }
.scan-status { font-size: .95rem; }
.ctx-card { display: flex; align-items: center; gap: .7rem; background: #fff; border: 1px solid var(--line); border-left: 4px solid #2c4a86; border-radius: .5rem; padding: .55rem .7rem; margin-bottom: .5rem; }
.ctx-card > i { font-size: 1.4rem; color: #2c4a86; }
.ctx-card.ctx-copy { border-left-color: #c98a1b; } .ctx-card.ctx-copy > i { color: #c98a1b; }
.ctx-card.ctx-to { border-left-color: #1f7a45; } .ctx-card.ctx-to > i { color: #1f7a45; }
.ctx-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-sub { font-size: .82rem; color: #6a7488; }
.min-w-0 { min-width: 0; }
.confirm-box, .done-box, .lookup-card { background: #fff; border: 1px solid var(--line); border-radius: .7rem; padding: 1rem; }
.confirm-summary { font-size: 1.15rem; text-align: center; }
.done-box { text-align: center; border-color: #b7dfc4; background: #f2fbf5; }
.done-box > i { font-size: 2.6rem; color: #1f7a45; }
.done-msg { font-size: 1.15rem; font-weight: 700; }
.lookup-loc { font-size: 1.8rem; font-weight: 800; color: var(--ink); margin: .3rem 0; }

/* Phone scan pages */
.scan-body { background: var(--surface); }
.scan-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; background: var(--ink); color: #fff; }
.scan-top a { color: #fff; text-decoration: none; }
.scan-top .brand-sm { font-weight: 650; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-main { padding: .75rem; max-width: 560px; margin: 0 auto; }
.scan-menu a { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1rem; background: #fff; border: 1px solid var(--line); border-radius: .8rem; margin-bottom: .7rem; text-decoration: none; color: var(--ink); font-size: 1.15rem; font-weight: 650; }
.scan-menu a i { font-size: 1.8rem; width: 2.2rem; text-align: center; }
.scan-menu a small { display: block; font-weight: 400; font-size: .82rem; color: #6a7488; }
.scan-camera.paused { aspect-ratio: auto; height: 96px; transition: height .2s; }
.scan-camera.paused ~ .scan-tip { display: none; }
