/* Live price board (public/board.js). Colours follow Vietnamese boards: ceiling purple, floor cyan, reference yellow. */
/* Dark board: an opaque near-black ground and brighter price colours, so the page glow never shows through the numbers. */
:root { --ceil: #ff6bff; --floor: #38e1ff; --ref: #ffd426; --up: #22e584; --down: #ff5252; --board-bg: #070b10; --board-line: rgba(255, 255, 255, 0.12); --board-head: #cbd2dc; --board-zebra: rgba(255, 255, 255, 0.03); }
:root[data-theme='light'] { --ceil: #a21caf; --floor: #0891b2; --ref: #a16207; --board-bg: #ffffff; --board-line: #dde3ea; --board-head: #374151; --board-zebra: #f7f9fb; }

.t-up { color: var(--up); }
.t-down { color: var(--down); }
.t-ref { color: var(--ref); }
.t-ceil { color: var(--ceil); }
.t-floor { color: var(--floor); }

/* Index cards fill the row and read in three lines: name + breadth, value + change, value traded + foreign net. */
.indexes { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin-bottom: 14px; }
.indexes__card { display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'name breadth' 'value chg' 'gtgd nn'; align-items: baseline; gap: 2px 12px; padding: 8px 12px; border: 1px solid var(--board-line); border-radius: var(--radius-control); background: var(--board-bg); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.indexes__name { grid-area: name; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.indexes__value { grid-area: value; font-size: 20px; font-weight: 700; line-height: 1.25; }
.indexes__chg { grid-area: chg; justify-self: end; }
.indexes__gtgd { grid-area: gtgd; }
.indexes__nn { grid-area: nn; justify-self: end; }
.indexes__breadth { grid-area: breadth; justify-self: end; display: flex; gap: 10px; white-space: nowrap; }
.board-mark { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin: 6px 0 0; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.board-mark img { width: 14px; height: 14px; }

.board-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.board-tabs .chip { height: 34px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; }
.board-tabs .chip.is-active { border-color: var(--accent); color: var(--accent); background: var(--surface-highlight); }
/* Opaque select and options: with the translucent surface, Windows drew the open list white under light text. */
.board-tabs__select { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-solid); color: var(--text); }
.board-tabs__select option { background: var(--surface-solid); color: var(--text); }
.board-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.board-tools:empty { display: none; }
.board-tools__input { height: var(--control-h); min-width: 240px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--bg); color: var(--text); }

/* Sans-serif semibold with tabular figures: thin monospace strokes blurred on dark screens. */
.board { width: 100%; border-collapse: collapse; background: var(--board-bg); font: 600 13.5px/1.3 "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif; font-variant-numeric: tabular-nums; }
.board th { padding: 6px 8px; background: var(--surface-solid); color: var(--board-head); font: 700 11px/1.2 "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif; text-transform: uppercase; text-align: center; border: 1px solid var(--board-line); white-space: nowrap; }
.board td { padding: 6px 8px; text-align: right; border: 1px solid var(--board-line); white-space: nowrap; }
/* Zebra rows and hover tint the cells; the sticky symbol cell stays opaque so scrolled columns never show through it. */
@media (min-width: 641px) { .board tbody tr:nth-child(even) td:not(.board__sym) { background-color: var(--board-zebra); } }
/* Touch screens keep :hover after a tap, which left a highlighted card behind. */
@media (hover: hover) { .board tbody tr:hover td:not(.board__sym) { background-color: var(--surface-highlight); } }
.board .board__sym { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--board-bg); }
.board td.board__sym .symbol { text-decoration: none; }
.board td.board__sym.t-up .symbol { color: var(--up); }
.board td.board__sym.t-down .symbol { color: var(--down); }
.board td.board__sym.t-ref .symbol { color: var(--ref); }
.board td.board__sym.t-ceil .symbol { color: var(--ceil); }
.board td.board__sym.t-floor .symbol { color: var(--floor); }
.board__remove, .board__heat { margin-left: 6px; }
.board__heat { font-size: 11px; font-weight: 600; color: var(--gold); }
.board td.board__price { font-weight: 700; }
.board td.board__tier { text-align: left; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.board td.board__tier.is-in { color: var(--up); font-weight: 600; }
.board td.board__tier.is-locked { color: var(--gold); }
.board .flash-up, .board .flash-down { animation-duration: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .board .flash-up, .board .flash-down { animation: none; }
}

/* Phones: one card per symbol (price and change, best bid/ask, high/low, volume and foreign flow, tier); deeper book levels and ref/ceiling/floor are dropped, their colours stay on the price. */
@media (max-width: 640px) {
  .indexes { display: flex; overflow-x: auto; scrollbar-width: none; gap: 8px; }
  .indexes__card { flex: 0 0 236px; padding: 7px 10px; font-size: 12px; }
  .indexes__breadth { gap: 6px; }
  .indexes__value { font-size: 18px; }
  .board-tools__input { min-width: 0; flex: 1; }
  .board-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .board-tabs .chip, .board-tabs__select { flex: none; }
  #boardWrap { overflow: visible; }
  .board, .board tbody { display: block; }
  .board thead { display: none; }
  .board tbody tr { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr) minmax(0, 1.25fr) minmax(0, 0.75fr); grid-template-areas: 'sym chg pct price' 'b1p b1q a1p a1q' 'high high low low' 'total total foreign foreign' 'tier tier tier tier'; gap: 4px 8px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--board-line); border-radius: var(--radius-control); background: var(--board-bg); }
  .board { background: none; }
  .board td { padding: 0; border: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; }
  .board td[data-k] { display: none; }
  .board .board__sym { position: static; background: none; }
  .board td[data-k='sym'] { display: block; grid-area: sym; font-size: 16px; font-weight: 700; }
  .board td[data-k='price'] { display: block; grid-area: price; font-size: 16px; text-align: right; }
  .board td[data-k='change'] { display: block; grid-area: chg; text-align: right; font-size: 13px; align-self: center; }
  .board td[data-k='pct'] { display: block; grid-area: pct; text-align: right; font-size: 13px; align-self: center; }
  .board td[data-k='b1p'] { display: block; grid-area: b1p; font-size: 12px; }
  .board td[data-k='b1q'] { display: block; grid-area: b1q; font-size: 12px; text-align: right; }
  .board td[data-k='a1p'] { display: block; grid-area: a1p; font-size: 12px; }
  .board td[data-k='a1q'] { display: block; grid-area: a1q; font-size: 12px; text-align: right; }
  .board td[data-k='high'] { display: block; grid-area: high; font-size: 12px; }
  .board td[data-k='low'] { display: block; grid-area: low; font-size: 12px; }
  .board td[data-k='total'] { display: block; grid-area: total; font-size: 12px; }
  .board td[data-k='foreign'] { display: block; grid-area: foreign; font-size: 12px; }
  .board td[data-k='tier'] { display: block; grid-area: tier; font-size: 12px; }
  .board td[data-k='tier']:empty, .board td[data-k='foreign']:empty { display: none; }
  .board td[data-k='b1p']::before { content: 'Mua '; color: var(--text-muted); }
  .board td[data-k='a1p']::before { content: 'Bán '; color: var(--text-muted); }
  .board td[data-k='high']::before { content: 'Cao '; color: var(--text-muted); }
  .board td[data-k='low']::before { content: 'Thấp '; color: var(--text-muted); }
  .board td[data-k='total']::before { content: 'Tổng KL '; color: var(--text-muted); }
  .board td[data-k='foreign']::before { content: 'NN ròng '; color: var(--text-muted); }
  .board td[data-k='tier']::before { content: 'Tầng: '; color: var(--text-muted); }
}
