:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #6d766f;
  --line: #d9ded8;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --soft: #e9f5f2;
  --danger: #b91c1c;
  --warn-bg: #fff7ed;
  --warn: #b45309;
  --shadow: 0 10px 30px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

/* Some component layout rules use display:grid/flex. Keep the semantic hidden
   attribute authoritative so completed preparation sheets cannot expose edit
   controls again on mobile. */
[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
  min-width: 0;
}

.topbar.compact {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: 0 -18px 14px;
  padding: 12px 18px;
  background: rgba(247, 248, 245, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(217, 222, 216, 0.86);
}

.topbar.compact h1 {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 23px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.danger-button,
.product-actions .delete-product {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--danger);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.16;
}

h2 {
  font-size: 19px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 850;
}

.warehouse-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ghost-link,
.primary-link,
.ghost-button,
.text-button,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.ghost-link,
.primary-link,
.ghost-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
}

.primary-link {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--brand);
}

.icon-button {
  width: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 28px;
  font-weight: 800;
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0 0 4px;
  scrollbar-width: none;
}

.module-tabs[hidden] {
  display: none;
}

.module-tabs::-webkit-scrollbar {
  display: none;
}

.module-tab {
  flex: 1 1 118px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.module-tab.active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf3f1;
}

.mode-switch button {
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 950;
}

.mode-switch button.active {
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(23, 32, 29, 0.08);
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: grid;
  gap: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-grid article,
.summary-card {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 32, 29, 0.05);
}

.summary-card {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}

.summary-card:hover {
  border-color: rgba(15, 118, 110, 0.38);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(23, 32, 29, 0.08);
}

.summary-card:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 2px;
}

.dashboard-grid strong {
  color: var(--brand-dark);
  font-size: 29px;
  line-height: 1;
}

.dashboard-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-card small {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

/* Today preparation is a read-only stock forecast. It deliberately does not
   share the inbound/outbound action styles so staff can distinguish it from
   a formal stock transaction. */
.today-preparation-entry {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 12px;
  background: #f0fdf9;
  color: var(--ink);
  text-align: left;
}

.today-preparation-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  font-weight: 950;
}

.today-preparation-entry strong,
.today-preparation-entry small {
  display: block;
}

.today-preparation-entry strong {
  font-size: 16px;
}

.today-preparation-entry small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.today-preparation-entry b {
  padding: 5px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  white-space: nowrap;
}

.today-preparation-entry i {
  color: var(--brand);
  font-size: 25px;
  font-style: normal;
  line-height: 1;
}

.preparation-panel {
  display: grid;
  gap: 9px;
  width: min(100%, 720px);
  margin: 0 auto;
}

.preparation-date-row,
.preparation-section-heading,
.preparation-item-head,
.preparation-item-footer,
.preparation-history-row,
.preparation-product-option,
.preparation-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preparation-date-row {
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.preparation-date-row label,
.preparation-result-controls > label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.preparation-date-display {
  display: grid;
  gap: 3px;
}

.preparation-date-display span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.preparation-date-display strong {
  color: var(--ink);
  font-size: 16px;
}

.preparation-date-display small {
  color: #b45309;
  font-size: 12px;
  font-weight: 800;
}

.preparation-date-row input,
.preparation-result-controls input[type="number"] {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.preparation-status,
.preparation-stock-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.preparation-status.pending { background: #fff7ed; color: #c2410c; }
.preparation-status.accepted { background: #e0f2fe; color: #0369a1; }
.preparation-status.prepared,
.preparation-stock-status.enough { background: #dcfce7; color: #15803d; }
.preparation-stock-status.short,
.preparation-stock-status.out { background: #fee2e2; color: #b91c1c; }

.preparation-role-hint {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  padding: 8px 10px;
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  background: #eef7f4;
}

.preparation-role-hint strong { color: var(--brand-dark); font-size: 13px; white-space: nowrap; }
.preparation-role-hint span { min-width: 0; color: var(--muted); font-size: 12px; font-weight: 700; }

.preparation-workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.preparation-step {
  display: grid;
  justify-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.preparation-step b {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid #cbd8d5;
  border-radius: 50%;
  background: #f6f8f7;
  color: #64748b;
  font-size: 11px;
}

.preparation-step.active { color: var(--brand-dark); }
.preparation-step.active b { border-color: var(--brand); background: #e8f6f1; color: var(--brand-dark); }
.preparation-step.done { color: #15803d; }
.preparation-step.done b { border-color: #86d7b8; background: #dcfce7; color: #15803d; }

.preparation-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preparation-summary span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0 4px;
  min-height: 62px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.preparation-summary small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.preparation-summary b {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.preparation-summary em {
  padding-bottom: 1px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 750;
}

.preparation-summary .enough b { color: #15803d; }
.preparation-summary .short b { color: #b91c1c; }

.preparation-empty-state {
  display: grid;
  gap: 5px;
  justify-items: start;
  padding: 13px 12px;
  border: 1px dashed #b7d8cf;
  border-radius: 11px;
  background: #f7fcfa;
}

.preparation-empty-state strong { color: var(--ink); font-size: 15px; }
.preparation-empty-state span { color: var(--muted); font-size: 12px; font-weight: 700; }
.preparation-empty-state .save-button { margin-top: 3px; }

.preparation-section {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.preparation-section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.preparation-section-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preparation-demand-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.preparation-refresh-button {
  justify-self: start;
  min-height: 34px;
  padding: 0 11px;
  border-color: transparent;
  color: var(--muted);
  background: #f4f7f6;
  font-size: 12px;
}

.preparation-product-picker {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: #f6f8f7;
}

.preparation-search-list {
  max-height: 250px;
  overflow: auto;
}

.preparation-product-option {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.preparation-product-option span,
.preparation-product-option small { display: grid; gap: 2px; }
.preparation-product-option strong { font-size: 15px; }
.preparation-product-option small { color: var(--muted); font-size: 12px; }
.preparation-product-option b { color: var(--brand-dark); font-size: 13px; white-space: nowrap; }

.preparation-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 112px;
  align-items: end;
  gap: 8px;
  padding-top: 2px;
}

.preparation-add-form strong { min-width: 0; font-size: 13px; }
.preparation-add-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 850; }
.preparation-add-form input,
.preparation-item-meta input {
  min-width: 0;
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: right;
}

.preparation-list { display: grid; gap: 6px; }

.preparation-item {
  display: grid;
  gap: 5px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-left: 3px solid #16a34a;
  border-radius: 9px;
  background: #fff;
}

.preparation-item.short,
.preparation-item.out { border-left-color: #dc2626; }
.preparation-item-head { align-items: center; gap: 6px; }
.preparation-item-head > div { flex: 1 1 auto; min-width: 0; display: grid; gap: 0; }
.preparation-item-head strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preparation-item-head span { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preparation-item-head .preparation-stock-status { flex: 0 0 auto; min-height: 23px; padding: 0 7px; font-size: 11px; }
.preparation-item-head .preparation-remove-button {
  flex: 0 0 32px;
  width: 32px;
  min-height: 32px;
  border-color: #fee2e2;
  border-radius: 8px;
  background: #fffafa;
  color: #b91c1c;
  font-size: 23px;
}
.preparation-item-head .prepared-check { min-height: 30px; padding: 0 7px; font-size: 12px; }
.preparation-item-head .prepared-check input { width: 16px; height: 16px; }
.preparation-item-head .prepared-state { padding-top: 0; font-size: 11px; }

.preparation-item-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.preparation-metric {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 7px;
  background: #f6f8f7;
}

.preparation-metric small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.preparation-metric b {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.1;
}

.preparation-item-meta input {
  width: 100%;
  min-height: 25px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 850;
  text-align: center;
}
.preparation-item-meta .preparation-metric.preparation-forecast { background: #eef8f5; }
.preparation-item-meta .preparation-forecast { color: #0f766e; }

.prepared-check {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid #9bd9c5;
  border-radius: 8px;
  background: #f0fdf7;
  color: #0f766e;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.prepared-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.prepared-state { padding-top: 4px; color: var(--muted); font-size: 12px; font-weight: 850; white-space: nowrap; }
.prepared-state.ready { color: #15803d; }
.prepared-state.saving { color: #a16207; }
.prepared-state.error { color: #b91c1c; }

.preparation-pick-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.preparation-pick-actions .prepared-check { min-height: 32px; }

.preparation-picked-quantity {
  display: grid;
  grid-template-columns: auto 48px;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preparation-picked-quantity small { color: var(--muted); font-size: 11px; font-weight: 800; }
.preparation-picked-quantity input { width: 48px; min-height: 28px; padding: 1px 3px; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 900; text-align: center; }
.preparation-pick-actions .prepared-state { padding: 0; font-size: 11px; }

.preparation-workflow-footer {
  position: sticky;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 14;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 1px 0;
  padding: 8px 9px;
  border: 1px solid #b8d8d0;
  border-radius: 11px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 -5px 18px rgba(20, 53, 48, .08);
}

.preparation-workflow-footer span { min-width: 0; color: var(--muted); font-size: 12px; font-weight: 800; }
.preparation-workflow-footer .save-button { min-height: 42px; padding: 0 13px; white-space: nowrap; }
.preparation-workflow-footer .save-button:disabled { opacity: .52; cursor: not-allowed; }

@media (max-width: 720px) {
  /* Keep the one allowed next action visible while staff work down a long list. */
  #preparationView .preparation-panel { padding-bottom: 74px; }

  #preparationView .preparation-workflow-footer {
    position: fixed;
    right: max(10px, calc((100vw - 540px) / 2 + 10px));
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: max(10px, calc((100vw - 540px) / 2 + 10px));
    z-index: 34;
    margin: 0;
  }
}

.preparation-result-controls { display: grid; gap: 9px; }
.preparation-result-actions { justify-content: flex-end; }

.preparation-new-photos,
.preparation-photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preparation-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preparation-photo-actions button {
  min-height: 40px;
  padding: 0 13px;
}

.preparation-photo-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preparation-photo {
  width: 68px;
  height: 68px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preparation-photo img { width: 100%; height: 100%; object-fit: cover; }
.preparation-photo.pending-upload { border-color: #75cbb0; }

.preparation-photo-wrap {
  position: relative;
  display: inline-flex;
  width: 68px;
  height: 68px;
}

.preparation-photo-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
  z-index: 1;
}

.preparation-photo-area {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.preparation-photo-area > strong { color: var(--ink); font-size: 13px; }

.preparation-completed-meta {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 9px;
  background: #ecfdf5;
  color: #166534;
}

.preparation-completed-meta strong { font-size: 15px; }
.preparation-completed-meta span { font-size: 12px; font-weight: 700; }

.preparation-history-list { display: grid; gap: 9px; }
.preparation-history-section {
  margin-top: 5px;
  border-color: #b8d8d0;
  background: #fbfdfc;
}
.preparation-history-month {
  overflow: hidden;
  border: 1px solid #c7ddd7;
  border-radius: 11px;
  background: #f7fcfa;
}
.preparation-history-month > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}
.preparation-history-month > summary::-webkit-details-marker { display: none; }
.preparation-history-month > summary > span { display: grid; gap: 1px; }
.preparation-history-month > summary strong { color: var(--brand-dark); font-size: 15px; }
.preparation-history-month > summary small { color: var(--muted); font-size: 11px; font-weight: 750; }
.preparation-history-month > summary b { color: var(--brand); font-size: 20px; line-height: 1; transition: transform 160ms ease; }
.preparation-history-month[open] > summary { border-bottom: 1px solid #d9e8e3; background: #eef8f4; }
.preparation-history-month[open] > summary b { transform: rotate(90deg); }
.preparation-history-month-list { display: grid; gap: 8px; padding: 8px; }
.preparation-history-receipt {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.preparation-history-receipt summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}

.preparation-history-receipt summary::-webkit-details-marker { display: none; }
.preparation-history-receipt summary > span { display: grid; gap: 2px; min-width: 0; }
.preparation-history-receipt summary strong { color: var(--ink); font-size: 15px; }
.preparation-history-receipt summary small { color: var(--muted); font-size: 11px; font-weight: 700; }
.preparation-history-receipt summary em {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}
.preparation-history-receipt summary em.pending { background: #fff7ed; color: #b45309; }
.preparation-history-receipt summary em.partial { background: #ffedd5; color: #c2410c; }
.preparation-history-receipt summary em.issue { background: #fee2e2; color: #b91c1c; }
.preparation-history-receipt summary em.received { background: #dcfce7; color: #15803d; }
.preparation-history-receipt summary b { flex: 0 0 auto; color: var(--brand); font-size: 20px; line-height: 1; transition: transform 160ms ease; }
.preparation-history-receipt[open] summary { border-bottom: 1px dashed var(--line); }
.preparation-history-receipt[open] summary b { transform: rotate(90deg); }

.preparation-receipt-body { display: grid; gap: 9px; padding: 9px 10px 10px; }
.preparation-receipt-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--muted); font-size: 11px; font-weight: 700; }
.preparation-receipt-times,
.preparation-stage-summary,
.preparation-receipt-count {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.preparation-stage-summary {
  justify-content: space-between;
  padding: 8px;
  border-radius: 8px;
  background: #f5f8f7;
}
.preparation-stage-summary b.ready,
.preparation-stage-summary b.received { color: #15803d; }
.preparation-stage-summary b.pending { color: #b45309; }
.preparation-stage-summary b.partial { color: #c2410c; }
.preparation-stage-summary b.issue { color: #b91c1c; }
.preparation-receipt-item-list { display: grid; gap: 6px; }
.preparation-receipt-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.preparation-receipt-item > label,
.preparation-receipt-item > span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 5px 8px;
}
.preparation-receipt-item input { width: 19px; height: 19px; margin: 0; accent-color: var(--brand); }
.preparation-receipt-item strong,
.preparation-receipt-item small { display: block; min-width: 0; }
.preparation-receipt-item strong { color: var(--ink); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preparation-receipt-item small { margin-top: 1px; color: var(--muted); font-size: 11px; font-weight: 750; }
.preparation-receipt-item em { color: #b45309; font-size: 12px; font-style: normal; font-weight: 850; white-space: nowrap; }
.preparation-receipt-item.received { border-color: #9bd9c5; background: #f0fdf7; }
.preparation-receipt-item.received em { color: #15803d; }
.preparation-receipt-hint { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.preparation-batch-receipt { display: grid; gap: 8px; }
.preparation-batch-receipt-check {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid #82c9bb;
  border-radius: 9px;
  background: #f0fdf7;
  cursor: pointer;
}
.preparation-batch-receipt-check input { width: 21px; height: 21px; margin: 0; accent-color: var(--brand); }
.preparation-batch-receipt-check span { display: grid; gap: 1px; min-width: 0; }
.preparation-batch-receipt-check strong { color: var(--brand-dark); font-size: 15px; }
.preparation-batch-receipt-check small { color: var(--muted); font-size: 11px; font-weight: 700; }
.preparation-receipt-issue-form {
  display: grid;
  gap: 7px;
  padding: 8px 0 0;
  border-top: 1px dashed var(--line);
}
.preparation-receipt-issue-form summary { color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.preparation-receipt-issue-form textarea { min-height: 68px; padding: 8px; resize: vertical; font-size: 13px; }
.preparation-receipt-issue-form .ghost-button { justify-self: start; min-height: 36px; padding: 0 11px; font-size: 12px; }
.preparation-receipt-issue-note {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}
.preparation-receipt-issue-note strong { color: #b91c1c; font-size: 12px; }
.preparation-receipt-issue-note span { color: var(--ink); font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
.preparation-receipt-issue-note small { color: var(--muted); font-size: 11px; font-weight: 700; }
.preparation-receipt-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.preparation-receipt-table { width: 100%; border-collapse: collapse; color: var(--ink); font-size: 12px; }
.preparation-receipt-table th,
.preparation-receipt-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.preparation-receipt-table th { background: #f3f7f5; color: var(--muted); font-size: 11px; font-weight: 850; }
.preparation-receipt-table tbody tr:last-child td { border-bottom: 0; }
.preparation-receipt-table td:first-child { max-width: 146px; overflow: hidden; font-weight: 850; text-overflow: ellipsis; }
.preparation-receipt-table td.ready { color: #15803d; font-weight: 850; }
.preparation-receipt-table td.pending { color: #b45309; font-weight: 850; }
.preparation-receipt-photos { padding-top: 1px; }

.text-danger-button {
  justify-self: start;
  min-height: 32px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: #b91c1c;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
}

.preparation-history-row {
  width: 100%;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.preparation-history-row > span:first-child { display: grid; gap: 1px; }
.preparation-history-row strong { font-size: 14px; }
.preparation-history-row small,
.preparation-history-row > span:nth-child(2) { color: var(--muted); font-size: 12px; font-weight: 700; }
.preparation-history-row b { color: var(--brand); font-size: 20px; }
.compact-empty { min-height: auto; padding: 10px; font-size: 12px; }

.stock-filter-bar {
  position: sticky;
  top: 69px;
  z-index: 7;
  display: grid;
  gap: 8px;
  margin: 0 -2px 10px;
  padding: 8px 2px 10px;
  background: rgba(247, 248, 245, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(217, 222, 216, 0.76);
}

.stock-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.76fr) 44px;
  gap: 8px;
}

.stock-filter-row select,
.stock-search-label input {
  min-height: 44px;
  padding: 9px 11px;
  font-size: 15px;
}

.add-category-button {
  width: 44px;
  min-height: 44px;
  color: var(--brand-dark);
  font-size: 24px;
}

.stock-search-label {
  display: block;
}

.stock-result-count {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.section-block,
.action-panel {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
}

/* Legacy fields remain in the form only for existing-data compatibility. */
#productForm .product-legacy-field[hidden] {
  display: none !important;
}

label span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

input,
textarea,
select {
  width: 100%;
  min-height: 52px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.search-label input {
  min-height: 60px;
  font-size: 20px;
  font-weight: 800;
}

.product-list,
.stack-list {
  display: grid;
  gap: 10px;
}

.initial-count-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.initial-count-list {
  display: grid;
  gap: 10px;
}

.initial-count-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 32, 29, 0.05);
}

.initial-count-card .product-thumb {
  width: 72px;
}

.initial-count-info {
  align-self: center;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.initial-count-card label {
  gap: 5px;
}

.initial-count-card label span {
  font-size: 12px;
}

.initial-count-card input {
  min-height: 46px;
  padding: 10px 11px;
  font-size: 16px;
}

.initial-count-complete {
  grid-column: 3 / -1;
  align-self: center;
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.initial-count-complete strong {
  font-size: 18px;
}

.product-card {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 32, 29, 0.05);
}

.compact-action {
  min-height: 36px;
  padding: 0 10px;
  font-size: 14px;
}

.purchase-suggestion-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.purchase-suggestion-summary article,
.purchase-suggestion-card,
.purchase-suggestion-composer {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 5px 14px rgba(23, 32, 29, 0.045);
}

.purchase-suggestion-summary article {
  display: grid;
  gap: 2px;
  padding: 10px;
}

.purchase-suggestion-summary span,
.purchase-suggestion-summary small,
.purchase-suggestion-card small,
.purchase-suggestion-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.purchase-suggestion-summary strong {
  color: var(--brand-dark);
  font-size: 24px;
  line-height: 1;
}

.purchase-suggestion-composer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 12px;
}

.purchase-suggestion-composer label {
  flex: 1 1 190px;
}

.purchase-suggestion-composer .primary-link {
  min-height: 52px;
  white-space: nowrap;
}

.purchase-suggestion-composer-final {
  margin-top: 2px;
  align-items: center;
}

.purchase-suggestion-composer-final .primary-link {
  min-height: 46px;
}

.purchase-suggestion-form-hint {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.purchase-suggestion-form-hint.is-warning {
  color: #b9473e;
}

.purchase-suggestion-form-hint.is-ready {
  color: var(--brand-dark);
}

.purchase-suggestion-select-hint {
  flex: 1 1 180px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.purchase-suggestion-search {
  display: block;
  margin-bottom: 10px;
}

.purchase-suggestion-search input {
  min-height: 46px;
}

.purchase-suggestion-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 11px;
}

.purchase-suggestion-filters button {
  min-height: 36px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #4a5954;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.purchase-suggestion-filters button b {
  margin-left: 3px;
  color: inherit;
  font-size: 11px;
}

.purchase-suggestion-filters button.active {
  border-color: #9fd6ca;
  background: var(--soft);
  color: var(--brand-dark);
}

.purchase-suggestion-list {
  display: grid;
  gap: 10px;
}

.purchase-suggestion-card {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 10px 11px;
}

.purchase-suggestion-card.is-replenishing {
  background: #fbfcfb;
}

.purchase-suggestion-card.is-quantity-step {
  gap: 7px;
  padding: 10px 11px;
}

.purchase-suggestion-card.is-quantity-step .purchase-suggestion-head {
  padding-right: 0;
}

.purchase-suggestion-card.is-quantity-step .purchase-suggestion-head strong {
  font-size: 17px;
}

.purchase-suggestion-card.is-quantity-step .purchase-suggestion-metrics span {
  gap: 2px;
  padding: 6px 5px;
  font-size: 10px;
}

.purchase-suggestion-card.is-quantity-step .purchase-suggestion-metrics b {
  font-size: 16px;
}

.purchase-suggestion-select {
  position: absolute;
  top: 11px;
  right: 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 850;
}

.purchase-suggestion-select input {
  width: 19px;
  min-height: 19px;
  margin: 0;
  accent-color: var(--brand);
}

.purchase-suggestion-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  padding-right: 54px;
}

.purchase-suggestion-head > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.purchase-suggestion-head .purchase-suggestion-badges {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.purchase-suggestion-head strong {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-suggestion-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border-radius: 8px;
  background: #f1f5f3;
}

.purchase-suggestion-metrics span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-align: center;
}

.purchase-suggestion-metrics b {
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
}

.purchase-suggestion-quantity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.purchase-suggestion-quantity label {
  display: grid;
  grid-template-columns: auto minmax(0, 130px);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.purchase-suggestion-quantity span {
  color: var(--brand-dark);
  font-weight: 850;
}

.purchase-suggestion-quantity input {
  min-height: 42px;
  padding: 7px 10px;
  font-size: 18px;
  font-weight: 850;
  text-align: right;
}

.purchase-suggestion-card.is-quantity-step .purchase-suggestion-quantity input {
  min-height: 38px;
  font-size: 16px;
}

.purchase-suggestion-card.is-quantity-step .purchase-suggestion-remove {
  min-height: 34px;
}

.purchase-suggestion-remove {
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid #f2c6c2;
  border-radius: 7px;
  background: #fff8f7;
  color: #b9473e;
  font-size: 13px;
  font-weight: 800;
}

.purchase-suggestion-empty-hint {
  flex: 1 1 100%;
  color: #b9473e;
  font-size: 13px;
  font-weight: 750;
}

.simple-purchase-list {
  display: grid;
  gap: 8px;
}

.simple-purchase-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.simple-purchase-row strong,
.simple-purchase-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.simple-purchase-row strong {
  font-size: 15px;
}

.simple-purchase-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.simple-purchase-status {
  justify-self: end;
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf7f4;
  color: var(--brand-dark);
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.simple-purchase-status.pending-confirmation,
.simple-purchase-status.returned {
  background: #fff4e9;
  color: #a55b13;
}

.simple-purchase-status.purchased {
  background: #e7f2fb;
  color: #21658f;
}

.simple-purchase-status.deferred {
  background: #f1f3f5;
  color: #667085;
}

.simple-purchase-modal-card {
  width: min(94vw, 430px);
  max-height: min(88vh, 720px);
  overflow: auto;
}

.simple-purchase-paper {
  display: grid;
  gap: 12px;
  padding: 2px 0 4px;
}

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

.simple-purchase-paper h3,
.simple-purchase-paper p {
  margin: 0;
}

.simple-purchase-paper h3 {
  font-size: 20px;
}

.simple-purchase-paper p,
.simple-purchase-paper small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.simple-purchase-paper-lines {
  border-top: 1px solid var(--line);
}

.simple-purchase-paper-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 43px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.simple-purchase-paper-line span:last-child {
  color: var(--brand-dark);
  white-space: nowrap;
}

.simple-purchase-note {
  padding: 10px;
  border-radius: 8px;
  background: #f5f7f8;
  color: #475467;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.simple-purchase-linked-task {
  margin: -2px 0 0;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.simple-purchase-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.simple-purchase-actions button {
  min-height: 42px;
  padding: 8px;
  font-size: 14px;
}

.simple-purchase-assignee {
  display: grid;
  grid-column: 1 / -1;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.simple-purchase-assignee select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
}

.simple-purchase-action-hint {
  grid-column: 1 / -1;
  color: #a55b13;
  font-size: 13px;
  font-weight: 800;
}

.simple-purchase-image-card {
  width: min(96vw, 520px);
  max-height: 94vh;
  overflow: auto;
}

.simple-purchase-image-card img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 4px;
  border: 1px solid var(--line);
  background: #fff;
}

@media (max-width: 374px) {
  .simple-purchase-actions { grid-template-columns: 1fr; }
}

.stock-request-source {
  display: block;
  width: 100%;
  margin: 7px 0;
  padding: 7px 8px;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 3px solid var(--brand);
  border-radius: 0 7px 7px 0;
  background: var(--soft);
  color: var(--brand-dark);
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
}

@media (max-width: 430px) {
  .purchase-suggestion-composer {
    align-items: stretch;
  }

  .purchase-suggestion-composer .primary-link {
    flex: 1 1 100%;
    width: 100%;
  }

  .purchase-suggestion-quantity label {
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 8px;
  }
}

.product-select {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.product-select input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

.product-thumb {
  width: 96px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f1;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.product-info {
  min-width: 0;
  display: grid;
  gap: 5px;
}

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

.sku-line strong {
  font-size: 21px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 850;
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.danger {
  background: #fef1f1;
  color: #bb2d2d;
}

.product-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stock-number {
  color: var(--brand-dark);
  font-size: 28px;
  font-weight: 950;
  text-align: right;
}

.product-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.product-actions button {
  min-height: 48px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 900;
}

.product-actions .out {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.product-actions .delete-product {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--danger);
}

#stockView .product-card {
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 9px 10px;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(23, 32, 29, 0.04);
}

#stockView .product-thumb {
  width: 64px;
  border-radius: 10px;
}

#stockView .product-info {
  align-self: center;
  gap: 2px;
}

#stockView .sku-line {
  padding-right: 20px;
}

#stockView .sku-line strong {
  font-size: 19px;
  line-height: 1.15;
}

#stockView .product-meta {
  font-size: 12px;
  line-height: 1.28;
}

.stock-summary {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 1px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.stock-summary strong {
  color: var(--brand-dark);
  font-size: 24px;
  line-height: 1;
}

.stock-summary em {
  color: var(--brand-dark);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.stock-summary em.warn {
  color: var(--warn);
}

.compact-stock-card {
  min-height: 58px;
}

#stockView .compact-stock-card {
  grid-template-columns: minmax(0, 1fr) 66px;
}

#stockView .compact-stock-card .product-thumb {
  display: none;
}

#stockView .compact-stock-card .product-meta {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#stockView .compact-stock-card .product-actions,
.warning-card .product-actions {
  display: none;
}

.warning-card {
  grid-template-columns: minmax(0, 1fr) 76px;
  cursor: pointer;
}

.warning-card .product-thumb {
  display: none;
}

.warning-card .stock-summary {
  align-content: center;
}

#stockView .product-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

#stockView .product-actions.two-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#stockView .product-actions > button,
#stockView .product-more summary {
  display: inline-grid;
  place-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 850;
  list-style: none;
}

#stockView .product-actions > .out {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

#stockView .product-more {
  position: relative;
}

#stockView .product-more summary::-webkit-details-marker {
  display: none;
}

#stockView .product-more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  z-index: 10;
  display: grid;
  min-width: 132px;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

#stockView .product-more-menu button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  text-align: left;
}

#stockView .product-more-menu .delete-product {
  color: var(--danger);
}

#stockView .product-select {
  top: 8px;
  right: 78px;
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

#stockView .product-select input {
  width: 16px;
  height: 16px;
}

.compact-list .product-card {
  cursor: pointer;
}

.stock-form {
  display: grid;
  gap: 12px;
}

.batch-panel {
  gap: 12px;
}

.import-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px dashed #b7cfc8;
  border-radius: 8px;
  background: #f7fbf8;
}

.import-strip span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.batch-table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.batch-table-head strong {
  font-size: 18px;
}

.batch-table-head span {
  color: var(--brand-dark);
  font-weight: 950;
}

.batch-rows {
  display: grid;
  gap: 9px;
}

.batch-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 148px 52px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.batch-row .product-thumb {
  width: 76px;
}

.batch-qty-stepper {
  display: grid;
  grid-template-columns: 40px minmax(52px, 1fr) 40px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.batch-qty-stepper button {
  min-height: 46px;
  border: 0;
  background: #eef4f2;
  color: var(--brand-dark);
  font-size: 22px;
  font-weight: 950;
}

.batch-qty-stepper input {
  min-height: 46px;
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  text-align: center;
  font-weight: 950;
}

.remove-line {
  width: 52px;
  min-height: 46px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--danger);
  font-size: 14px;
  font-weight: 900;
}

.preview-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preview-card .product-thumb {
  width: 104px;
}

.save-button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow);
  font-size: 20px;
  font-weight: 950;
}

.save-button.danger,
.save-button.inline-save.danger {
  background: var(--danger);
}

.inline-save {
  position: static;
  min-height: 50px;
  font-size: 18px;
}

.transaction-card {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.order-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 32, 29, 0.05);
}

.order-card .ghost-button {
  justify-self: start;
  min-height: 40px;
}

.transaction-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.transaction-main strong {
  font-size: 18px;
}

.quantity-plus {
  color: var(--brand-dark);
  font-weight: 950;
}

.quantity-minus {
  color: var(--danger);
  font-weight: 950;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 150px;
  gap: 10px;
  margin-bottom: 12px;
}

.warning-card .product-actions {
  grid-template-columns: repeat(2, minmax(0, 130px));
  justify-content: start;
}

.count-diff-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 0.9fr);
  gap: 8px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.count-diff-card span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.count-diff-card strong {
  color: var(--brand-dark);
  font-size: 24px;
  font-weight: 950;
  text-align: right;
}

.count-diff-card input {
  min-height: 46px;
  padding: 8px 10px;
  text-align: right;
  font-weight: 950;
}

.count-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.stock-request {
  border-color: rgba(15, 118, 110, 0.22);
}

.outbound-request {
  border-color: #fecaca;
}

.request-lines {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: #f8faf9;
}

.request-line {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) 72px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.request-line strong {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.request-line span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.request-line b {
  color: var(--ink);
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 560px);
  max-height: calc(100svh - 36px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-modal-card {
  width: min(100%, 620px);
}

.detail-content {
  display: grid;
  gap: 12px;
}

.detail-hero {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-hero.has-image {
  grid-template-columns: 82px minmax(0, 1fr) 86px;
}

.detail-hero.no-image {
  grid-template-columns: minmax(0, 1fr) 86px;
}

.detail-hero .product-thumb {
  width: 82px;
}

.detail-hero .product-thumb + div {
  min-width: 0;
}

.detail-stock {
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.detail-stock strong {
  color: var(--brand-dark);
  font-size: 30px;
  line-height: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-row {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.detail-row strong {
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-actions .save-button,
.detail-actions .ghost-button {
  min-height: 50px;
  font-size: 16px;
}

.category-admin-card {
  width: min(100%, 620px);
}

.category-create-card {
  width: min(100%, 500px);
}

.category-create-search {
  display: grid;
  gap: 6px;
}

.category-create-search span,
.category-create-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-create-primary-list {
  display: grid;
  gap: 8px;
  max-height: min(42svh, 340px);
  overflow: auto;
  padding: 2px;
}

.category-create-primary-option {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 850;
  text-align: left;
}

.category-create-primary-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-create-primary-option b {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.category-create-primary-option.selected {
  border-color: var(--brand);
  background: #edf7f5;
  color: var(--brand-dark);
}

.category-create-primary-option.selected b {
  color: var(--brand-dark);
}

.category-create-hint {
  min-height: 19px;
  margin: -3px 0 0;
}

.category-manage-list {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.category-manage-search {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.category-manage-search span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-manage-group {
  display: grid;
  gap: 8px;
}

.category-manage-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.category-manage-group > header strong {
  color: var(--brand-dark);
  font-size: 15px;
}

.category-manage-group > header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.category-manage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px 78px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.category-manage-row div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.category-manage-row strong {
  overflow-wrap: anywhere;
}

.category-manage-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.category-manage-row .ghost-button {
  min-height: 40px;
  padding: 0 8px;
  font-size: 13px;
}

.image-picker {
  display: grid;
  gap: 10px;
}

.attachment-button {
  min-height: 54px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 900;
}

#productImagePreview {
  width: 120px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 22px;
  min-height: 22px;
}

.check-row span {
  color: var(--ink);
}

.confirm-card {
  place-self: center;
}

.confirm-body {
  display: grid;
  gap: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.confirm-body strong {
  color: var(--ink);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.receipt-modal-card {
  width: min(100%, 760px);
  background: #f2f4f1;
}

.receipt-paper {
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  color: #111827;
}

.receipt-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 2px solid #111827;
  padding-bottom: 12px;
}

.receipt-title h2 {
  font-size: 24px;
}

.receipt-title span,
.receipt-meta span {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.4;
}

.receipt-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
}

.receipt-lines {
  display: grid;
  border: 1px solid #d1d5db;
  border-bottom: 0;
  font-size: 14px;
}

.receipt-line {
  display: grid;
  grid-template-columns: minmax(190px, 2fr) minmax(110px, 1fr) minmax(90px, 0.8fr) minmax(74px, 0.6fr);
  border-bottom: 1px solid #d1d5db;
}

.receipt-line > span {
  min-width: 0;
  padding: 9px 10px;
  border-right: 1px solid #d1d5db;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.receipt-line > span:last-child {
  border-right: 0;
  text-align: right;
}

.receipt-line-head {
  background: #f3f4f6;
  color: #111827;
  font-weight: 900;
}

.receipt-model {
  display: grid;
  gap: 3px;
}

.receipt-model strong {
  font-size: 15px;
}

.receipt-model em {
  color: #6b7280;
  font-size: 12px;
  font-style: normal;
}

.receipt-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-weight: 900;
}

.receipt-sign {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  margin-top: 18px;
}

.receipt-sign label {
  display: grid;
  gap: 8px;
}

.receipt-sign input {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid #111827;
  border-radius: 0;
  background: transparent;
  color: #111827;
  font-size: 18px;
  font-weight: 850;
}

.receipt-sign span {
  border-top: 1px solid #111827;
  padding-top: 8px;
  color: #4b5563;
}

.receipt-sign label span {
  border-top: 0;
  padding-top: 0;
}

.receipt-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.empty-panel,
.empty {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
}

.empty-panel strong,
.empty strong {
  color: var(--ink);
  font-size: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 80;
  transform: translate(-50%, 20px);
  opacity: 0;
  min-width: 220px;
  max-width: calc(100vw - 36px);
  padding: 13px 16px;
  border-radius: 8px;
  background: #17201d;
  color: #fff;
  text-align: center;
  font-weight: 850;
  transition: 180ms ease;
  pointer-events: none;
}

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100%, 540px);
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar.compact {
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .module-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
  }

  .module-tab {
    min-height: 50px;
    min-width: 0;
    padding: 0 4px;
    font-size: 15px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .dashboard-grid article,
  .summary-card {
    min-height: 76px;
    padding: 12px;
    border-radius: 12px;
  }

  .dashboard-grid strong {
    font-size: 29px;
  }

  .dashboard-grid span {
    font-size: 13px;
  }

  .topbar:not(.compact) {
    padding: 2px 0 10px;
  }

  .topbar:not(.compact) h1 {
    font-size: 25px;
  }

  .warehouse-subtitle {
    font-size: 12px;
  }

  .stock-filter-bar {
    top: 61px;
    margin-left: -2px;
    margin-right: -2px;
  }

  #stockView .product-card {
    grid-template-columns: minmax(0, 1fr) 58px;
    gap: 7px 8px;
    min-height: 58px;
    padding: 8px 9px;
  }

  #stockView .product-thumb {
    display: none;
  }

  #stockView .sku-line strong {
    font-size: 18px;
  }

  #stockView .product-meta {
    font-size: 12px;
  }

  #stockView .stock-summary strong {
    font-size: 22px;
  }

  .stock-header-actions {
    gap: 6px;
  }

  .stock-header-actions .ghost-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .detail-grid,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .detail-hero.has-image,
  .detail-hero.no-image {
    grid-template-columns: 1fr;
  }

  .detail-hero.has-image {
    position: relative;
    padding-right: 86px;
  }

  .detail-hero.has-image .product-thumb {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 62px;
  }

  .detail-stock {
    justify-items: start;
  }

  .category-manage-row {
    grid-template-columns: minmax(0, 1fr) 66px 66px;
    padding: 9px;
  }

  .initial-count-card {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .initial-count-card .product-thumb {
    width: 58px;
  }

  .initial-count-card label {
    grid-column: span 1;
  }

  .initial-count-card label:nth-last-child(2) {
    grid-column: 1 / 2;
  }

  .initial-count-card label:last-child {
    grid-column: 2 / 3;
  }

  .initial-count-complete {
    grid-column: 1 / -1;
  }

  .product-thumb {
    width: 74px;
  }

  .sku-line strong {
    font-size: 18px;
  }

  .product-meta {
    font-size: 12px;
    line-height: 1.26;
  }

  .stock-number {
    grid-column: 2;
    text-align: left;
    font-size: 22px;
  }

  .product-actions {
    gap: 6px;
  }

  .product-actions button {
    min-height: 40px;
    font-size: 14px;
  }

  .compact-list .product-card {
    grid-template-columns: 62px minmax(0, 1fr) auto;
  }

  .compact-list .product-thumb {
    width: 62px;
  }

  .compact-list .stock-number {
    grid-column: 3;
    text-align: right;
    font-size: 20px;
  }

  .filter-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .warning-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .batch-row {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .batch-row .product-thumb {
    width: 64px;
  }

  .batch-qty-stepper,
  .remove-line {
    grid-column: 2;
  }

  .batch-qty-stepper {
    grid-template-columns: 48px minmax(70px, 1fr) 48px;
  }

  .remove-line {
    width: 100%;
  }

  .receipt-paper {
    padding: 16px;
  }

  .receipt-title,
  .receipt-summary {
    display: grid;
  }

  .receipt-meta,
  .receipt-sign {
    grid-template-columns: 1fr;
  }

  .receipt-lines {
    gap: 8px;
    border: 0;
    font-size: 13px;
  }

  .receipt-line-head {
    display: none;
  }

  .receipt-line {
    grid-template-columns: 1fr;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
  }

  .receipt-line > span {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
    text-align: right;
  }

  .receipt-line > span:last-child {
    border-bottom: 0;
  }

  .receipt-line > span::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: #6b7280;
    font-weight: 850;
    text-align: left;
  }

  .receipt-model {
    display: grid !important;
    justify-content: stretch !important;
    text-align: left !important;
  }

  .receipt-model::before {
    content: none !important;
  }

  .receipt-actions {
    grid-template-columns: 1fr;
  }

  .request-line {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .request-line span {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .app-shell,
  .no-print,
  #toast,
  .modal:not(#receiptModal) {
    display: none !important;
  }

  #receiptModal {
    position: static;
    display: block !important;
    padding: 0;
    background: #fff;
  }

  .receipt-modal-card {
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 0;
    box-shadow: none;
    background: #fff;
  }

  .receipt-paper {
    border-radius: 0;
    padding: 0;
    gap: 10px;
  }

  .receipt-title h2 {
    font-size: 22px;
  }

  .receipt-line {
    grid-template-columns: minmax(170px, 2fr) minmax(90px, 1fr) minmax(70px, 0.8fr) minmax(56px, 0.6fr);
  }

  .receipt-line > span {
    padding: 7px 8px;
  }

  .receipt-sign {
    margin-top: 12px;
  }

  .receipt-sign input {
    appearance: none;
    -webkit-appearance: none;
    color: #111827;
    border-bottom: 1px solid #111827;
  }
}

@media (max-width: 380px) {
  .dashboard-grid strong {
    font-size: 26px;
  }

  .product-card {
    grid-template-columns: 64px minmax(0, 1fr);
    padding: 8px;
  }

  .product-thumb {
    width: 64px;
  }

  .sku-line strong {
    font-size: 17px;
  }
}

/* Use uploaded product pictures in the existing warehouse flows without adding a new page. */
.product-image-button {
  appearance: none;
  margin: 0;
  padding: 0;
  cursor: zoom-in;
}

.product-image-button:focus-visible {
  outline: 3px solid rgba(16, 132, 119, 0.45);
  outline-offset: 2px;
}

#stockView .stock-product-card.has-image {
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
}

#stockView .stock-product-card.has-image .product-image-button {
  display: block;
  grid-column: 1;
  grid-row: 1;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

#stockView .stock-product-card.has-image .stock-card-body {
  display: grid;
  grid-column: 2;
  min-width: 0;
  gap: 5px;
}

.product-image-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compact-list .product-card.has-image {
  grid-template-columns: 62px minmax(0, 1fr) auto;
}

.compact-list .product-card.has-image .product-image-button {
  display: block;
  width: 62px;
  height: 62px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.preview-card .product-image-button {
  display: block;
  width: 104px;
  height: 104px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.detail-hero.has-image .product-image-button {
  display: block;
  width: 82px;
  height: 82px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.image-preview-modal {
  z-index: 70;
  padding: 12px;
}

.image-preview-modal-card {
  width: min(100%, 860px);
  max-height: calc(100svh - 24px);
  padding: 12px;
  background: #fff;
}

.image-preview-heading {
  padding: 2px 2px 10px;
}

.image-preview-stage {
  display: grid;
  min-height: 220px;
  max-height: calc(100svh - 104px);
  place-items: center;
  overflow: auto;
  border-radius: 10px;
  background: #f3f6f5;
}

.image-preview-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100svh - 104px);
  object-fit: contain;
}

@media (max-width: 720px) {
  .inbound-review-line {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .inbound-review-line.has-image {
    grid-template-columns: 42px minmax(0, 1fr) auto;
  }

  /* The generic mobile request rule moves its text block below the quantity.
     V2 review rows need the model to remain above the decision buttons. */
  .inbound-review-line .request-line-copy {
    grid-column: 1;
    order: initial;
  }

  .inbound-review-line.has-image .request-line-copy {
    grid-column: 2;
  }

  .inbound-review-line > b {
    grid-column: 2;
    grid-row: 1;
  }

  .inbound-review-line.has-image > b {
    grid-column: 3;
  }

  .inbound-review-line .inbound-line-review-actions,
  .inbound-review-line .inbound-reject-reason,
  .inbound-review-line .inbound-line-result {
    order: initial;
  }

  #preparationView .topbar.compact {
    margin-left: -14px;
    margin-right: -14px;
  }

  .today-preparation-entry {
    margin-bottom: 10px;
  }

  .preparation-panel {
    gap: 8px;
  }

  .preparation-section {
    padding: 9px;
  }

  .preparation-add-form {
    grid-template-columns: minmax(0, 1fr) 64px 108px;
  }

  .preparation-add-form .save-button {
    min-height: 38px;
  }

  .preparation-result-actions {
    display: block;
  }

  .preparation-result-actions button {
    width: 100%;
    min-height: 42px;
    padding: 0 8px;
    font-size: 13px;
  }

  #stockView .stock-product-card.has-image {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  #stockView .stock-product-card.has-image .product-image-button {
    display: block;
    width: 58px;
    height: 58px;
  }

  .compact-list .product-card.has-image {
    grid-template-columns: 58px minmax(0, 1fr) auto;
  }

  .compact-list .product-card.has-image .product-image-button {
    display: block;
    width: 58px;
    height: 58px;
  }

  .preview-card .product-image-button {
    width: 82px;
    height: 82px;
  }
}

.module-tab.approval-tab {
  position: relative;
}

.tab-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0 6px;
  place-items: center;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.tab-badge[hidden] {
  display: none;
}

.summary-card.approval-summary.has-pending {
  border-color: rgba(234, 88, 12, 0.56);
  background: #fff7ed;
}

.summary-card.approval-summary.has-pending strong {
  color: #c2410c;
}

.detailed-request-line {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detailed-request-line.has-image {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.detailed-request-line .product-image-button {
  width: 42px;
  height: 42px;
  border-radius: 7px;
}

.request-line-copy { display: grid; gap: 2px; min-width: 0; }
.request-line-copy strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.request-line-copy small { color: var(--muted); font-size: 11px; font-weight: 700; }
.detailed-request-line > b { color: var(--brand-dark); font-size: 13px; white-space: nowrap; }

.inbound-review-line {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 9px;
}

.inbound-review-line.has-image {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.inbound-line-review-actions,
.inbound-review-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  grid-column: 1 / -1;
}

.inbound-line-review-actions button,
.line-resubmit-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
}

.inbound-line-review-actions button.selected.approve {
  border-color: #16a34a;
  background: #dcfce7;
  color: #15803d;
}

.inbound-line-review-actions button.selected.reject,
.line-resubmit-button {
  border-color: #fecaca;
  background: #fff7f7;
  color: #b91c1c;
}

.inbound-reject-reason {
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
  padding: 7px;
  border-radius: 7px;
  background: #fff7f7;
}

.inbound-reject-reason > span,
.inbound-reject-reason label {
  color: #991b1b;
  font-size: 12px;
  font-weight: 850;
}

.inbound-reject-reason-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.inbound-reject-reason-options button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff;
  color: #991b1b;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}

.inbound-reject-reason-options button.selected {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

.inbound-reject-reason input {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid #fecaca;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
}

.inbound-line-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  grid-column: 1 / -1;
}

.line-review-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.line-review-status.pending { background: #fee2e2; color: #b91c1c; }
.line-review-status.approved { background: #dcfce7; color: #15803d; }
.line-review-status.rejected { background: #f3f4f6; color: #6b7280; }
.line-reject-copy { width: 100%; color: #b91c1c; font-size: 11px; font-weight: 750; text-align: right; }

.inbound-resubmit-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 7px;
  width: 100%;
  margin-top: 2px;
  padding: 8px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fffafa;
}

.inbound-resubmit-panel label {
  display: grid;
  gap: 4px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 800;
}

.inbound-resubmit-panel input {
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.resubmit-product-results {
  display: grid;
  gap: 4px;
  grid-column: 1 / -1;
}

.resubmit-hint,
.selected-resubmit-product {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.selected-resubmit-product { color: var(--brand-dark); }

.resubmit-product-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.resubmit-product-option strong { font-size: 13px; }
.resubmit-product-option span { color: var(--muted); font-size: 11px; font-weight: 750; }
.inbound-resubmit-panel .save-button { grid-column: 1 / -1; min-height: 38px; font-size: 13px; }

.stock-request-overview { display: grid; gap: 2px; color: var(--ink); }
.stock-request-overview > span { font-size: 14px; font-weight: 850; }
.stock-request-overview small { color: var(--muted); font-size: 12px; font-weight: 700; }
.stock-request-overview b { color: var(--brand-dark); font-size: 13px; }
.stock-request-details { margin-top: 2px; border-top: 1px dashed var(--line); }
.stock-request-details summary { padding: 9px 0 2px; color: var(--brand-dark); font-size: 13px; font-weight: 850; cursor: pointer; list-style: none; }
.stock-request-details summary::-webkit-details-marker { display: none; }
.stock-request-details summary::after { content: "›"; display: inline-block; margin-left: 5px; font-size: 17px; line-height: 0; transition: transform 160ms ease; }
.stock-request-details[open] summary::after { transform: rotate(90deg); }
.stock-request-detail-body { display: grid; gap: 8px; padding: 7px 0 1px; }
.stock-request-number { color: var(--muted); font-size: 11px; font-weight: 700; }
.stock-request-detail-body .request-lines { padding: 0; background: transparent; }
.stock-request-detail-body .count-actions { padding-top: 2px; }

.request-status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.request-status.pending { background: #fee2e2; color: #b91c1c; }
.request-status.approved { background: #dcfce7; color: #15803d; }
.request-status.partial-approved { background: #fef3c7; color: #b45309; }
.request-status.rejected,
.request-status.cancelled { background: #f3f4f6; color: #6b7280; }

.approval-filter {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.approval-filter button {
  min-width: 0;
  min-height: 40px;
  padding: 0 4px;
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 430px) {
  #approvalsView .action-panel { padding: 10px; }
  .approval-filter { gap: 5px; padding: 4px; }
  .approval-filter button { min-height: 38px; font-size: 13px; }
  .stock-request { gap: 7px; padding: 10px; }
  .stock-request .transaction-main strong { font-size: 15px; }
}

@media (max-width: 520px) {
  .preparation-section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .preparation-demand-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .preparation-demand-actions.has-receive-action {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preparation-demand-actions button {
    width: 100%;
    min-height: 42px;
    padding: 0 8px;
    white-space: nowrap;
  }

  .preparation-summary span { min-height: 58px; padding: 7px; }
  .preparation-summary b { font-size: 20px; }
  .preparation-summary small { font-size: 10px; }
}

/* Dongxing mobile app shell */
body {
  background: #f6f7f8;
}

.app-shell {
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 35;
  width: min(100%, 980px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(217, 222, 216, 0.95);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -6px 18px rgba(23, 32, 29, 0.05);
  backdrop-filter: blur(14px);
}

.bottom-nav[hidden] {
  display: none;
}

.bottom-nav-item,
.module-tab.bottom-nav-item {
  display: grid;
  grid-template-rows: 24px auto;
  align-content: center;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  padding: 4px 3px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #334155;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.bottom-nav-icon {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.bottom-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-nav-item.active,
.module-tab.bottom-nav-item.active {
  background: #e6f4ef;
  color: var(--brand-dark);
}

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

@media (max-width: 374px) {
  .bottom-nav { padding-left: 5px; padding-right: 5px; }
  .bottom-nav-item,
  .module-tab.bottom-nav-item { min-height: 56px; font-size: 15px; }
  .bottom-nav-icon { width: 22px; height: 22px; }
}

.menu-modal {
  place-items: end center;
}

.more-menu-card {
  width: min(100%, 420px);
  border-radius: 14px 14px 0 0;
  background: #f6f7f8;
}

.more-menu-list {
  display: grid;
  gap: 8px;
}

.more-menu-list button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  text-align: left;
  padding: 0 14px;
}

.stock-mobile-header {
  height: 56px;
  margin-bottom: 0;
  padding-top: max(6px, env(safe-area-inset-top));
  padding-bottom: 6px;
}

.stock-mobile-header h1 {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  font-size: 18px;
  font-weight: 950;
}

.stock-mobile-header h1 small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.stock-mobile-header .icon-button {
  width: 42px;
  min-height: 42px;
  border: 0;
  background: transparent;
  font-size: 28px;
}

.floating-menu {
  position: fixed;
  top: calc(54px + env(safe-area-inset-top));
  right: 12px;
  z-index: 50;
  display: grid;
  min-width: 168px;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(23, 32, 29, 0.12);
}

.floating-menu[hidden] {
  display: none;
}

.floating-menu button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  text-align: left;
}

.floating-menu button:hover {
  background: #f2f5f4;
}

#stockView .stock-filter-bar {
  position: sticky;
  top: 56px;
  z-index: 6;
  gap: 7px;
  margin: 0 -4px 8px;
  padding: 8px 4px 8px;
  border-bottom: 0;
  background: rgba(246, 247, 248, 0.98);
}

#stockView .stock-search-label input {
  min-height: 47px;
  padding: 10px 13px;
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  font-weight: 750;
}

#stockView .compact-filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

#stockView .compact-filter-row::-webkit-scrollbar {
  display: none;
}

#stockView .compact-filter-row select {
  min-height: 38px;
  padding: 0 28px 0 10px;
  border-radius: 10px;
  background-color: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
}

#stockView .stock-result-count {
  min-height: 16px;
  margin: 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.warehouse-category-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.warehouse-category-filters select {
  min-width: 0;
}

#stockView .product-list {
  gap: 8px;
}

.stock-load-more {
  width: 100%;
  min-height: 42px;
  color: var(--brand);
  font-size: 14px;
}

#stockView .stock-product-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  min-height: 78px;
  padding: 10px 12px;
  border: 1px solid rgba(217, 222, 216, 0.84);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
  cursor: pointer;
}

.stock-card-main,
.stock-card-meta {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.stock-card-sku {
  min-width: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 950;
  line-height: 1.18;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-card-qty {
  color: var(--brand-dark);
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
  text-align: right;
}

.stock-card-qty-box {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 52px;
}

.stock-card-qty-box span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.stock-card-meta span {
  min-width: 0;
  color: #56615c;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-card-meta .badge {
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.stock-card-location {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-admin-card {
  width: min(100%, 760px);
  max-height: min(86vh, 760px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.model-manage-tools {
  display: grid;
  gap: 8px;
}

.model-manage-tools input,
.model-manage-tools select {
  min-height: 42px;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-weight: 800;
}

.model-manage-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.model-manage-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.model-manage-summary > div {
  display: flex;
  gap: 6px;
}

.model-manage-summary .ghost-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.model-manage-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 7px;
  margin-top: 10px;
  padding-right: 2px;
}

.model-manage-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(217, 222, 216, 0.9);
  border-radius: 10px;
  background: #fff;
}

.model-manage-row.is-inactive {
  background: #f7f8f7;
}

.model-manage-check {
  display: grid;
  place-items: center;
}

.model-manage-check input {
  width: 18px;
  height: 18px;
}

.model-manage-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.model-manage-info strong,
.model-manage-info span,
.model-manage-info small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-manage-info strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
}

.model-manage-info span {
  color: #56615c;
  font-size: 12px;
  font-weight: 800;
}

.model-manage-info small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.model-manage-actions {
  display: flex;
  gap: 5px;
}

.model-manage-actions .ghost-button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

/* Simplified warehouse detail view for mobile stock keepers */
#productDetailModal .detail-modal-card {
  width: min(100%, 540px);
  border-radius: 14px 14px 0 0;
}

#productDetailModal .detail-content {
  gap: 10px;
}

#productDetailModal .detail-hero {
  padding: 13px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
}

#productDetailModal .detail-row {
  border-radius: 12px;
  background: #fff;
}

#productDetailModal .detail-row strong {
  font-size: 16px;
}

@media (max-width: 560px) {
  .model-admin-card {
    width: calc(100vw - 18px);
    max-height: 88vh;
    padding: 12px;
  }

  .model-manage-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .model-manage-actions {
    grid-column: 2;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .model-manage-summary {
    align-items: flex-start;
    display: grid;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100%, 480px);
    padding: max(8px, env(safe-area-inset-top)) 10px calc(82px + env(safe-area-inset-bottom));
  }

  .topbar.compact {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 8px;
    padding-right: 8px;
  }

  #stockView .product-card {
    grid-template-columns: 1fr;
  }

  #stockView .stock-product-card {
    min-height: 88px;
  }
}

@media (max-width: 380px) {
  #stockView .stock-product-card {
    min-height: 84px;
    padding: 10px 11px;
    gap: 7px;
  }

  .stock-card-sku {
    font-size: 16px;
  }

  .stock-card-qty {
    font-size: 19px;
  }

  .stock-card-qty-box {
    min-width: 44px;
  }

  #stockView .compact-filter-row {
    grid-template-columns: repeat(3, 92px);
  }

  .model-manage-filters {
    grid-template-columns: repeat(3, 112px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .model-manage-filters::-webkit-scrollbar {
    display: none;
  }

  .model-manage-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .model-manage-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

/* Final mobile overrides: product photos remain visible in stock and outbound lists. */
#stockView .stock-product-card.has-image {
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
}

#stockView .stock-product-card.has-image .product-image-button {
  display: block;
  grid-column: 1;
  grid-row: 1;
  width: 64px;
  height: 64px;
}

#stockView .stock-product-card.has-image .stock-card-body {
  display: grid;
  grid-column: 2;
  min-width: 0;
  gap: 5px;
}

.compact-list .product-card.has-image {
  grid-template-columns: 62px minmax(0, 1fr) auto;
}

.compact-list .product-card.has-image .product-image-button {
  display: block;
  width: 62px;
  height: 62px;
}

@media (max-width: 720px) {
  #stockView .stock-product-card.has-image {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  #stockView .stock-product-card.has-image .product-image-button {
    display: block;
    width: 58px;
    height: 58px;
  }

  .compact-list .product-card.has-image {
    grid-template-columns: 58px minmax(0, 1fr) auto;
  }

  .compact-list .product-card.has-image .product-image-button {
    display: block;
    width: 58px;
    height: 58px;
  }
}

/* Search results show an uploaded product photo when one exists; missing photos take no space. */
.compact-list .compact-picker-card {
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  min-height: 74px;
  padding: 10px 12px;
}

.compact-list .compact-picker-card.has-image {
  grid-template-columns: 52px minmax(0, 1fr) 48px;
}

.compact-list .compact-picker-card.has-image .product-image-button {
  display: block;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.compact-list .compact-picker-card .product-info {
  gap: 3px;
}

.compact-list .compact-picker-card .sku-line,
.compact-list .compact-picker-card .product-meta {
  min-width: 0;
}

.compact-list .compact-picker-card .sku-line strong,
.compact-list .compact-picker-card .product-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-list .compact-picker-card .sku-line strong {
  font-size: 18px;
  line-height: 1.2;
}

.compact-list .compact-picker-card .product-meta {
  font-size: 13px;
  line-height: 1.25;
}

.compact-picker-stock {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: 48px;
}

.compact-picker-stock span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.compact-picker-stock strong {
  color: var(--brand-dark);
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
}

.preview-card.warehouse-preview-card {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 11px 12px;
}

.preview-card.warehouse-preview-card.has-image {
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.preview-card.warehouse-preview-card.has-image .product-image-button {
  display: block;
  width: 82px;
  height: 82px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.warehouse-preview-card .sku-line strong,
.warehouse-preview-card .product-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warehouse-preview-card .stock-number {
  margin-top: 4px;
  text-align: left;
}

@media (max-width: 720px) {
  .compact-list .compact-picker-card {
    grid-template-columns: minmax(0, 1fr) 46px;
    min-height: 72px;
    padding: 10px;
  }

  .compact-list .compact-picker-card.has-image {
    grid-template-columns: 50px minmax(0, 1fr) 46px;
  }

  .compact-list .compact-picker-card.has-image .product-image-button {
    width: 50px;
    height: 50px;
  }

  .preview-card.warehouse-preview-card.has-image {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .preview-card.warehouse-preview-card.has-image .product-image-button {
    width: 72px;
    height: 72px;
  }

  .compact-list .compact-picker-card .sku-line strong {
    font-size: 18px;
  }

  .compact-picker-stock strong {
    font-size: 20px;
  }
}

/* A single expandable directory replaces the old big-category/small-category selects. */
#stockView .compact-filter-row {
  grid-template-columns: minmax(0, 1fr) 112px;
  overflow: visible;
}

.classification-picker-button {
  min-width: 0;
  min-height: 40px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.classification-picker-button strong {
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.classification-picker-button span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classification-picker-button b {
  color: var(--brand-dark);
  font-size: 18px;
  line-height: 1;
}

.warehouse-category-filters {
  display: block;
  margin: 10px 0;
}

.warehouse-category-filters .classification-picker-button {
  width: 100%;
  min-height: 42px;
}

.classification-browser-card {
  width: min(100%, 620px);
  max-height: min(86vh, 760px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 9px;
  overflow: hidden;
}

.classification-browser-note,
.classification-admin-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.4;
}

.classification-clear-button {
  justify-self: start;
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.classification-tree {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 2px;
}

.warehouse-category-choice {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.warehouse-category-choice strong {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warehouse-category-choice small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.warehouse-category-choice b {
  color: var(--brand-dark);
  font-size: 20px;
  line-height: 1;
}

.classification-primary,
.classification-category,
.category-manage-primary,
.category-manage-category,
.category-manage-category-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.classification-primary > summary,
.classification-category > summary,
.category-manage-primary > summary,
.category-manage-category > summary,
.category-manage-category-row > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 11px;
  cursor: pointer;
  list-style: none;
}

.classification-primary > summary::-webkit-details-marker,
.classification-category > summary::-webkit-details-marker,
.category-manage-primary > summary::-webkit-details-marker,
.category-manage-category > summary::-webkit-details-marker,
.category-manage-category-row > summary::-webkit-details-marker {
  display: none;
}

.classification-primary > summary span,
.category-manage-primary > summary span {
  color: var(--brand-dark);
  font-size: 16px;
  font-weight: 950;
}

.classification-category > summary span,
.category-manage-category > summary span,
.category-manage-category-row > summary > span > strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.classification-primary > summary small,
.classification-category > summary small,
.category-manage-primary > summary small,
.category-manage-category > summary small,
.category-manage-category-row > summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.classification-level,
.category-manage-children {
  display: grid;
  gap: 7px;
  padding: 0 8px 8px;
}

.classification-category,
.category-manage-category,
.category-manage-category-row {
  background: #fbfcfc;
}

.classification-all-button,
.classification-series-list button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: #edf7f5;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 850;
  text-align: left;
}

.classification-all-button {
  padding: 0 10px;
}

.classification-series-list {
  display: grid;
  gap: 5px;
}

.classification-series-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.classification-series-list button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classification-series-list button small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.category-manage-list {
  min-height: 0;
  overflow: auto;
  gap: 9px;
}

.category-manage-primary-actions,
.category-manage-category-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 9px 9px;
}

.category-manage-primary-actions .ghost-button,
.category-manage-category-actions .ghost-button {
  min-height: 34px;
  padding: 0 9px;
  font-size: 12px;
}

.category-manage-category-row {
  display: block;
  overflow: hidden;
  padding: 0;
  border-radius: 10px;
  background: #fbfcfc;
}

.category-manage-category-row > summary {
  min-height: 52px;
  padding: 0 11px;
}

.category-manage-category-summary > b {
  color: var(--brand-dark);
  font-size: 21px;
  line-height: 1;
  transition: transform 150ms ease;
}

.category-manage-category-row[open] > summary > b {
  transform: rotate(90deg);
}

.category-manage-category-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.category-manage-category-main strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-manage-category-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.category-manage-category-main small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.category-manage-category-row .category-manage-category-actions {
  padding: 0 10px 9px;
}

.category-model-list {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.category-model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid #e2e7e3;
  border-radius: 8px;
  background: #fff;
}

.category-model-row.is-inactive {
  opacity: 0.72;
}

.category-model-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.category-model-info strong,
.category-model-info span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-model-info strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.category-model-info span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-model-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.category-model-actions .ghost-button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.category-model-empty {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.category-manage-pending-list {
  display: grid;
  gap: 5px;
}

.category-manage-series-list {
  display: grid;
  gap: 5px;
}

.category-manage-series-list article,
.category-manage-unused article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #fff;
}

.category-manage-series-list article > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.category-manage-unused article > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.category-manage-series-list strong,
.category-manage-series-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-manage-series-list strong {
  font-size: 13px;
}

.category-manage-series-list span,
.category-manage-unused span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.category-manage-series-list .ghost-button,
.category-manage-unused .ghost-button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.category-manage-unused {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.category-manage-unused > strong {
  color: var(--muted);
  font-size: 13px;
}

.category-manage-unused > p {
  margin: -2px 0 1px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.category-manage-pending-series {
  border: 1px dashed #9accc5;
  background: #f6fbfa !important;
}

.category-placement-card {
  gap: 13px;
}

.category-placement-note {
  margin: -3px 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Warning rows never reserve an image column and never wrap short model codes. */
.warehouse-warning-card {
  grid-template-columns: minmax(0, 1fr) 52px !important;
  align-items: center;
  gap: 8px;
  min-height: 74px;
  padding: 10px 12px;
}

.warehouse-warning-card .product-info {
  gap: 3px;
}

.warehouse-warning-card .sku-line {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  flex-wrap: nowrap;
}

.warehouse-warning-card .sku-line strong,
.warehouse-warning-card .product-meta {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warehouse-warning-card .sku-line strong {
  font-size: 18px;
  line-height: 1.2;
}

.warehouse-warning-card .product-meta {
  font-size: 12px;
  line-height: 1.25;
}

.warehouse-warning-card .stock-summary {
  display: grid;
  justify-items: end;
  gap: 2px;
  min-width: 52px;
}

.warehouse-warning-card .stock-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.warehouse-warning-card .stock-summary strong {
  color: var(--brand-dark);
  font-size: 21px;
  line-height: 1;
}

@media (max-width: 720px) {
  #stockView .compact-filter-row {
    grid-template-columns: minmax(0, 1fr) 108px;
  }

  .classification-browser-card {
    width: calc(100vw - 18px);
    max-height: 88vh;
    padding: 12px;
  }

  .warehouse-warning-card {
    grid-template-columns: minmax(0, 1fr) 48px !important;
    min-height: 70px;
    padding: 9px 10px;
  }

  .warehouse-warning-card .sku-line strong {
    font-size: 17px;
  }
}
