:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --card: #141a22;
  --card-2: #1b222c;
  --line: #2a3340;
  --text: #e7edf6;
  --muted: #8d99ab;
  --green: #3dd68c;
  --red: #ff5d73;
  --gold: #e2b657;
  --cyan: #5ec8ff;
  --orange: #ffb020;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  font-family: Manrope, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.01em; }
.mark {
  width: 22px; height: 22px; border-radius: 7px;
  background:
    linear-gradient(var(--red), var(--red)) center 12px / 14px 2px no-repeat,
    linear-gradient(var(--green), var(--green)) center 6px / 14px 2px no-repeat,
    #10151c;
  border: 1px solid var(--line);
}

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(61, 214, 140, 0.14), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(255, 93, 115, 0.12), transparent 55%),
    var(--bg);
}
.gate-card {
  width: min(460px, 100%);
  background: rgba(20, 26, 34, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 18px 0 8px; font-size: 28px; line-height: 1.15; }
.lead { color: var(--muted); line-height: 1.5; }
.primary, .link-btn {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 22px; width: 100%; min-height: 46px; border: 0; border-radius: 12px;
  background: var(--gold); color: #1a1408; font-weight: 700; text-decoration: none;
}
.primary:disabled { opacity: 0.55; cursor: wait; }
.status { min-height: 1.4em; margin-top: 12px; color: var(--muted); }
.text-link { display: inline-block; margin-top: 8px; color: var(--cyan); }
.denied { margin-top: 18px; padding: 14px; border-radius: 12px; background: rgba(255, 93, 115, 0.08); border: 1px solid rgba(255, 93, 115, 0.35); }
.denied p { margin-top: 6px; color: var(--muted); }
.denied .link-btn { margin-top: 12px; }

.app { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(12, 15, 20, 0.9); position: sticky; top: 0; z-index: 5;
}
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.ghost:hover, .swap:hover { border-color: #445066; }

.workspace { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 16px 0 28px; display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(160px, 1fr) auto minmax(160px, 1fr); gap: 10px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field span, .pair-status { color: var(--muted); font-size: 12px; }
.field input, .field select, .swap {
  height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 12px;
}
.field input:focus, .field select:focus { outline: 2px solid rgba(226, 182, 87, 0.45); border-color: transparent; }
.field select {
  appearance: none;
  padding-right: 42px;
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238d99ab' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px 12px;
}
.swap { width: 44px; padding: 0; background: var(--card-2); font-size: 18px; }
.pair-status { grid-column: 1 / -1; min-height: 1.2em; }
.menu {
  position: absolute; top: 72px; left: 0; right: 0; z-index: 6;
  max-height: 280px; overflow: auto; background: #1c232d; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 10px 12px; }
.menu button:hover, .menu button.active { background: #263140; }

.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.metrics article, .books article, .chart-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.metrics article { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.metrics span, .metrics small, .books dt, .chart-card header p { color: var(--muted); }
.metrics strong, .books dd { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 20px; font-weight: 500; }
.metrics small { font-size: 12px; }
.up { color: var(--green); }
.down { color: var(--red); }

.books { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.books article { padding: 14px 16px; }
.books header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.books header i { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); display: block; }
#dot-b { background: var(--orange); }
.books em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.books dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.books dt { font-size: 12px; }
.books dd { margin: 2px 0 0; font-size: 16px; }

.chart-card { padding: 12px 12px 8px; }
.chart-card header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 4px 6px 8px; }
.chart-card h2 { font-size: 16px; }
.legend { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; min-height: 1.2em; }
.plot { height: 280px; }
.spread-card .plot { height: 320px; }
.range-note { margin: 0 6px 8px; color: var(--gold); font-size: 13px; }
.ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.ranges button { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted); }
.ranges button.on { color: #1a1408; background: var(--gold); border-color: var(--gold); }
.credit { margin: 0; color: var(--muted); font-size: 12px; }
.credit a { color: inherit; text-decoration: none; }

@media (max-width: 900px) {
  .toolbar, .metrics, .books { grid-template-columns: 1fr 1fr; }
  .swap { width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics article:last-child { grid-column: 1 / -1; }
  .plot, .spread-card .plot { height: 240px; }
  .workspace { width: min(100% - 20px, 1180px); }
}
@media (max-width: 640px) {
  .toolbar, .books, .books dl { grid-template-columns: 1fr; }
  .top { padding-inline: 12px; }
}
