/* Only the saved-receipt list and its read-only detail view use these rules. */
.history-simple-panel {
  min-width: 0;
  padding: 20px;
  border-color: #d8e0e9;
  box-shadow: none;
  font-size: 16px;
  line-height: 1.6;
}

.history-simple-panel > details,
.history-simple-panel .history-search,
.history-simple-panel .history-search label {
  min-width: 0;
}

.history-simple-panel > details > summary {
  font-size: 20px;
}

.history-simple-panel .history-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 16px 0;
}

.history-simple-panel .history-search label,
.history-simple-panel input,
.history-simple-panel button {
  font-size: 16px;
}

.history-simple-panel button,
.history-simple-panel input {
  min-height: 44px;
}

.history-simple-panel button {
  white-space: normal;
  overflow-wrap: anywhere;
}

.history-simple-panel .history-message {
  margin: 12px 0 16px;
  color: #526176;
  overflow-wrap: anywhere;
}

/* Keep the list controls close to the receipts; avoid a card inside a card. */
#staffWorkspace .sw-history-panel {
  padding: 16px;
}

#staffWorkspace .sw-history-panel > h2 {
  margin-bottom: 8px;
}

#staffWorkspace .sw-history-panel > .sw-role-guide {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
}

#staffWorkspace .sw-history-panel > .sw-history-back {
  margin: 0 0 4px;
  padding: 8px 12px;
  font-size: 16px;
}

#staffWorkspace .sw-history-panel .history-simple-panel {
  margin: 8px 0 0 !important;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#staffWorkspace .history-simple-panel > details > summary {
  min-height: 44px !important;
  padding: 8px 0 !important;
  font-size: 16px;
}

#staffWorkspace .history-simple-panel .history-search {
  margin: 8px 0 4px;
}

#staffWorkspace .history-simple-panel .history-list-other > summary {
  min-height: 44px;
  padding: 8px 0;
  box-sizing: border-box;
  cursor: pointer;
  font-size: 16px;
  touch-action: manipulation;
}

#staffWorkspace .history-simple-panel .history-message {
  margin: 4px 0 10px;
}

.history-list-compact {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.history-list-compact .history-receipt-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  margin: 0;
  border: 1px solid #d8e0e9;
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.history-list-compact .history-receipt-card h3 {
  min-width: 0;
  margin: 0;
  color: #172033;
  font-size: 20px;
  line-height: 1.4;
}

.history-list-compact .history-card-meta {
  margin: 0;
  color: #526176;
  font-size: 16px;
  font-weight: 400;
}

.history-list-compact .history-card-products {
  min-width: 0;
  margin: 0;
  color: #334155;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.history-list-compact .history-card-status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  min-width: 0;
  margin: 0;
  color: #46566b;
  font-size: 16px;
  line-height: 1.5;
}

.history-list-compact .history-card-status span {
  max-width: 100%;
}

.history-list-compact .history-card-status[data-tone="attention"] {
  color: #98440e;
}

.history-list-compact .history-card-status[data-tone="done"] {
  color: #334155;
}

.history-list-compact .history-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
}

.history-list-compact .history-card-actions button,
.history-list-compact .history-receipt-card > button {
  min-width: 44px;
  min-height: 48px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 16px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}

.history-list-compact .history-card-actions .primary,
.history-list-compact .history-receipt-card > .primary {
  border-color: #2454b5;
  background: #2454b5;
  color: #fff;
}

.history-list-compact .history-card-actions .secondary {
  background: #f5f7fb;
  border-color: #cbd5e1;
  color: #334155;
}

.history-list-compact .history-card-actions .history-card-reuse {
  grid-column: 1 / -1;
  min-height: 60px;
  margin-top: 4px;
  border: 2px solid #15736b;
  background: #15736b;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}
.history-list-compact .history-card-actions .history-card-reuse:hover { background: #105c55; }
.history-reuse-dialog {
  box-sizing: border-box;
  width: min(640px, calc(100vw - 32px));
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
  padding: 24px;
  border: 1px solid #bdcadb;
  border-radius: 16px;
  color: #182231;
  font-size: 18px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.history-reuse-dialog::backdrop { background: #14243c88; }
.history-reuse-dialog h2 { margin: 0 0 16px; font-size: 24px; line-height: 1.4; }
.history-reuse-customer { font-weight: 700; }
.history-reuse-choices { display: grid; gap: 12px; margin: 20px 0; }
.history-reuse-dialog button { box-sizing: border-box; width: 100%; min-height: 60px; padding: 14px 16px; margin: 0; font-size: 18px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.history-reuse-dialog .navigation-back { background: #f0fdfa; color: #0f5e59; border: 2px solid #287c73; }

.history-list-compact .history-card-actions .primary:hover,
.history-list-compact .history-receipt-card > .primary:hover {
  background: #1d4598;
}

.receipt-readonly-preview {
  width: min(900px, calc(100vw - 24px));
  max-height: 92vh;
  max-height: 92dvh;
  border-color: #cbd5e1;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.receipt-readonly-preview .history-preview-header {
  padding: 14px 20px;
}

.receipt-readonly-preview .history-preview-header h2 {
  font-size: 20px;
  line-height: 1.5;
}

.receipt-readonly-preview .history-preview-header button {
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.receipt-readonly-preview .history-preview-content {
  min-width: 0;
  padding: 20px;
  gap: 16px;
}

.receipt-readonly-preview .history-preview-overview,
.receipt-readonly-preview .history-preview-product {
  padding: 18px;
  border-color: #d8e0e9;
  border-radius: 12px;
}

.receipt-readonly-preview .history-preview-overview h3 {
  font-size: 22px;
  line-height: 1.5;
}

.receipt-readonly-preview .history-preview-overview > p:nth-of-type(2) {
  padding: 0;
  background: transparent;
  color: #526176;
  font-size: 16px;
  font-weight: 400;
}

.receipt-readonly-preview .history-preview-fields {
  font-size: 16px;
}

.receipt-readonly-preview .receipt-detail-actions {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.receipt-readonly-preview .receipt-detail-primary,
.receipt-readonly-preview .receipt-detail-other {
  min-width: 0;
  padding: 16px;
  border: 1px solid #d8e0e9;
  border-radius: 12px;
  background: #fff;
}

.receipt-readonly-preview .receipt-detail-primary {
  border-color: #c3d4f0;
}

.receipt-readonly-preview .receipt-detail-actions h3 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.5;
}

.receipt-readonly-preview .receipt-detail-actions p {
  margin: 8px 0;
  font-size: 16px;
  line-height: 1.6;
}

.receipt-readonly-preview .receipt-detail-actions button {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin: 0 !important;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 16px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}

.receipt-readonly-preview .receipt-detail-actions button + button {
  margin-top: 8px !important;
}

.receipt-readonly-preview .receipt-detail-primary .primary {
  border-color: #2454b5;
  background: #2454b5;
  color: #fff;
}

.receipt-readonly-preview .receipt-detail-actions .secondary:not(:where(.navigation-back)) {
  border-color: #cbd5e1;
  background: #f5f7fb;
  color: #334155;
}

.receipt-readonly-preview .receipt-detail-actions button.receipt-detail-customer {
  border-color: #438363;
  background: #e4f3eb;
  color: #19563b;
}

.receipt-readonly-preview .receipt-detail-other > summary,
.receipt-readonly-preview .receipt-detail-other details > summary,
.receipt-readonly-preview .receipt-content-details > summary {
  min-height: 44px;
  padding: 9px 0;
  color: #334155;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.6;
  cursor: pointer;
  touch-action: manipulation;
}

.receipt-readonly-preview .receipt-detail-other[open] > summary {
  margin-bottom: 8px;
}

.receipt-readonly-preview .receipt-content-details {
  min-width: 0;
  padding: 10px 16px;
  border: 1px solid #d8e0e9;
  border-radius: 12px;
  background: #fff;
}

.receipt-readonly-preview .receipt-content-details[open] > summary {
  margin-bottom: 12px;
}

.receipt-readonly-preview .receipt-content-details > section + section {
  margin-top: 12px;
}

.receipt-readonly-preview .receipt-detail-other .receipt-detail-delete {
  margin-top: 16px !important;
  border-color: #e6c6cb;
  background: #fff;
  color: #a1273a;
}

.history-list-compact button:focus-visible,
.history-simple-panel input:focus-visible,
.receipt-readonly-preview button:focus-visible,
.receipt-readonly-preview summary:focus-visible {
  outline: 3px solid #e5a92f;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .history-simple-panel {
    padding: 14px;
  }

  .history-list-compact .history-receipt-card {
    padding: 14px;
  }

  .receipt-readonly-preview .history-preview-header {
    padding: 12px;
  }

  .receipt-readonly-preview .history-preview-header button {
    flex: 1 1 0;
  }

  .receipt-readonly-preview .history-preview-content {
    padding: 12px;
    gap: 12px;
  }

  .receipt-readonly-preview .history-preview-overview,
  .receipt-readonly-preview .history-preview-product,
  .receipt-readonly-preview .receipt-detail-primary,
  .receipt-readonly-preview .receipt-detail-other {
    padding: 14px;
  }

  .receipt-readonly-preview .history-preview-fields {
    grid-template-columns: minmax(88px, 0.85fr) minmax(0, 1.5fr);
  }

  .receipt-readonly-preview .receipt-content-details {
    padding: 8px 12px;
  }

  .receipt-readonly-preview .history-preview-fields dt,
  .receipt-readonly-preview .history-preview-fields dd {
    padding: 8px;
  }
}

/* iPad is the primary store device. Keep labels readable without shrinking. */
.history-list-compact .history-card-other {
  display: block;
  margin: 10px 0 0 auto;
  padding: 10px 14px;
  min-height: 48px;
  background: transparent;
  border: 1px solid #c8d3e1;
  border-radius: 8px;
  color: #405776;
  font-weight: 600;
}
@media (min-width: 601px) {
  .history-simple-panel,
  .history-simple-panel input,
  .history-simple-panel button,
  .history-list-compact .history-card-meta,
  .history-list-compact .history-card-products,
  .history-list-compact .history-card-status,
  .history-list-compact .history-card-actions button,
  .receipt-readonly-preview,
  .receipt-readonly-preview .history-preview-fields,
  .receipt-readonly-preview .receipt-detail-actions p,
  .receipt-readonly-preview .receipt-detail-actions button { font-size: 18px; }
  .history-simple-panel button,
  .history-simple-panel input,
  .history-list-compact .history-card-actions button,
  .receipt-readonly-preview .receipt-detail-actions button { min-height: 56px; }
  .history-list-compact .history-receipt-card h3 { font-size: 24px; }
  .receipt-readonly-preview { width: min(1000px, calc(100vw - 32px)); }
}
@media (max-width: 420px) {
  .history-list-compact .history-card-actions { grid-template-columns: 1fr; }
}
