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

:root {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface-2: #252836;
  --border: #2d3147;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --primary: #6c63ff;
  --primary-hover: #5a52d5;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --pending: #f59e0b;
  --processing: #3b82f6;
  --radius: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo { font-size: 20px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.nav { display: flex; gap: 4px; }
.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--primary); color: white; }

/* ── Main Layout ─────────────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h2 { font-size: 22px; font-weight: 600; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.section-actions { display: flex; gap: 8px; align-items: center; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: var(--text); }

/* ── Form ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--text-muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.form-group small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 4px; }
input[type="text"], input[type="number"], .select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, .select:focus { border-color: var(--primary); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; width: 100%; margin-top: 8px; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mt-1 { margin-top: 12px; }

/* ── Stats ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 8px;
  text-align: center;
}
.stat-box.pending { border-color: var(--pending); }
.stat-box.processing { border-color: var(--processing); }
.stat-box.success { border-color: var(--success); }
.stat-box.failed { border-color: var(--danger); }
.stat-value { display: block; font-size: 22px; font-weight: 700; }
.stat-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Result Box ─────────────────────────────────────────────────────── */
.result-box { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius); font-size: 13px; border: 1px solid; }
.result-box.success { background: rgba(34,197,94,0.1); border-color: var(--success); color: var(--success); }
.result-box.error { background: rgba(239,68,68,0.1); border-color: var(--danger); color: var(--danger); }
.result-box.info { background: rgba(59,130,246,0.1); border-color: var(--info); color: var(--info); }
.result-box pre { white-space: pre-wrap; word-break: break-all; font-family: monospace; font-size: 12px; }
.hidden { display: none !important; }

/* ── Table ──────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.table th {
  background: var(--surface-2);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.empty { text-align: center; color: var(--text-muted); padding: 40px !important; }

/* ── Status Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-PENDING    { background: rgba(245,158,11,0.15);  color: var(--pending); }
.badge-PROCESSING { background: rgba(59,130,246,0.15);  color: var(--processing); }
.badge-SUCCESS    { background: rgba(34,197,94,0.15);   color: var(--success); }
.badge-FAILED     { background: rgba(239,68,68,0.15);   color: var(--danger); }

/* ── Select ─────────────────────────────────────────────────────────── */
.select { cursor: pointer; }

/* ── Health ─────────────────────────────────────────────────────────── */
.health-dep {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.health-dep:last-child { border-bottom: none; }
.health-dep-name { font-weight: 500; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.health-dot.ok { background: var(--success); box-shadow: 0 0 6px var(--success); }
.health-dot.error { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.cb-state { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.cb-CLOSED    { background: rgba(34,197,94,0.15);  color: var(--success); }
.cb-OPEN      { background: rgba(239,68,68,0.15);  color: var(--danger); }
.cb-HALF_OPEN { background: rgba(245,158,11,0.15); color: var(--pending); }

/* ── Timeline Modal ─────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; line-height: 1; }
.modal-payment-id { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-bottom: 20px; }

/* ── Timeline ───────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: -18px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg); }
.timeline-time { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-bottom: 3px; }
.timeline-event { font-weight: 600; font-size: 13px; color: var(--text); }
.timeline-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-family: monospace; }
.timeline-item.event-PAYMENT_SUCCESS::before { background: var(--success); }
.timeline-item.event-PAYMENT_FAILED::before { background: var(--danger); }
.timeline-item.event-GATEWAY_TIMEOUT::before { background: var(--warning); }
.timeline-item.event-PAYMENT_RETRY_SCHEDULED::before { background: var(--warning); }
.timeline-item.event-CIRCUIT_BREAKER_OPENED::before { background: var(--danger); }

/* ── Link Button ─────────────────────────────────────────────────────── */
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: underline; padding: 0; }
.btn-link:hover { color: var(--primary-hover); }
