/*
 * Helius TP Engine — trader desk theme.
 * Palette: deep charcoal surfaces, mint-green longs, crimson shorts,
 * amber for "armed / waiting", steel blue for neutral data.
 */

:root {
  --bg: #080b10;
  --surface: #0f151d;
  --surface-2: #141c26;
  --surface-3: #1a2431;
  --border: #223041;
  --border-soft: #18222e;

  --text: #e9f0f7;
  --text-dim: #94a3b8;
  --text-faint: #64748b;

  --long: #16c784;
  --long-dim: rgba(22, 199, 132, 0.14);
  --short: #f6465d;
  --short-dim: rgba(246, 70, 93, 0.14);
  --armed: #f0b90b;
  --armed-dim: rgba(240, 185, 11, 0.14);
  --info: #4c8dff;
  --info-dim: rgba(76, 141, 255, 0.14);
  --violet: #a78bfa;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(76, 141, 255, 0.09), transparent 60%),
    radial-gradient(900px 460px at 92% -20%, rgba(22, 199, 132, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: rgba(8, 11, 16, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--long), #0ea5e9 55%, var(--violet));
  box-shadow: 0 0 22px rgba(22, 199, 132, 0.35);
}

.brand h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.pill b {
  color: var(--text);
  font-weight: 700;
}

.pill .led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.pill.ok .led {
  background: var(--long);
  box-shadow: 0 0 8px var(--long);
}
.pill.warn .led {
  background: var(--armed);
  box-shadow: 0 0 8px var(--armed);
}
.pill.bad .led {
  background: var(--short);
  box-shadow: 0 0 8px var(--short);
}
.pill.live {
  border-color: rgba(246, 70, 93, 0.45);
  background: var(--short-dim);
  color: #ffd8de;
}
.pill.paper {
  border-color: rgba(76, 141, 255, 0.4);
  background: var(--info-dim);
  color: #d6e6ff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--long);
  box-shadow: 0 0 10px var(--long);
}

.dot.busy {
  animation: pulse 0.9s ease-in-out infinite;
}

.dot.stale {
  background: var(--short);
  box-shadow: 0 0 10px var(--short);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

.btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--surface-3);
  border-color: #2e405a;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

/* --------------------------------------------------------------- banners */

.banner {
  margin: 12px 24px 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(240, 185, 11, 0.35);
  background: var(--armed-dim);
  color: #ffeab0;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  gap: 10px;
}

.banner.bad {
  border-color: rgba(246, 70, 93, 0.4);
  background: var(--short-dim);
  color: #ffd8de;
}

.banner::before {
  content: "▲";
  font-size: 10px;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ kpis */

main {
  padding: 20px 24px 60px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kpi {
  background: linear-gradient(180deg, var(--surface) 0%, rgba(15, 21, 29, 0.6) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent, var(--info));
  opacity: 0.85;
}

.kpi-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}

.kpi-value {
  margin-top: 7px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-sub {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-faint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s ease;
}

.tab:hover {
  color: var(--text-dim);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--long);
}

.tab-count {
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
}

.tab.active .tab-count {
  background: var(--long-dim);
  color: var(--long);
}

.tab-filter {
  margin-left: auto;
  padding-bottom: 6px;
}

.tab-filter input {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  width: 260px;
  outline: none;
}

.tab-filter input:focus {
  border-color: #2e405a;
}

/* ---------------------------------------------------------------- panels */

.panel {
  animation: fade 0.18s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

.hidden {
  display: none !important;
}

.panel-head {
  margin-bottom: 12px;
}

.panel-head h2 {
  font-size: 16px;
}

.panel-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
  max-width: 760px;
}

.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
  max-height: calc(100vh - 340px);
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: right;
  padding: 10px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

thead th:first-child,
tbody td:first-child {
  text-align: left;
}

tbody td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  font-weight: 500;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.clickable {
  cursor: pointer;
}

tbody tr:hover td {
  background: rgba(76, 141, 255, 0.05);
}

td.empty,
.empty-state {
  text-align: center;
  color: var(--text-faint);
  padding: 34px 14px;
  font-weight: 500;
}

/* ------------------------------------------------------------- cell bits */

.token {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: #04140d;
  background: linear-gradient(140deg, var(--long), #38bdf8);
  flex: none;
}

.token-name {
  font-weight: 700;
  color: var(--text);
}

.token-mint {
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 500;
}

.token-mint a {
  color: inherit;
  text-decoration: none;
}

.token-mint a:hover {
  color: var(--info);
  text-decoration: underline;
}

.up {
  color: var(--long);
}
.down {
  color: var(--short);
}
.flat {
  color: var(--text-dim);
}
.muted {
  color: var(--text-faint);
}
.armed-text {
  color: var(--armed);
  font-weight: 600;
}

/* Display-only USD label under a SOL amount — deliberately quieter than the
   SOL figure above it, which is the number the engine actually traded. */
.usd {
  margin-top: 1px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-faint);
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.tag-green {
  background: var(--long-dim);
  color: var(--long);
  border-color: rgba(22, 199, 132, 0.3);
}
.tag-red {
  background: var(--short-dim);
  color: var(--short);
  border-color: rgba(246, 70, 93, 0.3);
}
.tag-amber {
  background: var(--armed-dim);
  color: var(--armed);
  border-color: rgba(240, 185, 11, 0.3);
}
.tag-blue {
  background: var(--info-dim);
  color: var(--info);
  border-color: rgba(76, 141, 255, 0.3);
}
.tag-grey {
  background: var(--surface-3);
  color: var(--text-dim);
  border-color: var(--border);
}

/* Distance-to-trigger meter: how close a row is to firing. */
.meter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.meter-bar {
  width: 58px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
  flex: none;
}

.meter-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--armed);
}

.meter-fill.near {
  background: var(--long);
}

/* ------------------------------------------------------------------ desk */

.desk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
}

.card h3 {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 12.5px;
}

.kv:last-child {
  border-bottom: none;
}

.kv span:first-child {
  color: var(--text-dim);
  font-weight: 500;
}

.kv span:last-child {
  font-weight: 700;
}

.funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 92px 1fr 54px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.funnel-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--info), var(--long));
}

/* ---------------------------------------------------------------- drawer */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 40;
  display: flex;
  flex-direction: column;
  animation: slide 0.18s ease;
}

@keyframes slide {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.drawer-head h3 {
  font-size: 14px;
}

.drawer-body {
  padding: 16px 18px 30px;
  overflow: auto;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, 0.55);
  z-index: 30;
}

.drawer-body table {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 6px;
}

.sig {
  font-size: 11px;
  color: var(--info);
  text-decoration: none;
}

.sig:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ foot */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px 22px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  font-weight: 500;
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
  }
  .tab-filter {
    margin-left: 0;
    width: 100%;
  }
  .tab-filter input {
    width: 100%;
  }
  .table-wrap {
    max-height: none;
  }
}

/* ------------------------------------------------- sorting + pagination */

thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s ease;
}

thead th.sortable:hover {
  color: var(--text-dim);
}

thead th.sortable.active {
  color: var(--text);
}

.sort-ind {
  margin-left: 5px;
  font-size: 9px;
  opacity: 0.25;
}

.sort-ind.on {
  opacity: 1;
  color: var(--long);
}

.pager {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 4px 0;
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 500;
}

.pager-info b {
  color: var(--text);
}

.pager-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.page-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 28px;
  height: 26px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.pager-page {
  padding: 0 8px;
  white-space: nowrap;
}

.pager-size {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pager-size select,
#status-filter {
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
}

#status-filter {
  margin-left: 8px;
  padding: 7px 8px;
  font-size: 12px;
}
