:root {
  --bg: #eef2f7;
  --surface: #fff;
  --surface-soft: #f8fafc;
  --border: #d6dde7;
  --border-strong: #c3ccd8;
  --text: #18212f;
  --muted: #667085;
  --primary: #0b63e5;
  --primary-hov: #084fb8;
  --outline-bg: #ffffff;
  --outline-bg-hov: #e0edff;
  --sh-md: 0 10px 30px rgba(15,23,42,.08);
  --sh-sm: 0 1px 2px rgba(15,23,42,.05);
  --r: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg,#eef2f7 0%,#e8edf5 100%);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}
.shell {
  display: grid;
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
}

/* hero */
.hero { text-align: center; padding: 0 8px 2px; }
.title {
  margin: 0;
  color: #1539d1;
  font-size: clamp(1.9rem,3vw,2.4rem);
  font-weight: 800;
  letter-spacing: -.02em;
}
.subtitle {
  max-width: 900px;
  margin: 6px auto 0;
  color: #243244;
  font-size: clamp(.93rem,1.7vw,1.02rem);
  line-height: 1.45;
}
.subtitle span { color: var(--primary); }
.or-badge {
  display: inline-block;
  background: #e8f0fe;
  color: var(--primary);
  border-radius: 6px;
  padding: 1px 8px;
  font-weight: 900;
  margin: 0 2px;
}

/* toolbar */
.toolbar {
  display: grid;
  grid-template-columns: 1.25fr 52px 1fr 1fr;
  gap: 8px;
  padding: 10px 14px;
  align-items: end;
}
.toolbar-or {
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 800;
  color: #334155;
  padding-bottom: 11px;
}
.field-group {
  display: grid;
  gap: 6px;
  align-content: start;
}
.field-group label {
  font-size: .83rem;
  font-weight: 700;
  color: #445062;
}

/* inputs */
.field,
.search-wrap input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.field:focus,
.search-wrap input:focus,
.bp-box:focus {
  border-color: #93b4ff;
  box-shadow: 0 0 0 3px rgba(11,99,229,.11);
}

select.field {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #667085 50%),
    linear-gradient(135deg, #667085 50%, transparent 50%);
  background-position: calc(100% - 26px) 20px, calc(100% - 20px) 20px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 56px; /* arrow + divider + cross */
}
.field.has-clear { padding-right: 56px; }
.field:disabled {
  background: #f5f7fa;
  color: #98a2b3;
  cursor: not-allowed;
}

/* clear buttons & search */
.input-wrap { position: relative; }
.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #9ca3af;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}
.clear-btn:hover { color: #6b7280; }

/* dropdown clear after arrow */
.clear-select { right: 8px; }
.clear-select::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 18px;
  background: #e5e7eb;
}

.search-wrap { position: relative; }
.search-wrap input { padding-right: 46px; }
.search-wrap .clear-search { right: 32px; }
.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: #4b88ea;
  pointer-events: none;
}

/* search dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 256px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15,23,42,.13);
  z-index: 30;
}
.search-item {
  padding: 11px 13px;
  border-bottom: 1px solid #eef2f6;
  cursor: pointer;
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover,
.search-item.active { background: #f0f6ff; }
.search-item div {
  font-size: .94rem;
  font-weight: 600;
}
.search-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .77rem;
}
mark {
  background: #fff0a8;
  padding: 0 2px;
  border-radius: 3px;
}

/* buttons */
.reset-btn,
.action-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  border: 0;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color .2s,
    transform .12s,
    opacity .2s,
    border-color .2s,
    color .2s;
}
.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.action-btn { flex: 1 1 200px; }

.action-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(11,99,229,.22);
}
.action-primary:hover { background: var(--primary-hov); }

.action-outline,
.reset-btn {
  background: var(--outline-bg);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.action-outline:hover,
.reset-btn:hover {
  background: var(--outline-bg-hov);
}

.reset-btn:active,
.action-btn:active { transform: translateY(1px); }
.action-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
  box-shadow: none;
}

/* layout */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.workspace,
.barcode-card { padding: 10px 14px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.section-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #223046;
}

/* BP box */
.bp-box {
  width: 100%;
  min-height: 170px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* meta chips – vertical column desktop, single row mobile */
.meta-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 260px;
}
.meta-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--sh-sm);
}
.meta-chip label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.meta-chip span {
  display: block;
  color: var(--text);
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* barcode */
.barcode-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #fff;
  overflow: auto;
  max-width: 520px;
  margin: 0 auto;
}
.barcode-box canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.placeholder {
  color: #4b5563;
  font-size: .94rem;
  line-height: 1.4;
  max-width: 220px;
  text-align: center;
}

/* footer */
.footer-note {
  text-align: center;
  color: #8898aa;
  font-size: .8rem;
  padding-top: 2px;
}

/* utility */
.hidden { display: none !important; }

/* responsive layout for chips */
@media (min-width: 900px) {
  .content-grid {
    grid-template-columns: minmax(0,1.25fr) auto;
    align-items: flex-start;
  }
}

@media (max-width: 899px) {
  .meta-panel {
    flex-direction: row;
    max-width: none;
  }
  .meta-chip {
    flex: 1 1 0;
    text-align: left;
  }
}

@media (max-width: 700px) {
  .page { padding: 16px 12px 24px; }
  .toolbar { grid-template-columns: 1fr; }
  .action-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
}