/* ZigiLab HFT Demo — Scientific dashboard theme (dark, data-viz oriented) */
:root {
    --bg: #080b12;
    --bg-2: #0c111c;
    --panel: #0f1726;
    --panel-2: #111b2e;
    --border: #1a2436;
    --border-2: #24314a;
    --text: #e8eef7;
    --muted: #8290a8;
    --muted-2: #56627c;
    --accent: #21e6c1;
    --accent-2: #4a90e2;
    --bid: #22c55e;
    --ask: #f43f5e;
    --bot: #fbbf24;
    --mid-line: #38bdf8;
    --fast-line: #fbbf24;
    --slow-line: #a78bfa;
    --target-line: #21e6c1;
    --warn: #f59e0b;
    --danger: #f43f5e;
    --grid-line: #16223a;
    --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
    background:
        linear-gradient(transparent 0, transparent calc(100% - 1px), #ffffff04 100%) 0 0 / 100% 28px,
        radial-gradient(1100px 540px at 82% -8%, #11203a 0%, var(--bg) 58%) fixed;
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    height: 100vh;          /* khóa đúng 1 viewport: chỉ bảng cuộn nội bộ, footer luôn ghim đáy */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ───────── Header ───────── */
.topbar {
    display: flex; align-items: center; gap: 22px;
    padding: 11px 20px;
    background: linear-gradient(180deg, #0c1422 0%, #090f1a 100%);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { display: flex; filter: drop-shadow(0 2px 8px #21e6c130); }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: .3px; }
.brand-sub { font-size: 10px; color: var(--accent); letter-spacing: 1.3px; text-transform: uppercase; }
.brand-logo { height: 28px; display: block; filter: drop-shadow(0 2px 10px #21e6c128); }
.brand-tag {
    font-size: 10px; color: var(--accent); letter-spacing: 1.4px; text-transform: uppercase;
    border-left: 1px solid var(--border-2); padding-left: 13px;
}
.title-block { border-left: 1px solid var(--border-2); padding-left: 22px; }
.title-block h1 { margin: 0; font-size: 15px; font-weight: 700; }
.title-block p { margin: 2px 0 0; font-size: 10.5px; color: var(--muted); letter-spacing: .2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.ex-badges { display: flex; flex-wrap: wrap; gap: 6px; max-width: 560px; justify-content: flex-end; }
.ex-badge {
    display: flex; align-items: center; gap: 5px;
    font-size: 10px; padding: 3px 8px; border-radius: 20px;
    background: var(--panel); border: 1px solid var(--border);
    text-transform: capitalize; color: var(--muted);
}
.ex-badge .dot { width: 7px; height: 7px; }
.ex-badge.live { color: var(--text); border-color: #1f7a4d55; }
.ex-badge.off { opacity: .5; }
.ex-badge.ex-more { color: var(--muted); border-style: dashed; cursor: default; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--bid); box-shadow: 0 0 8px var(--bid); }
.dot-off { background: var(--ask); box-shadow: 0 0 8px var(--ask); }
.dot-disabled { background: var(--muted-2); box-shadow: none; }

.conn { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.clock { font-family: var(--mono); font-size: 13px; letter-spacing: .5px; min-width: 74px; text-align: right; }

/* ───────── KPI ───────── */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; padding: 14px 20px 4px; }
.kpi {
    background: linear-gradient(180deg, var(--panel) 0%, #0b1320 100%);
    border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px;
    position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .5; }
.kpi-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .9px; }
.kpi-value { font-family: var(--mono); font-size: 23px; font-weight: 600; margin-top: 4px; display: flex; align-items: baseline; gap: 5px; }
.kpi-value small { font-size: 10.5px; color: var(--muted); font-weight: 400; }
.kpi-foot { font-size: 9.5px; color: var(--muted-2); margin-top: 3px; letter-spacing: .2px; }
#kpiLatency { color: var(--accent); }

/* ───────── Analytics ───────── */
.analytics { display: grid; grid-template-columns: 1fr 440px; gap: 11px; padding: 8px 20px 4px; align-items: stretch; }
.chart-card, .pie-card {
    background: linear-gradient(180deg, var(--panel) 0%, #0b1320 100%);
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
    min-width: 0;   /* để grid 1fr ghì kích thước, tránh thanh scroll (#chartScrollInner) làm card phình ngang */
    position: relative;
}
/* tooltip hover điểm trên chart */
.chart-tip { position: absolute; pointer-events: none; z-index: 6; background: #0b1422f2; border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 11px; font-family: var(--mono); white-space: nowrap; box-shadow: 0 4px 14px #0008; }
.chart-tip .ct-t { color: var(--muted-2); font-size: 10px; margin-bottom: 3px; }
.chart-tip .ct-r { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.chart-tip .ct-r b { color: var(--text); }
.chart-tip .ct-sw { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.chart-title { font-size: 13px; font-weight: 700; }
.chart-title #chartCoin { color: var(--accent); }
.chart-sub { display: block; font-size: 10px; color: var(--muted-2); margin-top: 2px; }
.chart-legend { display: flex; gap: 13px; flex-wrap: wrap; font-size: 10.5px; color: var(--muted); }
.chart-legend .lg { display: flex; align-items: center; gap: 5px; }
.chart-legend em { color: var(--muted-2); font-style: italic; }
.ln { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.ln-mid { border-color: var(--mid-line); }
.ln-fast { border-color: var(--fast-line); }
.ln-slow { border-color: var(--slow-line); }
.ln-target { border-color: var(--target-line); border-top-style: dashed; }
.ln-bid { border-color: #22c55e; }
.ln-ask { border-color: #f43f5e; }
.ln-basis { border-color: #f59e0b; }
.ln-skew { border-color: #c084fc; }
.chart-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.chart-tabs { display: inline-flex; gap: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
.chart-tabs .ctab { font-size: 10.5px; padding: 3px 11px; border: none; background: none; color: var(--muted); border-radius: 5px; cursor: pointer; font-family: inherit; }
.chart-tabs .ctab.on { background: var(--accent); color: #04121f; font-weight: 700; }
.chart-canvas { width: 100%; height: 200px; display: block; }   /* cao cố định, khớp chiều cao pie-card */
/* thanh cuộn ngang cho chart Basis (xem quá khứ) — chỉ hiện khi vượt cửa sổ */
.chart-scroll { overflow-x: auto; overflow-y: hidden; height: 11px; margin-top: 5px; }
.chart-scroll #chartScrollInner { height: 1px; }
.chart-scroll::-webkit-scrollbar { height: 9px; }
.chart-scroll::-webkit-scrollbar-thumb { background: #2a3a5a; border-radius: 5px; }
.chart-scroll::-webkit-scrollbar-thumb:hover { background: #3a4d72; }
.chart-scroll::-webkit-scrollbar-track { background: #0c1422; border-radius: 5px; }

/* Liquidity Share — pie cạnh Price Tracking (to, dễ nhìn) */
.pie-card { position: relative; display: flex; flex-direction: column; }
.pie-head { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.pie-title { font-size: 13px; font-weight: 700; }
.pie-sub { display: block; font-size: 10px; color: var(--muted-2); margin-top: 2px; }
.pie-body { display: flex; align-items: center; gap: 16px; flex: 1; min-height: 0; }
.pie-canvas { width: 200px; height: 200px; flex: none; cursor: crosshair; }
.pie-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; max-height: 206px; overflow-y: auto; }
.pie-leg { display: flex; align-items: center; gap: 8px; font-size: 11px; min-width: 0; }
.pie-leg .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.pie-leg .nm { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-leg .pct { margin-left: auto; font-family: var(--mono); color: var(--text); font-weight: 600; }
.pie-tip { position: absolute; pointer-events: none; z-index: 5; background: #0b1422f2; border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 11px; font-family: var(--mono); white-space: nowrap; box-shadow: 0 4px 14px #0008; }
.pie-tip b { color: var(--accent); }

/* ───────── Toolbar ───────── */
.toolbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px 6px; flex-wrap: wrap; }
.search { background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text); padding: 8px 12px; border-radius: 9px; font-size: 12.5px; width: 280px; outline: none; }
.search:focus { border-color: var(--accent); }
.legend { display: flex; gap: 15px; align-items: center; color: var(--muted); font-size: 11px; margin-left: auto; }
.legend .lg { display: flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw-bid { background: var(--bid); } .sw-ask { background: var(--ask); } .sw-bot { background: var(--bot); }
.view-tag b { color: var(--accent); text-transform: uppercase; }

/* ───────── Table ───────── */
.table-wrap { flex: 1; min-height: 0; overflow: auto; margin: 6px 14px 0; border: 1px solid var(--border); border-radius: 12px; background: #090e17cc; }
.grid { border-collapse: collapse; width: 100%; font-family: var(--mono); }
.grid thead th {
    position: sticky; top: 0; z-index: 3;
    background: #0c1422; color: var(--muted);
    font-family: var(--sans); font-weight: 600; font-size: 10px;
    text-transform: uppercase; letter-spacing: .5px;
    padding: 9px 11px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border-2);
}
.grid thead th .u { color: var(--muted-2); font-weight: 400; text-transform: none; }
.grid thead th.sortable { cursor: pointer; user-select: none; }
.grid thead th.sortable:hover { color: var(--text); background: #101c30; }
.grid thead th.sort-on { color: var(--accent); }
.grid thead th .sort-ar { font-size: 9px; font-weight: 700; }
.grid thead th.col-coin { text-align: center; }
.grid thead th.grp-ex { color: var(--muted-2); }
.grid thead th.grp-bot { color: var(--bot); }

.grid tbody td { padding: 6px 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid #101827; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: #111c2e; }
.grid tbody tr.sel { background: #13243c; box-shadow: inset 2px 0 0 var(--accent); }
.grid tbody tr.degraded { opacity: .45; }

.col-coin { text-align: left !important; position: sticky; left: 0; z-index: 2; background: #090e17; }
.grid tbody tr:hover .col-coin { background: #111c2e; }
.grid tbody tr.sel .col-coin { background: #13243c; }
.coin-cell { display: flex; align-items: center; gap: 8px; }
.coin-sym { font-family: var(--sans); font-weight: 700; font-size: 12.5px; }
.pin { cursor: pointer; color: var(--muted-2); font-size: 11px; }
.pin.on { color: var(--bot); }

.cell-2 { display: flex; flex-direction: column; line-height: 1.34; }
.cell-2 .bid { color: var(--bid); } .cell-2 .ask { color: var(--ask); }
.cell-2 .lvl { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.cell-2 .q { color: var(--muted-2); font-size: 11px; font-weight: 400; }
.px-na { color: var(--muted-2); }

td.col-mkt .mkt { color: var(--mid-line); font-weight: 600; }
td.col-combined { background: #15120955; }
.bot-bid { color: var(--bid); font-weight: 600; } .bot-ask { color: var(--ask); font-weight: 600; }

.spread-val { font-weight: 600; }
.spread-ok { color: var(--bid); } .spread-warn { color: var(--warn); } .spread-danger { color: var(--danger); }
.liq-val { font-family: var(--mono); font-weight: 600; } .liq-bid { color: var(--bid); } .liq-ask { color: var(--ask); }
.basis-val { font-family: var(--mono); font-weight: 600; }
.basis-val.dev-pos { color: var(--bid); } .basis-val.dev-neg { color: var(--ask); }
.mark-na { color: var(--muted-2); }
.mark-val { color: #b9c4ff; font-weight: 600; }
.freq-val { color: var(--accent-2); }
.age-fresh { color: var(--bid); } .age-stale { color: var(--warn); }
.spark { width: 86px; height: 26px; display: block; margin-left: auto; }

@keyframes flashUp { from { background: #16a34a55; } to { background: transparent; } }
@keyframes flashDown { from { background: #e11d4855; } to { background: transparent; } }
.flash-up { animation: flashUp .4s ease-out; }
.flash-down { animation: flashDown .4s ease-out; }

body.view-combined .col-ex { display: none; }

.empty { padding: 40px; text-align: center; color: var(--muted); font-family: var(--sans); }
.footer { display: flex; justify-content: space-between; align-items: center; padding: 9px 20px; font-size: 10.5px; color: var(--muted-2); border-top: 1px solid var(--border); margin-top: 8px; }
.foot-brand { display: flex; align-items: center; gap: 7px; }
.foot-mark { height: 15px; opacity: .85; }

.table-wrap::-webkit-scrollbar { height: 11px; width: 11px; }
.table-wrap::-webkit-scrollbar-thumb { background: #223150; border-radius: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .analytics { grid-template-columns: 1fr; }
}
