:root {
  --bg: #000;
  --panel: #060606;
  --line: #262626;
  --amber: #ffa028;
  --amber-dim: #8a5714;
  --text: #e4e4e4;
  --muted: #7d7d7d;
  --green: #00e676;
  --red: #ff3d3d;
  --blue: #4da3ff;
  --yellow: #ffd400;
  --lamp-off: #1c1c1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.35 Consolas, "IBM Plex Mono", "Courier New", monospace;
}

body { display: flex; flex-direction: column; overflow: hidden; }

.up { color: var(--green); }
.dn { color: var(--red); }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 10px;
  background: #0b0b0b;
  border-bottom: 1px solid var(--amber-dim);
}
.brand { color: var(--amber); font-weight: 700; letter-spacing: 2px; font-size: 14px; white-space: nowrap; }
.brand span { color: #000; background: var(--amber); padding: 0 4px; margin-left: 4px; }

.cmd {
  flex: 1; max-width: 520px;
  display: flex; align-items: center;
  border: 1px solid var(--amber-dim); background: #000;
}
.cmd .prompt { color: var(--amber); padding: 0 6px; }
.cmd input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--yellow); font: inherit; font-size: 13px; padding: 4px 0;
  text-transform: uppercase;
}
.cmd input::placeholder { color: #555; text-transform: none; }
.go {
  background: #0a8f3c; color: #fff; border: 0; font: inherit; font-weight: 700;
  padding: 4px 12px; cursor: pointer;
}
.go:hover { background: #0cb04a; }

.status { display: flex; align-items: center; gap: 14px; color: var(--muted); white-space: nowrap; }
.stat { display: inline-flex; align-items: center; gap: 5px; }
.clocks { display: flex; gap: 12px; }
.clocks b { color: var(--amber); font-weight: 400; margin-right: 4px; }

/* ---------- lamps ---------- */
.lamp {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--lamp-off);
  box-shadow: inset 0 0 2px #000;
  flex: none;
}
.lamp.on-g { background: var(--green); box-shadow: 0 0 6px var(--green); }
.lamp.on-r { background: var(--red); box-shadow: 0 0 6px var(--red); }
.lamp.blink { animation: blink 1s steps(2, start) infinite; }
.lamp.g { animation: lampG .7s ease-out; }
.lamp.r { animation: lampR .7s ease-out; }

@keyframes blink { to { visibility: hidden; } }
@keyframes lampG {
  0%   { background: #3dff9a; box-shadow: 0 0 10px 3px var(--green); }
  100% { background: var(--lamp-off); box-shadow: none; }
}
@keyframes lampR {
  0%   { background: #ff6b6b; box-shadow: 0 0 10px 3px var(--red); }
  100% { background: var(--lamp-off); box-shadow: none; }
}

/* cel-flash bij koerswijziging */
.fu { animation: fu .8s ease-out; }
.fd { animation: fd .8s ease-out; }
@keyframes fu { 0% { background: rgba(0, 230, 118, .55); color: #fff; } 100% { background: transparent; } }
@keyframes fd { 0% { background: rgba(255, 61, 61, .55); color: #fff; } 100% { background: transparent; } }

/* ---------- ticker tape ---------- */
.tape {
  overflow: hidden; white-space: nowrap;
  background: #050505; border-bottom: 1px solid var(--line);
  padding: 3px 0;
}
.tape-track { display: inline-block; animation: tape 60s linear infinite; }
.tape:hover .tape-track { animation-play-state: paused; }
.ti { margin-right: 28px; cursor: pointer; }
.ti b { color: var(--amber); font-weight: 400; margin-right: 6px; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- function keys ---------- */
.fkeys {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 4px 10px; background: #0b0b0b; border-bottom: 1px solid var(--line);
}
.fk-label { color: var(--muted); margin: 0 4px 0 2px; }
.fk-sep { width: 1px; height: 16px; background: var(--line); margin: 0 8px; }
.fk {
  background: #1a1a1a; color: var(--amber); border: 1px solid #333;
  font: inherit; padding: 2px 8px; cursor: pointer;
}
.fk:hover { border-color: var(--amber-dim); }
.fk.active { background: var(--amber); color: #000; border-color: var(--amber); font-weight: 700; }

/* ---------- grid ---------- */
.grid {
  flex: 1; min-height: 0;
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: minmax(300px, 22%) 1fr minmax(290px, 21%);
  grid-template-rows: 1fr 290px;
  grid-template-areas:
    "watch chart book"
    "news  anal  trades";
}
.p-watch  { grid-area: watch; }
.p-chart  { grid-area: chart; }
.p-book   { grid-area: book; }
.p-news   { grid-area: news; }
.p-anal   { grid-area: anal; }
.p-trades { grid-area: trades; }

.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ph {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 3px 8px; background: #111; border-bottom: 1px solid var(--line);
  color: var(--amber); font-weight: 700; white-space: nowrap; overflow: hidden;
}
.pb { flex: 1; min-height: 0; }
.scroll { overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb { background: #333; }

/* ---------- watchlist ---------- */
#watch { width: 100%; border-collapse: collapse; }
#watch th {
  position: sticky; top: 0; background: #0d0d0d; color: var(--muted);
  font-weight: 400; text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line);
}
#watch th.num { text-align: right; }
#watch td { padding: 3px 6px; border-bottom: 1px solid #111; white-space: nowrap; }
#watch tr { cursor: pointer; }
#watch tbody tr:hover { background: #121212; }
#watch tr.sel { background: #1e1608; box-shadow: inset 2px 0 0 var(--amber); }
#watch .sym { color: var(--amber); }
#watch .sym small { color: var(--muted); margin-left: 5px; font-size: 10px; }
#watch td:first-child { width: 14px; padding-right: 0; }

/* ---------- chart ---------- */
.quote { justify-content: flex-start; gap: 14px; font-size: 13px; }
.q-sym { color: #000; background: var(--amber); padding: 0 6px; }
.q-name { color: var(--text); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.q-last { color: #fff; font-size: 15px; padding: 0 4px; }
.chart-wrap { position: relative; flex: 1; min-height: 0; }
.chart-wrap canvas { position: absolute; inset: 0; cursor: crosshair; }
.readout {
  position: absolute; left: 8px; top: 6px; pointer-events: none;
  font-size: 11px; color: var(--muted); background: rgba(0, 0, 0, .6); padding: 1px 4px;
}
.readout b { color: var(--text); font-weight: 400; margin-right: 8px; }

/* ---------- orderbook ---------- */
.book-head, .brow, .trade-head, .trow {
  display: grid; grid-template-columns: 16px 1fr 1fr 1fr; align-items: center;
  padding: 0 8px; gap: 6px;
}
.book-head, .trade-head { color: var(--muted); padding-top: 3px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.trade-head, .trow { grid-template-columns: 1fr 1fr 1fr 16px; }
.book { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; overflow: hidden; }
#bids { justify-content: flex-start; }
.brow { position: relative; height: 18px; font-variant-numeric: tabular-nums; }
.brow > * { position: relative; }
.brow .sz, .brow .cum { text-align: right; }
.brow .depth { position: absolute; right: 0; top: 1px; bottom: 1px; transition: width .25s; }
.brow.ask .depth { background: rgba(255, 61, 61, .14); }
.brow.bid .depth { background: rgba(0, 230, 118, .12); }
.brow.ask .px { color: var(--red); }
.brow.bid .px { color: var(--green); }
.brow .cum { color: var(--muted); }
.brow.best { font-weight: 700; }

.spread {
  display: flex; justify-content: space-between; padding: 3px 8px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: #0e0e0e; color: var(--amber);
}
.imbalance { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-top: 1px solid var(--line); }
.imb-bar { flex: 1; height: 8px; background: var(--red); position: relative; }
.imb-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); transition: width .3s; }

/* ---------- trades ---------- */
.trow { height: 17px; font-variant-numeric: tabular-nums; border-bottom: 1px solid #0d0d0d; }
.trow span:nth-child(2), .trow span:nth-child(3) { text-align: right; }
.trow span:first-child { color: var(--muted); }
.trow.buy span:nth-child(2) { color: var(--green); }
.trow.sell span:nth-child(2) { color: var(--red); }
.trow.big { background: #161004; font-weight: 700; }
.trow.big span:nth-child(3) { color: var(--yellow); }
.trow.new.buy { animation: fu .8s ease-out; }
.trow.new.sell { animation: fd .8s ease-out; }

/* ---------- news ---------- */
.news-item { padding: 4px 8px; border-bottom: 1px solid #111; cursor: pointer; }
.news-item:hover { background: #121212; }
.news-item .t { color: var(--muted); margin-right: 6px; }
.news-item .s { color: var(--amber); margin-right: 6px; }
.news-item.fresh { animation: newsIn 2.5s ease-out; }
.news-item.hot .h { color: var(--yellow); }
@keyframes newsIn { 0% { background: #3a2a05; } 100% { background: transparent; } }

/* ---------- analysis ---------- */
.anal { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 1px; background: var(--line); min-height: 100%; }
.anal > div { background: var(--panel); padding: 6px 10px; }
.anal h4 { color: var(--amber); font-weight: 400; margin-bottom: 6px; border-bottom: 1px dotted #333; padding-bottom: 2px; }
.verdict { font-size: 18px; font-weight: 700; letter-spacing: 1px; margin: 2px 0 6px; }
.gauge {
  position: relative; height: 10px; margin: 4px 0 4px;
  background: linear-gradient(90deg, var(--red), #553 50%, var(--green));
}
.gauge i {
  position: absolute; top: -4px; width: 3px; height: 18px; background: #fff;
  box-shadow: 0 0 6px #fff; transform: translateX(-1px); transition: left .4s;
}
.gauge-lbl { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; }
.kv.two { grid-template-columns: 1fr auto; }
.kv .k { color: var(--muted); white-space: nowrap; }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.sig { text-align: right; font-weight: 700; }
.sig.b { color: var(--green); }
.sig.s { color: var(--red); }
.sig.n { color: var(--muted); }
.lvl-r { color: var(--red); }
.lvl-s { color: var(--green); }
.lvl-p { color: var(--amber); }

/* ---------- status line ---------- */
.statusline {
  padding: 3px 10px; background: #0b0b0b; border-top: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.statusline .err { color: var(--red); }
.statusline .ok { color: var(--green); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  body { overflow: auto; height: auto; }
  .status .clocks { display: none; }
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 460px 420px 300px 320px;
    grid-template-areas:
      "chart chart"
      "watch book"
      "anal  anal"
      "news  trades";
  }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; }
  .status { display: none; }
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: 380px 420px 420px auto 300px 300px;
    grid-template-areas: "chart" "watch" "book" "anal" "trades" "news";
  }
  .anal { grid-template-columns: 1fr; }
}