:root {
  --bg: #0b0d14;
  --bg-elev: #11141d;
  --surface: #161a26;
  --surface-2: #1d2231;
  --border: #272d40;
  --border-soft: #1e2433;
  --text: #e6eaf2;
  --muted: #8b94a8;
  --faint: #5b6376;
  --accent: #6d6cf0;
  --accent-soft: #2a2a55;
  --green: #2dd4a7;
  --red: #f5566f;
  --yellow: #f5b545;
  --blue: #4d9bf5;
  --radius: 10px;
  --radius-sm: 7px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono, .value, td .id, code { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- Token gate ---------- */
.gate {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}
.gate-title { color: var(--accent); font-size: 22px; font-weight: 700; }
.gate-sub { color: var(--muted); margin: 6px 0 22px; }
.gate-card input { width: 100%; margin-bottom: 14px; }
.gate-card button { width: 100%; }
.gate-error { color: var(--red); font-size: 12px; margin-top: 12px; min-height: 16px; }

/* ---------- Header & nav ---------- */
header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
header h1::before { content: '♠ '; color: var(--accent); }
.status { font-size: 11px; color: var(--faint); font-family: var(--mono); }
.spacer { flex: 1; }

nav {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  background: var(--bg-elev);
  position: sticky;
  top: 49px;
  z-index: 9;
  overflow-x: auto;
}
nav button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 12px 16px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
nav button:hover { color: var(--text); }
nav button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Layout ---------- */
.main { padding: 24px; max-width: 1240px; margin: 0 auto; }
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}
.section-title.spaced { margin-top: 28px; }
.hint { color: var(--faint); font-size: 11.5px; margin-top: 14px; line-height: 1.5; }
.result { margin-top: 10px; }

/* ---------- Buttons & inputs ---------- */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}
button:hover { filter: brightness(1.12); }
button.secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
button.secondary:hover { border-color: var(--accent); filter: none; }
button.ghost { background: none; color: var(--muted); padding: 6px 12px; font-size: 11px; }
button.ghost:hover { color: var(--text); filter: none; }
button.danger { background: #3a1620; color: #fca5b5; }
button.danger:hover { background: #4d1a28; filter: none; }

input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 12.5px;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input.search { width: 260px; }
input.file { width: auto; flex: 1; }
input.amount { width: 120px; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-group { display: flex; gap: 8px; align-items: center; }
.page-info { font-size: 12px; color: var(--muted); margin: 0 6px; font-family: var(--mono); }

/* ---------- Cards / metric grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--border); }
.card .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 8px; }
.card .value { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.card .sub { font-size: 11px; color: var(--faint); margin-top: 5px; }
.ok { color: var(--green); } .warn { color: var(--yellow); } .err { color: var(--red); } .info { color: var(--blue); }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
th {
  padding: 11px 15px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
td { padding: 11px 15px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: var(--surface-2); }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; }
.badge.ok { background: #0f3b30; color: var(--green); }
.badge.err { background: #3a1620; color: #fca5b5; }
.badge.warn { background: #3d2a0a; color: var(--yellow); }
.badge.info { background: #16304f; color: #93c5fd; }

/* ---------- Spinner & progress ---------- */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; min-width: 80px; }
.progress-fill { background: var(--accent); height: 100%; transition: width 0.3s; }

/* ---------- Config / detail ---------- */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.config-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.config-item .k { font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.config-item .v { font-size: 13px; font-weight: 600; font-family: var(--mono); }

.detail { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 20px; }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.detail-head .section-title { margin: 0; }
.detail-name { font-size: 19px; font-weight: 700; }
.detail-meta { color: var(--muted); font-size: 11px; }
.detail-flag { color: var(--green); font-size: 11px; margin-top: 4px; }
.detail-actions { margin-top: 18px; display: flex; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--border-soft); padding-top: 16px; }
.detail-actions .group .label { font-size: 10px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.08em; }
.detail-actions .group .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.push-right { margin-left: auto; }

/* ---------- Logs ---------- */
.log-entry { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 8px; font-size: 11.5px; }
.log-entry .time { color: var(--faint); margin-bottom: 4px; font-family: var(--mono); }
.log-entry .endpoint { color: var(--accent); font-family: var(--mono); }
.log-entry .error { color: #fca5b5; white-space: pre-wrap; word-break: break-word; max-height: 80px; overflow: hidden; margin-top: 4px; }
details summary { cursor: pointer; padding: 5px 0; color: var(--muted); font-size: 11px; }
details pre { background: var(--bg); padding: 10px; font-size: 10.5px; white-space: pre-wrap; word-break: break-word; max-height: 140px; overflow: auto; margin-top: 6px; border-radius: 6px; font-family: var(--mono); }

/* ---------- Charts ---------- */
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
  height: 300px;
}
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-col { min-width: 0; }
.muted-note { color: var(--muted); }

@media (max-width: 760px) {
  .chart-row { grid-template-columns: 1fr; }
  input.search { width: 100%; }
}
