/* DepthLens v0.1.0 — dark trading-terminal theme.
   Why dark: traders stare at this for hours; dark reduces eye strain and
   red/green price semantics read instantly on near-black. */

:root {
  --bg: #0a0e14;
  --panel: #0f1520;
  --panel-2: #131b29;
  --line: rgba(255,255,255,.07);
  --text: #e6edf3;
  --muted: #8b98a9;
  --faint: #55606e;
  --bid: #26a69a;          /* teal-green for bids — softer than pure green on dark */
  --bid-dim: rgba(38,166,154,.14);
  --ask: #ef5350;          /* soft red for asks */
  --ask-dim: rgba(239,83,80,.14);
  --accent: #2997ff;
  --warn: #ff9500;
  --mono: "SF Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 14px; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
  overflow-x: clip; /* Darnel's rule: no horizontal scroll on mobile */
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand-tag {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
  color: var(--faint); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px;
}
.symbol-picker { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.symbol-picker label { font-size: .75rem; color: var(--muted); }
.symbol-picker select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-family: var(--mono); font-size: .85rem; cursor: pointer;
}
.conn { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.conn.on .dot { background: var(--bid); box-shadow: 0 0 8px rgba(38,166,154,.8); }
.conn.off .dot { background: var(--ask); }

/* ---------- layout ---------- */
.layout {
  flex: 1; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr) minmax(320px, 1fr);
  grid-template-areas:
    "price trade book"
    "price trade tape";
  align-items: start;
}
.price-panel { grid-area: price; }
.trade-panel { grid-area: trade; }
.book-panel { grid-area: book; }
.tape-panel { grid-area: tape; }

/* platform picker bar — full width under the header */
.platform-bar {
  margin: 12px 12px 0; padding: 12px 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.platform-bar .panel-title { margin: 0; }
.platform-bar .platform-row { margin: 0; }
.platform-bar .interest-btn { width: auto; padding: 9px 18px; }
.platform-bar .interest-picker { flex-basis: 100%; margin-top: 2px; }
.platform-bar .paper-fine { margin: 0 0 0 auto; max-width: 280px; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; min-width: 0;
}
.panel-title {
  margin: 18px 0 10px; font-size: .72rem; letter-spacing: .12em;
  color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 8px;
}
.panel-title:first-child { margin-top: 0; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bid); display: inline-block; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.book-count { margin-left: auto; font-family: var(--mono); font-size: .68rem; color: var(--faint); letter-spacing: 0; }

/* ---------- price panel ---------- */
.price-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sym { font-family: var(--mono); font-size: .75rem; color: var(--muted); letter-spacing: .08em; }
.last-price { font-family: var(--mono); font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin: 4px 0; }
.last-price.up { color: var(--bid); } .last-price.down { color: var(--ask); }
.chg { font-family: var(--mono); font-size: .85rem; }
.chg.up { color: var(--bid); } .chg.down { color: var(--ask); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; align-content: start; }
.stat span { display: block; font-size: .65rem; color: var(--faint); letter-spacing: .06em; }
.stat b { font-family: var(--mono); font-size: .85rem; font-weight: 600; }

/* imbalance */
.imbalance-wrap { margin-top: 16px; }
.imbalance-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .7rem; color: var(--muted); margin-bottom: 6px; }
.imbalance-labels b { color: var(--text); }
.imbalance-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--panel-2); }
.imb-bids { background: var(--bid); transition: width .5s; }
.imb-asks { background: var(--ask); transition: width .5s; margin-left: auto; }
.imb-note { font-size: .68rem; color: var(--faint); margin-top: 6px; }

/* depth chart */
#depthChart { width: 100%; height: 220px; display: block; background: var(--panel-2); border-radius: 10px; }
.chart-legend { display: flex; gap: 16px; font-size: .7rem; color: var(--muted); margin-top: 8px; font-family: var(--mono); }
.lg-bid { color: var(--bid); } .lg-ask { color: var(--ask); } .lg-mid { color: var(--faint); }

/* wall radar */
.controls { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: .8rem; color: var(--muted); }
.controls input[type=number] {
  width: 110px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  font-family: var(--mono); font-size: .8rem; margin-left: 6px;
}
.controls .chk { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.alerts { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.alert-empty { color: var(--faint); font-size: .8rem; padding: 12px; text-align: center; }
.alert {
  border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: 8px; padding: 9px 12px; font-size: .78rem; background: var(--panel-2);
  animation: slidein .3s ease;
}
.alert.wall-bid { border-left-color: var(--bid); }
.alert.wall-ask { border-left-color: var(--ask); }
.alert.spoof { border-left-color: var(--ask); background: rgba(239,83,80,.07); }
.alert .a-top { display: flex; justify-content: space-between; font-family: var(--mono); margin-bottom: 2px; }
.alert .a-sub { color: var(--muted); font-size: .72rem; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- order book ---------- */
.book-head, .tape-head {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  font-size: .62rem; letter-spacing: .08em; color: var(--faint);
  padding: 4px 6px; text-transform: uppercase;
}
.book-head span:nth-child(2), .book-head span:nth-child(3),
.row span:nth-child(2), .row span:nth-child(3),
.tape-head span:nth-child(2), .tape-row span:nth-child(2) { text-align: right; }
.book-head span:nth-child(3), .row span:nth-child(3) { text-align: right; }
.tape-head span:nth-child(3), .tape-row span:nth-child(3) { text-align: right; }
.book-asks, .book-bids { display: flex; flex-direction: column; font-family: var(--mono); font-size: .78rem; }
.book-asks { flex-direction: column-reverse; } /* lowest ask sits nearest the spread */
.row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 3px 6px; position: relative; cursor: default; border-radius: 4px;
}
.row:hover { background: rgba(255,255,255,.04); }
.row .depth-bar { position: absolute; top: 0; bottom: 0; right: 0; border-radius: 4px; pointer-events: none; }
.ask-row { color: var(--ask); } .ask-row .depth-bar { background: var(--ask-dim); }
.bid-row { color: var(--bid); } .bid-row .depth-bar { background: var(--bid-dim); }
.row span { position: relative; z-index: 1; }
.row .wall-flag { color: var(--warn); font-size: .7rem; margin-left: 4px; }
.book-spread {
  text-align: center; font-family: var(--mono); font-size: .8rem; color: var(--muted);
  padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin: 4px 0;
}

/* ---------- tape ---------- */
.tape { display: flex; flex-direction: column; font-family: var(--mono); font-size: .76rem; max-height: 560px; overflow: hidden; }
.tape-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 3px 6px; animation: slidein .25s ease; border-radius: 4px;
}
.tape-row.buy { color: var(--bid); } .tape-row.sell { color: var(--ask); }
.tape-row .t-time { color: var(--faint); font-size: .68rem; }
.tape-row.big { background: rgba(255,149,0,.1); font-weight: 700; }

/* ---------- footer ---------- */
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line);
  font-size: .72rem; color: var(--faint);
}
.foot a { color: var(--accent); text-decoration: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "price trade"
      "book tape";
  }
  .platform-bar .paper-fine { margin: 0; max-width: none; }
  .tape { max-height: 300px; }
}
@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "price" "trade" "book" "tape";
  }
  .brand-tag { display: none; }
  .last-price { font-size: 1.6rem; }
  .platform-bar { gap: 10px; }
  .platform-bar .interest-btn { width: 100%; }
}

/* ---------- paper trading ---------- */
/* platform picker */
.platform-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.plat {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; font-size: .85rem; background: var(--panel-2);
}
.plat.soon { opacity: .55; }
.plat-name { font-weight: 600; }
.plat-badge {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: var(--muted);
}
.plat-badge.live { background: rgba(38,166,154,.18); color: var(--bid); }
.interest-btn {
  width: 100%; padding: 11px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px dashed var(--faint); color: var(--muted);
  font-size: .82rem;
}
.interest-btn:hover { border-color: var(--accent); color: var(--accent); }
.interest-picker { margin-top: 10px; }
.vote-label { font-size: .75rem; color: var(--muted); margin-bottom: 8px; }
.vote-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.vote-btns button {
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-size: .8rem;
}
.vote-btns button:hover { border-color: var(--accent); color: var(--accent); }
.voted { font-size: .82rem; color: var(--muted); padding: 10px; background: var(--panel-2); border-radius: 10px; }
.voted b { color: var(--bid); }
.paper-fine { font-size: .68rem; color: var(--faint); margin: 14px 0 0; line-height: 1.5; }

/* trade terminal */
.trade-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.trade-head .panel-title { margin: 0; }
.mark-wrap { text-align: right; }
.mark-wrap span { display: block; font-family: var(--mono); font-size: .65rem; color: var(--faint); letter-spacing: .08em; }
.mark-wrap b { font-family: var(--mono); font-size: 1.3rem; }
.acct-row { display: flex; gap: 18px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.acct span { display: block; font-size: .62rem; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; }
.acct b { font-family: var(--mono); font-size: 1rem; }
.acct b.up, .pos-pnl.up, .hist-row .up { color: var(--bid); }
.acct b.down, .pos-pnl.down, .hist-row .down { color: var(--ask); }
.ghost-btn {
  margin-left: auto; background: transparent; border: 1px solid var(--line);
  color: var(--muted); border-radius: 8px; padding: 7px 14px; font-size: .75rem; cursor: pointer;
}
.ghost-btn:hover { color: var(--ask); border-color: var(--ask); }
.order-form { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.side-btn {
  padding: 11px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer;
  background: transparent; color: var(--muted); font-weight: 800; letter-spacing: .06em; font-size: .85rem;
}
.side-btn.long.active { background: rgba(38,166,154,.15); border-color: var(--bid); color: var(--bid); }
.side-btn.short.active { background: rgba(239,83,80,.15); border-color: var(--ask); color: var(--ask); }
.lev-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.lev-row span { font-size: .72rem; color: var(--faint); margin-right: 4px; }
.lev-btn {
  padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer;
  background: transparent; color: var(--muted); font-family: var(--mono); font-size: .75rem;
}
.lev-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(41,151,255,.1); }
.size-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.size-row label { font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.size-row input {
  width: 140px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-family: var(--mono); font-size: .9rem;
}
.open-btn {
  flex: 1; min-width: 180px; padding: 12px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem;
}
.open-btn:disabled { opacity: .4; cursor: wait; }
.paper-note {
  margin-top: 10px; font-size: .78rem; color: var(--warn);
  opacity: 0; transition: opacity .25s; min-height: 1.2em;
}
.paper-note.show { opacity: 1; }

/* positions + history */
.pos { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel-2); }
.pos.long { border-left: 3px solid var(--bid); }
.pos.short { border-left: 3px solid var(--ask); }
.pos.liq { border-color: var(--ask); background: rgba(239,83,80,.06); }
.pos-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.pos-top b { letter-spacing: .05em; font-size: .85rem; }
.pos-pnl { font-family: var(--mono); font-weight: 700; }
.pos-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .8rem; }
.pos-grid span { color: var(--faint); }
.pos-grid b { font-family: var(--mono); font-weight: 600; text-align: right; }
.liq-px { color: var(--ask); }
.pos-close { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pos-close button {
  flex: 1; min-width: 70px; padding: 8px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: .75rem;
}
.pos-close button:hover { border-color: var(--ask); color: var(--ask); }
.pos-empty { color: var(--faint); font-size: .82rem; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.hist-row {
  display: grid; grid-template-columns: auto 1fr 1.4fr auto auto; gap: 12px;
  font-family: var(--mono); font-size: .74rem; padding: 8px 4px;
  border-bottom: 1px solid var(--line); align-items: center;
}
.hist-row .long { color: var(--bid); } .hist-row .short { color: var(--ask); }
.hist-row .t-time { color: var(--faint); font-size: .68rem; }

@media (max-width: 1100px) {
  .paper-section { grid-template-columns: 1fr; }
}

/* vote standings bars */
.vote-sub { color: var(--faint); font-size: .68rem; }
.vote-standings-label { font-size: .72rem; color: var(--faint); margin: 14px 0 8px; letter-spacing: .06em; text-transform: uppercase; }
.vote-empty { font-size: .78rem; color: var(--faint); padding: 8px 0; }
.vote-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.vote-bar-row { display: grid; grid-template-columns: 130px 1fr 84px; gap: 10px; align-items: center; font-size: .78rem; }
.vote-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vote-bar-row.mine .vote-name { color: var(--bid); font-weight: 700; }
.vote-track { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.vote-fill { height: 100%; border-radius: 6px; background: var(--faint); transition: width .6s ease; }
.vote-bar-row.lead .vote-fill { background: var(--accent); }
.vote-bar-row.mine .vote-fill { background: var(--bid); }
.vote-num { font-family: var(--mono); font-size: .7rem; color: var(--muted); text-align: right; }
@media (max-width: 720px) {
  .vote-bar-row { grid-template-columns: 96px 1fr 70px; }
}

/* how-to instructions */
.howto { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.howto summary { padding: 12px 16px; cursor: pointer; font-size: .82rem; font-weight: 700; color: var(--accent); list-style: none; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::before { content: "▸ "; }
.howto[open] summary::before { content: "▾ "; }
.howto ol { margin: 0; padding: 0 18px 6px 38px; font-size: .8rem; color: var(--muted); display: grid; gap: 8px; }
.howto ol b { color: var(--text); }
.howto > p { margin: 0; padding: 0 18px 14px 38px; font-size: .8rem; color: var(--muted); line-height: 1.6; }
.howto > p b { color: var(--text); }
.howto-fine { font-size: .7rem; color: var(--faint); padding: 0 18px 14px 38px; margin: 8px 0 0; }
/* explainer inside the flex platform bar */
.platform-bar .howto { flex-basis: 100%; margin: 0; }
.platform-bar .howto > p { padding-left: 18px; }
