:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #0b1736;
  --ink-soft: #33415c;
  --muted: #6b7a90;
  --line: #e6ebf3;
  --brand: #1d5bff;
  --brand-deep: #1447d6;
  --brand-soft: #eaf0ff;
  --good: #0e9f6e;
  --warn: #b45309;
  --warn-bg: #fff4e5;
  --danger: #d92d20;
  --empty-bg: #eef2f8;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(23, 43, 99, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

.hidden {
  display: none !important;
}

/* ---------- Login ---------- */

.login {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(45, 110, 255, 0.5), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(0, 196, 255, 0.22), transparent 60%),
    linear-gradient(160deg, #071a3a 0%, #0a2050 48%, #081630 100%);
  overflow: hidden;
}

.login-glow {
  position: absolute;
  width: 460px;
  height: 460px;
  left: 50%;
  top: -180px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(70, 130, 255, 0.4), transparent 65%);
  filter: blur(10px);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 24px;
  padding: 28px 24px 22px;
  box-shadow: 0 30px 70px rgba(0, 8, 30, 0.45);
  animation: card-in 0.5s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 16px;
  background: linear-gradient(145deg, #2f6dff, #1447d6);
  box-shadow: 0 10px 22px rgba(29, 91, 255, 0.35);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand-text h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
}

.brand-text p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.field {
  margin-bottom: 16px;
}

.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.field input,
.field select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid #dfe5ef;
  border-radius: 12px;
  background: #fbfcfe;
  outline: none;
  font-size: 15px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  appearance: none;
}

.field input::placeholder {
  color: #9aa7bb;
}

.field input:focus,
.field select:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(29, 91, 255, 0.12);
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a90' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 62px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  height: 34px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--brand);
  border-radius: 8px;
}

.pw-toggle:active {
  background: var(--brand-soft);
}

.remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 2px 0 18px;
  user-select: none;
}

.remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.4px;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(145deg, #2b67ff, #1244d2);
  box-shadow: 0 10px 22px rgba(29, 91, 255, 0.28);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: default;
  box-shadow: none;
}

.btn-secondary {
  color: var(--ink-soft);
  background: #eef2f8;
}

.btn-block {
  width: 100%;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading .spinner {
  display: inline-block;
}

.btn.is-loading .btn-text {
  opacity: 0.7;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.form-error {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

.login-note {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: #94a3b8;
  text-align: center;
  line-height: 1.6;
}

/* ---------- App shell ---------- */

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(243, 245, 250, 0.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.75);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16c784;
  box-shadow: 0 0 0 4px rgba(22, 199, 132, 0.14);
  flex: 0 0 auto;
}

.app-title h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.4px;
}

.app-title p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-btn {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #dbe2ee;
  background: #fff;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.ghost-btn:active {
  background: #f4f6fb;
}

.search-row {
  display: flex;
  gap: 9px;
  margin-top: 12px;
}

.loc-row {
  display: flex;
  gap: 9px;
  margin-top: 9px;
}

.search-btn {
  flex: 0 0 auto;
  width: 80px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  font-size: 14px;
  letter-spacing: 1px;
}

.loc-field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}

.loc-field .search-box {
  flex: 1;
}

.loc-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 268px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(9, 20, 45, 0.18);
}

.loc-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  border-radius: 10px;
  text-align: left;
  font-size: 14px;
  color: var(--ink);
}

.loc-option small {
  flex: 0 0 auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

.loc-option.is-active,
.loc-option:active {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 46px;
  padding: 0 12px;
  background: #fff;
  border: 1.5px solid #e3e9f3;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(23, 43, 99, 0.04);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(29, 91, 255, 0.1);
}

.search-icon {
  width: 19px;
  height: 19px;
  color: #8a99b0;
  flex: 0 0 auto;
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0 8px;
  font-size: 15px;
  appearance: none;
}

.search-box input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-box input::placeholder {
  color: #9aa7bb;
  font-size: 14px;
}

.clear-btn {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e9edf5;
  color: #62718a;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.filter-btn {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 80px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  background: #fff;
  border: 1.5px solid #e3e9f3;
  font-size: 13.5px;
  color: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(23, 43, 99, 0.04);
}

.filter-btn svg {
  width: 17px;
  height: 17px;
  color: #6b7a90;
}

.filter-btn:active {
  background: #f6f8fc;
}

.dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  border: 1.5px solid #fff;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 500;
}

.recent {
  margin-top: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.recent-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  padding-top: 6px;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e3e9f3;
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip:active {
  background: var(--brand-soft);
  border-color: #c9d8ff;
  color: var(--brand-deep);
}

/* ---------- Content ---------- */

.content {
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
}

.summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.summary strong {
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.2s;
}

.results.is-refreshing {
  opacity: 0.55;
  pointer-events: none;
}

.mat-card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 15px 11px;
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mat-info {
  min-width: 0;
}

.mat-name-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.mat-name-line h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  word-break: break-all;
}

.mat-code {
  flex: 0 0 auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  color: #5b6b84;
  background: #f1f4f9;
  border-radius: 6px;
  padding: 2px 6px;
  letter-spacing: 0.2px;
}

.mat-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: #eef4ff;
  color: var(--brand-deep);
  font-size: 11px;
  font-weight: 500;
}

.mat-total {
  flex: 0 0 auto;
  text-align: right;
  line-height: 1.3;
}

.total-line {
  white-space: nowrap;
}

.total-line strong {
  font-size: 19px;
  font-weight: 700;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.total-line span {
  margin-left: 3px;
  font-size: 11px;
  color: var(--muted);
}

.total-sub {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stock-list {
  margin-top: 11px;
}

.stock-row {
  padding: 11px 0;
  border-top: 1px solid #f0f3f8;
}

.stock-row.is-zero {
  opacity: 0.55;
}

.stock-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 0;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}

.stock-main:active .loc-badge {
  background: #e2ebff;
}

.stock-loc {
  min-width: 0;
  flex: 1;
}

.loc-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.loc-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 23px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid #d8e4ff;
  background: #eef4ff;
  color: var(--brand-deep);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  font-weight: 700;
  word-break: break-all;
}

.grade-chip {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid #ffe6bf;
  background: #fff7e6;
  color: #a35a06;
  font-size: 11px;
  font-weight: 600;
}

.wh-inline {
  color: var(--ink-soft);
}

.weight-text {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.title-prefix {
  margin-right: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
}

.mat-name-sub {
  color: var(--ink-soft);
  font-weight: 600;
}

.stock-side {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chevron {
  width: 15px;
  height: 15px;
  color: #93a1b5;
}

.row-more {
  font-size: 10.5px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 2px 7px;
  line-height: 1.4;
}

.wh {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  word-break: break-all;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  background: #eef7f2;
  color: #0b7a55;
  font-size: 10.5px;
}

.status-chip.is-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.stock-amt {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

.stock-amt strong {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.stock-amt .unit {
  margin-left: 3px;
  font-size: 11px;
  color: var(--muted);
}

.extras {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--good);
  font-variant-numeric: tabular-nums;
}

.expand-btn {
  width: 100%;
  margin-top: 8px;
  height: 36px;
  border-radius: 10px;
  background: #f5f8ff;
  color: var(--brand-deep);
  font-size: 12.5px;
  font-weight: 500;
}

.expand-btn:active {
  background: #e9f0ff;
}

/* ---------- States ---------- */

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sk-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.sk-line {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef1f7 25%, #f7f9fc 37%, #eef1f7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  margin-bottom: 11px;
}

.sk-line:last-child {
  margin-bottom: 0;
}

.w30 { width: 30%; }
.w40 { width: 40%; }
.w50 { width: 50%; }
.w60 { width: 60%; }
.w70 { width: 70%; }
.w80 { width: 80%; }

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.empty {
  text-align: center;
  padding: 54px 20px 40px;
  color: #b6c2d4;
}

.empty-icon {
  width: 120px;
  height: 120px;
  margin-bottom: 10px;
}

.empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.empty-sub {
  margin: 7px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.error-box {
  margin: 24px auto 0;
  max-width: 320px;
  padding: 20px;
  text-align: center;
  background: #fff;
  border: 1px solid #f2d6d3;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.error-box p {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: #a4251b;
  line-height: 1.6;
}

.trunc {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Filter sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 20, 45, 0.46);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease both;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 86dvh;
  overflow: auto;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(16px + env(safe-area-inset-bottom));
  animation: sheet-up 0.28s cubic-bezier(0.22, 0.85, 0.3, 1) both;
  box-shadow: 0 -20px 50px rgba(9, 20, 45, 0.25);
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
}

.ghost-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f4f9;
  color: #5b6b84;
  font-size: 19px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.sheet-body {
  padding-bottom: 4px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 2px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  position: relative;
}

.switch-row > span strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.switch-row > span small {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  flex: 0 0 auto;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  background: #dbe2ee;
  position: relative;
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
  transition: transform 0.2s;
}

.switch-row input:checked + .switch {
  background: var(--brand);
}

.switch-row input:checked + .switch::after {
  transform: translateX(19px);
}

.sheet-foot {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  margin-top: 16px;
}

.sheet-foot .btn {
  height: 46px;
}

/* ---------- Barcode sheet ---------- */

.barcode-panel {
  max-height: 88dvh;
}

.barcode-meta {
  margin: -4px 0 13px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.barcode-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.barcode-lot {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.barcode-qty {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.barcode-sub {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-all;
}

.barcode-stats {
  margin: 7px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.barcode-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}

.barcode-skeleton {
  padding: 6px 2px;
}

.piece-card {
  padding: 11px 12px;
  border: 1px solid #e6ebf3;
  border-radius: 14px;
  background: #fbfcfe;
}

.piece-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.piece-index {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.piece-barcode {
  flex: 1;
  min-width: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  word-break: break-all;
}

.piece-barcode.is-empty {
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.piece-qty {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.piece-qty strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-deep);
  letter-spacing: -0.2px;
}

.piece-qty em {
  margin-left: 2px;
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
}

.piece-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.piece-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid #e9eef6;
  background: #fff;
  font-size: 11px;
  color: var(--ink-soft);
}

.piece-chip em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
}

.piece-chip b {
  font-weight: 600;
  word-break: break-all;
}

.barcode-empty {
  padding: 34px 16px 22px;
  text-align: center;
}

.barcode-empty-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.barcode-empty-sub {
  margin: 7px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.barcode-retry {
  margin-top: 16px;
  height: 40px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 48px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(11, 23, 54, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 80;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.sheet-open {
  overflow: hidden;
}

/* ---------- Larger screens ---------- */

@media (min-width: 720px) {
  body {
    background: #e9edf5;
  }

  .app {
    background: var(--bg);
    box-shadow: 0 0 60px rgba(15, 23, 42, 0.08);
    min-height: 100dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
