:root {
  --bg:      #050a12;
  --bg2:     #0a1220;
  --bg3:     #12203a;
  --bg4:     #1a2d4d;
  --line:    #1e3355;
  --fg:      #f0f4fa;
  --fg2:     #d0daf0;
  --muted:   #5a7aa8;
  --accent:  #00ffdd;
  --accent2: #00d4b8;
  --up:      #00ff94;
  --down:    #ff3a5c;
  --warn:    #ffb830;
  --radius:  12px;
  --glass:   rgba(8, 16, 32, 0.55);
  --glow:    0 0 24px rgba(0, 255, 221, 0.15);
}

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

/* ------------------------------------------------------------------ grain */
.grain {
  position: fixed; inset: 0; z-index: 100; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ------------------------------------------------------------------ base */
body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0,255,221,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(0,120,255,0.07) 0%, transparent 50%);
  color: var(--fg);
  font: 400 14px/1.55 'Outfit', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

code, .mono {
  font-family: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 0.92em;
}

::selection { background: rgba(0,255,221,0.3); color: var(--fg); }

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  height: 56px;
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid rgba(30, 51, 85, 0.7);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
  color: var(--fg);
  flex-shrink: 0;
}
.brand-icon {
  display: flex;
  align-items: center;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(0,255,221,0.45));
}

.tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  /* still scrollable when it overflows, but no stray scrollbar across the topbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}
.tab svg { opacity: 0.5; transition: opacity 0.2s; flex-shrink: 0; }
.tab:hover { background: var(--bg3); color: var(--fg2); }
.tab:hover svg { opacity: 0.8; }
.tab.active {
  color: var(--accent);
  font-weight: 600;
}
.tab.active svg { opacity: 1; stroke: var(--accent); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 12px var(--accent), 0 0 4px var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.discord-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  transition: all 0.2s ease;
  text-decoration: none;
  border: 1px solid transparent;
}
.discord-link:hover {
  color: #5865F2;
  background: rgba(88,101,242,0.1);
  border-color: rgba(88,101,242,0.3);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 8px;
}
/* keep icons from collapsing to 0-width inside flex buttons (the "missing" refresh glyph) */
.btn svg { flex-shrink: 0; }

/* signed-in member badge in the topbar */
.user-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0,255,148,0.10);
  border: 1px solid rgba(0,255,148,0.22);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ layout */
main {
  padding: 24px;
  max-width: 1520px;
  margin: 0 auto;
}
.panel { display: none; animation: fadeUp 0.3s ease; }
.panel.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes rowSlide {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* live-tick price flash — a quick tinted pulse when a swap moves the price */
@keyframes flashUp {
  0%   { background: rgba(0,255,148,0.35); color: var(--up); }
  100% { background: transparent; }
}
@keyframes flashDown {
  0%   { background: rgba(255,58,92,0.35); color: var(--down); }
  100% { background: transparent; }
}
td.flash-up   { animation: flashUp 0.9s ease-out; border-radius: 4px; }
td.flash-down { animation: flashDown 0.9s ease-out; border-radius: 4px; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: rgba(30, 51, 85, 0.9); }
.card h2 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--fg2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card h3 {
  margin: 22px 0 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.card h4 {
  margin: 16px 0 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.settings-divider {
  border: none;
  border-top: 1px solid var(--bg4, rgba(255,255,255,0.08));
  margin: 24px 0 4px;
}
.two-col {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 20px;
}
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ inputs */
input, select, button, textarea {
  font-family: inherit;
  font-size: 14px;
}

input[type=text], input[type=number], input[type=password], select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 9px 12px;
  border-radius: 8px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(0,255,221,0.12), var(--glow);
}
input::placeholder { color: var(--muted); opacity: 0.6; }

.btn {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover {
  border-color: var(--accent2);
  background: var(--bg4);
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #041a16;
  border-color: transparent;
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
.btn.primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 20px rgba(0,255,221,0.35), 0 0 6px rgba(0,255,221,0.2);
}
.btn.ghost { background: none; }
.btn.danger:hover { border-color: var(--down); color: var(--down); }
.btn.tiny { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.addbar { display: flex; gap: 8px; margin-bottom: 16px; }
.addbar select { width: 180px; flex: none; }
.addbar input { flex: 1; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--fg2);
  font-size: 13px;
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}
.form label.check input { width: auto; accent-color: var(--accent); }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 120px; }
.hint { color: var(--muted); font-weight: 400; font-size: 11px; text-transform: none; letter-spacing: 0; }
.filter { margin-top: 12px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent2); color: var(--fg2); }
.chip.on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,255,221,0.10);
  box-shadow: 0 0 10px rgba(0,255,221,0.18);
}
.chip.off { opacity: 0.35; cursor: not-allowed; }

.msg {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 4px;
  font-weight: 500;
  animation: fadeIn 0.2s ease;
}
.msg.ok { background: rgba(0,255,148,0.08); color: var(--up); border: 1px solid rgba(0,255,148,0.2); }
.msg.err { background: rgba(255,58,92,0.08); color: var(--down); border: 1px solid rgba(255,58,92,0.2); }
.msg.warn { background: rgba(255,184,48,0.08); color: var(--warn); border: 1px solid rgba(255,184,48,0.2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------------ tables */
.table-wrap {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 14px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-weight: 600;
}
th.num, td.num { text-align: right; }
th.sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
th.sortable:hover { color: var(--fg2); }
th.sortable::after { content: '⇅'; margin-left: 4px; opacity: 0.25; font-size: 9px; }
th.sort-asc::after { content: '▲'; opacity: 0.7; }
th.sort-desc::after { content: '▼'; opacity: 0.7; }
td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(30,51,85,0.45);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 400;
}
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(0,255,221,0.04); }
tbody tr:last-child td { border-bottom: none; }

.tok { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.tok img {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.tok .sym {
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
}
.tok .nm {
  color: var(--muted);
  font-size: 11px;
  font-family: 'Outfit', sans-serif;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--bg3);
  font-size: 10px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  color: var(--muted);
  margin-left: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-danger { background: rgba(255,58,92,0.14); color: #ff5c78; border: 1px solid rgba(255,58,92,0.3); }
.badge-warn { background: rgba(255,184,48,0.14); color: #ffb830; border: 1px solid rgba(255,184,48,0.3); }
.badge-ok { background: rgba(0,255,148,0.12); color: #00ff94; border: 1px solid rgba(0,255,148,0.25); }
.badge-info { background: rgba(88,101,242,0.14); color: #8c9aff; border: 1px solid rgba(88,101,242,0.3); }

.up { color: var(--up); }
.down { color: var(--down); }
.empty {
  padding: 60px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty-icon {
  margin-bottom: 16px;
  opacity: 0.3;
}
.stale { opacity: 0.35; }
.err-dot { color: var(--down); cursor: help; }

.search-results {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  max-height: 360px;
  overflow-y: auto;
  animation: fadeIn 0.15s ease;
}
.token-search-wrap { position: relative; }
.token-search-wrap .search-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 2px rgba(0,255,221,0.15);
}
.token-search-wrap input[type="text"] { width: 100%; }
.token-selected-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
}
.token-selected-badge .clear {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.token-selected-badge .clear:hover { opacity: 1; color: var(--down); }
.sr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(30,51,85,0.45);
  cursor: pointer;
  transition: background 0.15s;
}
.sr-row:hover { background: rgba(0,255,221,0.05); }
.sr-row .grow { flex: 1; min-width: 0; }
.sr-row img {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--line);
}

/* ------------------------------------------------------------------ lists */
.alert-list, .event-list, .chain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
}

.alert-row, .chain-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: all 0.15s;
}
.alert-row:hover, .chain-row:hover { border-color: rgba(30,51,85,0.9); background: var(--bg3); }
.alert-row .grow, .chain-row .grow { flex: 1; min-width: 0; }
.alert-row.off { opacity: 0.4; }
.alert-desc { font-size: 13px; font-weight: 500; }
.alert-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

.event-row {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  animation: rowSlide 0.3s ease;
}
.event-row.failed { border-color: rgba(255,77,106,0.25); }
.event-time { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* ------------------------------------------------------------------ drawer */
.drawer {
  position: fixed; inset: 0; z-index: 60;
  display: flex; justify-content: flex-end;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.drawer-inner {
  position: relative;
  background: var(--bg2);
  border-left: 1px solid var(--line);
  width: min(700px, 100%);
  height: 100%;
  overflow-y: auto;
  padding: 28px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  z-index: 2;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  font-size: 13px;
  margin: 16px 0;
}
.kv .k { color: var(--muted); font-weight: 500; }
.kv .v {
  word-break: break-all;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
}

.spark {
  width: 100%;
  height: 150px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.verify {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 14px 0;
}
.verify .verify-out { margin-top: 10px; font-size: 13px; color: var(--muted); }
.verify .kv { margin: 0; }
.verify .kv .v.ok { color: var(--up); }
.verify .kv .v.warn { color: var(--warn); }
.note { margin-top: 10px; font-size: 13px; line-height: 1.55; }
.note.warn { color: var(--warn); }

table.holders { margin-top: 14px; }
table.holders th { padding: 6px 10px; font-size: 10px; }
table.holders td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(30,51,85,0.35);
  font-size: 12px;
}
table.holders td.mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--muted);
  font-size: 11px;
}

.status-panel { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.status-panel .line {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--line);
  transition: border-color 0.15s;
}
.status-panel .line:hover { border-color: var(--bg4); }
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}
.dot.on {
  background: var(--up);
  box-shadow: 0 0 6px var(--up);
  animation: pulse 2s infinite;
}
.dot.off { background: var(--muted); }

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

/* --------------------------------------------------------- responsive */
@media (max-width: 768px) {
  .topbar { padding: 0 12px; gap: 4px; }
  .brand { font-size: 15px; margin-right: 4px; }
  .tab { padding: 6px 8px; font-size: 12px; }
  .tab svg { display: none; }
  main { padding: 12px; }
  .addbar { flex-wrap: wrap; }
  .addbar select { width: 100%; }
  .discord-link { display: none; }
}
