:root {
  --bg: #f6f4f0;
  --panel: #ffffff;
  --ink: #1f1f24;
  --muted: #6d6a73;
  --line: #ded8ce;
  --brand: #6d2e8c;
  --brand-dark: #4d1e67;
  --red: #c91f3a;
  --blue: #0879ba;
  --green: #23815d;
  --warn: #bb6b00;
  --shadow: 0 8px 24px rgba(31, 31, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: #17141a;
  color: white;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.topbar p {
  margin-top: 4px;
  color: #d7d0de;
}

.header-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px 0;
  background: white;
  border-bottom: 1px solid var(--line);
}

.mode-banner {
  margin: 12px 24px 0;
  padding: 12px 14px;
  border: 2px solid #e0a800;
  border-radius: 8px;
  background: #fff1b8;
  color: #5f3300;
  font-size: 17px;
  font-weight: 900;
}

body.test-mode .topbar {
  border-bottom: 4px solid #e0a800;
}

.tab {
  border: 0;
  background: transparent;
  padding: 12px 18px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  color: var(--brand);
  border-color: var(--brand);
}

main {
  padding: 20px 24px 32px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 0.8fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel.sticky {
  position: sticky;
  top: 14px;
  align-self: start;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

input,
select,
button,
a.secondary {
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font: inherit;
}

input,
select {
  background: white;
  min-width: 0;
}

.search {
  width: 100%;
  margin-bottom: 12px;
}

.scan-box {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  border: 2px solid #cdb8dc;
  border-radius: 8px;
  background: #fbf7ff;
}

.scan-box label {
  color: var(--brand);
  font-size: 16px;
  font-weight: 900;
}

.scan-input {
  width: 100%;
  height: 52px;
  border-color: var(--brand);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.scan-box small {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.inventory-scan-panel {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  border: 2px solid #cdb8dc;
  border-radius: 8px;
  background: #fbf7ff;
}

.inventory-scan-panel label {
  color: var(--brand);
  font-size: 17px;
  font-weight: 900;
}

.inventory-scan-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  gap: 8px;
  align-items: center;
}

.inventory-camera-preview {
  width: 100%;
  max-height: 260px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #111;
  object-fit: cover;
}

.inventory-scan-panel small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.inventory-scan-panel small.scan-error {
  padding: 8px 10px;
  border-radius: 6px;
  background: #ffe9ee;
  color: var(--red);
  font-weight: 800;
}

.inventory-count-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 18, 24, 0.64);
}

.inventory-count-dialog.show {
  display: flex;
}

.inventory-count-card {
  position: relative;
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 10px;
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}

.inventory-count-info {
  display: grid;
  gap: 6px;
}

.inventory-count-info strong {
  padding-right: 36px;
  font-size: 20px;
  line-height: 1.3;
}

.inventory-count-info small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.inventory-count-card label {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.inventory-count-card input {
  height: 56px;
  border: 2px solid #cdb8dc;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
}

.inventory-count-card input:disabled {
  background: #f3f1ee;
  color: var(--muted);
  opacity: 1;
}

.inventory-count-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button,
a.secondary {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary {
  width: 100%;
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  font-weight: 800;
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  background: white;
  color: var(--brand);
  border-color: #cdb8dc;
}

.secondary.strong {
  background: #f4e9fb;
  color: var(--brand-dark);
  border-color: #8a51a5;
  font-weight: 900;
}

.danger {
  color: var(--red);
  border-color: #ecc2ca;
}

.ghost {
  background: white;
}

.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 235px);
  overflow: auto;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: white;
}

.product-image {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-image.card {
  width: 100%;
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
}

.product-image.thumb {
  width: 62px;
  height: 62px;
}

.product-image img {
  width: 112%;
  height: 112%;
  object-fit: contain;
  display: block;
}

.image-preview {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(23, 20, 26, 0.72);
}

.image-preview.show {
  display: grid;
}

.image-preview-panel {
  position: relative;
  width: min(92vw, 760px);
  max-height: 92vh;
  display: grid;
  gap: 10px;
  padding: 14px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.image-preview-panel img {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  display: block;
  background: white;
}

.image-preview-panel strong {
  line-height: 1.35;
}

.image-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-color: rgba(31, 31, 36, 0.18);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.product-image.missing {
  border-style: dashed;
}

.product-title {
  min-height: 46px;
  font-weight: 700;
  line-height: 1.35;
}

.size-callout {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 2px;
  padding: 6px 12px;
  border: 2px solid #ffcf24;
  border-radius: 8px;
  background: #111111;
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.barcode-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #d8c7a8;
  border-radius: 6px;
  background: #fbfaf7;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.barcode-line strong,
.barcode-code {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
  word-break: break-all;
}

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

.badge {
  padding: 3px 7px;
  border-radius: 99px;
  font-size: 12px;
  background: #efedf2;
  color: #44394c;
}

.badge.zone-a {
  background: #ffe9ed;
  color: var(--red);
}

.badge.zone-b {
  background: #ffe9ed;
  color: var(--red);
}

.badge.zone-c {
  background: #e6f3fb;
  color: var(--blue);
}

.gift-badge {
  background: #fff1b8;
  color: #7a4100;
  border: 1px solid #e0a800;
  font-weight: 900;
}

.gift-card-note {
  padding: 10px;
  border: 2px solid #e0a800;
  border-radius: 6px;
  background: #fff8d7;
  color: #5f3300;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
}

.gift-image {
  background: #fff8d7;
  border-color: #e0a800;
  color: #5f3300;
  text-align: center;
  font-size: 18px;
  line-height: 1.45;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.price {
  color: var(--red);
  font-size: 20px;
  font-weight: 900;
}

.add-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
}

.add-on-section {
  margin: 12px 0;
  padding: 12px;
  border: 2px solid #d8c7a8;
  border-radius: 8px;
  background: #fbfaf7;
}

.add-on-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.add-on-head h3 {
  margin: 0;
  font-size: 18px;
}

.add-on-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.add-on-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.add-on-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.add-on-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.add-on-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.add-on-price {
  color: var(--red);
  font-size: 24px;
  font-weight: 900;
}

.add-on-card button {
  grid-column: 1 / -1;
  width: 100%;
  font-size: 18px;
  font-weight: 900;
}

.cart-list {
  min-height: 170px;
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.cart-list.empty {
  align-content: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr 74px 92px 34px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cart-name {
  font-weight: 700;
  line-height: 1.3;
}

.checkout-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-top: 2px solid var(--ink);
  font-size: 18px;
}

.checkout-total strong {
  font-size: 30px;
  color: var(--red);
}

.gift-notice {
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
  padding: 14px;
  border-radius: 8px;
  border: 2px solid #d8c7a8;
  font-size: 16px;
  line-height: 1.35;
}

.gift-notice strong {
  font-size: 20px;
}

.gift-notice.waiting {
  background: #f7f1e7;
  color: #5f5140;
}

.gift-notice.eligible {
  background: #fff1b8;
  border-color: #e0a800;
  color: #5f3300;
  box-shadow: 0 0 0 4px rgba(224, 168, 0, 0.18);
}

.gift-notice.eligible strong {
  color: #9c1530;
  font-size: 28px;
}

.gift-reroll {
  justify-self: start;
  margin-top: 4px;
  height: 42px;
  font-weight: 900;
}

.poster-wheel-wrap {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px 14px;
  align-items: center;
  margin-top: 8px;
}

.poster-wheel-pointer {
  grid-column: 1;
  justify-self: center;
  margin-bottom: -8px;
  color: #9c1530;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  z-index: 1;
}

.poster-wheel {
  grid-column: 1;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border: 5px solid #111111;
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22);
}

.poster-wheel strong {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #111111;
  color: #ffffff;
  font-size: 26px;
}

.poster-wheel.spinning {
  animation: wheel-spin 1.8s cubic-bezier(0.16, 0.82, 0.2, 1) both;
}

.wheel-labels {
  grid-column: 2;
  display: grid;
  gap: 4px;
  color: #5f3300;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.wheel-result {
  grid-column: 1 / -1;
  padding: 8px 10px;
  border-radius: 6px;
  background: #111111;
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
}

@keyframes wheel-spin {
  from {
    transform: rotate(0turn);
  }
  to {
    transform: rotate(5.8turn);
  }
}

.campaign-box {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.campaign-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

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

.campaign-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-left: 5px solid var(--brand);
  border-radius: 6px;
  background: white;
}

.campaign-item strong {
  font-size: 15px;
}

.campaign-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.campaign-item em {
  color: var(--green);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.form-grid,
.count-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.count-mode-guide {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  padding: 12px;
  border: 2px solid #d8c7a8;
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.count-mode-guide strong {
  color: var(--ink);
  font-size: 17px;
}

.count-mode-guide b {
  color: var(--brand-dark);
}

.inventory-mobile-list {
  display: none;
}

.arrival-check-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  border: 2px solid #cdb8dc;
  border-radius: 8px;
  background: #fff;
}

.arrival-check-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.arrival-check-head div {
  display: grid;
  gap: 4px;
}

.arrival-check-head strong {
  font-size: 18px;
}

.arrival-check-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.arrival-check-head em {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.arrival-check-head em.ok {
  background: #eef8f2;
  color: var(--green);
}

.arrival-check-head em.warn {
  background: #ffe9ee;
  color: var(--red);
}

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

.arrival-check-kpis span {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf8;
  color: var(--muted);
  font-size: 13px;
}

.arrival-check-kpis strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 24px;
}

.arrival-check-kpis .plus,
.arrival-mismatch-row .plus {
  color: var(--green);
}

.arrival-check-kpis .minus,
.arrival-mismatch-row .minus {
  color: var(--red);
}

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

.arrival-mismatch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff8fa;
  color: var(--ink);
  font-size: 13px;
}

.arrival-mismatch-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrival-mismatch-list small,
.arrival-check-ok {
  color: var(--muted);
  font-size: 13px;
}

.admin-stock-panel {
  margin: 12px 0;
  padding: 14px;
  border: 2px solid #d6c2e1;
  border-radius: 8px;
  background: #fff;
}

.admin-stock-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.admin-stock-head h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.admin-stock-head p,
.admin-stock-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.admin-stock-layout {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.admin-stock-main {
  display: grid;
  gap: 10px;
}

.admin-stock-title {
  display: grid;
  gap: 3px;
}

.admin-stock-title strong {
  font-size: 17px;
}

.admin-stock-title span {
  color: var(--muted);
  font-size: 13px;
}

.admin-stock-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.admin-stock-stats span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf8;
  color: var(--muted);
  font-size: 12px;
}

.admin-stock-stats strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 17px;
}

.barcode-edit-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) max-content;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 2px solid #d6c2e1;
  border-radius: 8px;
  background: #fbf7ff;
}

.barcode-edit-panel label {
  display: grid;
  gap: 5px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.barcode-edit-panel input {
  font-family: Consolas, "Courier New", monospace;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.barcode-edit-panel small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.admin-stock-actions {
  display: grid;
  grid-template-columns: minmax(120px, 180px) max-content max-content;
  gap: 8px;
  align-items: end;
}

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

.chip {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.chip.active {
  border-color: var(--brand);
  background: #f3e8fa;
  color: var(--brand-dark);
}

.inline-stock-tools {
  display: grid;
  grid-template-columns: 96px 64px;
  gap: 6px;
  align-items: center;
}

.inline-stock-tools input {
  width: 96px;
  min-width: 0;
}

.expected-count-input:disabled,
.mobile-expected-count-input:disabled {
  background: #f3f1ee;
  color: var(--muted);
  opacity: 1;
}

.compact-btn {
  min-width: 64px;
  padding: 0 8px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

label input,
label select {
  width: 100%;
  color: var(--ink);
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f0ebe3;
  z-index: 1;
}

tr.row-updated td {
  background: #fff3bf;
  transition: background 0.2s ease;
}

td.stock,
td.money,
td.qty {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.status {
  font-weight: 800;
}

.status.ok {
  color: var(--green);
}

.status.low {
  color: var(--warn);
}

.status.out {
  color: var(--red);
}

.sell-through {
  display: grid;
  gap: 5px;
  margin: 8px 0;
}

.sell-through-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sell-through-head strong {
  color: var(--green);
}

.sell-through.watch .sell-through-head strong {
  color: var(--warn);
}

.sell-through.need .sell-through-head strong,
.sell-through.urgent .sell-through-head strong {
  color: var(--red);
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee8df;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.sell-through.watch .progress i {
  background: var(--warn);
}

.sell-through.need .progress i,
.sell-through.urgent .progress i {
  background: var(--red);
}

.restock-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef8f2;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.restock-tag.watch {
  background: #fff3dc;
  color: var(--warn);
}

.restock-tag.need,
.restock-tag.urgent {
  background: #ffe9ee;
  color: var(--red);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.kpi.target {
  border-color: #cdb8dc;
  background: #fff;
}

.kpi.target strong {
  color: var(--brand);
}

.kpis.compact {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.kpi.urgent {
  border-color: #efbdc8;
  background: #fff8fa;
}

.report-section {
  margin-top: 18px;
}

.report-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.report-table table {
  min-width: 560px;
}

.report-table th,
.report-table td {
  white-space: nowrap;
}

.kpi.urgent strong {
  color: var(--red);
}

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

.restock-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 116px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.restock-card.watch {
  border-left-color: var(--warn);
}

.restock-card.need,
.restock-card.urgent {
  border-left-color: var(--red);
}

.restock-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.restock-title {
  display: grid;
  gap: 3px;
}

.restock-title strong {
  font-size: 16px;
}

.restock-title span {
  color: var(--muted);
  font-size: 12px;
}

.restock-numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.restock-numbers span {
  padding: 7px 8px;
  border-radius: 8px;
  background: #fbfaf8;
  color: var(--muted);
  font-size: 12px;
}

.restock-numbers strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.restock-action {
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.restock-log-row {
  grid-template-columns: 1fr 96px 56px;
}

.bar-chart {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 110px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.bar-bg {
  height: 18px;
  background: #eee8df;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #c5549b);
}

.mini-table {
  display: grid;
  gap: 6px;
}

.mini-row {
  display: grid;
  grid-template-columns: 1fr 100px 70px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

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

.sale-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.sale-card.void {
  background: #f3f1ee;
  opacity: 0.78;
}

.sale-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sale-total {
  font-weight: 900;
  color: var(--red);
}

.void-badge {
  margin-left: 8px;
  background: #eee1e4;
  color: var(--red);
}

.void-note {
  margin-top: 10px;
  padding: 10px;
  border-radius: 6px;
  background: #f8ecef;
  color: #7c2336;
  font-size: 13px;
  line-height: 1.45;
}

.sale-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.mobile-checkout-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  display: none;
  grid-template-columns: 1fr 148px;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(31, 31, 36, 0.16);
}

.mobile-checkout-bar.show {
  display: grid;
}

.mobile-cart-summary {
  height: auto;
  min-height: 48px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 2px;
  background: white;
  color: var(--ink);
}

.mobile-cart-summary span {
  font-size: 12px;
  color: var(--muted);
}

.mobile-cart-summary strong {
  font-size: 18px;
  color: var(--red);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #17141a;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.floating-scroll-actions {
  position: fixed;
  right: 12px;
  bottom: 88px;
  z-index: 19;
  display: none;
  grid-template-columns: 1fr;
  gap: 8px;
}

.floating-scroll-actions button {
  min-width: 58px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--brand);
  box-shadow: var(--shadow);
  font-weight: 900;
}

@media (max-width: 980px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two,
  .kpis,
  .form-grid,
  .count-bar,
  .admin-stock-head,
  .barcode-edit-panel,
  .admin-stock-actions {
    grid-template-columns: 1fr;
  }

  .panel.sticky {
    position: static;
  }

  .tabs {
    overflow-x: auto;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 86px;
  }

  .topbar {
    padding: 14px;
  }

  main {
    padding: 14px;
  }

  .mode-banner {
    margin: 10px 14px 0;
    font-size: 15px;
  }

  h1 {
    font-size: 20px;
  }

  .product-list {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .cart-item {
    grid-template-columns: 1fr;
  }

  .add-on-head {
    display: grid;
  }

  .add-on-list {
    grid-template-columns: 1fr;
  }

  .admin-stock-panel {
    padding: 12px;
  }

  .admin-stock-layout {
    grid-template-columns: 1fr;
  }

  .admin-stock-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-list {
    max-height: 128px;
    overflow: auto;
  }

  .poster-wheel-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .restock-card {
    grid-template-columns: 1fr;
  }

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

  .restock-action {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }

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

  .poster-wheel-pointer,
  .poster-wheel,
  .wheel-labels,
  .wheel-result {
    grid-column: 1;
  }

  .wheel-labels {
    justify-self: stretch;
  }

  input,
  select,
  button,
  a.secondary {
    min-height: 44px;
    font-size: 16px;
  }

  .kpi strong {
    font-size: 22px;
  }

  th,
  td {
    min-width: 86px;
  }

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4) {
    min-width: 180px;
  }

  .floating-scroll-actions {
    display: grid;
  }

  #inventory .table-wrap {
    display: none;
  }

  .inventory-mobile-list {
    display: grid;
    gap: 10px;
  }

  .count-mode-guide {
    font-size: 15px;
  }

  .arrival-check-head {
    display: grid;
  }

  .arrival-check-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .arrival-check-kpis span {
    padding: 8px 6px;
    text-align: center;
  }

  .arrival-check-kpis strong {
    font-size: 20px;
  }

  .arrival-mismatch-row {
    grid-template-columns: 1fr;
  }

  .arrival-mismatch-row strong {
    white-space: normal;
  }

  .count-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .count-card .product-image.thumb {
    width: 96px;
    height: 96px;
  }

  .count-card-main {
    min-width: 0;
    display: grid;
    gap: 8px;
  }

  .count-card-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .count-card h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
  }

  .count-card-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .count-card-meta span {
    padding: 7px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfaf8;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
  }

  .count-card-meta strong {
    display: block;
    margin-top: 2px;
    color: var(--ink);
    font-size: 18px;
  }

  .mobile-count-label {
    gap: 6px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 900;
  }

  .mobile-expected-label {
    color: var(--muted);
  }

  .mobile-count-input,
  .mobile-expected-count-input {
    width: 100%;
    height: 54px;
    border: 2px solid #cdb8dc;
    font-size: 24px;
    font-weight: 900;
    text-align: center;
  }

  .mobile-count-foot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    min-width: 0;
  }

  .mobile-count-foot .barcode-code {
    min-width: 0;
    font-size: 12px;
  }
}

@media (min-width: 641px) {
  .mobile-checkout-bar {
    display: none !important;
  }
}
