:root {
  --bg: #05070a;
  --bg-panel: #0d1117;
  --bg-card: #10161f;
  --border: #1e2732;
  --border-hi: #2c3a4a;
  --text: #e6edf3;
  --text-dim: #7d8a9a;
  --text-faint: #4c5867;
  --accent: #6ee7c8;
  --accent-dim: #2a6e5c;
  --up: #4ade80;
  --down: #f87171;
  --warn: #fbbf24;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(110, 231, 200, 0.06), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(110, 150, 231, 0.05), transparent 40%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

header.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.beer-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 0 auto;
}
.beer-glass {
  width: 52px;
  height: 68px;
  transform-origin: bottom center;
  animation: beerSway 6s ease-in-out infinite;
}
@keyframes beerSway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

header.top h1 {
  font-size: 20px;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}
header.top .sub {
  color: var(--text-dim);
  font-size: 12.5px;
  max-width: 560px;
  line-height: 1.5;
}

.credit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.credit-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-hi);
  flex-shrink: 0;
}
.credit a {
  color: var(--accent);
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-dim);
  white-space: nowrap;
}
.status-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2s infinite;
}
.status-pill.err .dot { background: var(--down); box-shadow: 0 0 6px var(--down); animation: none; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.ipo-pill {
  color: var(--accent);
  border-color: rgba(110, 231, 200, 0.35);
  cursor: help;
}

.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }


.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
  align-items: stretch;
}
@media (max-width: 760px) {
  .top-grid { grid-template-columns: 1fr; }
}

section.leaderboard {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.leaderboard .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.leaderboard h2 {
  font-size: 13px; margin: 0; color: var(--text-dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center; gap: 6px;
}
.leaderboard h2 .medal { font-size: 15px; text-transform: none; letter-spacing: 0; }
.leaderboard .spread-value { font-size: 30px; font-weight: 700; }
.leaderboard .spread-value.pos { color: var(--up); }
.leaderboard .spread-value.neg { color: var(--down); }
.leaderboard .spread-detail { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.leaderboard .spread-detail a.ex-link { color: #7db4fb; font-weight: 700; }
.leaderboard .spread-detail a.ex-link:hover { text-decoration: underline; }

.spread-alert {
  margin: 48px auto 0;
  width: fit-content;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 22px;
  border-radius: 10px;
  border: 2px solid currentColor;
  background: rgba(248, 113, 113, 0.07);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
  animation: alertPulse 2.6s ease-in-out infinite;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.spread-alert:hover {
  text-decoration: none;
  background: rgba(248, 113, 113, 0.18);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px rgba(248, 113, 113, 0.25);
}
.spread-alert .alert-icon { font-size: 19px; line-height: 1; flex-shrink: 0; }
.spread-alert .tg-icon { width: 20px; height: 20px; flex-shrink: 0; }
@keyframes alertPulse {
  0%, 100% { color: #b45252; text-shadow: none; }
  50% { color: #f87171; text-shadow: 0 0 6px rgba(248, 113, 113, 0.35); }
}

section.constructor {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}
.constructor h2 {
  font-size: 13px; margin: 0 0 12px; color: var(--text-dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.constructor-picker {
  position: relative;
  padding-right: 42px;
}
.constructor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.constructor-swap {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #060a0f;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.constructor-swap:hover { border-color: var(--accent); color: var(--accent); }
.side-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
}
.side-icon.short { background: rgba(248, 113, 113, 0.18); border: 1px solid rgba(248, 113, 113, 0.6); color: var(--down); }
.side-icon.long { background: rgba(74, 222, 128, 0.18); border: 1px solid rgba(74, 222, 128, 0.6); color: var(--up); }

.constructor-select {
  flex: 1;
  background: #060a0f;
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.constructor-select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.constructor-result {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.constructor-result .spread-value { font-size: 26px; font-weight: 700; }
.constructor-result .spread-value.pos { color: var(--up); }
.constructor-result .spread-value.neg { color: var(--down); }

.constructor-result-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 72px;
  flex-wrap: wrap;
}
.constructor-amount {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}
.constructor-amount label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.constructor-amount input {
  background: #060a0f;
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.constructor-amount input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.constructor-calc-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(110, 231, 200, 0.14);
  border: 1px solid var(--accent);
  color: var(--accent);
  cursor: pointer;
}
.constructor-calc-btn:hover { background: rgba(110, 231, 200, 0.26); }

.constructor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.constructor-foot .spread-detail { color: var(--text-dim); font-size: 12px; }

.side-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}
.side-badge.short {
  background: rgba(248, 113, 113, 0.16);
  border: 1px solid rgba(248, 113, 113, 0.55);
  color: var(--down);
}
.side-badge.long {
  background: rgba(74, 222, 128, 0.16);
  border: 1px solid rgba(74, 222, 128, 0.55);
  color: var(--up);
}

.chart-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 12.1px;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 5.5px 11px;
  margin-left: 6px;
  border-radius: 6px;
  background: rgba(251, 146, 60, 0.16);
  border: 1px solid rgba(251, 146, 60, 0.65);
  color: #fb923c;
  cursor: pointer;
  text-transform: none;
  vertical-align: middle;
}
.chart-btn:hover { background: rgba(251, 146, 60, 0.28); }

/* ---- spread history modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 7, 0.72);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-panel {
  width: 82vw;
  min-width: 320px;
  max-width: 1500px;
  max-height: 90vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (max-width: 900px) {
  .modal-panel { width: 96vw; }
}

.modal-panel.calc-panel {
  width: 504px;
  max-width: 92vw;
  max-height: none;
}

.calc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  line-height: 1.5;
}
.calc-row b { color: var(--text); }
.calc-logo { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; }
.calc-profit {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.6;
}
.calc-profit b { font-size: 17px; }
.calc-profit b.pos { color: var(--up); }
.calc-profit b.neg { color: var(--down); }
.calc-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.modal-title { font-size: 14px; font-weight: 700; }
.modal-close {
  font-family: var(--mono);
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--down); border-color: var(--down); }

.chart-timeframes {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.chart-timeframes button {
  font-family: var(--mono);
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
}
.chart-timeframes button:hover { border-color: var(--accent); color: var(--accent); }
.chart-timeframes button.active { background: rgba(110, 231, 200, 0.14); border-color: var(--accent); color: var(--accent); }

.modal-body {
  padding: 14px 18px 18px;
  overflow: auto;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.chart-loading {
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 40px 0;
  text-align: center;
}

#chartContainer {
  flex: 1;
  min-height: 600px;
  position: relative;
}
#chartPane {
  width: 100%;
  height: 100%;
  min-height: 600px;
}

.spread-end-badge {
  position: absolute;
  display: none;
  transform: translateY(-50%);
  background: #8a97a8;
  color: #05070a;
  font-weight: 800;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}

.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.chart-tooltip .t { color: var(--text-faint); font-size: 10.5px; margin-bottom: 2px; }
.chart-tooltip .v { color: var(--up); font-weight: 700; }
.chart-tooltip .v.approx { color: var(--text-dim); font-weight: 600; }

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: relative;
  transition: border-color .2s;
}
.card.stale { border-color: var(--warn); }
.card.error { border-color: var(--down); }

.card .cardhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card .ex-name-row { display: flex; align-items: center; gap: 7px; }
.card .ex-logo { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; }
.card .ex-logo-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.card .spot-tag {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  color: #05070a;
  font-size: 7.5px;
  font-weight: 800;
  line-height: 11px;
  text-align: center;
  border: 1px solid var(--bg-card);
}
.card .ex-name { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.card .ex-symbol { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.card .pair-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(96, 165, 250, 0.14);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #7db4fb;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.card .pair-link:hover { background: rgba(96, 165, 250, 0.26); text-decoration: none; }

.card .spot-pill {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(110, 231, 200, 0.14);
  border: 1px solid rgba(110, 231, 200, 0.5);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.card .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.card .badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 6px var(--up);
  animation: pulse 1.8s ease-in-out infinite;
}
.card.stale .badge, .card.error .badge { color: var(--down); border-color: var(--down); }
.card.stale .badge .dot, .card.error .badge .dot {
  background: var(--down);
  box-shadow: 0 0 6px var(--down);
}

.card .price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 2px;
}
.card .price { font-size: 22px; font-weight: 700; }
.card .chg { font-size: 12px; font-weight: 600; }
.card .chg.up { color: var(--up); }
.card .chg.down { color: var(--down); }

.card .range { font-size: 11px; color: var(--text-faint); margin-bottom: 12px; }

.card .valuation {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 4px;
}
.card .valuation .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.card .valuation .val { font-size: 19px; font-weight: 700; color: var(--accent); }

.card .mult-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.card .mult-row input {
  flex: 1;
  min-width: 0;
  background: #060a0f;
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 7px;
  font-family: var(--mono);
  font-size: 11.5px;
}
.card .mult-row input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.card .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--text-faint);
}
.card .foot a.ref-link { color: var(--accent); font-weight: 600; }

.card .error-msg {
  font-size: 10.5px;
  color: var(--down);
  margin-top: 6px;
  word-break: break-word;
}

section.topspreads {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
section.topspreads h2 {
  font-size: 13px; margin: 0 0 12px; color: var(--text-dim);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}

.top-list { display: flex; flex-direction: column; gap: 8px; }

.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  transition: border-color .15s;
}
.top-row:hover { border-color: var(--border-hi); }

.top-row .rank {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  border-radius: 50%;
  color: var(--text-dim);
}
.top-row .rank.medal { font-size: 19px; }
.top-row .rank.plain {
  border: 1px solid var(--border-hi);
  font-size: 12px;
  color: var(--text-dim);
}

.top-row .pair {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-row .pair a.ex-link { color: #7db4fb; font-weight: 700; }
.top-row .pair a.ex-link:hover { text-decoration: underline; }
.top-row .pair .vs { color: var(--text-faint); font-weight: 400; margin: 0 5px; }

.top-row .valuations { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; margin-right: 6px; }

.top-row .spread-pct {
  font-size: 15px;
  font-weight: 700;
  color: var(--up);
  min-width: 66px;
  text-align: right;
  flex-shrink: 0;
}

/* narrow screens: the flex row (rank + pair + chart-btn + valuations + %)
   doesn't have room for all five — pair/valuations were getting silently
   clipped instead of wrapping. Switch to a 2-line grid: rank/pair/% on top,
   the chart button on its own row below; valuations are dropped since the
   same numbers are already on each exchange card. */
@media (max-width: 480px) {
  .top-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "rank pair pct" "btn btn btn";
    row-gap: 8px;
  }
  .top-row .rank { grid-area: rank; }
  .top-row .pair {
    grid-area: pair;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .top-row .spread-pct { grid-area: pct; }
  .top-row .chart-btn { grid-area: btn; justify-self: start; margin-left: 0; }
  .top-row .valuations { display: none; }
}

/* ---- home screen (asset picker) ---- */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.asset-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, background .15s;
}
.asset-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  background: var(--bg-card);
}
.asset-card.soon {
  cursor: default;
  opacity: 0.5;
}
.asset-card.soon:hover {
  border-color: var(--border);
  transform: none;
  background: var(--bg-panel);
}

.asset-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: var(--bg-card);
  padding: 10px;
  object-fit: contain;
}
.asset-name { font-size: 15px; font-weight: 700; }
.asset-cta { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.asset-soon {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  border: 1px solid var(--border-hi);
  border-radius: 100px;
  padding: 3px 10px;
}

/* ---- asset section header ---- */
.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.section-head h1 { margin: 0; }

.back-btn {
  font-family: var(--mono);
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Ссылка на календарь событий: заметная, но не спорит с «SPREAD ALERT BOT» */
.cal-link {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border: 1px solid var(--line, #263042);
  border-radius: 8px;
  font-size: 13px;
  color: #ffd685;
  text-decoration: none;
}
.cal-link:hover { border-color: #ffd685; }
.cal-pill { text-decoration: none; color: #ffd685; }
.cal-pill:hover { border-color: #ffd685; }
