/* Boards page: a header, then a grid of panel cards. Colours and spacing come from the Kadran tokens (both themes). */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: var(--fw-regular) var(--fs-sm)/1.35 var(--font-ui); font-feature-settings: "tnum" 1; }
body { display: flex; flex-direction: column; overflow-x: hidden; }

#bar { height: 48px; flex: none; display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-4); background: var(--surface); border-bottom: 1px solid var(--line); }
#bar .home { color: var(--text); font-weight: var(--fw-semibold); letter-spacing: .04em; text-decoration: none; }
#bar .home:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
#bar .page { font-weight: var(--fw-semibold); color: var(--text-2); }
.status { margin-left: auto; color: var(--text-2); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bb-pick, .bb-symbol label { display: flex; align-items: center; gap: var(--s-2); color: var(--text-2); font-size: var(--fs-xs); }
.bb-pick select, .bb-symbol input { height: 28px; background: var(--well); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 0 var(--s-3); font: inherit; font-size: var(--fs-sm); }
.bb-symbol input { width: 96px; text-transform: uppercase; }
.bb-pick select:focus-visible, .bb-symbol input:focus-visible, .bb-btn:focus-visible, .bb-key-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.bb-btn, .bb-key-btn { height: 28px; padding: 0 var(--s-3); background: var(--raised); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-xs); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.bb-btn:hover, .bb-key-btn:hover { border-color: var(--line-strong); }
.bb-seg { display: flex; gap: 2px; }
.bb-key-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

#app { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: var(--s-3); gap: var(--s-3); }
.bb-note { margin: 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text-2); }
.bb-note[data-kind="error"] { border-color: var(--danger); color: var(--text); }
#board { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }

/* The grid: --bb-cols × --bb-rows equal cells; a panel may span several (style grid-column / grid-row set by the engine). */
.bb-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(var(--bb-cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--bb-rows), minmax(var(--bb-row-min, 0px), 1fr)); }
.bb-panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: inset 0 1px 0 var(--hi); overflow: hidden; }
.bb-head { flex: none; display: flex; flex-wrap: wrap; row-gap: 4px; align-items: baseline; gap: var(--s-3); padding: var(--s-2) var(--s-4) 0; min-height: 26px; }
.bb-title { flex: 0 1 auto; margin: 0; font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: .02em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bb-sub { flex: 1 1 0; text-align: right; color: var(--text-3); font-size: var(--fs-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; }
.bb-link { color: var(--accent-text); font-size: 8px; }
.bb-body { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.bb-veil { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: var(--s-4); background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--text-3); font-size: var(--fs-xs); }
.bb-veil[data-kind="error"] { color: var(--danger); }

.bb-matrix, .bb-series { display: flex; flex-direction: column; height: 100%; }
.bb-plot { flex: 1; min-height: 0; position: relative; }
.bb-plot svg { display: block; }
.bb-dot, .bb-tile { cursor: pointer; }
.bb-dot:hover { stroke: var(--text); stroke-width: 1.5; }
.bb-tile:hover rect { stroke: var(--text); }
.bb-legend { flex: none; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); padding: 0 var(--s-4); font-size: var(--fs-label); color: var(--text-2); max-height: 36px; overflow: hidden; line-height: 1.5; }
.bb-legend:empty { display: none; }
.bb-key { display: inline-flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.bb-key i, .bb-dot-key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: var(--s-2); }
.bb-key b { color: var(--text); font-weight: var(--fw-semibold); font-family: var(--font-num); }
.bb-key em { font-style: normal; font-family: var(--font-num); }
.up { color: var(--up); } .down { color: var(--down); }
.bb-tip { position: absolute; z-index: 3; pointer-events: none; min-width: 120px; max-width: 220px; padding: var(--s-2) var(--s-3); background: var(--tip-bg, var(--raised)); color: var(--tip-text, var(--text)); border: 1px solid var(--line-strong); border-radius: var(--r-xs); font-size: var(--fs-label); line-height: 1.4; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.bb-tip b { display: block; margin-bottom: 2px; }
.bb-tip span { color: var(--tip-text-2, var(--text-2)); }

.bb-rank { display: flex; flex-direction: column; height: 100%; overflow: auto; padding: var(--s-1) var(--s-3) var(--s-3); }
.bb-row { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: var(--s-3); padding: 2px var(--s-2); background: none; border: 0; border-radius: var(--r-xs); color: var(--text); font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer; min-height: 22px; }
.bb-row:hover, .bb-row.on { background: var(--well); }
.bb-name { font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-track { height: 10px; background: transparent; position: relative; }
.bb-track i { position: absolute; left: 0; top: 1px; bottom: 1px; border-radius: 2px; }
.bb-val { text-align: right; font-family: var(--font-num); color: var(--text-2); }

.bb-table { height: 100%; overflow: auto; }
.bb-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.bb-table th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: var(--fw-regular); color: var(--text-3); padding: 0; border-bottom: 1px solid var(--line); }
.bb-table th button { all: unset; display: block; width: 100%; padding: var(--s-2) var(--s-3); cursor: pointer; color: inherit; white-space: nowrap; }
.bb-table th.on { color: var(--text); }
.bb-table th.num button { text-align: right; }
.bb-table td { padding: 3px var(--s-3); border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); white-space: nowrap; }
.bb-table td.num { text-align: right; font-family: var(--font-num); }
.bb-table td.sym { font-weight: var(--fw-semibold); }
.bb-table tbody tr { cursor: pointer; }
.bb-table tbody tr:hover, .bb-table tbody tr.on { background: var(--well); }

.bb-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--surface); }

/* Phones: panels stack in one column, each a readable height; the page scrolls. */
@media (max-width: 760px) {
  #bar { overflow-x: auto; gap: var(--s-3); }
  .status { display: none; }
  #board.bb-grid { display: flex; flex-direction: column; }
  .bb-panel { min-height: 320px; flex: none; }
  #app { padding: var(--s-2); overflow-y: auto; }
}

/* group panels (panels/groups.js) and the focus charts (focus.js) */
.bb-controls { display: flex; gap: var(--s-4); align-items: center; }
.bb-fplot { position: absolute; inset: 0; }
.bb-fplot svg { display: block; }
.bb-grank { position: absolute; inset: 0; overflow: auto; padding: var(--s-2) var(--s-4); }
.bb-grow { all: unset; box-sizing: border-box; display: grid; grid-template-columns: minmax(80px, 128px) 1fr 54px; align-items: center; gap: var(--s-3); width: 100%; min-height: 22px; padding: 0 var(--s-2); border-radius: var(--r-xs); font-size: var(--fs-xs); cursor: pointer; color: var(--text-2); }
.bb-grow:hover, .bb-grow.on { background: var(--well); }
.bb-grow.f, .bb-grow.on { color: var(--text); }
.bb-grow.on .bb-gname { font-weight: var(--fw-semibold); }
.bb-grow:focus-visible { box-shadow: var(--focus); }
.bb-gname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-gtrack { position: relative; height: 12px; }
.bb-gtrack i { position: absolute; top: 1px; bottom: 1px; border-radius: 2px; }
.bb-gtrack u { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-strong); }
.bb-gval { text-align: right; font-family: var(--font-num); }
.bb-gap { color: var(--text-3); text-align: center; font-size: var(--fs-label); line-height: 12px; }
.bb-mkt td { color: var(--text-2); font-style: italic; border-bottom: 1px solid var(--line-strong); }
.bb-table td.up { color: var(--up); } .bb-table td.down { color: var(--down); }
.bb-table tbody tr.on { background: var(--well); box-shadow: inset 2px 0 0 var(--accent); }
.bb-key-btn { white-space: nowrap; }
.bb-gtable table, .bb-table.bb-gtable table { width: max-content; min-width: 100%; }
.bb-table th button { white-space: nowrap; box-sizing: border-box; }
.bb-gtable td, .bb-gtable th button { padding-left: 6px; padding-right: 6px; }
.bb-gtable td { padding-top: 3px; padding-bottom: 3px; }

/* rotation board additions: header tools, sorted tiles, "newly rising" rows, explanation box */
.bb-tools { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.bb-mini-select { height: 28px; max-width: 150px; background: var(--well); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 0 var(--s-2); font: inherit; font-size: var(--fs-xs); }
.bb-mini-select:focus-visible { outline: none; box-shadow: var(--focus); }
.bb-info { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--raised); color: var(--text-2); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semibold); cursor: pointer; align-self: center; }
.bb-info:hover { color: var(--text); border-color: var(--text-2); }
.bb-explain { position: absolute; z-index: 5; left: var(--s-3); right: var(--s-3); top: var(--s-2); padding: var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0, 0, 0, .22); color: var(--text); font-size: var(--fs-xs); line-height: 1.5; }
.bb-explain[hidden] { display: none; }
.bb-explain p { margin: 0 0 var(--s-3); }
.bb-tiles { position: absolute; inset: 0; overflow: auto; padding: var(--s-2) var(--s-3) var(--s-3); display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); grid-auto-rows: 58px; gap: 4px; align-content: start; }
.bb-tile-card { all: unset; box-sizing: border-box; display: flex; flex-direction: column; justify-content: space-between; padding: 5px 7px; border-radius: 4px; border: 1px solid var(--surface); cursor: pointer; color: var(--text); overflow: hidden; }
.bb-tile-card:hover { border-color: var(--line-strong); }
.bb-tile-card.on { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.bb-tile-card:focus-visible { box-shadow: var(--focus); }
.bb-tn { font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bb-tv { font-family: var(--font-num); font-size: var(--fs-sm); }
.bb-tm { font-size: 9.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bb-movers .bb-mrow { grid-template-columns: minmax(70px, 116px) 64px 62px 1fr; min-height: 26px; }
.bb-spark { display: block; }
.bb-mrank { white-space: nowrap; font-family: var(--font-num); }
.bb-mrank small { color: var(--text-3); font-size: 9.5px; }
.bb-badge { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.bb-badge.up { color: var(--up); } .bb-badge.down { color: var(--down); } .bb-badge.info { color: var(--series-3); } .bb-badge.acc { color: var(--accent-text); }
.bb-empty { margin: var(--s-4); color: var(--text-3); font-size: var(--fs-xs); }
.bb-grow.pair { grid-template-columns: minmax(80px, 116px) 1fr 58px 54px; }
.bb-gpair.up { color: var(--up); } .bb-gpair.down { color: var(--down); }
.bb-gtrack .bb-ref { left: auto; width: 0; border-left: 2px dashed var(--text-2); background: none; top: -4px; bottom: -4px; z-index: 1; }

.bb-foot { flex: none; padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-label); text-align: center; background: var(--surface); }
