/* ═══════════════════════════════════════════
   ITEM SEARCH — FILTER / SEARCH SIDEBAR
   Loaded only when the Item Search page is active.
   Relies on tokens.css + chrome.css being loaded first.
═══════════════════════════════════════════ */
.filter-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; transition: width .2s ease, opacity .15s;
}
.filter-sidebar.hidden { width: 0; opacity: 0; pointer-events: none; }
.fs-screen-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px 6px; border-bottom: 1px solid var(--border);
  background: #f8f8f8; flex-shrink: 0;
}
.fs-screen-name {
  font-size: 12px; font-weight: 600; color: var(--green);
  display: flex; align-items: center; gap: 5px;
}
.fs-screen-name i { font-size: 13px; }
.fs-actions { display: flex; gap: 6px; padding: 8px 10px 6px; flex-shrink: 0; }
.fs-reset {
  flex: 1; padding: 5px 0; border-radius: 4px; font-size: 12px; font-weight: 500;
  border: 1px solid #bbb; color: #555; background: #f5f5f5; cursor: pointer;
  transition: background .13s;
}
.fs-reset:hover { background: #e8e8e8; }
.fs-find {
  flex: 1; padding: 5px 0; border-radius: 4px; font-size: 12px; font-weight: 600;
  border: none; color: #fff; background: var(--green); cursor: pointer;
  transition: background .13s;
}
.fs-find:hover { background: var(--green-dk); }
.fs-inner { flex: 1; overflow-y: auto; padding: 2px 10px 16px; }
.fs-inner::-webkit-scrollbar { width: 4px; }
.fs-inner::-webkit-scrollbar-thumb { background: rgba(0,0,0,.16); border-radius: 3px; }
.fg-row { border-bottom: 1px solid #eee; padding: 8px 2px 6px; }
.fg-row:last-child { border-bottom: none; }
.fl { font-size: 11px; font-weight: 500; color: #777; margin-bottom: 4px; display: block; }
.f-underline {
  width: 100%; border: none; border-bottom: 1px solid var(--border);
  background: transparent; padding: 3px 2px; font-size: 12px; color: #222; outline: none;
}
.f-underline:focus { border-bottom-color: var(--green); }
.f-underline::placeholder { color: #bbb; }
.f-select {
  width: 100%; border: 1px solid var(--border); border-radius: 4px;
  background: #fafafa; padding: 5px 6px; font-size: 12px; color: #222;
  outline: none; margin-bottom: 6px; cursor: pointer;
}
.f-select:focus { border-color: var(--green); }
.fchk { display: flex; align-items: center; gap: 8px; padding: 6px 2px; cursor: pointer; user-select: none; font-size: 12px; color: #333; }
.fchk input[type=checkbox] { accent-color: var(--green); width: 14px; height: 14px; cursor: pointer; }
.fchk:hover { color: var(--green); }

.sort-dir-btn { display: flex; }
.sort-hint { display: flex; align-items: flex-start; gap: 5px; font-size: 10.5px; color: #999; margin-top: 6px; line-height: 1.4; }
.sort-hint i { font-size: 12px; flex-shrink: 0; margin-top: 1px; }

.sb-util-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 0; border-radius: 4px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); color: #444; background: #f5f5f5;
  cursor: pointer; transition: background .13s, color .13s, border-color .13s; text-align: center;
}
.sb-util-btn + .sb-util-btn { margin-top: 5px; }
.sb-util-btn:hover { background: #e8e8e8; color: #222; }

.mds-info {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 11px; color: #888; padding: 4px 2px 8px; line-height: 1.4;
}
.mds-info i { font-size: 13px; color: #aaa; flex-shrink: 0; margin-top: 1px; }

/* ── Status pill in sub-bar ── */
.mds-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 10px;
  border: 1px solid transparent;
}
.mds-pill i { font-size: 12px; }
.mds-loading { color: #c5dc80; }
.mds-loading i { animation: mds-spin 0.9s linear infinite; }
.mds-ready { color: #c5dc80; background: rgba(98,129,40,.25); }
.mds-error { color: #f5a3a3; background: rgba(220,53,69,.18); }
@keyframes mds-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   COLUMN PICKER  (genericized from LCPS's Pick-Zone picker;
   grouped by master-data section, searchable, footer actions)
═══════════════════════════════════════════ */
.col-picker-wrap { position: relative; width: 100%; }
.col-picker-field {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 4px; background: #fafafa;
  padding: 6px 8px; cursor: pointer; min-height: 30px; transition: border-color .15s;
}
.col-picker-field:hover { border-color: #aaa; }
.col-picker-field.open { border-color: #1565c0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.col-picker-lbl { font-size: 12px; color: #1a56a0; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-picker-panel {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid #1565c0; border-top: none;
  border-bottom-left-radius: 4px; border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); z-index: 500;
}
.col-picker-panel.open { display: block; }
.col-picker-search {
  width: 100%; padding: 6px 10px; border: none;
  border-bottom: 1px solid var(--border); outline: none;
  font-size: 12px; background: #fff; color: #222;
}
.col-picker-search::placeholder { color: #bbb; }
.col-picker-list { max-height: 320px; overflow-y: auto; }
.cp-group-hdr {
  background: #f0f0f0; padding: 5px 12px; font-size: 10.5px; font-weight: 600;
  color: #888; letter-spacing: .3px; position: sticky; top: 0;
  border-top: 1px solid #e4e4e4; border-bottom: 1px solid #e4e4e4;
}
.col-picker-list .cp-group-hdr:first-child { border-top: none; }
.col-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; cursor: pointer; font-size: 12px; color: #333;
  border-bottom: 1px solid #f5f5f5; user-select: none; transition: background .1s;
}
.col-picker-item:hover:not(.cp-lock) { background: #f0f4f8; }
.col-picker-item.cp-lock { opacity: .55; cursor: default; }
.cp-cb {
  width: 16px; height: 16px; border: 2px solid #bbb; border-radius: 3px;
  flex-shrink: 0; position: relative; background: #fff;
  transition: background .1s, border-color .1s;
}
.cp-cb.on { background: #1565c0; border-color: #1565c0; }
.cp-cb.on::after {
  content: ''; position: absolute; top: 2px; left: 5px;
  width: 4px; height: 8px; border: 2px solid #fff;
  border-top: none; border-left: none; transform: rotate(45deg);
}
.cp-cb.lock-cb { background: #9eb5d0; border-color: #9eb5d0; }
.col-picker-footer {
  display: flex; gap: 6px; padding: 8px; border-top: 1px solid #e8e8e8; background: #fafafa;
}
.cp-footer-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 0; border-radius: 4px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border); color: #444; background: #fff; cursor: pointer;
  transition: background .13s;
}
.cp-footer-btn:hover { background: #eef2e7; color: var(--green-dk); border-color: var(--green); }

/* ═══════════════════════════════════════════
   ITEM SEARCH — RESULTS TABLE
═══════════════════════════════════════════ */
.table-wrap { flex: 1; overflow: auto; position: relative; min-height: 0; }
.table-wrap::-webkit-scrollbar { width: 7px; height: 7px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(0,0,0,.25); border-radius: 4px; }

#itemTable { width: 100%; border-collapse: collapse; background: #fff; }
#itemTable th, #itemTable td { border: 1px solid #c0c0c0; padding: 6px 8px; text-align: center; vertical-align: middle; font-size: 13px; font-weight: 700; white-space: nowrap; }
#itemTable th {
  background: var(--green); color: #fff; position: sticky; top: 0; z-index: 20;
  font-size: 11px; font-weight: 600; letter-spacing: .1px; padding: 6px 8px;
  cursor: pointer; user-select: none;
}
#itemTable th:hover { background: var(--green-dk); }
#itemTable th.sel-th { width: 18px; cursor: default; }
#itemTable th.sel-th:hover { background: var(--green); }
#itemTable .sort-arrow { font-size: 9px; opacity: .9; }
#itemTable td:nth-child(odd)  { background: #f5f1ea; }
#itemTable td:nth-child(even) { background: #fff; }
#itemTable tbody tr { height: 38px; cursor: pointer; transition: background .1s; }
#itemTable tbody tr:hover td { filter: brightness(0.97); }
#itemTable tbody tr.row-selected td { background: #dce8ff !important; outline: 2px solid #1a56a0; outline-offset: -2px; }
#itemTable td.item-code-cell { color: var(--green-dk); font-family: 'Roboto Mono', monospace, sans-serif; }
#itemTable td.slot-cell { font-family: monospace; letter-spacing: .5px; color: #444; }
#itemTable td.missing-val { color: #bbb; font-weight: 400; font-style: italic; }

.sel-th { width: 18px; }
.sel-cb { display: flex; align-items: center; justify-content: center; }
.sel-cb input[type=checkbox] { accent-color: var(--green); width: 14px; height: 14px; cursor: pointer; }

.table-empty, .table-loading, .table-search-prompt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #999; padding: 60px 20px; text-align: center;
}
.table-empty.hidden, .table-loading.hidden, .table-search-prompt.hidden { display: none; }
.table-empty i, .table-loading i, .table-search-prompt i { font-size: 36px; opacity: .35; }
.table-loading i { animation: mds-spin 0.9s linear infinite; color: var(--green); opacity: .6; }
.table-search-prompt i { color: var(--green); opacity: .45; }
.table-empty span, .table-loading span, .table-search-prompt span { font-size: 13px; opacity: .75; max-width: 380px; line-height: 1.5; }

/* ═══════════════════════════════════════════
   DETAIL PANEL  ("Cards" view) — shows EVERY field
   for the selected item, grouped by section.
═══════════════════════════════════════════ */
.detail-panel {
  width: 340px; flex-shrink: 0;
  background: #fff; border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .2s ease, opacity .15s;
  overflow: hidden; position: relative;
  box-shadow: -2px 0 8px rgba(0,0,0,.08);
}
.detail-panel.hidden { width: 0; opacity: 0; pointer-events: none; }
.dp-controls {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid #e0e0e0; flex-shrink: 0; background: #fafafa;
}
.dp-header-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dp-header-code { font-size: 13px; font-weight: 700; color: var(--green-dk); font-family: monospace; }
.dp-header-desc { font-size: 11px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-ctrl-btn {
  width: 26px; height: 26px; border-radius: 4px; border: none; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #888; cursor: pointer; background: transparent;
  transition: background .12s, color .12s;
}
.dp-ctrl-btn:hover { background: #f0f0f0; color: #333; }
.dp-ctrl-btn.close-btn:hover { background: #fdecea; color: #c0392b; }
/* Tab bar — Details / Related (matches LCPS's pattern) */
.dp-tabs {
  display: flex; border-bottom: 1px solid #e0e0e0; flex-shrink: 0;
  background: #fff; min-height: 40px;
}
.dp-tab {
  flex: 1; padding: 10px 0; text-align: center;
  font-size: 13px; font-weight: 400; color: #555;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; user-select: none;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.dp-tab:hover { color: #222; background: #fafafa; }
.dp-tab.active { color: #222; border-bottom-color: #555; font-weight: 500; }
.dp-tab.active .dp-tab-check { display: inline-flex; }
.dp-tab-check {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--green); color: #fff;
  align-items: center; justify-content: center; font-size: 9px; flex-shrink: 0;
}

.dp-body { flex: 1; overflow-y: auto; background: #fff; }
.dp-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; padding: 24px; text-align: center; color: #bbb; }
.dp-empty i { font-size: 44px; opacity: .25; }
.dp-empty p { font-size: 12px; line-height: 1.6; color: #aaa; }
.dp-section-hdr {
  background: #f0f0f0; border-top: 1px solid #e4e4e4; border-bottom: 1px solid #e4e4e4;
  padding: 6px 14px; font-size: 11px; font-weight: 600; color: #888;
  letter-spacing: .4px; position: sticky; top: 0; z-index: 5;
}
.dp-row { display: flex; align-items: flex-start; padding: 7px 12px 7px 14px; border-bottom: 1px solid #f2f2f2; min-height: 32px; gap: 8px; }
.dp-row:hover { background: #f9f9f9; }
.dp-row-label { width: 150px; flex-shrink: 0; font-size: 11.5px; color: #1a56a0; font-weight: 400; line-height: 1.45; }
.dp-row-value { flex: 1; font-size: 12px; color: #111; font-weight: 500; line-height: 1.45; word-break: break-word; text-align: right; }
.dp-row-value.dp-empty-val { color: #bbb; font-weight: 400; font-style: italic; }

.dp-barcode-block { padding: 10px 14px 14px; text-align: center; border-bottom: 1px solid #f2f2f2; }
.dp-barcode-lbl { display: block; font-size: 11px; color: #888; margin-bottom: 6px; }
.dp-barcode-wrap { display: flex; flex-direction: column; align-items: center; }
.dp-barcode-wrap svg { max-width: 100%; height: auto; }

#cardsBtn.active, #cardsBtnHeader.active { background: rgba(98,129,40,.2); color: #c5dc80; }

/* ═══════════════════════════════════════════
   PRINT
═══════════════════════════════════════════ */
@media print {
  @page { size: landscape; margin: 6mm; }
  .dc-bar, .header-bar, .sub-bar, .sidebar-rail, .pages-panel, .filter-sidebar, .status-bar, .detail-panel { display: none !important; }
  html, body { overflow: visible; }
  .app-body { display: block; height: auto; }
  .main-content { overflow: visible; }
  .table-wrap { overflow: visible; }
  th, td { font-size: 9px; padding: 3px 5px; border: 1px solid #666; }
  th { position: static; background: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  td:nth-child(odd)  { background: #fff !important; }
  td:nth-child(even) { background: #fff !important; }
}

/* ═══════════════════════════════════════════
   CREATE CYCLE COUNT — sub-bar button + modal
═══════════════════════════════════════════ */
.create-cc-btn { position: relative; }
.create-cc-btn.disabled,
.create-cc-btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.cc-count-badge {
  background: var(--green); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; padding: 1px 6px; min-width: 16px; text-align: center;
  display: inline-block; line-height: 1.4;
}
.create-cc-btn:not(.disabled) .cc-count-badge { background: #c5dc80; color: #1a2b08; }

.cc-modal-box { width: 480px; max-width: calc(100vw - 32px); }
.cc-modal-body { max-height: 60vh; overflow-y: auto; gap: 14px; }
.cc-hint {
  display: flex; align-items: flex-start; gap: 6px; font-size: 11px; color: #888;
  margin-top: 6px; line-height: 1.5;
}
.cc-hint i { font-size: 13px; color: #aaa; flex-shrink: 0; margin-top: 1px; }
.cc-hint strong { color: var(--green-dk); }

.cc-section-hdr {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: #888; letter-spacing: .3px;
  text-transform: uppercase; border-top: 1px solid #eee; padding-top: 10px;
}
.cc-section-hdr i { font-size: 13px; }

.cc-item-list { display: flex; flex-direction: column; gap: 8px; }
.cc-item-card { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cc-item-card-hdr {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: #f5f5f5; border-bottom: 1px solid #eee;
}
.cc-item-code { font-family: monospace; font-weight: 700; color: var(--green-dk); font-size: 12px; }
.cc-item-desc { font-size: 11px; color: #777; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.cc-no-loc {
  display: flex; align-items: flex-start; gap: 6px; padding: 10px;
  font-size: 11px; color: #8a6d3b; background: #fcf8e3; line-height: 1.5;
}
.cc-no-loc i { font-size: 14px; flex-shrink: 0; margin-top: 1px; color: #c9a227; }

.cc-loc-checklist { display: flex; flex-direction: column; }
.cc-loc-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-bottom: 1px solid #f5f5f5; cursor: pointer; font-size: 12px;
}
.cc-loc-row:last-child { border-bottom: none; }
.cc-loc-row:hover { background: #fafafa; }
.cc-loc-row input[type=checkbox] { accent-color: var(--green); width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; }
.cc-loc-code { font-family: monospace; letter-spacing: .3px; color: #333; min-width: 90px; }
.cc-loc-type-badge {
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 8px;
  letter-spacing: .3px; color: #fff; flex-shrink: 0;
}
.cc-type-PICK { background: #1a56a0; }
.cc-type-CSPK { background: #6b4fa0; }
.cc-type-LCPK { background: #a06b1a; }
.cc-loc-zone { font-size: 10px; color: #888; flex: 1; }
.cc-loc-qty { font-size: 11px; color: #555; font-weight: 600; white-space: nowrap; }
