:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: #f3f6fb;
  color: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
    #f3f6fb;
  color: #111827;
}

a {
  color: #1d4ed8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  width: min(1380px, calc(100vw - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 24px;
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(420px, 560px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.workspace-history {
  grid-column: 1 / -1;
}

.workspace-orders {
  grid-column: 1 / -1;
}

.workspace-panel {
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar h1,
.section-head h2,
.subsection h3 {
  margin: 0;
}

.toolbar p,
.section-head p {
  margin: 8px 0 0;
}

.section-head {
  display: grid;
  gap: 8px;
}

.form {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.form-grid,
.compact-grid {
  display: grid;
  gap: 14px 16px;
}

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

.compact-grid-card {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

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

.field-span-full {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.link-button {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1d4ed8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.link-button:hover {
  transform: none;
  box-shadow: none;
  text-decoration: underline;
}

input:focus,
select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

button {
  height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
}

.subsection {
  display: grid;
  gap: 14px;
  margin-top: 4px;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #f8fafc;
}

.subsection-highlight {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 233, 0.08));
  border-color: rgba(37, 99, 235, 0.18);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #0f172a;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.flash {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
  color: #1e3a8a;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: #475569;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.result-meta p {
  margin: 0;
}

.compact-result-meta {
  margin-top: -4px;
}

.notice {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.notice strong,
.notice p {
  margin: 0;
}

.notice p {
  margin-top: 6px;
}

.history-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(0, auto));
  align-items: center;
  gap: 10px 16px;
}

.history-link {
  font-weight: 700;
}

.history-meta {
  font-size: 13px;
  color: #475569;
}

.action-list {
  padding-left: 18px;
}

.action-list li {
  display: list-item;
}

.code-block {
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
}

.charge-query-form {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}

.charge-query-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.charge-query-actions {
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.charge-browser {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.charge-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.charge-card {
  width: 100%;
  height: auto;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  color: #0f172a;
  text-align: left;
  box-shadow: none;
}

.charge-card:hover,
.charge-card.is-active {
  transform: none;
  border-color: #93c5fd;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.12);
}

.charge-card-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.charge-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: #475569;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.status-succeeded {
  background: #dcfce7;
  color: #166534;
}

.status-pill.status-failed,
.status-pill.status-create-failed {
  background: #fee2e2;
  color: #991b1b;
}

.status-pill.status-created,
.status-pill.status-customer-action-required,
.status-pill.status-card-held {
  background: #fef3c7;
  color: #92400e;
}

.charge-detail {
  min-width: 0;
  display: grid;
  gap: 14px;
  align-content: start;
}

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

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

.charge-kv-item {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}

.charge-kv-item span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #64748b;
}

.charge-kv-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: #0f172a;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h3 {
  margin: 0;
}

.json-panel {
  display: grid;
  gap: 8px;
}

.json-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.json-panel-head strong {
  overflow-wrap: anywhere;
}

.copy-button {
  width: auto;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 12px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  color: #64748b;
  background: #f8fafc;
}

@media (max-width: 1180px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workspace-history {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .compact-grid-card,
  .compact-grid-customer,
  .form-grid,
  .charge-query-grid,
  .charge-browser,
  .charge-kv,
  .history-row {
    grid-template-columns: 1fr;
  }

  .field-span-full {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100vw - 16px, 100%);
    margin: 16px auto 24px;
    gap: 16px;
  }

  .card {
    padding: 18px;
    border-radius: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions,
  .toolbar form {
    width: 100%;
  }

  button {
    width: 100%;
  }
}
/* Complete request editor uses the same form controls on desktop and mobile. */
.request-editor-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.request-editor-group { grid-column: 1 / -1; border: 1px solid #dbe3ee; border-radius: 8px; padding: 12px; margin: 8px 0; min-width: 0; }
.request-editor-group > summary { cursor: pointer; overflow-wrap: anywhere; margin-bottom: 10px; }
.request-editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.request-editor-field label { overflow-wrap: anywhere; font-size: 12px; }
.request-editor-small-button { padding: 4px 8px; font-size: 12px; margin: 5px 4px 0 0; }
[data-request-editor] textarea { width: 100%; box-sizing: border-box; font-family: monospace; }
