/* The layout. Colours, type and spacing come from tokens.css. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 400 12px/1.4 var(--ui); font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }
.n { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .mute { color: var(--ink-3); } .dim { color: var(--ink-2); }
.shell { display: grid; grid-template-rows: 48px 1fr; height: 100%; }
main { min-height: 0; display: grid; }

/* top bar */
.top { display: flex; align-items: center; gap: 22px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -0.02em; color: var(--ink); }
.logo i { width: 18px; height: 18px; border-radius: 5px; background: conic-gradient(from 210deg, var(--accent), #2a7cf6, var(--accent)); }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--ink-3); padding: 6px 10px; border-radius: 6px; font-weight: 500; font-size: 13px; }
.nav a.on { color: var(--ink); background: var(--panel-2); }
.ticker { display: flex; align-items: center; gap: 22px; padding-left: 18px; border-left: 1px solid var(--line); height: 100%; min-width: 0; overflow: hidden; }
.pair { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.tag { font: 500 10px var(--mono); color: var(--accent); background: var(--accent-bg); padding: 1px 5px; border-radius: 4px; }
.tag.dim { color: var(--ink-2); background: var(--panel-3); }
.last { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.stat { display: grid; gap: 1px; white-space: nowrap; }
.stat small { color: var(--ink-3); font-size: 10.5px; }
.stat b { font-weight: 500; font-size: 12px; }
.right { margin-left: auto; display: flex; align-items: center; gap: 12px; white-space: nowrap; }
#who { display: flex; align-items: center; gap: 8px; }
.live { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 11px; }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--up); }
.live.warn i { background: var(--warn); } .live.bad i { background: var(--down); }
.who { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 12px; color: var(--ink-2); }
.who b { color: var(--ink); font-weight: 600; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-3); font-size: 11px; }

/* panes */
.grid { display: grid; gap: 1px; background: var(--line); min-height: 0; min-width: 0; }
.panel { background: var(--panel); min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.ph { display: flex; align-items: center; gap: 14px; height: 36px; padding: 0 12px; border-bottom: 1px solid var(--line); flex: none; }
.tab { color: var(--ink-3); font-weight: 500; font-size: 12px; height: 100%; display: flex; align-items: center; border: 0; border-bottom: 2px solid transparent; cursor: pointer; background: none; padding: 0; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab sup { color: var(--ink-4); font-size: 10px; margin-left: 3px; }
.ph .sp { margin-left: auto; }
.chip { font-size: 11px; color: var(--ink-3); padding: 2px 7px; border-radius: 5px; background: none; border: 0; cursor: pointer; }
.chip.on { color: var(--ink); background: var(--panel-2); }
.scroll { overflow: auto; flex: 1; min-height: 0; }
.empty { color: var(--ink-3); padding: 14px 12px; line-height: 1.5; }
.error { color: var(--down); }

/* watchlist */
.search { margin: 10px 10px 6px; height: 30px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line-2); display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--ink-3); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); }
.cats { display: flex; gap: 2px; padding: 0 8px 6px; flex-wrap: wrap; }
.wl { overflow: auto; flex: 1; }
.wl .row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-left: 2px solid transparent; cursor: pointer; }
.wl .row:hover { background: var(--panel-2); }
.wl .row.sel { background: var(--panel-2); border-left-color: var(--accent); }
.wl .sym { font-weight: 600; font-size: 12.5px; display: flex; gap: 6px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.wl .sym small { color: var(--ink-4); font-weight: 500; font-size: 10px; }
.wl .vol { color: var(--ink-3); font-size: 10.5px; }
.wl .p { text-align: right; font-weight: 500; }
.wl .c { text-align: right; font-weight: 500; font-size: 11.5px; padding: 3px 6px; border-radius: 5px; }
.wl .c.up { background: var(--up-bg); } .wl .c.down { background: var(--down-bg); }

/* chart */
.chart-wrap { flex: 1; position: relative; min-height: 0; }
.chart-wrap > .plot { position: absolute; inset: 0; }
.legend { position: absolute; left: 12px; top: 8px; z-index: 3; display: flex; gap: 12px; font-size: 11px; color: var(--ink-3); pointer-events: none; }
.legend b { color: var(--ink-2); font-weight: 500; }

/* book */
.book { display: grid; font-size: 11.5px; }
.bh, .lv { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 0 12px; }
.bh { color: var(--ink-3); font-size: 10.5px; height: 26px; align-items: center; }
.bh span:not(:first-child), .lv span:not(:first-of-type) { text-align: right; }
.lv { position: relative; height: 20px; align-items: center; cursor: pointer; }
.lv .bar { position: absolute; right: 0; top: 1px; bottom: 1px; transition: width 0.25s ease-out; }
.asks .bar { background: var(--down-bg); } .bids .bar { background: var(--up-bg); }
.lv span { position: relative; z-index: 1; }
.asks .lv span:first-of-type { color: var(--down); } .bids .lv span:first-of-type { color: var(--up); }
/* A level whose size changed lights up for a moment: brighter where it grew, a red edge where it shrank. */
.lv.grew { animation: grew 0.6s ease-out; } .lv.shrank { animation: shrank 0.6s ease-out; }
@keyframes grew { from { background: rgba(255, 255, 255, 0.09); box-shadow: inset 2px 0 0 var(--up); } }
@keyframes shrank { from { background: rgba(255, 255, 255, 0.05); box-shadow: inset 2px 0 0 var(--down); } }
.mid { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.mid .lastp { font-size: 15px; font-weight: 600; }
.mid .spr { margin-left: auto; color: var(--ink-3); font-size: 11px; }
.tape { font-size: 11.5px; }
.tape .t { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 0 12px; height: 20px; align-items: center; }
.tape .t span:not(:first-child) { text-align: right; }
.tape .t.big { background: rgba(255, 255, 255, 0.03); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .lv.grew, .lv.shrank { animation: none; } .lv .bar { transition: none; } }

/* ticket */
.ticket { padding: 12px; display: grid; gap: 10px; align-content: start; overflow: auto; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; background: var(--panel-2); border-radius: 7px; }
.seg button { border: 0; background: none; padding: 6px 0; border-radius: 5px; color: var(--ink-3); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--panel-3); color: var(--ink); }
.seg.sides button.on.buy { background: var(--up); color: #032116; } .seg.sides button.on.sell { background: var(--down); color: #2a0509; }
.field { display: grid; gap: 4px; }
.field > span { color: var(--ink-3); font-size: 11px; display: flex; justify-content: space-between; gap: 8px; }
.field .box { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel-2); }
.field .box:focus-within { border-color: var(--accent); }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.field .box em { font-style: normal; color: var(--ink-3); font-size: 11px; }
.field textarea { min-height: 64px; resize: vertical; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel-2); outline: 0; font-size: 12px; line-height: 1.45; }
.field textarea:focus { border-color: var(--accent); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.quick button { border: 1px solid var(--line-2); background: none; border-radius: 5px; padding: 3px 0; color: var(--ink-3); font-size: 11px; cursor: pointer; }
.sum { display: grid; gap: 4px; padding: 10px; border-radius: 7px; background: var(--panel-2); font-size: 11.5px; }
.sum div { display: flex; justify-content: space-between; gap: 10px; }
.sum div span:first-child { color: var(--ink-3); }
.refusal { color: var(--down); background: var(--down-bg); border-radius: 7px; padding: 8px 10px; font-size: 11.5px; line-height: 1.45; }
.go { height: 38px; border: 0; border-radius: 7px; font-weight: 700; font-size: 13px; cursor: pointer; }
.go.buy { background: var(--up); color: #032116; } .go.sell { background: var(--down); color: #2a0509; }
.go:disabled { opacity: 0.45; cursor: not-allowed; }
.note { color: var(--ink-3); font-size: 11px; line-height: 1.45; }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 30; max-width: 360px; padding: 12px 14px; border-radius: 8px; background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); font-size: 12px; line-height: 1.45; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
th { color: var(--ink-3); font-weight: 500; font-size: 10.5px; text-align: right; padding: 0 12px; height: 28px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 1; }
td { text-align: right; padding: 0 12px; height: 27px; border-bottom: 1px solid rgba(28, 33, 41, 0.6); white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
td.why { text-align: left; white-space: normal; color: var(--ink-2); line-height: 1.5; padding-top: 7px; padding-bottom: 7px; min-width: 280px; }
td.why .platform { display: block; color: var(--ink-3); font-style: italic; }
.pill { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 4px; letter-spacing: 0.02em; }
.pill.buy { color: var(--up); background: var(--up-bg); } .pill.sell { color: var(--down); background: var(--down-bg); }
.pill.mk { color: var(--accent); background: var(--accent-bg); } .pill.tk, .pill.st { color: var(--ink-2); background: var(--panel-2); }

/* leaderboard: the caller's own rows in the accent, the only ones that link */
.board td { height: 34px; font-size: 12.5px; }
.board .rank { width: 44px; color: var(--ink-3); }
.board .name { color: var(--ink); font-family: var(--ui); }
.board .name .tag { margin-left: 8px; }
.board tr.mine td { background: var(--accent-bg); }
.board tr.mine td:first-child { box-shadow: inset 2px 0 var(--accent); color: var(--accent); }
.board tr.mine .name a { color: var(--accent); font-weight: 600; }

/* account: the briefing */
.acct { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.acct-grid { grid-template-columns: minmax(0, 1fr) 420px; grid-template-rows: 340px minmax(0, 1fr); flex: 1; }
.acct-side { grid-row: span 2; }
.title { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.title h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.title select { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 8px; }
.title .sp { margin-left: auto; color: var(--ink-3); font-size: 11.5px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--panel); border-bottom: 1px solid var(--line); }
.kpi { padding: 12px 16px; border-right: 1px solid var(--line); display: grid; gap: 4px; min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi small { color: var(--ink-3); font-size: 11px; }
.kpi b { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.kpi em { font-style: normal; font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; font: 600 10.5px var(--mono); color: #071410; background: var(--ink-2); }
.num.buy { background: var(--up); } .num.sell { background: var(--down); color: #2a0509; } .num.off { background: none; color: var(--ink-3); box-shadow: inset 0 0 0 1.5px var(--ink-4); }
.keyrow { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--ink-3); align-items: center; }
.keyrow i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }

/* sign-in prompt and key form */
.ask { margin: 40px auto; width: min(460px, calc(100% - 32px)); display: grid; gap: 12px; padding: 20px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; align-self: start; }
.ask h2 { margin: 0; font-size: 16px; }
.welcome { margin-top: 12vh; }
.welcome h2 { font-size: 22px; letter-spacing: -0.02em; }
.ask p { margin: 0; color: var(--ink-2); line-height: 1.5; }
.ask form { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel-2); font-family: var(--mono); }
.btn { height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--panel-2); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.credit { font-size: 10.5px; color: var(--ink-4); }
.credit a { color: var(--ink-3); }

/* phone */
.tabbar { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-rows: 48px 1fr 60px; }
  .top { gap: 12px; }
  .top .nav, .top .ticker, .top .right .live { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--ink-3); font-size: 10.5px; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 20px; height: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .acct-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: 300px auto auto; }
  .acct-side { grid-row: auto; }
  .acct-side .scroll, .acct-grid .scroll { overflow-x: auto; }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi { border-bottom: 1px solid var(--line); }
  .hide-sm { display: none; }
  .board th, .board td { padding: 0 6px; }
  .board th { white-space: normal; line-height: 1.2; padding-top: 4px; padding-bottom: 4px; }
  .board td { font-size: 12px; }
  .board .rank { width: 26px; }
  .board .name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .board .name .tag { display: none; }
  .who b { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
}
