/* ====================== Relai — futures terminal ====================== */
:root {
  --up: #11A66B;
  --up-bg: rgba(17,166,107,.08);
  --down: #E5484D;
  --down-bg: rgba(229,72,77,.07);
  --term-line: #ECECEC;
  --term-faint: #8A8A8A;
}
body.term-body { overflow: auto; }

/* ticker strip */
.ticker {
  border-bottom: 1px solid var(--term-line); background: #fff;
  overflow: hidden; white-space: nowrap; height: 46px; display: flex; align-items: center;
}
.ticker-track { display: inline-flex; align-items: center; }
.tk { display: inline-flex; align-items: baseline; gap: 8px; padding: 0 22px; border-right: 1px solid var(--line-2); font-family: var(--mono); font-size: 13px; }
.tk .nm { color: var(--ink); font-weight: 600; }
.tk .px { color: var(--muted); }
.tk .ch { font-weight: 600; }
.tk .ch.up { color: var(--up); } .tk .ch.down { color: var(--down); }

/* terminal grid */
.term {
  display: grid; grid-template-columns: 1fr 326px 312px;
  height: calc(100vh - 68px - 46px); min-height: 520px;
}
.term > div { min-width: 0; }
.col-chart { border-right: 1px solid var(--term-line); display: flex; flex-direction: column; }
.col-book  { border-right: 1px solid var(--term-line); display: flex; flex-direction: column; min-height: 0; }
.col-panel { display: flex; flex-direction: column; overflow-y: auto; }

/* chart header */
.chart-head { display: flex; align-items: stretch; border-bottom: 1px solid var(--term-line); flex-wrap: wrap; }
.mkt-sel { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-right: 1px solid var(--term-line); cursor: pointer; position: relative; }
.mkt-sel .nm { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.mkt-sel .fut { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.mkt-sel .cv { color: var(--faint); font-size: 12px; }
.mkt-menu { position: absolute; top: 100%; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 50px -20px rgba(0,0,0,.28); padding: 6px; z-index: 30; display: none; min-width: 220px; }
.mkt-menu.on { display: block; }
.mkt-menu button { display: flex; width: 100%; justify-content: space-between; gap: 14px; background: none; border: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-family: var(--mono); font-size: 13px; color: var(--ink); }
.mkt-menu button:hover { background: var(--line-2); }
.mkt-menu button .mc { font-weight: 600; }
.stat-cell { padding: 11px 18px; border-right: 1px solid var(--term-line); display: flex; flex-direction: column; justify-content: center; }
.stat-cell .k { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.stat-cell .val { font-family: var(--mono); font-size: 15px; color: var(--ink); margin-top: 3px; }
.stat-cell .val.up { color: var(--up); } .stat-cell .val.down { color: var(--down); }

/* chart canvas */
.chart-wrap { position: relative; flex: 1; min-height: 0; }
#chart { display: block; width: 100%; height: 100%; }
.chart-tag { position: absolute; left: 14px; bottom: 10px; font-family: var(--mono); font-size: 11px; color: #C2C2C2; letter-spacing: .04em; }
.chart-prev { position: absolute; right: 12px; top: 12px; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; background: #fff; }

/* order book */
.book-tabs { display: flex; border-bottom: 1px solid var(--term-line); }
.book-tabs button { flex: 1; background: none; border: none; padding: 13px; font-family: var(--body); font-size: 13.5px; font-weight: 600; color: var(--faint); cursor: pointer; border-bottom: 2px solid transparent; }
.book-tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.book-head, .book-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 4px 14px; font-family: var(--mono); font-size: 11.5px; }
.book-head { color: var(--faint); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 9px 14px; border-bottom: 1px solid var(--line-2); }
.book-rows { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.book-row { position: relative; }
.book-row .depth { position: absolute; top: 0; bottom: 0; right: 0; z-index: 0; }
.book-row.ask .depth { background: var(--down-bg); }
.book-row.bid .depth { background: var(--up-bg); }
.book-row span { position: relative; z-index: 1; text-align: right; }
.book-row span:first-child { text-align: left; }
.book-row.ask .p { color: var(--down); } .book-row.bid .p { color: var(--up); }
.book-row .sz, .book-row .tt { color: var(--muted); }
.book-mid { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); font-family: var(--mono); }
.book-mid .m { font-size: 18px; font-weight: 600; color: var(--ink); }
.book-mid .s { font-size: 11px; color: var(--faint); }

/* trade panel */
.panel-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--term-line); }
.chip-cross { font-family: var(--mono); font-size: 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; }
.chip-lev { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ink); }
.ml-tabs { display: flex; padding: 0 16px; border-bottom: 1px solid var(--term-line); }
.ml-tabs button { background: none; border: none; padding: 13px 4px; margin-right: 22px; font-family: var(--body); font-weight: 600; font-size: 14px; color: var(--faint); cursor: pointer; border-bottom: 2px solid transparent; }
.ml-tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.pbody { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.tok-card { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.tok-card .l { display: flex; align-items: center; gap: 8px; }
.tok-card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); }
.tok-card .sym { font-family: var(--display); font-weight: 700; }
.tok-card .src { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px; }
.tok-card .r { text-align: right; }
.tok-card .pr { font-family: var(--mono); font-size: 14px; color: var(--ink); }
.tok-card .pc { font-family: var(--mono); font-size: 11.5px; color: var(--up); }
.wallets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wallet { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; }
.wallet .k { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; color: var(--faint); }
.wallet .v { font-family: var(--mono); font-size: 15px; color: var(--ink); margin-top: 4px; word-break: break-all; }
.kv { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }
.lev-row { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; }
.lev-row button { padding: 9px 0; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-family: var(--mono); font-size: 13px; cursor: pointer; color: var(--muted); }
.lev-row button.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }
.size-field { border: 1px solid var(--line); border-radius: 11px; padding: 11px 14px; }
.size-field input { width: 100%; border: none; outline: none; font-family: var(--mono); font-size: 17px; color: var(--ink); }
.lbl-sm { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.bs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bs { border: none; border-radius: 12px; padding: 14px; font-family: var(--body); font-weight: 700; font-size: 15px; color: #fff; cursor: pointer; }
.bs.long { background: var(--up); } .bs.long:hover { filter: brightness(1.06); }
.bs.short { background: var(--down); } .bs.short:hover { filter: brightness(1.06); }
.deposit { width: 100%; border: 1px dashed var(--line); background: #fff; border-radius: 12px; padding: 13px; font-family: var(--body); font-size: 14px; color: var(--muted); cursor: pointer; }
.deposit:hover { border-color: #c9c9c9; color: var(--ink); }
.summary-rows { border-top: 1px solid var(--line-2); padding-top: 12px; display: flex; flex-direction: column; gap: 9px; }

/* mobile */
@media (max-width: 1080px) {
  body.term-body { overflow: auto; }
  .term { grid-template-columns: 1fr; height: auto; }
  .col-chart, .col-book { border-right: none; border-bottom: 1px solid var(--term-line); }
  .chart-wrap { height: 360px; }
  .book-rows { max-height: 360px; }
}

/* ---- positions panel ---- */
.positions { border-top: 1px solid var(--term-line); }
.pos-tabs { display: flex; align-items: center; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--term-line); }
.pos-tabs button { background: none; border: none; padding: 14px 12px; font-family: var(--body); font-weight: 600; font-size: 13.5px; color: var(--faint); cursor: pointer; border-bottom: 2px solid transparent; }
.pos-tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.pos-tabs .cnt { display: inline-block; min-width: 18px; text-align: center; font-family: var(--mono); font-size: 11px; background: var(--line-2); border-radius: 999px; padding: 1px 6px; margin-left: 4px; color: var(--ink); }
.pos-note { margin-left: auto; font-family: var(--mono); font-size: 10.5px; letter-spacing: .03em; color: var(--faint); padding-right: 6px; }
.pos-table { overflow-x: auto; }
.pos-head, .pos-row { display: grid; grid-template-columns: 1.2fr .8fr 1fr 1fr 1fr 1.1fr 1.3fr .6fr .8fr; gap: 10px; align-items: center; padding: 12px 18px; min-width: 760px; }
.pos-head { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line-2); }
.pos-head .num, .pos-row .num { text-align: right; }
.pos-row { border-bottom: 1px solid var(--line-2); font-family: var(--mono); font-size: 13px; }
.pos-row .mkt { font-family: var(--display); font-weight: 700; }
.pos-row .side-long { color: var(--up); font-weight: 600; }
.pos-row .side-short { color: var(--down); font-weight: 600; }
.pos-row .pnl-up { color: var(--up); } .pos-row .pnl-down { color: var(--down); }
.pos-row .close-btn { justify-self: end; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font-family: var(--body); font-size: 12.5px; cursor: pointer; color: var(--ink); }
.pos-row .close-btn:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.pos-empty { padding: 30px 18px; font-family: var(--mono); font-size: 13px; color: var(--faint); text-align: center; }

/* ---- trade nav: logo far-left + Futures tag ---- */
.term-nav .wrap { max-width: none; padding-left: 18px; padding-right: 18px; }
.brand-wrap { display: flex; align-items: center; gap: 9px; }
.brand-tag { font-family: 'Syne', var(--display); font-weight: 700; font-size: 18px; letter-spacing: -.02em; color: var(--muted); }
