#shop-section {
  display: none;
  min-width: 0;
  max-width: 100%;
}

#shop-section.active {
  display: block;
}

.shop-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-bottom: 20px;
}

.shop-toolbar .shop-tabs {
  margin-bottom: 0;
}

.shop-toolbar #shop-refresh-btn {
  min-height: 48px;
}

.shop-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin-bottom: 16px;
}

.shop-tab {
  min-width: 0;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: auto;
  cursor: pointer;
}

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

.shop-tab:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.shop-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

@media (max-width: 1100px) {
  .shop-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shop-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .shop-toolbar #shop-refresh-btn {
    justify-self: end;
    min-height: 44px;
  }
}

.shop-tab.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-primary);
}

.shop-panel[hidden],
.shop-state[hidden] {
  display: none !important;
}

.shop-state {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  color: var(--text-muted);
}

.shop-state-loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 10px;
  vertical-align: -2px;
  border: 2px solid var(--border-color-hover);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: shop-spin 0.8s linear infinite;
}

.shop-state-error {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

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

.shop-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.shop-overview-groups {
  display: grid;
  gap: 18px;
  margin-bottom: 16px;
}

.shop-kpi-group {
  position: relative;
  min-width: 0;
  padding: 20px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  border-radius: calc(var(--border-radius-md) + 4px);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.shop-kpi-group::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--primary);
}

.shop-kpi-group-payments::before { background: var(--color-warning, #d97706); }
.shop-kpi-group-finance::before { background: var(--color-success, #15803d); }
.shop-kpi-group-calculation::before { background: #6366f1; }

.shop-kpi-group-title {
  margin: 0 0 16px;
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.shop-kpi-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.shop-kpi-card span,
.shop-kpi-card small {
  display: block;
  color: var(--text-muted);
}

.shop-kpi-card span { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; }
.shop-kpi-card strong { display: block; margin: 7px 0; font-size: clamp(1.25rem, 5vw, 1.8rem); }
.shop-kpi-card small { font-size: 0.78rem; line-height: 1.35; }

.shop-overview-groups .shop-kpi-grid { margin-bottom: 0; }

.shop-overview-groups .shop-kpi-card {
  min-height: 132px;
  padding: 18px;
  background: var(--bg-card-hover);
  box-shadow: none;
}

.shop-overview-groups .shop-kpi-card span {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.035em;
}

.shop-overview-groups .shop-kpi-card strong {
  margin: 10px 0;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.1;
}

.shop-overview-health {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--color-warning, #b45309);
  border-radius: var(--border-radius-md);
  background: rgba(245, 158, 11, 0.12);
  color: var(--text-main);
  font-weight: 700;
}

.shop-orders-view-switch {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
}

.shop-orders-view {
  min-height: 42px;
  padding: 8px 18px;
  border: 0;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.shop-orders-view:hover { color: var(--text-main); background: var(--bg-card-hover); }
.shop-orders-view.active { color: white; background: var(--primary); }
.shop-orders-view:focus-visible { outline: 3px solid rgba(var(--primary-rgb), 0.32); outline-offset: 2px; }

.shop-filter-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
}

.shop-payment-import-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
}

.shop-payment-import-card label {
  display: grid;
  min-width: 0;
  gap: 12px;
  color: var(--text-main);
  font-weight: 700;
}

.shop-payment-import-card input[type="file"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 18px;
  border: 1px dashed rgba(var(--primary-rgb), 0.4);
  border-radius: 12px;
  background: rgba(var(--primary-rgb), 0.04);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.shop-payment-import-card input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: 14px;
  padding: 10px 16px;
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 10px;
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.shop-payment-import-card input[type="file"]:not(:disabled):hover::file-selector-button {
  background: rgba(var(--primary-rgb), 0.2);
}
.shop-payment-import-card input[type="file"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
.shop-payment-import-card input[type="file"]:disabled {
  opacity: 0.6;
  cursor: default;
}
.shop-payment-import-card input[type="file"]:disabled::file-selector-button { cursor: default; }

.shop-payment-import-help {
  grid-column: 1;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.shop-payment-import-card .btn { grid-column: 2; grid-row: 1; min-height: 44px; margin-bottom: 19px; }

@media (max-width: 480px) {
  .shop-payment-import-card input[type="file"] { padding: 14px; }
  .shop-payment-import-card input[type="file"]::file-selector-button { display: block; margin: 0 0 12px; }
}

.shop-payment-import-progress {
  margin: -4px 0 16px;
  color: var(--text-muted);
  font-weight: 700;
}

.shop-payment-import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.shop-payment-import-summary > span {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
}

.shop-payment-import-summary small,
.shop-payment-import-summary strong { display: block; }
.shop-payment-import-summary small { color: var(--text-muted); font-size: 0.75rem; font-weight: 700; }
.shop-payment-import-summary strong { margin-top: 4px; color: var(--text-main); font-size: 1.25rem; }

.shop-payment-import-status-paid { border-color: var(--color-success); }
.shop-payment-import-status-error,
.shop-payment-import-status-amount_mismatch { border-color: var(--color-danger); }
.shop-payment-import-status-ambiguous,
.shop-payment-import-status-order_not_found { border-color: var(--color-warning, #d97706); }

.shop-filter-card label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.shop-filter-card .input-field,
.shop-filter-actions .btn,
.shop-detail-button,
.shop-icon-button {
  min-height: 44px;
}

.shop-filter-card .input-field {
  width: 100%;
  min-width: 0;
}

.shop-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 0;
  gap: 8px;
}

.shop-filter-actions .btn {
  width: 100%;
  min-width: 0;
  padding-inline: 10px;
}

.shop-panel {
  min-width: 0;
  max-width: 100%;
}

.shop-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
}

.shop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.shop-table th,
.shop-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

.shop-table th {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.shop-table tr:last-child td { border-bottom: 0; }
.shop-table td small { display: block; margin-top: 4px; color: var(--text-muted); }

.shop-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.shop-dialog {
  width: min(920px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-color-hover);
  border-radius: var(--border-radius-lg);
  background: var(--bg-modal);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
}

.shop-dialog::backdrop { background: rgba(2, 6, 23, 0.76); backdrop-filter: blur(5px); }

.shop-dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-modal);
}

.shop-eyebrow { margin-bottom: 3px; color: var(--primary); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.shop-dialog-header h2 { font-size: 1.25rem; }
.shop-icon-button { width: 44px; border: 0; border-radius: 50%; background: var(--bg-card-hover); color: var(--text-main); font-size: 1.6rem; cursor: pointer; }
.shop-dialog-body { padding: 20px; }

.shop-order-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 24px;
  padding: 20px;
  border: 1px solid rgba(var(--primary-rgb), 0.24);
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.13), rgba(var(--primary-rgb), 0.035) 58%, var(--bg-card));
  box-shadow: var(--shadow-sm);
}

.shop-order-summary span,
.shop-order-summary strong,
.shop-order-summary small { display: block; min-width: 0; overflow-wrap: anywhere; }
.shop-order-summary span { color: var(--text-muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.shop-order-summary-main strong { margin: 4px 0; font-size: clamp(1.2rem, 3vw, 1.55rem); }
.shop-order-summary-main small { color: var(--text-muted); font-size: 0.84rem; }
.shop-order-summary-amount { text-align: right; }
.shop-order-summary-amount strong { margin-top: 4px; color: var(--primary); font-size: clamp(1.35rem, 3vw, 1.75rem); }
.shop-order-summary-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.shop-order-summary-status .shop-status { text-transform: none; letter-spacing: normal; }
.shop-order-summary-meta { display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 14px; text-align: right; }
.shop-order-summary-meta strong { margin-top: 3px; font-size: 0.86rem; }
.shop-order-contact { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.shop-order-contact > div { min-width: 0; }
.shop-order-contact strong { margin-top: 4px; font-size: 0.95rem; user-select: text; }

.shop-status-payment { background: rgba(var(--primary-rgb), 0.14); color: var(--primary); }
.shop-status-order { border: 1px solid var(--border-color-hover); background: var(--bg-card); }

.shop-status-cancelled {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.shop-order-cancelled td { background: var(--color-danger-bg); }
.shop-order-cancelled td:first-child { box-shadow: inset 4px 0 0 var(--color-danger); }
.shop-order-summary-cancelled { border-color: var(--color-danger); }

.shop-btn-danger {
  border-color: #991b1b;
  background: #991b1b;
  color: #fff;
}

.shop-btn-danger:hover {
  border-color: #7f1d1d;
  background: #7f1d1d;
}

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

.shop-detail-actions:empty { display: none; }

.shop-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shop-detail-grid > div {
  min-width: 0;
  padding: 12px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
}

.shop-detail-grid span,
.shop-detail-grid strong { display: block; overflow-wrap: anywhere; }
.shop-detail-grid span { margin-bottom: 4px; color: var(--text-muted); font-size: 0.72rem; }
.shop-detail-grid strong { font-size: 0.9rem; }
.shop-detail-section {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.shop-detail-actions .shop-detail-section { margin-top: 0; }
.shop-detail-section h3 { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; font-size: 1rem; }
.shop-detail-section h3::before { content: ""; width: 7px; height: 18px; flex: 0 0 auto; border-radius: 999px; background: var(--primary); }
.shop-detail-section > p { margin: -4px 0 14px; color: var(--text-muted); font-size: 0.82rem; line-height: 1.45; }

.shop-detail-form,
.shop-dialog-body .shop-detail-section form { display: grid; gap: 12px; }
.shop-detail-form label,
.shop-dialog-body .shop-detail-section form label { display: grid; gap: 6px; color: var(--text-muted); font-size: 0.78rem; font-weight: 700; }

.shop-control,
.shop-dialog-body .shop-detail-section input:not([type="checkbox"]):not([type="radio"]),
.shop-dialog-body .shop-detail-section select,
.shop-dialog-body .shop-detail-section textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-color-hover);
  border-radius: 12px;
  outline: none;
  background-color: var(--bg-app);
  color: var(--text-main);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.shop-select,
.shop-dialog-body .shop-detail-section select {
  appearance: none;
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--primary) 50%), linear-gradient(135deg, var(--primary) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.shop-control:focus,
.shop-dialog-body .shop-detail-section input:not([type="checkbox"]):not([type="radio"]):focus,
.shop-dialog-body .shop-detail-section select:focus,
.shop-dialog-body .shop-detail-section textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.16);
  background-color: var(--bg-card);
}

.shop-control:disabled,
.shop-dialog-body .shop-detail-section input:disabled,
.shop-dialog-body .shop-detail-section select:disabled,
.shop-dialog-body .shop-detail-section textarea:disabled { cursor: not-allowed; opacity: 0.62; background-color: var(--bg-card-hover); }
.shop-dialog-body .shop-detail-section form .btn { min-height: 44px; }
.shop-inventory-line {
  position: relative;
  overflow: hidden;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border-color-hover);
  border-top: 5px solid var(--primary);
  border-radius: var(--border-radius-md);
  background: var(--bg-app);
  box-shadow: var(--shadow-sm);
}

.shop-inventory-line h4 {
  margin: 0 0 14px;
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.35;
}

.shop-inventory-line dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.shop-inventory-line dl > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
}

.shop-inventory-line dt {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.shop-inventory-line dd {
  margin: 3px 0 0;
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 800;
}

.shop-inventory-line-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.shop-inventory-operation {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
}

.shop-inventory-operation h5 {
  margin: 0 0 10px;
  color: var(--text-main);
  font-size: 0.82rem;
}

.shop-inventory-operation > span {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.shop-receipt-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.7fr);
  align-items: end;
  gap: 12px;
}

.shop-receipt-select {
  display: flex !important;
  grid-template-columns: none !important;
  flex-direction: row !important;
  align-items: center;
  gap: 9px !important;
  min-height: 44px;
  color: var(--text-main) !important;
  font-size: 0.86rem !important;
}

.shop-receipt-select input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--primary);
}

.shop-receipt-batch-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.6fr) minmax(240px, 1fr);
  align-items: end;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 2px solid var(--primary);
  border-radius: var(--border-radius-md);
  background: rgba(var(--primary-rgb), 0.08);
}

.shop-handover-batch-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 2px solid var(--primary);
  border-radius: var(--border-radius-md);
  background: rgba(var(--primary-rgb), 0.08);
}

.shop-handover-line {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.shop-handover-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 700px) {
  .shop-handover-line {
    align-items: stretch;
    flex-direction: column;
  }

  .shop-handover-batch-form {
    grid-template-columns: 1fr;
  }

  .shop-handover-batch-form .btn {
    width: 100%;
  }
}

.shop-inventory-operation .btn { width: 100%; }
.shop-payment-overview { margin-bottom: 14px; }
.shop-payment-intent-status { margin: 0 0 14px; padding: 11px 12px; border-left: 3px solid var(--primary); border-radius: 0 10px 10px 0; background: rgba(var(--primary-rgb), 0.1); color: var(--text-main); font-size: 0.84rem; line-height: 1.45; }

.shop-supplier-management,
.shop-product-management {
  margin-bottom: 16px;
}

.shop-management-grid,
.shop-form-grid,
.shop-toggle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.shop-action-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.shop-action-card h3 { margin: 0; font-size: 1rem; }
.shop-supplier-recovery-card { align-self: start; align-content: start; }
.shop-action-card > p { margin: 0; color: var(--text-muted); font-size: 0.82rem; line-height: 1.45; }
.shop-action-card label { display: grid; gap: 6px; color: var(--text-muted); font-size: 0.78rem; font-weight: 700; }
.shop-action-card .input-field,
.shop-action-card .btn { min-height: 44px; }
.shop-action-card textarea.input-field { min-height: 92px; resize: vertical; }

.shop-choice-list,
.shop-toggle-grid {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
}

.shop-choice-list legend,
.shop-toggle-grid legend {
  padding: 0 5px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.shop-choice-row {
  grid-template-columns: auto minmax(0, 1fr) !important;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-color);
}

.shop-choice-row:last-child { border-bottom: 0; }
.shop-choice-row input { width: 20px; height: 20px; margin-top: 1px; }
.shop-choice-row span,
.shop-choice-row strong,
.shop-choice-row small { display: block; min-width: 0; overflow-wrap: anywhere; }
.shop-choice-row small { margin-top: 3px; color: var(--text-muted); font-weight: 500; }
.shop-choice-row:has(input:disabled) { opacity: 0.72; }

.shop-batch-selection-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.shop-batch-selection-toolbar span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

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

.shop-batch-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-content: start;
  gap: 0 16px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.shop-batch-choice-list legend,
.shop-batch-choice-list > p {
  grid-column: 1 / -1;
}

.shop-batch-choice-list .shop-choice-row {
  min-width: 0;
}

.shop-intent-status {
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--text-main) !important;
}

.shop-product-id {
  display: block;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-card-hover);
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.shop-legacy-fallback {
  display: inline-block;
  margin-left: 5px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.shop-toggle-grid label {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.shop-toggle-grid input { width: 20px; height: 20px; }

.shop-timeline { display: grid; gap: 8px; list-style: none; }
.shop-timeline li { padding: 12px; border-left: 3px solid var(--primary); border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0; background: var(--bg-card); }
.shop-timeline span, .shop-timeline strong, .shop-timeline small { display: block; }
.shop-timeline span, .shop-timeline small { color: var(--text-muted); font-size: 0.76rem; }
.shop-timeline strong { margin: 3px 0; font-size: 0.9rem; }

@media (max-width: 699px) {
  .shop-kpi-group { padding: 16px; }
  .shop-overview-groups .shop-kpi-grid { grid-template-columns: 1fr; }
  .shop-overview-groups .shop-kpi-card { min-height: 0; }
  .shop-dialog { width: min(100% - 12px, 920px); max-height: calc(100dvh - 12px); }
  .shop-dialog-header { position: sticky; padding: 14px 64px 14px 14px; }
  .shop-dialog-header .shop-icon-button { position: absolute; top: 12px; right: 12px; }
  .shop-dialog-body { padding: 14px; }
  .shop-order-summary { grid-template-columns: 1fr; gap: 15px; padding: 16px; }
  .shop-order-summary-amount { text-align: left; }
  .shop-order-summary-meta { text-align: left; }
  .shop-detail-actions { grid-template-columns: 1fr; }
  .shop-detail-section { padding: 15px; }
  .shop-inventory-line { padding: 14px; }
  .shop-inventory-line dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-inventory-line-actions { grid-template-columns: 1fr; }
  .shop-receipt-line,
  .shop-receipt-batch-form { grid-template-columns: 1fr; }
  .shop-table-wrap { overflow: visible; border: 0; background: transparent; }
  .shop-orders-table thead { display: none; }
  .shop-orders-table, .shop-orders-table tbody, .shop-orders-table tr, .shop-orders-table td { display: block; width: 100%; }
  .shop-orders-table tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius-md); background: var(--bg-card); }
  .shop-orders-table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border: 0; text-align: right; }
  .shop-orders-table td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: 0.72rem; font-weight: 700; text-align: left; }
  .shop-orders-table td:last-child { padding-top: 12px; }
  .shop-orders-table .shop-detail-button { width: 100%; }
  .shop-payment-import-table thead { display: none; }
  .shop-payment-import-table,
  .shop-payment-import-table tbody,
  .shop-payment-import-table tr,
  .shop-payment-import-table td { display: block; width: 100%; }
  .shop-payment-import-table tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius-md); background: var(--bg-card); }
  .shop-payment-import-table td { display: flex; align-items: center; justify-content: space-between; min-width: 0; gap: 12px; padding: 8px 4px; border: 0; overflow-wrap: anywhere; text-align: right; }
  .shop-payment-import-table td[data-label]::before { content: attr(data-label); flex: 0 0 auto; color: var(--text-muted); font-size: 0.72rem; font-weight: 700; text-align: left; }
  .shop-payment-import-card { grid-template-columns: 1fr; align-items: stretch; }
  .shop-payment-import-card .btn,
  .shop-payment-import-help { grid-column: auto; grid-row: auto; }
  .shop-payment-import-card .btn { width: 100%; margin-bottom: 0; }
  .shop-payment-import-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 700px) {
  .shop-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .shop-kpi-group-orders .shop-kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .shop-kpi-group-orders .shop-kpi-card { grid-column: span 2; }
  .shop-kpi-group-orders .shop-kpi-card:nth-child(n + 4) { grid-column: span 3; }
  .shop-kpi-group-finance .shop-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shop-filter-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shop-filter-search { grid-column: span 2; }
  .shop-filter-actions { grid-column: 1 / -1; align-self: end; }
  .shop-management-grid,
  .shop-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-form-wide { grid-column: 1 / -1; }
  .shop-toggle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shop-batch-choice-list { grid-template-columns: 1fr; max-height: 360px; }
  .shop-batch-selection-toolbar .btn { width: 100%; }
  .shop-filter-card { grid-template-columns: 1fr; }
  .shop-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .shop-table,
  .shop-table tbody,
  .shop-table tr,
  .shop-table td { display: block; width: 100%; }
  .shop-table tr {
    display: grid;
    gap: .5rem;
    margin-bottom: 12px;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
  }
  .shop-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border: 0;
  }
  .shop-table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 700;
    text-align: left;
  }
}

@media (min-width: 1400px) {
  .shop-filter-card { grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; }
  .shop-filter-search { grid-column: span 2; }
  .shop-filter-actions { grid-column: span 2; }
}
.shop-orders-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.shop-orders-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.shop-orders-page-size .input-field { width: auto; min-width: 76px; min-height: 42px; }

@media (max-width: 700px) {
  .shop-batch-actions { grid-template-columns: 1fr; }
  .shop-orders-pagination { align-items: stretch; flex-direction: column; }
  .shop-orders-pagination .btn { width: 100%; }
  .shop-orders-page-size { justify-content: space-between; }
  .shop-orders-view-switch { display: flex; }
  .shop-orders-view { flex: 1; }
}

/* Shop selection is shown only while creating a product. */
.shop-product-form [hidden] { display: none; }

/* Product editor: use the portal palette for uploads, previews and options. */
.shop-product-form #shop-product-images-fieldset,
.shop-product-form .shop-toggle-grid {
  min-width: 0;
  margin: 4px 0 0;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
}
.shop-product-form fieldset legend {
  padding: 0 8px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
}
#shop-product-images-fieldset > p {
  margin: 0 0 16px;
  max-width: 72ch;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.6;
}
#shop-product-images-fieldset > label {
  gap: 12px;
  padding: 18px;
  border: 1px dashed rgba(var(--primary-rgb), 0.4);
  border-radius: 12px;
  background: rgba(var(--primary-rgb), 0.04);
  color: var(--text-main);
}
#shop-product-images-input {
  width: 100%;
  min-width: 0;
  color: var(--text-muted);
  font: inherit;
  font-weight: 400;
  cursor: pointer;
}
#shop-product-images-input::file-selector-button {
  min-height: 44px;
  margin-right: 12px;
  padding: 10px 16px;
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 10px;
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
#shop-product-images-input:not(:disabled):hover::file-selector-button {
  background: rgba(var(--primary-rgb), 0.2);
}
#shop-product-images-fieldset #shop-product-images-status { margin: 12px 0; }
#shop-product-images-status:empty,
.shop-product-images-preview:empty { display: none; }
#shop-product-images-reset,
.shop-product-image-card button {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
}
#shop-product-images-reset { margin-top: 4px; font-size: 0.8rem; }
#shop-product-images-reset:not(:disabled):hover,
.shop-product-image-card button:not(:disabled):hover {
  border-color: var(--border-color-hover);
  background: var(--bg-card-hover);
}
.shop-product-images-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 180px)); gap: 12px; margin: 16px 0; }
.shop-product-image-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card); }
.shop-product-image-card img { width: 100%; height: 140px; object-fit: contain; background: var(--bg-card); border-radius: 8px; }
.shop-product-image-card button { min-height: 40px; padding: 8px; border-radius: 8px; font-size: 0.75rem; cursor: pointer; }
.shop-product-image-card:first-child { border-color: rgba(var(--primary-rgb), 0.35); }
.shop-product-image-card:first-child button:first-of-type { color: var(--primary); background: rgba(var(--primary-rgb), 0.1); }
.shop-product-form .shop-toggle-grid { gap: 8px; }
.shop-product-form .shop-toggle-grid label {
  min-height: 48px;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 500;
  line-height: 1.4;
}
.shop-product-form .shop-toggle-grid label:has(input:checked) {
  border-color: rgba(var(--primary-rgb), 0.3);
  background: rgba(var(--primary-rgb), 0.07);
}
.shop-product-form .shop-toggle-grid input {
  appearance: none;
  position: relative;
  width: 36px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--text-muted);
  border-radius: 99px;
  background: rgba(var(--primary-rgb), 0.06);
  cursor: pointer;
}
.shop-product-form .shop-toggle-grid input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
}
.shop-product-form .shop-toggle-grid input:checked { background: var(--primary); border-color: var(--primary); }
.shop-product-form .shop-toggle-grid input:checked::before { transform: translateX(14px); background: #fff; }
.shop-product-form input:focus-visible,
.shop-product-form button:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.shop-product-form fieldset:disabled { opacity: 0.6; }
.shop-product-form input:disabled,
.shop-product-form button:disabled,
.shop-product-form label:has(input:disabled) { cursor: default; }

@media (max-width: 480px) {
  .shop-product-form #shop-product-images-fieldset,
  .shop-product-form .shop-toggle-grid { padding: 12px; }
  #shop-product-images-fieldset > label { padding: 12px; }
  #shop-product-images-input::file-selector-button { display: block; margin: 0 0 10px; }
  #shop-product-images-reset { width: 100%; }
  .shop-product-images-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.shop-order-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.shop-release-button,
.shop-release-done {
  min-width: 8.5rem;
  white-space: nowrap;
}

.shop-release-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.shop-release-done {
  color: var(--color-success, #166534);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}
.shop-import-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(440px, calc(100vw - 40px));
  box-sizing: border-box;
  padding: 32px;
  border: 1px solid #d8e5df;
  border-radius: 20px;
  background: #fff;
  color: #173b2e;
  text-align: center;
  box-shadow: 0 24px 80px #102b3040;
}
.shop-import-dialog::backdrop { background: #102b30a6; }
.shop-import-dialog h2 { margin: 20px 0 12px; font-size: 1.4rem; }
.shop-import-dialog p { line-height: 1.6; }
.shop-import-spinner {
  display: inline-block;
  width: 44px;
  height: 44px;
  border: 4px solid #dcebe3;
  border-top-color: #087443;
  border-radius: 50%;
  animation: shop-import-spin 1s linear infinite;
}
.shop-import-elapsed { font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes shop-import-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .shop-import-spinner { animation: none; }
}

/* Small club stock controls */
.shop-stock-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border-color, #d7dce2); }
.shop-stock-line p { margin: .4rem 0; }
.shop-stock-allocation-form, .shop-stock-adjust-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.shop-stock-allocation-form label, .shop-stock-adjust-form label { display: grid; gap: .3rem; }
.shop-stock-adjust-form { margin: 1rem 0; }
.shop-stock-quantity { max-width: 8rem; }
@media (max-width: 640px) { .shop-stock-adjust-form label, .shop-stock-adjust-form button { width: 100%; } .shop-stock-allocation-form { width: 100%; } }

/* Per-position size correction and permanent notes. */
.shop-size-editor { margin-top: .5rem; min-width: 12rem; max-width: 22rem; }
.shop-size-editor summary { cursor: pointer; color: var(--primary-color, #08763e); font-weight: 600; }
.shop-line-size-form { display: grid; gap: .6rem; margin-top: .6rem; }
.shop-line-size-form label { display: grid; gap: .25rem; }
.shop-line-size-form .input-field { width: 100%; min-width: 0; box-sizing: border-box; }
.shop-line-size-form textarea { resize: vertical; white-space: normal; }
.shop-size-status, .shop-size-blocked { display: block; white-space: normal; font-size: .78rem; line-height: 1.4; max-width: 22rem; margin-top: .35rem; }
.shop-size-history { padding: 0; margin: 0; list-style: none; min-width: 12rem; max-width: 25rem; white-space: normal; overflow-wrap: anywhere; }
.shop-size-history li { display: grid; gap: .2rem; padding: .35rem 0; }
.shop-size-history small { opacity: .75; }

/* Editable recipient in order details; addresses also wrap on narrow screens. */
.shop-order-email-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.shop-order-email-form .input-field { flex: 1 1 220px; min-width: 0; width: 100%; }
.shop-order-email-form small { flex-basis: 100%; overflow-wrap: anywhere; }
.shop-order-email-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.shop-timeline .shop-mail-resend { margin-top: 8px; }
.shop-mail-outbox-row small, .shop-timeline li small { overflow-wrap: anywhere; }

/* Order positions stay within the detail dialog at every viewport width. */
.shop-order-line-list { display: grid; gap: 12px; min-width: 0; }
.shop-order-line { min-width: 0; padding: 16px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card-hover); overflow-wrap: anywhere; }
.shop-order-line-heading { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.shop-order-line-heading h4 { min-width: 0; flex: 1 1 180px; margin: 0; font-size: 1rem; }
.shop-order-line-heading .btn { max-width: 100%; white-space: normal; }
.shop-order-line-values { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
.shop-order-line-values > div { min-width: 0; }
.shop-order-line-values dt { color: var(--text-muted); font-size: .78rem; }
.shop-order-line-values dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.shop-order-line .shop-size-editor { min-width: 0; max-width: none; margin-top: 14px; }
.shop-order-line .shop-line-size-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.shop-order-line .shop-line-size-form > small,
.shop-order-line .shop-line-size-form > label:has(textarea),
.shop-order-line .shop-line-size-form > button { grid-column: 1 / -1; }
.shop-order-line .shop-line-size-form label { min-width: 0; }
.shop-line-notes-dialog { margin: auto; box-sizing: border-box; width: min(600px, calc(100% - 24px)); max-width: calc(100% - 24px); max-height: calc(100dvh - 32px); padding: 20px; border: 1px solid var(--border-color); border-radius: 16px; color: var(--text-main); background: #fff; overflow-y: auto; overflow-wrap: anywhere; }
.shop-line-notes-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.shop-line-notes-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.shop-line-notes-heading h3 { margin: 0; }
.shop-line-notes-product { color: var(--text-muted); }
.shop-line-notes-dialog .shop-size-history { min-width: 0; max-width: none; }
.shop-line-notes-dialog .shop-size-history li { padding: 14px 0; border-top: 1px solid var(--border-color); gap: 8px; }
.shop-line-notes-dialog .shop-size-history span { white-space: pre-wrap; }
@media (max-width: 760px) {
  .shop-order-line-values { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 440px) {
  .shop-order-line { padding: 12px; }
  .shop-order-line-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-order-line .shop-line-size-form { grid-template-columns: minmax(0, 1fr); }
}

[data-theme="dark"] .shop-line-notes-dialog { background: #0f172a; }

.shop-cash-heading h2 { margin: 0 0 8px; }
.shop-cash-heading p, .shop-cash-kpis small { color: var(--text-muted, #687386); }
.shop-cash-kpis { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; margin: 22px 0; }
.shop-cash-kpis > div { border: 1px solid var(--border-color, #dce3ea); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 9px; background: var(--bg-card, #fff); }
.shop-cash-kpis strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.shop-cash-kpis .shop-cash-balance { background: var(--color-success-bg, #edf7f2); border-color: var(--color-success, #acd3bd); }
.shop-cash-form fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
.shop-cash-form label, .shop-cash-filters label { display: flex; flex-direction: column; gap: 7px; }
.shop-cash-note, #shop-cash-form-hint { grid-column: 1 / -1; }
#shop-cash-form-hint { margin: 0; color: var(--text-muted, #687386); }
.shop-cash-form button { justify-self: start; }
.shop-cash-filters { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
#shop-cash-rows small { display: block; margin-top: 5px; color: var(--text-muted, #687386); }
#shop-cashbook-panel .shop-detail-card { margin-bottom: 20px; padding: 22px; border: 1px solid var(--border-color, #dce3ea); border-radius: 14px; background: var(--bg-card, #fff); }
.shop-cash-form label, .shop-cash-filters label { min-width: 0; }
@media (max-width: 640px) {
  .shop-cash-kpis, .shop-cash-form fieldset { grid-template-columns: 1fr; }
  .shop-cash-filters { display: grid; grid-template-columns: minmax(0, 1fr); }
  .shop-cash-filters label:last-child { grid-column: 1 / -1; }
  .shop-cash-kpis strong { font-size: 1.6rem; }
}

#shop-cashbook-panel .shop-detail-card > h3 { margin-bottom: 12px; }
#shop-cashbook-panel .shop-detail-card > p { margin-bottom: 16px; color: var(--text-muted); line-height: 1.45; }

/* Persistent confirmation belongs to the position, including inside modal dialogs. */
.shop-line-save-confirmation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .75rem;
  padding: .7rem .85rem;
  margin: .65rem 0;
  border: 1px solid #57b982;
  border-left: 4px solid #19814a;
  border-radius: 8px;
  background: #ecf9f1;
  color: #165b35;
  overflow-wrap: anywhere;
}
.shop-line-save-confirmation > span { flex-basis: 100%; }
.shop-line-save-confirmation:focus { outline: 2px solid #19814a; outline-offset: 2px; }
.shop-size-status[data-state] { padding: .75rem; border-radius: 8px; font-weight: 600; }
.shop-size-status[data-state="error"] { background: #fff0ef; color: #a52820; border: 1px solid #d9918a; }
.shop-size-status[data-state="uncertain"] { background: #fff6df; color: #795800; border: 1px solid #d2b768; }
.shop-size-status[data-state="saving"] { background: #edf5ff; color: #204f81; border: 1px solid #9dbbe0; }
.shop-line-size-form select { min-width: 0; width: 100%; }
.shop-supplier-dialog { max-width: min(540px, calc(100vw - 32px)); }
.shop-supplier-download-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 20px 0; }
.shop-supplier-dialog [hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .shop-supplier-dialog .shop-import-spinner { animation: none; } }
