:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --border: #e2e5ea;
  --accent: #1a73e8;
  --accent-text: #ffffff;
  --success: #188038;
  --warning: #b06000;
  --danger: #c5221f;
  --live-bg: #fde8e7;
  --live-text: #a50e0e;
  --sandbox-bg: #e8f0fe;
  --sandbox-text: #174ea6;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #e9ebef;
    --muted: #9aa1ad;
    --border: #2a2f38;
    --accent: #8ab4f8;
    --accent-text: #0f1115;
    --success: #81c995;
    --warning: #fdd663;
    --danger: #f28b82;
    --live-bg: #3b1715;
    --live-text: #f6aea9;
    --sandbox-bg: #172540;
    --sandbox-text: #aecbfa;
  }
}

* {
  box-sizing: border-box;
}

/* Classes like .button set display, which would otherwise beat [hidden]. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.25;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.1rem;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

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

.merchant {
  font-weight: 700;
  font-size: 1.1rem;
}

.badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.line-item,
.total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.line-item {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.item-name {
  font-weight: 600;
}

.total {
  padding-top: 12px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.notice {
  margin: 0 0 12px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.notice-live {
  background: var(--live-bg);
  color: var(--live-text);
}

.status {
  margin: 0 0 12px;
  color: var(--muted);
}

.status-error {
  color: var(--danger);
}

.widget {
  min-height: 120px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

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

.result {
  text-align: center;
}

.result-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 4px auto 12px;
  border-radius: 50%;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--surface);
  background: var(--muted);
}

.result[data-state='success'] .result-icon {
  background: var(--success);
}

.result[data-state='review'] .result-icon,
.result[data-state='pending'] .result-icon {
  background: var(--warning);
}

.result[data-state='rejected'] .result-icon,
.result[data-state='error'] .result-icon {
  background: var(--danger);
}

.result[data-state='loading'] .result-icon {
  visibility: hidden;
}

.details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 16px 0;
  text-align: left;
  font-size: 0.9rem;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.diagnostics {
  font-size: 0.8rem;
  color: var(--muted);
}

.diagnostics summary {
  cursor: pointer;
  padding: 8px 0;
}

.diagnostics-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.diagnostics-body h3 {
  margin: 12px 0 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.diagnostics-body h3:first-child {
  margin-top: 0;
}

.diagnostics-body ol,
.diagnostics-body ul {
  margin: 0;
  padding-left: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.diagnostics-body dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0;
}

.diagnostics-body dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.diagnostics-body .button {
  margin-top: 12px;
}

.copy-fallback {
  display: block;
  width: 100%;
  min-height: 160px;
  margin-top: 12px;
  font: 0.75rem ui-monospace, SFMono-Regular, Menlo, monospace;
}
