/* Terminal-style dark UI: near-black canvas, warm-white ink, a teal brand accent, green/red for
   bid/ask, one monospace family with tabular figures so every digit sits in a fixed column. */

:root {
  --bg-base: #08090c;
  --bg-1: #0e0f14;
  --bg-2: #14151c;
  --bg-3: #1c1e28;
  --bg-pin: #050608;

  --rule: #1f2230;
  --rule-bright: #2e3244;

  --brand: #14b8a6;
  --brand-glow: rgba(20, 184, 166, 0.3);
  --cyan: #5fc3e7;

  --ink: #e8e8ec;
  --ink-2: #b4b4be;
  /* ink-3/ink-4 are brightened from the original #767684/#44454f: at the 9.5-13px sizes they're used
     at, the originals measured 4.1-4.5:1 and 1.9-2.1:1 against the panel backgrounds -- both below
     WCAG AA's 4.5:1 floor for normal text. These clear >=4.6:1 against every background they sit on. */
  --ink-3: #888898;
  --ink-4: #7d7f91;

  --bid: #34d399;
  --bid-bar: rgba(52, 211, 153, 0.14);
  --ask: #f87171;
  --ask-bar: rgba(248, 113, 113, 0.14);

  /* System monospace stack: the page stays fully self-hosted — no third-party font CDN. */
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Cascadia Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums slashed-zero;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  color: var(--brand);
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  /* The static placeholder always fit; the real quote line (name/exchange/last/asOf) doesn't at
     narrow widths, so this shrinks and truncates rather than wrapping and blowing out the topbar's
     fixed height. */
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ===== Chrome: top bar + status bar ===================================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 46px;
  padding: 0 18px;
  background: var(--bg-pin);
  border-bottom: 1px solid var(--rule-bright);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 14px;
  min-width: 0;
  flex-shrink: 1;
  white-space: nowrap;
}

.brand .mark {
  color: var(--brand);
  text-shadow: var(--brand-glow) 0 0 10px;
}

.symbol-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.symbol-picker input {
  width: 92px;
  padding: 5px 8px;
  background: var(--bg-pin);
  border: 1px solid var(--rule-bright);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

.symbol-picker input:focus {
  outline: 0;
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan);
}

.symbol-picker button {
  padding: 5px 10px;
  background: var(--bg-pin);
  border: 1px solid var(--rule-bright);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.symbol-picker button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.topbar .status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-2);
}

.statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  min-height: 30px;
  padding: 6px 18px;
  background: var(--bg-pin);
  border-top: 1px solid var(--rule-bright);
  font-size: 10.5px;
  color: var(--ink-3);
}

.statusbar .grow {
  margin-left: auto;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Market-stats strip ============================================== */
.stats {
  display: flex;
  gap: 1px;
  background: var(--rule);
  border-bottom: 1px solid var(--rule-bright);
}

.stat {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg-1);
}

.stat .k {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat .v {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v.pos {
  color: var(--bid);
}

.v.neg {
  color: var(--ask);
}

.up::after {
  content: " \25B2";
  font-size: 9px;
  color: var(--bid);
}

.down::after {
  content: " \25BC";
  font-size: 9px;
  color: var(--ask);
}

/* ===== Layout ========================================================== */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-1);
  border: 1px solid var(--rule);
}

.phead {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 9px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.phead .sub {
  margin-left: auto;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== Order-book ladder =============================================== */
.ladder-head,
.row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
}

.ladder-head {
  padding: 6px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.ladder-head span:not(:first-child),
.row span:not(.px):not(.bar) {
  text-align: right;
}

.ladder {
  display: flex;
  flex-direction: column;
}

.row {
  position: relative;
  padding: 3px 14px;
  font-size: 13px;
  overflow: hidden;
}

/* Depth bar grows from the spread edge; width is set inline via --w. */
.row .bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  width: var(--w, 0);
  z-index: 0;
  transition: width 0.25s ease;
}

.row .px,
.row .sz,
.row .tot {
  position: relative;
  z-index: 1;
}

.row .sz {
  color: var(--ink-2);
}

.row .tot {
  color: var(--ink-4);
}

.asks .px {
  color: var(--ask);
}

.asks .bar {
  background: var(--ask-bar);
}

.bids .px {
  color: var(--bid);
}

.bids .bar {
  background: var(--bid-bar);
}

/* Brief highlight when a level's size changes. */
.row.flash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--ink);
  opacity: 0.12;
  animation: fade 0.6s ease forwards;
}

@keyframes fade {
  to {
    opacity: 0;
  }
}

.empty {
  padding: 14px;
  text-align: center;
  color: var(--ink-4);
}

.spread-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--bg-pin);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink-2);
}

.spread-row .mid {
  font-weight: 600;
  color: var(--ink);
}

.spread-row .lbl {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* ===== Order ticket ==================================================== */
.ticket {
  padding: 14px;
}

.ticket .phead {
  margin: -14px -14px 14px;
  padding: 9px 14px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.seg-btn {
  padding: 9px;
  background: var(--bg-2);
  border: 1px solid var(--rule-bright);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.seg-btn.buy.active {
  background: rgba(52, 211, 153, 0.14);
  border-color: var(--bid);
  color: var(--bid);
}

.seg-btn.sell.active {
  background: rgba(248, 113, 113, 0.14);
  border-color: var(--ask);
  color: var(--ask);
}

.ticket label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 11px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ticket input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-pin);
  border: 1px solid var(--rule-bright);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
}

.ticket input:focus {
  outline: 0;
  border-color: var(--cyan);
  box-shadow:
    0 0 0 1px var(--cyan),
    0 0 9px var(--brand-glow);
}

.submit {
  margin-top: 3px;
  padding: 11px;
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  color: #04110c;
}

.submit.buy {
  background: var(--bid);
  border-color: var(--bid);
}

.submit.sell {
  background: var(--ask);
  border-color: var(--ask);
  color: #1a0606;
}

.submit:hover {
  filter: brightness(1.08);
}

.result {
  margin-top: 10px;
  min-height: 14px;
  font-size: 11px;
  color: var(--ink-3);
}

.result.ok {
  color: var(--bid);
}

.result.err {
  color: var(--ask);
}

/* ===== Trade tape ===================================================== */
.tape {
  flex: 1;
}

.tape-head,
.trow {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr 0.7fr;
  align-items: center;
}

.tape-head {
  padding: 6px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.tape-head span:not(:first-child),
.trow span:not(.tt) {
  text-align: right;
}

.tape-body {
  max-height: 340px;
  overflow-y: auto;
}

.trow {
  padding: 4px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
}

.trow .tt {
  font-size: 11px;
  color: var(--ink-4);
}

.trow .tz {
  color: var(--ink-2);
}

.trow.buy .ts,
.trow.buy .tp {
  color: var(--bid);
}

.trow.sell .ts,
.trow.sell .tp {
  color: var(--ask);
}

.trow.new {
  animation: slidein 0.4s ease;
}

@keyframes slidein {
  from {
    background: rgba(95, 195, 231, 0.12);
  }
  to {
    background: transparent;
  }
}

.tape-empty {
  padding: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-4);
}

/* ===== Connection dot ================================================= */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--ink-4);
}

.dot.live {
  background: var(--bid);
  box-shadow: 0 0 8px var(--bid);
  animation: pulse 1.8s ease-in-out infinite;
}

.dot.off {
  background: var(--ask);
}

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

/* ===== Responsive ===================================================== */
@media (max-width: 760px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .stats {
    flex-wrap: wrap;
  }

  .stat {
    flex: 1 1 30%;
  }

  .stat .v {
    font-size: 14px;
  }

  .statusbar .tagline {
    display: none;
  }
}

/* ===== Prose page (privacy notice) ===================================== */
.prose-wrap {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
}

.prose {
  padding: 14px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.prose p {
  margin: 0 0 10px;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* Embedded as a trading-desk tab (?embed=1): the desk supplies the outer chrome, so hide the
   brand and status bars. The symbol picker stays — it's how the tab switches symbol. */
.embedded .topbar .brand,
.embedded .topbar .status,
.embedded .statusbar {
  display: none;
}
