:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d7dde5;
  --text: #1f2933;
  --muted: #64748b;
  --ink: #0f172a;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --ok: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--primary-strong);
}

button:disabled {
  cursor: not-allowed;
  background: #aab4c1;
}

button.secondary {
  background: #e6eaf0;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  min-height: 96px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr[data-id] {
  cursor: pointer;
}

tr[data-id]:hover,
tr.selected {
  background: #eef4ff;
}

.shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 30px;
}

.topbar,
.panel-head,
.actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.15;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions select {
  width: 150px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.metric.ok strong {
  color: var(--ok);
}

.metric.warn strong {
  color: var(--warn);
}

.metric.bad strong {
  color: var(--bad);
}

.layout {
  display: grid;
  grid-template-columns: minmax(480px, 0.95fr) minmax(420px, 1.05fr);
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2,
.raw-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.chip,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-badge.PENDING {
  background: #fef3c7;
  color: var(--warn);
}

.status-badge.SENT {
  background: #dcfce7;
  color: var(--ok);
}

.status-badge.FAILED {
  background: #fee2e2;
  color: var(--bad);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 250px);
}

.empty,
.empty-state {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 36px 14px;
}

.review-form,
.detail-grid {
  display: grid;
  gap: 12px;
}

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

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

.radio-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
}

.radio-card input {
  width: auto;
  margin-right: 8px;
}

.radio-card.decline:has(input:checked) {
  border-color: var(--bad);
  background: #fff1f2;
}

.radio-card.approve:has(input:checked) {
  border-color: var(--ok);
  background: #f0fdf4;
}

.radio-card.neutral:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
}

.checkbox-line {
  display: flex;
  grid-column: span 1;
  align-items: center;
  min-height: 42px;
  gap: 8px;
}

.checkbox-line input {
  width: auto;
}

.raw-section {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

#rawOutput {
  min-height: 160px;
  max-height: 340px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101827;
  color: #dce7f7;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .layout,
  .detail-grid,
  .decision-row {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }

  .actions,
  .button-row {
    align-items: stretch;
  }

  .actions select,
  .button-row button {
    width: 100%;
  }
}
