:root {
  --bg: #0b1018; --panel: #121a27; --field: #0d1420; --line: #1e2a3d; --text: #e7edf5; --muted: #8a9ab5;
  --accent: #4f8cff; --up: #22c55e; --down: #ef4444; --warn: #f59e0b; --radius: 10px;
}
* { box-sizing: border-box; }
[v-cloak] { display: none; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* header */
.top {
  position: sticky; top: 0; z-index: 5; height: 48px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; }
.brand .tag { margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
.right { display: flex; align-items: center; gap: 14px; }
.pills { display: flex; gap: 10px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status.live { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); display: inline-block; }
.status.live .dot { background: var(--up); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.who { white-space: nowrap; }

/* page: full width; on laptop/desktop the board fills the viewport and cards scroll internally */
html, body { height: 100%; }
main { padding: 12px 16px; display: grid; gap: 12px; }
main.login { max-width: 440px; margin: 48px auto 0; }
main.checking { height: calc(100vh - 48px); display: flex; align-items: center; justify-content: center; }
main.board { grid-template-rows: auto minmax(0, 1fr); }
main.board.warned { grid-template-rows: auto auto minmax(0, 1fr); }
@media (min-width: 1000px) {
  main.board { height: calc(100vh - 48px); overflow: hidden; }
}

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px; border: 1px solid var(--down); background: rgba(239,68,68,.08); border-radius: var(--radius);
}

/* summary bar: one full-width card, equal segments */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat { padding: 10px 16px; display: grid; gap: 1px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat strong { font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat { border-top: 1px solid var(--line); } .stat:nth-child(-n+2) { border-top: 0; } .stat:nth-child(odd) { border-left: 0; } }

/* board: the price board beside a rail of ticket + activity (positions, ledger and inbox as tabs);
   one column on phones, with the ticket first so an order is one tap away */
.layout {
  display: grid; gap: 12px; align-items: stretch; min-height: 0; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "ticket" "prices" "activity";
}
.side { display: contents; }
.side .card.ticket { grid-area: ticket; }
.side .card.activity { grid-area: activity; }
.card.prices { grid-area: prices; }
@media (max-width: 999px) {
  .card.prices, .card.activity { max-height: 60vh; }
}
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 3fr) minmax(520px, 2fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "prices side"; }
  .side { grid-area: side; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
  .side .card.ticket { flex: none; grid-area: auto; }
  .side .card.activity { flex: 1 1 auto; min-height: 0; grid-area: auto; }
}
@media (min-width: 1600px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* cards: header pinned, body scrolls, pager pinned */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; min-height: 0; display: flex; flex-direction: column; container-type: inline-size; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex: none; flex-wrap: wrap; }
.card > header .meta { margin-right: auto; }
.card > .table-wrap, .card > .inbox, .pane > .table-wrap, .pane > .inbox { flex: 1 1 auto; min-height: 0; overflow: auto; }
.card > .pager, .card > form, .card > .link, .card > p:not(.empty), .pane > .pager, .pane > .link { flex: none; }
/* a tab body; contents so its children are the card's flex items (petite-vue needs a real element to toggle) */
.pane { display: contents; }
thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.card h2 { margin: 0; font-size: 14px; font-weight: 600; }
.meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
/* empty state and loading spinner: centred in the section's body, which keeps its final size */
.empty, .loading { flex: 1 1 auto; min-height: 140px; display: flex; align-items: center; justify-content: center; text-align: center; margin: 0; padding: 12px; }
.empty { color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; margin: 4px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.error { color: var(--down); margin: 8px 0 0; }

/* tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
th { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.025); }
td.num, th.num { text-align: right; width: 1%; }
.sym { font-weight: 600; }
.desc { display: block; font-size: 11px; color: var(--muted); }
tr.dim td { opacity: .5; }
tr.pick { cursor: pointer; }
tr.sel td { background: rgba(79,140,255,.10); }
tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.stale td { opacity: .55; }
/* the Close column stays in view when the positions table scrolls sideways */
.positions th:last-child, .positions td:last-child { position: sticky; right: 0; background: var(--panel); }
.stale-tag { margin-left: 6px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--warn); border: 1px solid; border-radius: 999px; padding: 0 5px; vertical-align: middle; }
/* only the last-price cell reacts to a tick: text turns green/red and fades */
td.px { transition: color .7s ease-out; font-weight: 600; }
td.px.up { color: var(--up); transition: none; }
td.px.down { color: var(--down); transition: none; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid; }
.badge.long { color: var(--up); border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.1); }
.badge.short { color: var(--down); border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.1); }
.badge.liq { margin-left: 4px; color: var(--warn); border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.1); }

/* session range: low ── open ─●── high */
.range-h { min-width: 180px; }
.rw { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.bar { position: relative; flex: 1; min-width: 80px; height: 4px; border-radius: 2px; background: var(--line); }
.bar i { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.bar .open { width: 2px; height: 10px; background: var(--muted); opacity: .7; }
.bar .mark { width: 9px; height: 9px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 2px var(--panel); }
.bar .mark.up { background: var(--up); }
.bar .mark.down { background: var(--down); }

/* pager */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }

/* forms */
.ticket form { display: grid; gap: 10px; }
.ticket .row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
input, select {
  width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login form { display: flex; gap: 8px; }
button {
  background: var(--accent); color: #06111f; border: 0; border-radius: 6px; padding: 8px 12px;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:not(:disabled):hover { border-color: var(--muted); }
button.small { padding: 4px 9px; font-size: 12px; }
button.danger { background: var(--down); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0 0 8px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; align-items: center; }
.chipset { display: contents; }
.chip { background: var(--field); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.chip.on { color: var(--text); border-color: var(--accent); background: rgba(79,140,255,.15); }
.seg { display: flex; }
.seg button { flex: 1; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.seg button.on { position: relative; z-index: 1; }
.seg button.buy.on { background: rgba(34,197,94,.18); color: var(--up); border-color: var(--up); }
.seg button.sell.on { background: rgba(239,68,68,.18); color: var(--down); border-color: var(--down); }

/* inbox: one line per notification */
.inbox { list-style: none; margin: 0; padding: 0; }
.inbox li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline;
  padding: 6px 0 6px 10px; border-left: 3px solid var(--accent); border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.inbox li:last-child { border-bottom: 0; }
.inbox .ttl { font-weight: 600; white-space: nowrap; }
.inbox .msg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox .time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.inbox li.success { border-left-color: var(--up); }
.inbox li.warning { border-left-color: var(--warn); }
.inbox li.danger { border-left-color: var(--down); }

/* small screens */
/* columns drop by the card's width, not the viewport's: a table in the rail is narrower than one across the page */
@container (max-width: 900px) { .quotes .hide-lg { display: none; } }
@container (max-width: 800px) { .quotes .hide-sm { display: none; } }
@container (max-width: 620px) { .quotes .hide-md { display: none; } }
@container (max-width: 740px) { .positions .hide-sm { display: none; } }
@container (max-width: 640px) { .ledger .hide-sm { display: none; } }
@media (max-width: 720px) {
  .top { height: auto; min-height: 44px; padding: 8px 12px; flex-wrap: wrap; row-gap: 6px; }
  .right { gap: 8px; margin-left: auto; }
  .status .lbl, .who .lbl, button .lbl { display: none; }
  .pills { gap: 6px; }
  main { padding: 10px 12px; gap: 10px; }
  main.checking { height: auto; min-height: 60vh; }
  main.login { margin-top: 24px; }
  .layout { gap: 10px; }
  .card { padding: 10px 12px; }
  .banner { flex-wrap: wrap; }
  th, td { padding: 6px 6px; }
  .stat:last-child:nth-child(odd) { grid-column: span 2; border-left: 0; }
  .ticket .row { grid-template-columns: 1fr 100px; }
  button.small { min-height: 30px; }
  .pager { justify-content: space-between; }
  .toasts { right: 12px; left: 12px; bottom: 12px; width: auto; }
}

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; width: min(360px, calc(100vw - 32px)); }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
  padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35); cursor: pointer; animation: toast-in .2s ease-out;
}
.toast.success { border-left-color: var(--up); }
.toast.warning { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--down); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* confirmation dialog */
.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  width: min(420px, 100%); box-shadow: 0 16px 48px rgba(0,0,0,.5); animation: toast-in .15s ease-out;
}
.modal h3 { margin: 0 0 8px; font-size: 15px; }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* activity card: tabs in the header, one body at a time */
.card > header.tabs { justify-content: flex-start; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); margin: -2px 0 8px; }
.tab { background: none; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 10px 8px; margin-bottom: -1px; font-weight: 600; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { margin-left: 6px; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.tab.on .count { color: var(--text); }
header.tabs > .danger { margin-left: auto; } /* Close all sits at the right edge */
