/* ============================================================================
   Design tokens — ngôn ngữ thị giác Binance Futures.

   Bảng màu lấy đúng token của Binance: nền #0B0E11, panel #181A20,
   viền #2B3139, chữ #EAECEF, long #0ECB81, short #F6465D.

   Nguyên tắc màu:
   - --action  : VÀNG BINANCE #FCD535 — màu CỐ ĐỊNH cho mọi nút hành động chính
                 (chữ tối trên vàng, đúng chuẩn nút Binance). Không đổi theo account.
   - --accent  : màu ĐỊNH DANH account. CHỈ dùng cho chrome (dot, viền chip tài
                 khoản, strip, viền trái thẻ account). Tab và gạch chân active dùng
                 --action cho đúng Binance.
   - --long/--short/--warn/--info/--rest : màu TRẠNG THÁI, cố định, có bản riêng
     cho từng theme để đạt WCAG AA (>= 4.5:1 cho chữ thường) — mọi cặp đã đo.
   ========================================================================= */
:root {
  /* --- dark (mặc định) --- */
  --bg: #0B0E11;
  --chrome: #181A20;
  --panel: #181A20;
  --panel-2: #1E2329;
  --panel-3: #2B3139;

  --ink: #EAECEF;          /* 14.7:1 trên panel */
  --ink-2: #B7BDC6;        /*  9.2:1 */
  --muted: #909AA8;        /*  5.6:1 trên panel-2, 4.6:1 trên panel-3 */

  --line: #2B3139;
  --line-2: #363A45;

  /* nút hành động — VÀNG BINANCE, cố định, không phụ thuộc account */
  --action: #FCD535;       /* 12.2:1 với --action-ink, 12.2:1 trên panel */
  --action-ink: #181A20;   /* chữ tối trên vàng — đúng chuẩn nút Binance */
  --action-hover: #FFE066;
  --action-soft: rgba(252, 213, 53, .16);

  /* trạng thái — bản dark */
  --long: #0ECB81;         /*  8.2:1 */
  --long-ink: #0ECB81;     /* 6.4:1 trên nền long-soft */
  --long-soft: rgba(14, 203, 129, .14);
  --short: #F6465D;        /*  4.9:1 */
  --short-ink: #F75167;    /* 4.5:1 trên nền short-soft */
  --short-soft: rgba(246, 70, 93, .14);
  --warn: #F0B90B;         /*  9.7:1 */
  --warn-ink: #F0B90B;     /* 7.3:1 */
  --warn-soft: rgba(240, 185, 11, .14);
  --info: #4D93FF;         /*  5.7:1 */
  --info-ink: #4D93FF;     /* 4.7:1 */
  --info-soft: rgba(77, 147, 255, .14);
  --rest: #4D93FF;
  --rest-ink: #4D93FF;
  --rest-soft: rgba(77, 147, 255, .14);

  /* màu định danh account — chỉ dùng cho chrome, đã đo >= 4.5:1 trên panel */
  --acct-1: #0891B2;
  --acct-2: #E0478B;
  --acct-3: #9965F1;

  --accent: var(--acct-1);
  --accent-soft: rgba(8, 145, 178, .16);

  --scrim: rgba(2, 5, 9, .72);
  --shadow: 0 12px 36px -18px rgba(0, 0, 0, .9);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .9);
  --radius: 4px;          /* Binance dùng góc vuông hơn */
  color-scheme: dark;
}

/* --- light: kích hoạt bằng nút theme, hoặc theo hệ thống nếu chưa chọn --- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #FAFAFA;
    --chrome: #FFFFFF;
    --panel: #FFFFFF;
    --panel-2: #F5F5F5;
    --panel-3: #EAECEF;
    --ink: #1E2329;
    --ink-2: #474D57;
    --muted: #626B78;      /* 5.4:1 trên panel, 5.0 trên panel-2, 4.6 trên panel-3 */
    --line: #EAECEF;
    --line-2: #D9DBDF;
    --action: #B8860B;
    --action-ink: #181A20;
    --action-hover: #CE9A19;
    --action-soft: rgba(184, 134, 11, .14);
    --long: #098655;
    --long-ink: #087B4E;
    --long-soft: rgba(9, 134, 85, .12);
    --short: #D63D51;
    --short-ink: #C23749;
    --short-soft: rgba(214, 61, 81, .12);
    --warn: #927107;
    --warn-ink: #866806;
    --warn-soft: rgba(146, 113, 7, .12);
    --info: #3D74C9;
    --info-ink: #386BBA;
    --info-soft: rgba(61, 116, 201, .12);
    --rest: #3D74C9;
    --rest-ink: #386BBA;
    --rest-soft: rgba(61, 116, 201, .12);
    --acct-1: #07819E;
    --acct-2: #DB2777;
    --acct-3: #7C3AED;
    --accent: var(--acct-1);
    --accent-soft: rgba(7, 129, 158, .12);
    --scrim: rgba(12, 17, 22, .42);
    --shadow: 0 1px 2px rgba(12, 17, 22, .06), 0 10px 26px -18px rgba(12, 17, 22, .35);
    --shadow-lg: 0 24px 60px -20px rgba(12, 17, 22, .35);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #FAFAFA;
  --chrome: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #F5F5F5;
  --panel-3: #EAECEF;
  --ink: #1E2329;
  --ink-2: #474D57;
  --muted: #626B78;
  --line: #EAECEF;
  --line-2: #D9DBDF;
  --action: #B8860B;
  --action-ink: #181A20;
  --action-hover: #CE9A19;
  --action-soft: rgba(184, 134, 11, .14);
  --long: #098655;
  --long-ink: #087B4E;
  --long-soft: rgba(9, 134, 85, .12);
  --short: #D63D51;
  --short-ink: #C23749;
  --short-soft: rgba(214, 61, 81, .12);
  --warn: #927107;
  --warn-ink: #866806;
  --warn-soft: rgba(146, 113, 7, .12);
  --info: #3D74C9;
  --info-ink: #386BBA;
  --info-soft: rgba(61, 116, 201, .12);
  --rest: #3D74C9;
  --rest-ink: #386BBA;
  --rest-soft: rgba(61, 116, 201, .12);
  --acct-1: #07819E;
  --acct-2: #DB2777;
  --acct-3: #7C3AED;
  --accent: var(--acct-1);
  --accent-soft: rgba(7, 129, 158, .12);
  --scrim: rgba(12, 17, 22, .42);
  --shadow: 0 1px 2px rgba(12, 17, 22, .06), 0 10px 26px -18px rgba(12, 17, 22, .35);
  --shadow-lg: 0 24px 60px -20px rgba(12, 17, 22, .35);
  color-scheme: light;
}
:root[data-acct="a2"] { --accent: var(--acct-2); --accent-soft: rgba(224, 71, 139, .16); }
:root[data-acct="a3"] { --accent: var(--acct-3); --accent-soft: rgba(153, 101, 241, .16); }
:root[data-acct="a1"] { --accent: var(--acct-1); }
:root[data-theme="light"][data-acct="a2"] { --accent-soft: rgba(219, 39, 119, .12); }
:root[data-theme="light"][data-acct="a3"] { --accent-soft: rgba(124, 58, 237, .12); }

/* ============================ base ============================ */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.px, .v, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace; }
.spacer { flex: 1; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; border-radius: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================ chrome ============================ */
/* ============================ khung: sidebar + nội dung ============================ */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.content { display: flex; flex-direction: column; min-width: 0; }

.sidebar {
  background: var(--chrome); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.side-brand .mark { font-weight: 700; font-size: 16px; letter-spacing: .02em; }
.side-brand .mark span { color: var(--action); }
.side-brand .sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.navlist { display: flex; flex-direction: column; padding: 8px 8px 12px; gap: 2px; }
.navgroup {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 6px;
}
.navgroup:first-child { padding-top: 6px; }
.navitem {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: 0; border-radius: 4px; padding: 9px 10px;
  font-size: 13px; font-weight: 500; color: var(--ink-2); text-align: left;
}
.navitem:hover { background: var(--panel-2); color: var(--ink); }
.navitem[aria-current="page"] { background: var(--action-soft); color: var(--action); font-weight: 600; }
.navitem .ic { width: 15px; height: 15px; flex: none; }
.navitem .count {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--panel-2); border-radius: 8px; padding: 1px 7px;
}
.navitem[aria-current="page"] .count { color: var(--action); background: transparent; }
.navitem .count.alert { color: var(--short-ink); background: var(--short-soft); }
.navitem:disabled { opacity: .5; cursor: not-allowed; }
.navsub { display: flex; flex-direction: column; padding-left: 14px; }
.navsub .navitem { font-size: 12px; padding: 7px 10px; }
.side-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }

/* ============================ thanh trên ============================ */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--chrome); border-bottom: 1px solid var(--line);
  padding: 7px 16px; min-height: 48px; position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding-right: 14px; margin-right: 4px; border-right: 1px solid var(--line); }
.brand .mark { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand .mark span { color: var(--warn); }
.brand .sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.acctwrap { position: relative; display: flex; }
.acctbtn {
  display: flex; align-items: center; gap: 9px; background: var(--panel-2);
  border: 2px solid var(--accent); border-radius: 4px; padding: 4px 8px 4px 10px;
}
.acctbtn .who { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.acctbtn .who b { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.acctbtn .who span { font-size: 11px; color: var(--muted); }
.acctdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); }
.acctstrip { height: 3px; background: var(--accent); }
.select {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  appearance: none; border: 0; background: transparent; cursor: pointer;
}
.caret { color: var(--muted); font-size: 10px; align-self: center; padding-right: 4px; }

.iconbtn {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 4px;
  height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2);
}
.iconbtn:hover { border-color: var(--action); color: var(--action); }
.iconbtn[aria-pressed="true"] { border-color: var(--action); color: var(--action); background: var(--action-soft); }
.iconbtn.danger { color: var(--short); border-color: var(--short); }
.iconbtn.danger:hover { background: var(--short); color: #fff; }
.ic { width: 14px; height: 14px; flex: none; }

/* chip trạng thái kết nối sàn — cho biết app đang mô phỏng hay nói chuyện thật với Binance */
.linkchip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 4px 9px; border-radius: 20px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--ink-2); white-space: nowrap;
}
.linkchip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.linkchip.off { color: var(--muted); }
.linkchip.off .dot { background: var(--muted); }
.linkchip.wait { border-color: var(--warn); color: var(--warn-ink); background: var(--warn-soft); }
.linkchip.wait .dot { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.linkchip.on { border-color: var(--info); color: var(--info-ink); background: var(--info-soft); }
.linkchip.on .dot { background: var(--info); }
.linkchip.live { border-color: var(--warn); color: var(--warn-ink); background: var(--warn-soft); }
.linkchip.live .dot { background: var(--warn); }

/* banner trạng thái hệ thống (mất kết nối / tạm dừng) */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  font-size: 12px; border-bottom: 1px solid var(--line);
}
.banner.offline { background: var(--short-soft); color: var(--short-ink); }
.banner.paused { background: var(--warn-soft); color: var(--warn-ink); }
.banner .ic { width: 15px; height: 15px; }
.banner b { font-weight: 600; }
.banner .btn { margin-left: auto; height: 26px; }

.wrap { padding: 0 16px 64px; width: 100%; }

/* thanh cuộn mảnh, tối — Binance không dùng thanh cuộn mặc định của hệ điều hành */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* ============================ risk strip ============================ */
.riskbar {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(250px, 1.3fr);
  background: var(--panel); border: 1px solid var(--line); border-top: 0;
  /* Binance: thanh tài sản là dải phẳng chạy hết chiều ngang, không bo góc */
  border-radius: 0;
}
.metric { padding: 10px 16px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric .k { font-size: 11px; color: var(--muted); }
.metric .v { font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.metric .n { font-size: 11px; color: var(--muted); }
.metric .v.pos { color: var(--long); }
.metric .v.neg { color: var(--short); }
.metric .n .sep { opacity: .55; }
.bar { height: 4px; border-radius: 2px; background: var(--panel-3); overflow: hidden; margin: 7px 0 5px; }
.bar i { display: block; height: 100%; border-radius: 2px; background: var(--long); transition: width .4s ease; }
.bar.mid i { background: var(--warn); }
.bar.high i { background: var(--short); }

/* ============================ tabs ============================ */
.nav {
  display: flex; align-items: stretch; overflow-x: auto;
  /* Binance: dải chỉ số → thanh tab → nội dung là MỘT khối liền mạch */
  background: var(--panel); border: 1px solid var(--line); border-top: 0;
  border-radius: 0;
}
.nav button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 16px;
  font-size: 13px; font-weight: 500; color: var(--muted); display: flex; align-items: center;
  gap: 7px; white-space: nowrap;
}
.nav button:hover { color: var(--ink); }
.nav button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--action); }
.nav .count { font-size: 13px; color: inherit; }
.nav .count::before { content: "("; }
.nav .count::after { content: ")"; }
.nav .count.alert { color: var(--short-ink); font-weight: 600; }

/* ============================ toolbar ============================ */
/* Binance: tiêu đề mục và bảng là MỘT khối — header dính liền thân, không phải
   hai thẻ rời rồi ghép bằng khoảng trắng. Chỉ áp khi header thật sự có bảng theo sau. */
.toolrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 0 12px; }
.sechead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 0 10px; }
.sechead:has(+ .tablewrap),
.sechead:has(+ .toolrow + .tablewrap) {
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 11px 16px; margin-top: 14px;
}
/* dải lọc nằm trong header của khối, không phải một dải rời */
.sechead:has(+ .toolrow + .tablewrap) + .toolrow {
  background: var(--panel); border: 1px solid var(--line); border-top: 0; border-bottom: 0;
  padding: 0 16px 11px; margin: 0;
}
.sechead:has(+ .tablewrap) + .tablewrap,
.sechead:has(+ .toolrow + .tablewrap) + .toolrow + .tablewrap {
  border-radius: 0 0 var(--radius) var(--radius);
}
.sechead h2 { font-size: 14px; }
.sechead .note { font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: transparent; border: 1px solid var(--line-2); border-radius: 4px;
  height: 28px; padding: 0 12px; font-size: 12px; color: var(--ink-2);
}
.chip:hover { color: var(--ink); border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--action-soft); border-color: var(--action); color: var(--action); }
.hint { font-size: 12px; color: var(--muted); }
.hint b { color: var(--ink-2); font-weight: 550; }
.miniStats { display: flex; gap: 15px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.miniStats b { color: var(--ink); font-weight: 600; font-size: 13px; }

/* ============================ chart cặp ============================ */
.chartpanel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: 16px; overflow: hidden;
}
.cp-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.cp-pair { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.cp-last { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cp-chg { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cp-chg.pos { color: var(--long); }
.cp-chg.neg { color: var(--short); }
.cp-ivs { display: flex; gap: 4px; }
.cp-ivs button {
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  height: 26px; padding: 0 8px; font-size: 12px; font-weight: 500; color: var(--muted);
}
.cp-ivs button:hover { color: var(--ink); background: var(--panel-2); }
.cp-ivs button[aria-pressed="true"] { background: var(--action-soft); border-color: var(--action); color: var(--action); }
.cp-note { font-size: 11px; color: var(--muted); }
.cp-note.err { color: var(--short-ink); }
.cp-x {
  background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1;
  padding: 2px 6px; border-radius: 3px;
}
.cp-x:hover { color: var(--ink); background: var(--panel-2); }

/* thanh công cụ: loại chart, chỉ báo, pane, thang, hành động */
.cp-tools {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.cp-tbtn {
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  height: 26px; padding: 0 9px; font-size: 12px; font-weight: 500; color: var(--ink-2);
}
.cp-tbtn:hover { color: var(--ink); background: var(--panel-3); }
.cp-tbtn.on, .cp-tbtn[aria-pressed="true"] { background: var(--action-soft); border-color: var(--action); color: var(--action); }
.cp-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 3px; }
.cp-hint { font-size: 11px; color: var(--muted); }
.cp-menu { position: relative; display: flex; }
.cp-pop {
  position: absolute; left: 0; top: calc(100% + 4px); min-width: 168px; z-index: 50;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column;
}
.cp-pop.hidden { display: none; }
.cp-pop button {
  background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 3px;
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.cp-pop button:hover { background: var(--panel-3); color: var(--ink); }
.cp-pop button.on { color: var(--action); font-weight: 600; }
.cp-pop button.on::after { content: " ✓"; }

.cp-body { height: 340px; }
.cp-body canvas { width: 100%; height: 100%; display: block; touch-action: none; }
/* toàn màn hình: panel tự lo nền, canvas giãn hết */
.chartpanel:fullscreen { display: flex; flex-direction: column; background: var(--panel); border: 0; border-radius: 0; margin: 0; }
.chartpanel:fullscreen .cp-body { flex: 1; height: auto; }
@media (max-width: 860px) {
  .cp-body { height: 240px; }
  .cp-head, .cp-tools { gap: 6px; padding: 8px 12px; }
  .cp-hint { display: none; }
}
/* bấm được vào symbol để mở chart */
.pair[data-chart-pair] { cursor: pointer; border-bottom: 1px dashed transparent; }
.pair[data-chart-pair]:hover { color: var(--action); border-bottom-color: var(--action); }
.pair[data-chart-pair]:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }
.pair.dang-xem { color: var(--action); }

/* ==================== panel chi tiết + bảng tham số tín hiệu ==================== */
/* Bảng để QUÉT, panel phải để ĐỌC đủ tham số model gửi. */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.work > div { min-width: 0; }
.detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: 14px; overflow: hidden;
}
.detail .head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.dhead { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.dhead .pair { font-size: 14px; font-weight: 600; }
.detail .body { padding: 14px; display: flex; flex-direction: column; gap: 16px; }
.dsec { display: flex; flex-direction: column; gap: 6px; }
.dsec > .t {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: .02em; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; line-height: 1.6; }
.kv .k { color: var(--muted); }
.kv b { font-weight: 600; }
.kv.total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.acctline { display: flex; align-items: baseline; gap: 7px; font-size: 12px; line-height: 1.6; flex-wrap: wrap; }
.acctline .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }
.acctline .nm { color: var(--ink-2); }
.acctline b { font-weight: 600; margin-left: auto; }
.acctline .sub { flex-basis: 100%; margin: 0; }

/* bảng tham số: nhãn | giá trị | ghi chú nguồn */
.paramtab { display: flex; flex-direction: column; }
.paramtab .pr {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.5;
}
.paramtab .pr:last-child { border-bottom: 0; }
.paramtab .pk { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.paramtab .pv { text-align: right; font-variant-numeric: tabular-nums; }
.paramtab .pn { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.w { color: var(--warn-ink); font-weight: 600; }

/* phiếu phân bổ tài khoản ở tầng duyệt cuối */
.allocrow {
  display: grid; grid-template-columns: 1fr; gap: 5px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.allocrow:last-of-type { border-bottom: 0; }
.allocrow.off { opacity: .55; }
.allocpick { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.allocpick .nm { color: var(--ink-2); }
.allocpick b { margin-left: auto; font-weight: 600; }
.allocin { display: flex; align-items: center; gap: 6px; }
.allocin .unit { font-size: 11px; color: var(--muted); width: 34px; flex: none; text-align: right; }
.allocin .cellinput { max-width: none; flex: 1; }
.allocnote { font-size: 11px; color: var(--muted); line-height: 1.5; }
.allocnote .w { font-weight: 600; }
@media (max-width: 1100px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .detail { margin-top: 12px; }
}

/* ============================ table ============================ */
/* Bảng dữ liệu kiểu Binance: KHÔNG kẻ ô dọc, KHÔNG kẻ sọc; phân tách bằng
   đường ngang mảnh + hover. Đây là khác biệt lớn nhất so với bảng kiểu bảng tính. */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
thead th {
  text-align: left; font-size: 12px; font-weight: 400; color: var(--muted);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  background: transparent; white-space: nowrap; position: relative; user-select: none;
}
thead th[data-sort] { cursor: pointer; }
thead th[data-sort]:hover { color: var(--ink); }
thead th .sortind { display: inline-block; width: 10px; margin-left: 4px; font-size: 10px; color: var(--action); opacity: 0; }
thead th .sortind::after { content: "▲"; }
thead th.num .sortind { margin: 0 4px 0 0; }
thead th[data-dir] .sortind { opacity: 1; }
thead th[data-dir="desc"] .sortind::after { content: "▼"; }
thead th[data-sort]:hover .sortind { opacity: .5; }
thead th[data-dir]:hover .sortind { opacity: 1; }
.col-resizer { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 3; touch-action: none; }
.col-resizer::after { content: ""; position: absolute; top: 22%; bottom: 22%; left: 3px; width: 1px; background: transparent; }
.col-resizer:hover::after, .col-resizer.active::after { background: var(--action); width: 2px; left: 2px; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
table.fixedcols { table-layout: fixed; }
table.fixedcols td, table.fixedcols th { overflow: hidden; text-overflow: ellipsis; }
/* ô nhập phải co được theo cột đã kéo, nếu không giá trị bị cắt cụt */
table.fixedcols .cellinput { min-width: 0; }
th.num, td.num { text-align: right; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody td:has(.actions) { white-space: nowrap; width: 1%; }
tbody td:first-child { min-width: 150px; }
tbody tr.row:last-child td { border-bottom: 0; }
tbody tr.row:hover td { background: var(--panel-2); }
/* Binance để bảng PHẲNG: ý nghĩa do badge và màu chênh lệch mang, nền dòng chỉ
   phủ một lớp rất nhạt để không phá cảm giác nền tối liền mạch. */
tbody tr.row.stale td { background: color-mix(in srgb, var(--warn-soft) 26%, var(--panel)); }
tbody tr.row.fav td { background: color-mix(in srgb, var(--long-soft) 22%, var(--panel)); }
tbody tr.row.stale:hover td { background: color-mix(in srgb, var(--warn-soft) 44%, var(--panel)); }
tbody tr.row.fav:hover td { background: color-mix(in srgb, var(--long-soft) 40%, var(--panel)); }
tbody tr.row.blocked td { opacity: .62; }
td.num > .cellinput { min-width: 104px; }
.symcap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.symcap:empty { display: none; }
.cellnote { display: block; font-size: 11px; line-height: 1.35; margin-top: 4px; color: var(--muted); white-space: nowrap; }
.cellnote:empty { display: none; }
.cellnote.err { color: var(--short-ink); font-weight: 500; }
.cellnote.ok { color: var(--long-ink); }
.cellnote b { color: var(--ink-2); font-weight: 600; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.empty span { display: block; font-size: 12px; }
.empty .btn { margin-top: 12px; }
.emptyrow:hover td { background: transparent !important; }

/* ============================ cell content ============================ */
.sym { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pair { font-weight: 600; font-size: 13px; letter-spacing: .01em; }
.model { font-size: 11px; color: var(--muted); margin-top: 3px; }
.modeltag {
  display: inline-block; font-family: "IBM Plex Mono", monospace; font-size: 10px;
  border: 1px solid var(--line-2); border-radius: 3px; padding: 0 5px; color: var(--ink-2); margin-right: 5px;
}
.side { font-size: 10px; font-weight: 700; letter-spacing: .05em; border-radius: 3px; padding: 1px 6px; }
.side.long { background: var(--long-soft); color: var(--long-ink); }
.side.short { background: var(--short-soft); color: var(--short-ink); }
.levchip {
  font-size: 11px; font-weight: 600; border: 1px solid var(--line-2); background: var(--panel-2);
  border-radius: 3px; padding: 2px 7px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px;
}
.levchip .mm { font-size: 10px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
button.levchip:hover { border-color: var(--action); color: var(--action); }
button.levchip:hover .mm { color: var(--action); }
td.px { font-size: 13px; }
.sub { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.pnl { font-variant-numeric: tabular-nums; font-weight: 600; }
.pnl.pos { color: var(--long); }
.pnl.neg { color: var(--short); }
.pnlbreak { cursor: help; border-bottom: 1px dashed currentColor; }

/* delta: màu theo HƯỚNG có lợi, không theo dấu (sửa issue V2) */
.delta { font-variant-numeric: tabular-nums; font-weight: 500; }
.delta.good { color: var(--long); }
.delta.bad { color: var(--short); }
.delta.flat { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 550; border-radius: 2px; padding: 2px 7px; white-space: nowrap; }
.badge.long { background: var(--long-soft); color: var(--long-ink); }
.badge.short { background: var(--short-soft); color: var(--short-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.info { background: var(--info-soft); color: var(--info-ink); }
.badge.rest { background: var(--rest-soft); color: var(--rest-ink); }
.badge.ghost { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.riskpill { font-size: 12px; font-weight: 600; border-radius: 3px; padding: 2px 6px; }
.riskpill.ok { background: var(--long-soft); color: var(--long-ink); }
.riskpill.mid { background: var(--warn-soft); color: var(--warn-ink); }
.riskpill.high { background: var(--short-soft); color: var(--short-ink); }
.countdown { font-size: 11px; color: var(--muted); }
.countdown.warn { color: var(--warn-ink); font-weight: 600; }
.countdown.danger { color: var(--short-ink); font-weight: 600; }

.spark { width: 100%; height: 40px; display: block; }
.meter { display: block; height: 4px; border-radius: 2px; background: var(--panel-3); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--action); }

/* ============================ inputs ============================ */
.cellinput {
  width: 100%; max-width: 130px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 3px; height: 30px; padding: 0 9px; text-align: right; color: var(--ink);
  font-variant-numeric: tabular-nums; font-size: 13px;
}
.cellinput::placeholder { color: var(--muted); }
.cellinput:hover { border-color: var(--ink-2); }
.cellinput:focus { border-color: var(--action); outline: none; background: var(--bg); }
.cellinput.invalid { border-color: var(--short); }
.cellinput.limit { border-color: var(--rest); }
.cellinput.tp { border-color: color-mix(in srgb, var(--long) 45%, var(--line-2)); }
.cellinput.sl { border-color: color-mix(in srgb, var(--short) 45%, var(--line-2)); }
.cellinput.tp:focus { border-color: var(--long); }
.cellinput.sl:focus { border-color: var(--short); }
.cellinput:disabled { opacity: .6; cursor: not-allowed; }
.cfgrow input {
  width: 82px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px;
  padding: 4px 7px; text-align: right; color: var(--ink); font-size: 12px;
}

/* Ô nhập trong hộp thoại (lý do từ chối, TP/SL). `.field`/`.input` đã được dùng ở
   các hộp thoại nhưng chưa từng có style — bổ sung để không rơi về input mặc định. */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; height: 36px; background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 3px; padding: 0 10px; color: var(--ink); font: inherit; font-size: 13px;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--ink-2); }
.input:focus { border-color: var(--action); outline: none; background: var(--bg); }

/* ==================== Pending Approvals: bảng sửa tại chỗ ==================== */
/* Một bảng toàn chiều rộng, mọi ô sửa được ngay trên dòng — không panel hẹp bên phải. */
table.approvals { table-layout: auto; }
table.approvals td { vertical-align: top; }
table.approvals .tin {
  width: 100%; min-width: 76px; max-width: 132px; height: 28px; padding: 0 6px; text-align: right;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--ink); font: inherit; font-size: 12px;
}
table.approvals select.tin { text-align: left; max-width: 118px; }
table.approvals .tin:focus { outline: none; border-color: var(--action); }
table.approvals .tin::placeholder { color: var(--muted); }
table.approvals .tin:disabled { opacity: .55; }
table.approvals .sizecell { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
table.approvals .blocknote { color: var(--warn-ink); font-size: 11px; display: block; max-width: 190px; text-align: left; }
.acctpick {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--ink); font: inherit; font-size: 12px; white-space: nowrap;
}
.acctpick:hover { border-color: var(--ink-2); }
.acctpick .nm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
tr.expand > td { background: var(--bg); border-top: 0; padding: 10px 12px 14px; }
tr.expand .accttable { max-width: 940px; }
tr.expand .accttable th:last-child, tr.expand .accttable td:last-child { text-align: right; }
.expandfoot { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 12px; }
.expandfoot .k { color: var(--muted); }
.expandfoot b { font-weight: 600; margin-right: 12px; }

/* ==================== form đặt lệnh kiểu Binance (phiếu duyệt) ==================== */
/* Nhãn trên, khung nhập dưới, đơn vị nằm trong khung — bám layout order form của Binance. */
.orderform { display: flex; flex-direction: column; gap: 10px; }
.ofield { display: flex; flex-direction: column; gap: 5px; }
.ofield > .k { font-size: 12px; color: var(--muted); }
.ofield .ctl {
  display: flex; align-items: stretch; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden;
}
.ofield .ctl:focus-within { border-color: var(--action); }
.ofield .ctl input {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px; background: transparent; border: 0;
  color: var(--ink); font: inherit; font-size: 13px; text-align: right;
}
.ofield .ctl input:focus { outline: none; }
.ofield .ctl input:disabled { color: var(--muted); }
.ofield .ctl input::placeholder { color: var(--muted); }
.ofield .ctl .suffix {
  display: flex; align-items: center; padding: 0 10px; font-size: 12px; color: var(--ink-2);
  border-left: 1px solid var(--line-2); white-space: nowrap;
}
.ofield .row2 { display: flex; gap: 8px; }
.ofield .row2 .ctl { flex: 1; }

/* Dòng Avbl: nhãn trái, số dư phải — giống "Avbl 4,997.84 USDT" của Binance */
.avbl { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.avbl .k { color: var(--muted); }
.avbl b { font-weight: 600; margin-left: auto; }
.avbl .sub { color: var(--muted); font-size: 11px; }

/* Dải tab loại lệnh: chữ thường, gạch chân ở tab đang chọn (không phải nút khối) */
.seg.tabs { border: 0; gap: 16px; border-radius: 0; overflow: visible; border-bottom: 1px solid var(--line); }
.seg.tabs button {
  flex: none; background: transparent; border: 0; border-bottom: 2px solid transparent;
  height: 32px; padding: 0; color: var(--muted); font-size: 13px; border-radius: 0;
}
.seg.tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--action); font-weight: 600; }
.seg.tabs button:hover { color: var(--ink); }
.seg.unit { border: 1px solid var(--line-2); border-radius: 4px; }
.seg.unit button { flex: 1; height: 30px; font-size: 12px; }

/* Bảng tài khoản trong phiếu: ô nhập gọn, số căn phải */
.accttable { width: 100%; border-collapse: collapse; }
.accttable th {
  font-size: 11px; font-weight: 500; color: var(--muted); text-align: right;
  padding: 4px 6px; white-space: nowrap;
}
.accttable th:first-child { text-align: left; }
.accttable td { padding: 4px 6px; border-top: 1px solid var(--line); font-size: 12px; }
.accttable tr.off td { opacity: .5; }
.accttable tr.noterow td {
  border-top: 0; padding: 0 6px 6px; color: var(--warn-ink); font-size: 11px; text-align: left;
}
.accttable .tin {
  width: 100%; min-width: 58px; height: 28px; padding: 0 6px; text-align: right;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--ink); font: inherit; font-size: 12px;
}
.accttable .tin:focus { outline: none; border-color: var(--action); }
.accttable .tin::placeholder { color: var(--muted); }
.actions.nowrap { flex-wrap: nowrap; }
.btn.compact { height: 26px; padding: 0 10px; font-size: 12px; min-width: 0; }

/* ============================ buttons ============================ */
.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 3px; height: 30px;
  padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); font-weight: 600; }
.btn.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn.primary:disabled { background: var(--panel-2); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.long { background: var(--long); border-color: var(--long); color: #04150F; font-weight: 600; min-width: 100px; }
.btn.long:hover { filter: brightness(1.1); }
.btn.long:disabled { background: var(--panel-2); border-color: var(--line); color: var(--muted); cursor: not-allowed; filter: none; }
.btn.short { background: var(--short); border-color: var(--short); color: #fff; font-weight: 600; min-width: 100px; }
.btn.short:hover { filter: brightness(1.08); }
.btn.short:disabled { background: var(--panel-2); border-color: var(--line); color: var(--muted); cursor: not-allowed; filter: none; }
.btn.quiet { color: var(--muted); background: transparent; min-width: 68px; }
.btn.quiet:hover { color: var(--short-ink); border-color: var(--short); }
.btn.danger { color: var(--short-ink); border-color: var(--short); background: transparent; }
.btn.danger:hover { background: var(--short); color: #fff; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }

/* ============================ popovers ============================ */
.cfg { position: relative; }
.cfgpop {
  position: absolute; right: 0; top: calc(100% + 7px); width: 320px; background: var(--panel);
  border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 14px 16px; z-index: 60;
}
.cfgpop h3 { font-size: 13px; margin-bottom: 6px; }
.cfgrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; }
.cfgrow label { font-size: 12px; color: var(--ink-2); }
.cfgpop p { margin: 8px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.cfgpop hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

.pnlpop {
  position: fixed; z-index: 85; width: 250px; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: 12px; pointer-events: none;
}
.pnlpop-h { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.pnlpop .r { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--ink-2); }
.pnlpop .r b { font-weight: 600; }
.pnlpop .r.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; color: var(--ink); }

/* ============================ modal ============================ */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center;
  justify-content: center; padding: 20px; z-index: 70;
}
.modal {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px;
  box-shadow: var(--shadow-lg); width: min(460px, 100%); max-height: 92vh; overflow-y: auto;
}
.modal.wide { width: min(760px, 100%); }
.modal-h { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px 12px; }
.modal-h h2 { font-size: 18px; letter-spacing: -.005em; }
.modal-h .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.modal-h .x { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 2px 6px; }
.modal-h .x:hover { color: var(--ink); }
.modal-b { padding: 4px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; gap: 10px; padding: 0 20px 20px; }
.modal-f .btn { flex: 1; height: 40px; padding: 0 14px; font-size: 13px; font-weight: 600; }

.confirm-acct {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2);
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.acctchip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 20px;
  padding: 3px 10px 3px 8px; background: var(--panel-2); white-space: nowrap;
}
.lvinfo { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--ink-2); }
.lvinfo .r { display: flex; justify-content: space-between; gap: 14px; }
.lvinfo .r b { font-weight: 600; color: var(--ink); }
.lvinfo .r.total { border-top: 1px solid var(--line); padding-top: 8px; }
.field-k { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; }
.seg button { flex: 1; background: var(--panel-2); border: 0; height: 34px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--action-soft); color: var(--action); font-weight: 600; }
.pctrow { display: flex; gap: 6px; }
.pctrow button {
  flex: 1; height: 32px; border: 1px solid var(--line-2); background: var(--panel-2);
  border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--ink-2);
}
.pctrow button:hover { border-color: var(--ink-2); }
.pctrow button[data-on="1"] { background: var(--action-soft); border-color: var(--action); color: var(--action); }
.closeqty { display: flex; align-items: center; gap: 8px; }
.closeqty label { font-size: 12px; color: var(--ink-2); flex: none; }
.closeqty input { flex: 1; max-width: 160px; }
.closeqty .unit { font-size: 12px; color: var(--muted); flex: none; }
.stepper { display: flex; align-items: center; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.stepper button { background: none; border: 0; width: 50px; height: 44px; font-size: 20px; color: var(--ink-2); line-height: 1; }
.stepper button:hover:not(:disabled) { background: var(--panel-3); color: var(--action); }
.stepper button:disabled { color: var(--line-2); cursor: not-allowed; }
.stepper .lv { flex: 1; text-align: center; font-size: 24px; font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--track, var(--line-2)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--action); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; background: var(--panel);
  border: 2px solid var(--action); transform: rotate(45deg); margin-top: -6px;
}
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; background: var(--panel); border: 2px solid var(--action); }
.ticks { display: flex; justify-content: space-between; margin-top: 8px; flex-wrap: wrap; gap: 4px; }
.ticks button { background: none; border: 0; font-size: 11px; color: var(--muted); padding: 2px 4px; }
.ticks button:hover { color: var(--action); }
.ticks button[data-on="1"] { color: var(--ink); font-weight: 600; }
.ticks button[aria-current="true"] { color: var(--action); font-weight: 700; }

.alertbox {
  display: flex; gap: 8px; background: var(--short-soft); border: 1px solid var(--short);
  border-radius: var(--radius); padding: 10px 12px; font-size: 12px; color: var(--short-ink); line-height: 1.5;
}
.alertbox.warnlvl { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-ink); }
.alertbox.infolvl { background: var(--info-soft); border-color: var(--info); color: var(--info-ink); }
.alertbox .ic { width: 15px; height: 15px; margin-top: 1px; }
.alertbox ul { margin: 0; padding-left: 16px; }
.alertbox li + li { margin-top: 3px; }
.alertbox b { font-weight: 600; }

/* ============================ toasts ============================ */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 90; max-width: 400px; }
.toast {
  background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--action);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.toast.good { border-left-color: var(--long); }
.toast.bad { border-left-color: var(--short); }
.toast.warn { border-left-color: var(--warn); }
.toast .msg { flex: 1; }
.toast .msg b { font-weight: 600; }
.toast button { background: none; border: 0; color: var(--action); font-size: 12px; font-weight: 600; padding: 0; }
.toast .toast-x { color: var(--muted); font-size: 16px; padding: 0 2px; }
.toast .toast-x:hover { color: var(--ink); }

/* ============================ exposure / models ============================ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding-top: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { font-size: 13px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card .kv { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 3px 0; color: var(--ink-2); }
.card .kv b { color: var(--ink); font-weight: 600; }
.card .kv.pos b { color: var(--long); }
.card .kv.neg b { color: var(--short); }
.card .desc { font-size: 11px; color: var(--muted); margin: -6px 0 10px; }
.card.acct { border-left: 3px solid var(--accent); }
.card.acct[data-acct="a2"] { border-left-color: var(--acct-2); }
.card.acct[data-acct="a3"] { border-left-color: var(--acct-3); }
.exposurebar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--panel-3); margin: 6px 0; }
.exposurebar i { display: block; height: 100%; }
.exposurebar i.long { background: var(--long); }
.exposurebar i.short { background: var(--short); }

/* ============================ timeline (audit) ============================ */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 10px; font-size: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: 0; }
.tl-item .t { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-item .who { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tl-item .txt { flex: 1; }
.tl-item .kind { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

footer { margin-top: 22px; font-size: 11px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }

/* ============================ mobile ============================ */
@media (max-width: 1080px) {
  .riskbar { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(even), .metric:last-child { border-right: 0; }
}
/* Hẹp: sidebar thành dải ngang trên cùng, nội dung chiếm hết bề rộng */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .navlist { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px; }
  .navgroup { padding: 0 8px 0 0; flex-basis: auto; }
  .navitem { width: auto; }
  .navitem .count { margin-left: 6px; }
  .side-foot { flex-direction: row; align-items: center; gap: 12px; padding: 8px 12px; }
  .wrap { padding: 0 12px 48px; }
  /* bảng chuyển sang dạng thẻ: mỗi dòng là một khối, nhãn lấy từ data-label */
  .tablewrap { border: 0; background: transparent; overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100% !important; }
  thead { display: none; }
  /* cả dòng rỗng cũng phải thành thẻ, nếu không thông điệp trôi trên nền trang */
  tbody tr.row, tbody tr.emptyrow {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 10px; padding: 6px 2px;
  }
  tbody tr.row td {
    border: 0; padding: 6px 12px; display: flex; justify-content: space-between;
    gap: 12px; align-items: baseline; text-align: right;
    /* .num/.px đặt nowrap cho bảng desktop; ở dạng thẻ phải cho xuống dòng,
       nếu không các dòng phụ (account, ghi chú) sẽ tràn ngang cả trang */
    white-space: normal; flex-wrap: wrap;
  }
  tbody tr.row td > * { min-width: 0; }
  tbody tr.row td .sub,
  tbody tr.row td .cellnote,
  tbody tr.row td .sym,
  tbody tr.row td .symcap { white-space: normal; }
  tbody tr.row td::before {
    content: attr(data-label); color: var(--muted); font-size: 11px; text-align: left; flex: none;
  }
  tbody tr.row td:first-child { min-width: 0; }
  tbody tr.row td:has(.actions) { justify-content: flex-end; }
  tbody tr.row td:has(.actions)::before { display: none; }
  td.num > .cellinput { max-width: 160px; }
  .card.acct { border-left-width: 3px; }
}
@media (max-width: 560px) {
  .topbar { padding: 6px 12px; gap: 8px; }
  .side-brand { padding: 10px 12px; }
  .side-brand .sub { display: none; }
  #acctBal { display: none; }
  .cfgpop { width: min(320px, calc(100vw - 24px)); right: -8px; }
  .riskbar { grid-template-columns: 1fr; }
  .metric { border-right: 0 !important; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .modal-f { flex-direction: column-reverse; }
  .toasts { left: 12px; right: 12px; max-width: none; }
  .cards { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .iconbtn .lbl { display: none; }
  /* nút tạm dừng là lệnh khẩn — luôn giữ nhãn, kể cả màn hẹp nhất */
  #killBtn .lbl { display: inline; }
}
