/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f4f5f7;
  --surface:     #ffffff;
  --border:      #e1e4e8;
  --text:        #1a1d23;
  --text-muted:  #6b7280;
  --accent:      #2563eb;
  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --green-border:#bbf7d0;
  --yellow:      #d97706;
  --yellow-bg:   #fffbeb;
  --yellow-border:#fde68a;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --red-border:  #fecaca;
  --blue-bg:     #eff6ff;
  --blue-border: #bfdbfe;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header {
  margin-bottom: 24px;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

header .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

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

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Fields ── */
.field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.field input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.field-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Fetch status ── */
.fetch-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.loading {
  background: var(--yellow);
  animation: pulse 1.2s infinite;
}

.dot.ok     { background: var(--green); }
.dot.error  { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ── Run button ── */
.run-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  margin-top: 4px;
}

.run-btn:hover  { background: #1d4ed8; }
.run-btn:active { transform: scale(.98); }

/* ── Output panel ── */
.output-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 200px;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

/* ── Output sections ── */
.out-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.out-section:last-child { border-bottom: none; }

.out-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Summary row ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}

.stat {
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
}

.stat .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat .value {
  font-size: 15px;
  font-weight: 600;
}

/* ── Market check ── */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge.green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.badge.red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }

/* ── Action box ── */
.action-box {
  border-radius: 8px;
  padding: 16px 20px;
}

.action-box.green  { background: var(--green-bg);  border: 1px solid var(--green-border); }
.action-box.yellow { background: var(--yellow-bg); border: 1px solid var(--yellow-border); }
.action-box.red    { background: var(--red-bg);    border: 1px solid var(--red-border); }
.action-box.blue   { background: var(--blue-bg);   border: 1px solid var(--blue-border); }

.action-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-box.green  .action-title { color: var(--green); }
.action-box.yellow .action-title { color: var(--yellow); }
.action-box.red    .action-title { color: var(--red); }
.action-box.blue   .action-title { color: var(--accent); }

.action-detail {
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.6;
}

/* ── Steps list ── */
.steps {
  list-style: none;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.steps li {
  display: flex;
  gap: 10px;
  font-size: 13px;
  align-items: baseline;
}

.step-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── KV rows ── */
.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.kv-table tr td {
  padding: 4px 0;
}

.kv-table tr td:first-child {
  color: var(--text-muted);
  width: 55%;
}

.kv-table tr td:last-child {
  font-weight: 600;
  text-align: right;
}

.kv-table tr + tr td {
  border-top: 1px solid var(--border);
  padding-top: 5px;
}

/* ── Monospace values ── */
.mono { font-family: "SF Mono", Consolas, monospace; }
