:root {
  --navy: #202535;
  --blue: #3478d4;
  --mint: #83ba46;
  --purple: #6554c9;
  --apple-green: #83ba46;
  --surface: #ffffff;
  --surface-subtle: #f5f7fc;
  --border: #dfe4ef;
  --text-muted: #68708a;
  --focus: #ffb020;
  --shadow-card: 0 8px 22px rgba(50, 61, 91, 0.09);
}

body {
  background: var(--surface-subtle);
  color: var(--navy);
}

.auth {
  background: var(--purple);
}

header {
  background: var(--purple);
}

header small {
  color: #f1efff;
}

.ghost {
  min-height: 44px;
  background: rgba(255, 255, 255, 0.14);
}

nav {
  border-color: #e3e7ef;
}

nav button.active {
  border-bottom-color: var(--purple);
  color: var(--purple);
}

.primary {
  background: var(--blue);
}

.secondary {
  background: #eaf2fc;
  color: #244f84;
}

button,
a,
input,
select,
summary,
[role="button"] {
  -webkit-tap-highlight-color: rgba(23, 107, 135, 0.16);
}

button,
[role="button"] {
  touch-action: manipulation;
}

:where(button, a, input, select, summary, [role="button"]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.photo-upload:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  filter: saturate(0.45);
  opacity: 0.58;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

#home {
  display: flex;
  flex-direction: column;
}

#home > h2 {
  order: 0;
}

#home > .scan-workspace {
  order: 1;
}

#home > .stats {
  order: 2;
}

#home > .setup-panel {
  order: 3;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}

.stats article {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  box-shadow: none;
}

.stats article strong {
  overflow-wrap: anywhere;
}

.stats article span {
  overflow-wrap: anywhere;
}

.stats .stat-positive {
  border-color: #d8eac9;
  background: #edf7e5;
}

.stats .stat-positive strong,
.stats .stat-positive span {
  color: #3f7220;
}

.stats .stat-zero {
  border-color: #ded5f4;
  background: #f1edfb;
}

.stats .stat-zero strong,
.stats .stat-zero span {
  color: #674bb7;
}

.stats .stat-all {
  border-color: #d1e2f6;
  background: #eaf2fc;
}

.stats .stat-all strong,
.stats .stat-all span {
  color: #2868b5;
}

.stats .stat-units {
  border-color: #e0e5ef;
  background: var(--surface);
}

.stats .stat-units strong,
.stats .stat-units span {
  color: #34405e;
}

.stats .stat-expiry {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding-block: 12px;
  border-color: #ded5f4;
  background: #faf8ff;
  text-align: left;
}

.stats .stat-expiry strong {
  color: #674bb7;
  font-size: 1.35rem;
}

.stats .stat-expiry span {
  color: #4f5670;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h3 {
  margin: 3px 0 6px;
  font-size: clamp(1.2rem, 3vw, 1.45rem);
}

.section-heading p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.eyebrow {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.setup-panel {
  background: var(--surface-subtle);
  box-shadow: none;
}

.device-setup-disclosure > summary {
  color: var(--navy);
  cursor: pointer;
  font-weight: 850;
}

.device-setup-disclosure[open] > summary {
  margin-bottom: 16px;
}

.product-list-search-label {
  display: block;
  color: var(--navy);
  font-weight: 750;
}

.product-list-search-label input {
  margin-top: 5px;
}

.dialog-open {
  overflow: hidden;
}

.remove-line {
  min-height: 40px;
  margin-top: 10px;
  background: #fff0ee;
  color: #b42318;
}

.scan-workspace {
  border-top: 4px solid var(--apple-green);
  background: var(--surface);
}

.scan-workspace .eyebrow {
  color: #3f7220;
}

.scan-workspace > .barcode-camera,
.professional-scan {
  min-height: 64px;
  background: var(--apple-green);
  color: #17310a;
}

.scan-workspace > .barcode-camera:active,
.professional-scan:active {
  background: #6fa237;
}

#home summary,
#home .button-link,
#home .cert-download,
#home a[href] {
  min-height: 44px;
}

.scan-alternatives {
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.scan-alternatives > summary {
  color: #2868b5;
  cursor: pointer;
  font-weight: 800;
}

.scan-alternatives[open] > summary {
  margin-bottom: 10px;
}

#home summary,
#home .cert-download,
#home a[href] {
  display: flex;
  align-items: center;
}

.scan-workspace > .barcode-camera + .barcode-camera {
  margin-top: 10px;
}

.scan-workspace .camera-warning {
  font-weight: 700;
}

.page-heading {
  margin-bottom: 16px;
}

.page-heading h2 {
  margin: 3px 0 7px;
}

.page-heading p {
  max-width: 68ch;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.operation-panel {
  border-top: 4px solid var(--blue);
}

.operation-type select {
  border-color: var(--blue);
  background: #f2f9fa;
  color: var(--navy);
  font-weight: 800;
}

.operation-code input {
  min-height: 58px;
  border-color: #8eabb6;
  font-weight: 750;
}

.operation-camera-zone {
  display: grid;
  gap: 10px;
}

.operation-camera-button {
  min-height: 64px;
}

.operation-camera-zone .camera-warning {
  margin: 0;
  font-weight: 700;
}

.operation-notes {
  display: grid;
  gap: 8px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.operation-notes strong {
  color: var(--navy);
}

.receipt-section {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-subtle);
}

.receipt-section legend {
  padding: 0 8px;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 850;
}

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

.receipt-section > .hint {
  margin: 12px 0 0;
}

.receipt-add-line {
  min-height: 56px;
  border: 2px solid var(--blue);
}

.receipt-draft {
  display: grid;
  gap: 12px;
  background: #f7fbfc;
}

.receipt-draft-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.receipt-draft-heading h3,
.receipt-line h4,
.receipt-line p {
  margin: 0;
}

.receipt-lines {
  display: grid;
  gap: 10px;
}

.receipt-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.receipt-line > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.receipt-line p {
  color: var(--text-muted);
  line-height: 1.45;
}

.receipt-line strong {
  color: var(--navy);
}

.receipt-remove {
  min-width: 48px;
  min-height: 44px;
  background: #fff0ee;
  color: var(--red);
}

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

.receipt-summary > span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 10px;
  background: #eaf3f5;
  color: var(--text-muted);
}

.receipt-summary strong {
  color: var(--navy);
  font-size: 1.03rem;
}

.receipt-summary .receipt-total {
  background: #e7f7f0;
}

.operation-submit {
  min-height: 58px;
  font-size: 1.04rem;
}

.operation-panel[data-operation="ISSUE"] {
  border-top-color: #c47a00;
}

.operation-panel[data-operation="ISSUE"] .operation-submit {
  background: #9a5f00;
}

.operation-panel[data-operation="TRANSFER"] {
  border-top-color: #5b5fc7;
}

.operation-panel[data-operation="TRANSFER"] .operation-submit {
  background: #4d51a8;
}

.operation-panel[data-operation="ADJUSTMENT"] {
  border-top-color: var(--red);
}

.operation-panel[data-operation="ADJUSTMENT"] .operation-submit {
  background: var(--red);
}

.count-title-row {
  align-items: flex-start;
  gap: 16px;
}

.count-title-row .page-heading {
  margin-bottom: 0;
}

.count-start-panel {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 12px;
  align-items: end;
  border-top: 4px solid var(--blue);
}

.count-start-panel label {
  color: var(--navy);
  font-weight: 750;
}

.count-start-panel input,
.count-start-panel select {
  margin-top: 5px;
}

.count-scan-bar {
  margin-top: 14px;
}

.count-head {
  border-left: 5px solid var(--blue);
}

.count-head > div,
.count-history-item {
  min-width: 0;
  overflow-wrap: anywhere;
}

.count-head .badge {
  flex-shrink: 0;
  white-space: nowrap;
}

.count-head .count-document-no {
  display: block;
  margin-top: 6px;
}

.count-history-item .count-document-no {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 500;
}

.count-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 10px;
  margin-top: 10px;
}

.count-history-row .count-history-item {
  margin-top: 0;
}

.count-history-open {
  margin-top: 8px;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 800;
}

.count-history-cancel {
  min-width: 76px;
  min-height: 50px;
  align-self: stretch;
  border: 2px solid #b42318;
  background: #fff;
  color: #9b1c14;
}

.count-history-cancel:active {
  background: #fff0ee;
}

.count-history-protected {
  display: grid;
  min-width: 76px;
  padding: 8px;
  place-items: center;
  border-radius: 10px;
  background: #eef1f3;
  color: #52616c;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.count-history-protected.is-cancelled {
  background: #f4f4f4;
  color: #777;
}

#count-history-message:not(:empty) {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
}

@media (max-width: 360px) {
  .count-history-row {
    grid-template-columns: minmax(0, 1fr) 68px;
    gap: 8px;
  }

  .count-history-cancel,
  .count-history-protected {
    min-width: 68px;
    padding-inline: 6px;
  }
}

.count-history-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.count-history-filter input {
  width: 22px;
  height: 22px;
  margin: 0;
}

.count-cancel-zone {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.count-cancel-zone .danger {
  background: #fff;
  color: var(--red);
  border: 1px solid var(--red);
}

.count-line {
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(21, 50, 74, 0.06);
}

.count-line.is-completed {
  border: 2px solid #69a98a;
  border-left-width: 7px;
  background: #eef9f3;
  box-shadow: 0 4px 14px rgba(8, 116, 67, 0.09);
}

.count-line-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.count-line-title h3 {
  min-width: 0;
}

.count-item-state {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.count-item-state.is-counting {
  background: #edf2f5;
  color: #52616c;
}

.count-item-state.is-completed {
  background: #087443;
  color: #fff;
}

.count-completed-by {
  display: block;
  margin-top: 8px;
  color: #426755;
}

.count-line-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.count-completion-button,
.count-line-actions .remove-line {
  min-height: 44px;
}

.count-complete-lock {
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 76px;
  color: #087443;
}

.count-complete-lock strong {
  font-size: 1.2rem;
}

.count-complete-lock span {
  font-size: 0.78rem;
  font-weight: 800;
}

.count-completion-help {
  border-left: 4px solid #69a98a;
  padding-left: 10px;
}

.count-quantity-help {
  margin-top: 8px;
  border-left: 4px solid var(--blue);
  padding-left: 10px;
}

.count-quantity-tools {
  display: grid;
  gap: 8px;
  width: min(310px, 100%);
}

.count-quantity-tools .adjust {
  justify-content: flex-end;
}

.count-quantity-tools .adjust button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.count-direct-label {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 800;
}

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

.count-direct input {
  min-width: 0;
  font-size: 1.1rem;
  font-weight: 850;
  text-align: center;
}

.count-direct button {
  min-width: 104px;
  min-height: 50px;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .count-quantity-tools {
    width: 100%;
  }

  .count-quantity-tools .adjust {
    justify-content: stretch;
  }

  .count-quantity-tools .adjust button,
  .count-quantity-tools .adjust strong {
    flex: 1;
  }
}

.count-meta {
  margin-bottom: 8px;
  color: var(--text-muted);
}

.count-difference {
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 850;
}

.count-difference.is-even {
  background: #e7f7f0;
  color: #087443;
}

.count-difference.has-difference {
  background: #fff1e1;
  color: #8a4b00;
}

.count-confirm-zone {
  margin-top: 18px;
  padding: 15px;
  border: 2px solid #e4a39e;
  border-radius: 14px;
  background: #fff6f5;
}

.count-confirm-zone strong,
.count-confirm-zone span {
  display: block;
}

.count-confirm-zone strong {
  color: var(--red);
}

.count-confirm-zone span {
  margin-top: 5px;
  color: #6f4541;
  line-height: 1.5;
}

.movement-table-wrap {
  padding: 0;
  overflow: hidden;
}

.movement-table caption {
  padding: 16px 18px 10px;
  color: var(--navy);
  font-weight: 850;
  text-align: left;
}

.movement-table thead {
  background: #eef4f6;
}

.movement-table tbody tr:hover {
  background: #f7fafb;
}

.movement-type,
.movement-delta {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 800;
}

.movement-type {
  background: #eaf3f6;
  color: var(--navy);
}

.movement-delta.is-positive {
  background: #e7f7f0;
  color: #087443;
}

.movement-delta.is-negative {
  background: #fff0ee;
  color: var(--red);
}

.movement-delta.is-neutral {
  background: #edf1f3;
  color: #52616c;
}

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

.admin-card {
  position: relative;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 11px;
  border-top: 4px solid #91a8b2;
}

.admin-card label {
  color: var(--navy);
  font-weight: 750;
}

.admin-card input,
.admin-card select {
  margin-top: 5px;
}

.admin-card-kind {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 850;
}

.admin-card-kind.is-preview {
  background: #fff1e1;
  color: #8a4b00;
}

.admin-card-kind.is-readonly {
  background: #e7f7f0;
  color: #087443;
}

.admin-card-kind.is-account {
  background: #eeedff;
  color: #4d51a8;
}

.admin-card-kind.is-maintenance {
  background: #eaf3f6;
  color: var(--navy);
}

.write-preview-card {
  border-top-color: #c47a00;
}

.readonly-card {
  border-top-color: #0a7b59;
}

.platform-eligibility-panel {
  gap: 16px;
}

.platform-eligibility-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.platform-eligibility-heading h3,
.platform-eligibility-card h4,
.platform-eligibility-card p {
  margin: 0;
}

.platform-eligibility-source,
.eligibility-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #c17b12;
  border-radius: 999px;
  background: #fff8e8;
  color: #744500;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}

.platform-eligibility-notice {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border-left: 4px solid #c17b12;
  border-radius: 10px;
  background: #fff8ed;
  color: #663b00;
}

.platform-eligibility-filter {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.platform-eligibility-filter label {
  min-width: 0;
}

.platform-eligibility-filter input,
.platform-eligibility-filter button {
  min-height: 48px;
}

.platform-eligibility-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.platform-eligibility-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid #d7e0e4;
  border-top: 4px solid #c17b12;
  border-radius: 13px;
  background: #fff;
}

.platform-eligibility-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: auto;
  height: auto;
  min-height: 0;
  margin-bottom: 12px;
  padding: 0;
  background: transparent;
  color: inherit;
}

.platform-eligibility-card .platform-name {
  display: block;
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 1.05rem;
  font-weight: 900;
}

.platform-eligibility-card h4 {
  color: #744500;
  font-size: 0.9rem;
}

.eligibility-badge {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 8px;
  font-size: 0.72rem;
}

.platform-blocker {
  display: grid;
  gap: 4px;
  margin-bottom: 12px !important;
  padding: 10px;
  border-radius: 9px;
  background: #fff5e5;
  color: #663b00;
  overflow-wrap: anywhere;
}

.platform-blocker code {
  color: #744500;
  font-size: 0.75rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.platform-eligibility-card dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.platform-eligibility-card dl > div {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #e5ebee;
}

.platform-eligibility-card dt {
  color: #61717a;
  font-size: 0.78rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.platform-eligibility-card dd {
  min-width: 0;
  margin: 0;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .platform-eligibility-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .platform-eligibility-heading {
    display: grid;
  }

  .platform-eligibility-source {
    justify-self: start;
  }

  .platform-eligibility-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .platform-eligibility-filter {
    grid-template-columns: minmax(0, 1fr);
  }
}

.account-card {
  border-top-color: #5b5fc7;
}

.maintenance-card {
  border-top-color: var(--blue);
}

.admin-card > button,
.admin-card > .button-link {
  width: 100%;
}

.admin-card > a:not(.button-link) {
  color: #12657a;
  font-weight: 750;
}

.sync-readiness-summary {
  display: grid;
  gap: 14px;
  margin-top: 2px;
}

.sync-readiness-heading {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-left: 4px solid #c47a00;
  border-radius: 10px;
  background: #fff8ed;
  color: #663b00;
}

.sync-readiness-heading span {
  color: #52616c;
  font-size: 0.9rem;
}

.sync-readiness-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sync-readiness-metrics > div {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.sync-readiness-metrics strong {
  color: var(--blue);
  font-size: 1.35rem;
}

.sync-readiness-metrics span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.sync-readiness-steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 22px;
}

.sync-readiness-steps li {
  padding-left: 3px;
  line-height: 1.55;
}

.sync-state {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.sync-state.is-ready {
  background: #e7f7f0;
  color: #087443;
}

.sync-state.is-blocked {
  background: #fff1e1;
  color: #8a4b00;
}

.sync-readiness-gate {
  margin: 0;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.sync-readiness-table {
  max-width: 100%;
  margin-top: 16px;
}

.order-source-status {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding: 15px 17px;
  border: 1px solid #bfd0e9;
  border-radius: 14px;
  background: #eef5ff;
}

.order-source-status strong {
  font-size: 1.04rem;
}

.order-source-status span {
  color: #4d5f78;
  line-height: 1.5;
}

.order-source-status.is-ready {
  border-color: #9bcdb2;
  background: #eaf8f0;
}

.order-source-status.is-blocked {
  border-color: #e4bd54;
  background: #fff7db;
}

.order-source-status.is-error {
  border-color: #e3aaa5;
  background: #fff0ee;
}

.order-source-status.is-loading {
  border-color: #b7b0df;
  background: #f2f0ff;
}

.order-filter-panel {
  display: grid;
  grid-template-columns: minmax(230px, 2fr) minmax(170px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.order-filter-panel label {
  display: grid;
  gap: 6px;
  color: #3f4b63;
  font-weight: 750;
}

.order-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.order-metrics article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.order-metrics strong,
.order-metrics span {
  display: block;
}

.order-metrics strong {
  color: var(--purple);
  font-size: 1.55rem;
}

.order-metrics span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.picking-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 2fr) auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px 16px;
}

.picking-toolbar label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.picking-toolbar input,
.order-pick-select input,
.picking-item input {
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0;
}

.picking-toolbar > div {
  display: grid;
  gap: 3px;
}

.picking-toolbar > div span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.order-list {
  display: grid;
  gap: 14px;
}

.order-card,
.order-empty {
  border: 1px solid var(--border);
  border-left: 5px solid #8d82dc;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-card);
}

.order-card {
  padding: 17px;
}

.order-card.is-attention {
  border-left-color: #cc4b42;
}

.order-card.is-closed {
  border-left-color: #7b8798;
}

.order-card.is-progress {
  border-left-color: #3478d4;
}

.order-card.is-reserved {
  border-left-color: #83ba46;
}

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

.order-card-head h3 {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.order-card-identity {
  flex: 1 1 auto;
  min-width: 0;
}

.order-pick-select {
  display: grid;
  flex: 0 0 84px;
  justify-items: center;
  gap: 4px;
  color: #47566e;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.order-pick-select:has(input:disabled) {
  color: #8c93a0;
}

.order-platform {
  color: #58647b;
  font-size: 0.88rem;
  font-weight: 750;
}

.order-status {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #edf0fa;
  color: #40368e;
  font-size: 0.85rem;
  font-weight: 800;
}

.order-card-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 14px 0;
  padding: 11px 13px;
  border-radius: 10px;
  background: #f6f7fb;
  color: #515d72;
}

.order-lines {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-lines li {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 1px solid #e6e9f0;
  border-radius: 11px;
}

.order-lines li > div:first-child {
  display: grid;
  gap: 3px;
}

.order-lines li span,
.order-lines li small {
  color: #5f6980;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.order-line-quantities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.order-line-quantities span {
  padding: 4px 7px;
  border-radius: 7px;
  background: #eef3f9;
  color: #3f4d64;
  font-size: 0.82rem;
  font-weight: 750;
}

.order-operation-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 10px;
  border-radius: 9px;
  background: #f7f8fb;
}

.order-operation-status span {
  color: #4d596f;
  font-size: 0.82rem;
  line-height: 1.45;
}

.order-operation-status b {
  display: block;
  margin-bottom: 2px;
  color: #263650;
}

.order-operation-status .is-attention {
  color: #9f2f2a;
  font-weight: 750;
}

.order-card footer {
  margin-top: 12px;
  color: #757d8f;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.order-empty {
  padding: 22px;
  border-left-color: #e4bd54;
}

.order-empty p {
  margin: 7px 0 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.picking-panel {
  margin-top: 18px;
  scroll-margin-top: 18px;
}

.picking-sheet {
  position: relative;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-card);
}

.picking-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid #263650;
}

.picking-sheet-head h3,
.picking-sheet-head p {
  margin: 5px 0 0;
}

.picking-preview-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff1ca;
  color: #725000;
  font-weight: 850;
}

.picking-fingerprint {
  margin: 12px 0;
  color: #6b7383;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.picking-items {
  display: grid;
}

.picking-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 18px 4px;
  border-bottom: 1px solid #dfe4eb;
}

.picking-item.is-checked {
  background: #edf8f0;
}

.picking-item label {
  position: relative;
  display: block;
}

.picking-checkmark {
  display: none;
}

.picking-location {
  color: #3b6817;
}

.picking-item h4,
.picking-item p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.picking-item details {
  margin-top: 10px;
}

.picking-item summary {
  min-height: 44px;
  padding: 11px 0;
  color: #41526a;
  font-weight: 750;
  cursor: pointer;
}

.picking-quantity {
  color: #172a46;
  font-size: 1.65rem;
}

.picking-quantity small {
  font-size: 0.8rem;
}

.picking-progress,
.picking-missing {
  padding: 12px 14px;
  border-radius: 10px;
  line-height: 1.55;
}

.picking-progress {
  background: #eef5ff;
  color: #254b77;
  font-weight: 800;
}

.picking-missing {
  background: #fff4d7;
  color: #725000;
}

.picking-print-actions {
  display: grid;
  grid-template-columns: minmax(250px, auto) 1fr;
  gap: 12px;
  align-items: center;
}

.picking-print-actions span {
  color: #6c5360;
  line-height: 1.5;
}

.sales-source-status {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding: 15px 17px;
  border: 1px solid #bfd0e9;
  border-radius: 14px;
  background: #eef5ff;
}

.sales-source-status span {
  color: #4d5f78;
  line-height: 1.5;
}

.sales-source-status.is-ready {
  border-color: #9bcdb2;
  background: #eaf8f0;
}

.sales-source-status.is-blocked {
  border-color: #e4bd54;
  background: #fff7db;
}

.sales-source-status.is-error {
  border-color: #e3aaa5;
  background: #fff0ee;
}

.sales-source-status.is-loading {
  border-color: #b7b0df;
  background: #f2f0ff;
}

.sales-entry-panel,
.sales-draft-panel,
.sales-expense-panel {
  margin-bottom: 14px;
  padding: 18px;
}

.sales-entry-panel {
  display: grid;
  gap: 14px;
}

.sales-channel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.sales-channel legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  font-weight: 800;
}

.sales-channel label {
  position: relative;
  display: block;
  min-height: 54px;
}

.sales-channel input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.sales-channel span {
  display: grid;
  min-height: 54px;
  place-items: center;
  border: 2px solid #cfd6e3;
  border-radius: 12px;
  background: #fff;
  color: #526078;
  font-weight: 800;
}

.sales-channel input:checked + span {
  border-color: var(--purple);
  background: #f1efff;
  color: #40368e;
}

.sales-channel input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sales-code,
.sales-entry-grid label,
.sales-expense-grid label {
  display: grid;
  gap: 6px;
  color: #3f4b63;
  font-weight: 750;
}

.sales-photo-scan {
  display: grid;
  min-height: 50px;
  place-items: center;
  border-radius: 10px;
  background: #eaf2fc;
  color: #244f84;
  font-weight: 800;
  cursor: pointer;
}

.sales-photo-scan input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.sales-photo-scan:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sales-entry-grid,
.sales-expense-grid,
.sales-profit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sales-expense-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 12px 0;
}

.sales-draft-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sales-draft-heading h3,
.sales-expense-panel h3 {
  margin: 3px 0 0;
}

.sales-lines {
  display: grid;
  gap: 10px;
  margin-top: 13px;
}

.sales-line {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid #cfe5d8;
  border-radius: 12px;
  background: #f0faf4;
}

.sales-line-check {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: #208452;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
}

.sales-line h4,
.sales-line p {
  margin: 0 0 4px;
}

.sales-line small {
  color: #526b5c;
  line-height: 1.4;
}

.sales-profit-grid span {
  display: grid;
  gap: 4px;
  padding: 13px;
  border-radius: 11px;
  background: #f5f7fc;
  color: #5c667b;
}

.sales-profit-grid strong {
  color: #29364f;
  font-size: 1.12rem;
}

.sales-profit-grid .is-positive {
  background: #eaf8f0;
}

.sales-profit-grid .is-negative {
  background: #fff0ee;
}

.sales-profit-grid .is-positive strong {
  color: #087443;
}

.sales-profit-grid .is-negative strong {
  color: #a02c25;
}

.sales-preview-receipt,
.sales-write-boundary {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  line-height: 1.55;
}

.sales-preview-receipt {
  background: #edf7f2;
  color: #285c43;
  font-size: 0.86rem;
  font-weight: 750;
}

.sales-write-boundary {
  border: 1px solid #e4bd54;
  background: #fff7db;
  color: #765400;
}

@media (max-width: 700px) {
  .receipt-header-grid,
  .receipt-summary {
    grid-template-columns: 1fr;
  }

  .receipt-section {
    padding: 14px;
  }

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

  .receipt-remove {
    width: 100%;
  }

  .sales-entry-panel,
  .sales-draft-panel,
  .sales-expense-panel {
    padding: 15px;
  }

  .sales-entry-grid,
  .sales-expense-grid,
  .sales-profit-grid {
    grid-template-columns: 1fr;
  }

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

  .sales-line > button {
    grid-column: 1 / -1;
    width: 100%;
  }

  nav button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 56px;
    padding: 8px 2px;
    white-space: normal;
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .order-filter-panel {
    grid-template-columns: 1fr;
  }

  .order-filter-panel button {
    width: 100%;
  }

  .picking-toolbar {
    grid-template-columns: 1fr;
  }

  .picking-toolbar button {
    width: 100%;
  }

  .order-card {
    padding: 14px;
  }

  .order-card-head {
    display: grid;
  }

  .order-pick-select {
    grid-template-columns: auto 1fr;
    justify-items: start;
    justify-self: stretch;
    text-align: left;
  }

  .order-status {
    justify-self: start;
  }

  .order-card-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .order-operation-status {
    grid-template-columns: 1fr;
  }

  .picking-sheet {
    padding: 15px;
  }

  .picking-sheet-head,
  .picking-print-actions {
    grid-template-columns: 1fr;
  }

  .picking-sheet-head {
    display: grid;
  }

  .picking-preview-badge {
    justify-self: start;
  }

  .picking-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .picking-quantity {
    grid-column: 2;
    justify-self: start;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stats article {
    padding: 14px 10px;
  }

  .stats article strong {
    font-size: clamp(1.45rem, 8vw, 1.8rem);
  }

  .stats article span {
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .stats .stat-expiry {
    grid-column: 1 / -1;
    padding-inline: 14px;
  }

  .setup-panel {
    padding: 15px;
  }

  .scan-workspace {
    padding: 16px;
  }

  .scan-workspace .photo-steps {
    font-weight: 650;
  }

  .operation-panel {
    padding: 16px;
  }

  .count-title-row {
    display: grid;
  }

  .count-title-row > button {
    width: 100%;
  }

  .count-start-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 16px;
  }

  .count-scan-bar {
    grid-template-columns: 1fr;
  }

  .movement-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .movement-table,
  .movement-table tbody,
  .movement-table tr,
  .movement-table td {
    display: block;
    width: 100%;
  }

  .movement-table caption {
    padding: 0 0 10px;
  }

  .movement-table thead {
    display: none;
  }

  .movement-table tbody {
    display: grid;
    gap: 12px;
  }

  .movement-table tbody tr {
    display: grid;
    gap: 7px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }

  .movement-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }

  .movement-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 750;
    text-align: left;
  }

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

  .admin-card {
    padding: 16px;
  }

  .sync-readiness-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .admin-result-table {
    overflow: visible;
  }

  .admin-result-table table,
  .admin-result-table tbody,
  .admin-result-table tr,
  .admin-result-table td {
    display: block;
    width: 100%;
  }

  .admin-result-table thead {
    display: none;
  }

  .admin-result-table tbody {
    display: grid;
    gap: 10px;
  }

  .admin-result-table tr {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }

  .admin-result-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }

  .admin-result-table td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 750;
    text-align: left;
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  .receipt-header-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Keep the login form above iOS Safari's floating address bar and keyboard. */
@media (max-width: 700px), (max-width: 900px) and (any-pointer: coarse) {
  .auth {
    min-height: 100vh;
    min-height: 100dvh;
    place-content: start center;
    overflow-y: auto;
    padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  }

  .auth .brand > div,
  .auth .brand p {
    display: none;
  }

  .auth .brand h1 {
    margin: 0 0 8px;
    font-size: 1.3rem;
    line-height: 1.3;
  }

  .auth .panel {
    width: min(380px, 100%);
    gap: 10px;
    padding: 14px;
  }
}

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

  body * {
    visibility: hidden !important;
  }

  #order-picking-panel,
  #order-picking-panel * {
    visibility: visible !important;
  }

  #order-picking-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    margin: 0;
  }

  #order-picking-status,
  .picking-print-actions,
  .picking-item details,
  .picking-item input {
    display: none !important;
  }

  .picking-sheet {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .picking-sheet::before {
    content: "檢貨預覽｜尚未寫入防重列印收據｜不是官方面單";
    display: block;
    margin-bottom: 8mm;
    padding: 3mm;
    border: 1px solid #111;
    font-weight: 800;
    text-align: center;
  }

  .picking-item {
    break-inside: avoid;
    grid-template-columns: 1fr auto;
    padding: 5mm 0;
  }

  .picking-item > label {
    display: none;
  }

  .picking-quantity {
    grid-column: auto;
  }
}

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