:root {
  --bg: #000;          /* khe giua cac khoi, nhu TradingView (giao dien toi moi) */
  --bar: #0f0f0f;      /* thanh cong cu tren / trai / duoi */
  --hover: #2a2e39;
  --panel: #131722;
  --line: #2a2e39;
  --text: #d1d4dc;
  --muted: #787b86;
  --accent: #2962ff;
  --up: #089981;
  --down: #f23645;
  --strong: #fff;      /* chu noi bat (ten symbol, nut dang chon) */
  --menu: #1e222d;     /* nen menu, hop thoai, thanh noi */
  --soft: #b2b5be;     /* chu phu sang hon --muted */
  --disabled: #50535e;
  --grid: #1e222d;     /* luoi chart */
  --cross: #9598a1;    /* crosshair */
  --cross-label: #363a45;
  --buy-text: #6d95ff; /* chu nut BUY vien xanh */
  --shadow: #000a;
  color-scheme: dark;
}

/* giao dien sang (theme.js dat data-theme="light" tren <html>) */
:root[data-theme="light"] {
  --bg: #e0e3eb;
  --bar: #ffffff;
  --hover: #f0f3fa;
  --panel: #ffffff;
  --line: #e0e3eb;
  --text: #131722;
  --muted: #787b86;
  --strong: #131722;
  --menu: #ffffff;
  --soft: #6a6d78;
  --disabled: #c1c4cd;
  --grid: #f0f3fa;
  --cross: #9598a1;
  --cross-label: #131722;
  --buy-text: #2962ff;
  --shadow: #0003;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
}

body { display: flex; flex-direction: column; }

/* ---- thanh cong cu tren cung kieu TradingView: nut phang, khong vien, re chuot thi nen xam */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  min-height: 38px;
  padding: 0 6px;
  margin-bottom: 4px;
  background: var(--bar);
}
header .sep { height: 22px; margin: 0 4px; }
/* logo goc tren ben trai: ve trang chu (portal) */
.tlogo { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 8px 0 6px; border-radius: 4px; color: var(--strong); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; text-decoration: none; }
.tlogo:hover { background: var(--hover); color: var(--strong); }
.tlogo-mark { display: inline-flex; align-items: flex-end; gap: 2px; height: 15px; }
.tlogo-mark i { display: block; width: 3px; border-radius: 1px; background: var(--text); }
.tlogo-mark i:nth-child(1) { height: 8px; }
.tlogo-mark i:nth-child(2) { height: 15px; background: var(--up); }
.tlogo-mark i:nth-child(3) { height: 11px; }
.tgroup { display: flex; align-items: center; gap: 1px; }
.tgrow { flex: 1 1 0; }
.tbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 32px; min-width: 28px; padding: 0 6px;
  border: 0; border-radius: 4px; background: none; color: var(--text); font-size: 14px; white-space: nowrap;
}
.tbtn:hover:not(:disabled) { background: var(--hover); border: 0; }
.tbtn:disabled { color: var(--disabled); cursor: default; }
.tbtn svg { display: block; }
.tbtn.tf { min-width: 30px; padding: 0 5px; font-size: 14px; }
.tbtn.tf.on { color: var(--strong); background: var(--hover); font-weight: 600; }
.tbtn.tchev { min-width: 20px; padding: 0 3px; color: var(--muted); font-size: 16px; }
.tbtn.ttext span { font-size: 14px; }
#ctypeBtn svg { width: 22px; height: 22px; }
header .tbtn.on, header button.on { color: var(--strong); background: #2962ff33; border: 0; }
.tsym { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 8px; border-radius: 4px; color: var(--text); cursor: pointer; }
.tsym:hover { background: var(--hover); }
.tsym select { border: 0; background: none; padding: 0 4px; height: 32px; font-weight: 700; font-size: 14px; color: var(--strong); cursor: pointer; }
.tsym select option { background: var(--menu); }
.tlabel { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; color: var(--text); font-size: 14px; }
.rbox { display: flex; flex-direction: column; gap: 10px; }
.rnow { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rnow b { color: var(--strong); font-weight: 600; }
.rrow { display: flex; gap: 8px; }
.rdate { flex: 1; min-width: 0; height: 36px; padding: 0 10px; color-scheme: dark; font-size: 14px; cursor: pointer; }
.rdate::-webkit-calendar-picker-indicator { display: none; }
.rgo { height: 36px; padding: 0 18px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#dlg .dlg:has(.rbox) { width: 400px; }
header select#speed { height: 28px; border-color: transparent; background: none; font-size: 13px; }
header select#speed:hover { background: var(--hover); }
.tbtn.tplay { min-width: 32px; font-size: 15px; }

/* ---- thanh duoi chart: khoang thoi gian, di toi ngay, dong ho + mui gio */
#chartcol { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#botbar { flex: none; display: flex; align-items: center; gap: 2px; height: 34px; padding: 0 6px; margin-top: 4px; background: var(--bar); }
#botbar .sep { height: 18px; margin: 0 4px; }
#rangebar button { height: 26px; padding: 0 7px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: 13px; }
#rangebar button:hover { background: var(--hover); }
#botbar .tbtn { height: 26px; font-size: 13px; }
#clock { font-variant-numeric: tabular-nums; color: var(--text); }
#clock b { font-weight: 400; }

/* ---- menu khung thoi gian (nhom thu gon duoc, sao yeu thich) va mui gio */
#ctxmenu.tfmenu { width: 240px; min-width: 0; overflow-y: auto; }
#ctxmenu .tfadd .ticon { font-size: 16px; }
#ctxmenu .tfgroup { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 7px 14px; }
#ctxmenu .tfgroup .tfchev { flex: none; font-size: 14px; }
#ctxmenu .tfitem { padding: 5px 14px 5px 24px; }
#ctxmenu .tfitem.on { background: #2962ff; color: #fff; }
#ctxmenu .tfitem.on:hover { background: #1e53e5 !important; }
.tfacts { display: inline-flex; gap: 6px; flex: none; }
.tfacts i { font-style: normal; font-size: 15px; line-height: 1; padding: 2px 3px; border-radius: 3px; color: var(--muted); visibility: hidden; }
.tfacts i.fav { color: #f7a600; visibility: visible; }
#ctxmenu .tfitem:hover .tfacts i { visibility: visible; }
.tfacts i:hover { background: color-mix(in srgb, var(--strong) 10%, transparent); color: var(--strong); }
.tfacts i.fav:hover { color: #f7a600; }
#ctxmenu.tzmenu { max-height: min(70vh, 560px); min-width: 230px; }
#ctxmenu.tzmenu button { padding: 5px 14px; }

/* ---- dem nguoc nen duoi nhan gia Bid tren truc gia */
.chartwrap > .pclose { position: absolute; z-index: 5; top: 4px; right: 72px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; background: color-mix(in srgb, var(--menu) 80%, transparent); color: var(--muted); opacity: 0; }
.panel:hover .chartwrap > .pclose { opacity: 1; }
.chartwrap > .pclose:hover { color: var(--down); background: var(--hover); }

.brand { font-weight: 700; color: var(--strong); margin-right: 4px; }
.sep { width: 1px; height: 20px; background: var(--line); }

label { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

button, select, input {
  background: var(--menu);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
input[type="datetime-local"] { color-scheme: dark; }

/* man hinh rong: header 1 dong co dinh, trang thai tu co lai, de chart khong bi day len xuong khi chu doi do dai */
#status { min-width: 0; margin-left: 6px; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 1100px) { header { flex-wrap: nowrap; } header > * { flex-shrink: 0; } header > #status { flex-shrink: 1; } }
#status .bid { color: var(--down); }
#status .ask { color: var(--up); }
#status .dim { color: var(--muted); }
#toast { position: fixed; z-index: 40; top: 58px; left: 50%; transform: translateX(-50%); max-width: 90vw; padding: 8px 14px; border: 1px solid #f7a60088; border-radius: 6px; background: var(--menu); color: #f7a600; font-weight: 600; box-shadow: 0 4px 16px #0008; pointer-events: none; }
#toast[hidden] { display: none; }
:root[data-theme="light"] #toast { color: #b26a00; background: #fff8e6; }
/* thanh "Da co phien ban moi" (deploy moi) */
#updbar { position: fixed; z-index: 60; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 8px 8px 8px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); color: var(--text); box-shadow: 0 6px 24px var(--shadow); }
#updbar button { padding: 5px 12px; }
/* popup san pham tai tro (promo.js) */
#promo { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: #0007; }
#promo .pbox { width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--menu); box-shadow: 0 12px 40px var(--shadow); }
#promo .phead { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
#promo .px { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--soft); font-size: 13px; cursor: pointer; }
#promo .px:disabled { cursor: default; opacity: .7; }
#promo .px:not(:disabled):hover { background: var(--hover); color: var(--strong); }
#promo .pbody { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text); text-decoration: none; text-align: center; }
#promo .pbody img { width: 100%; max-height: 240px; object-fit: contain; border-radius: 6px; background: #fff; }
#promo .pname { color: var(--strong); font-size: 15px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#promo .pprice { color: #ee4d2d; font-size: 18px; font-weight: 700; }
#promo .pgo { display: block; padding: 10px; border-radius: 6px; background: #ee4d2d; color: #fff; font-weight: 700; text-align: center; text-decoration: none; }
#promo .pgo:hover { background: #d73211; }
#promo .pup { align-self: center; color: var(--muted); font-size: 12px; text-decoration: underline; }
#promo .pup:hover { color: var(--text); }

#work { flex: 1; min-height: 0; display: flex; }

#leftbar { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 52px; flex: none; padding: 4px 0; margin-right: 4px; background: var(--bar); overflow-y: auto; scrollbar-width: none; }
#leftbar hr { width: 28px; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.lb { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 4px; background: none; font-size: 17px; }
.lb:hover { background: var(--hover); }
.lb.on { background: #2962ff44; color: var(--strong); }
.lbgroup { position: relative; display: flex; }
.lbmore { position: absolute; right: -6px; top: 0; bottom: 0; width: 10px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; opacity: 0; }
.lbgroup:hover .lbmore { opacity: 1; }
.lbmore:hover { color: var(--strong); }
.ticon { width: 22px; height: 22px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }

#floatbar { position: fixed; z-index: 15; display: flex; align-items: center; gap: 3px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--menu); box-shadow: 0 4px 16px #0008; }
#floatbar[hidden] { display: none; }
#floatbar button { padding: 2px 7px; border: 0; background: none; }
#floatbar button:hover { background: var(--hover); }
#floatbar button.on { background: #2962ff44; }
#floatbar select { padding: 2px 4px; border: 0; background: none; }
#floatbar .fcount { padding: 0 6px; color: var(--muted); }
#floatbar .swatch { width: 24px; height: 24px; padding: 0; border-radius: 4px; }
#floatbar .swatch::after { content: ""; display: block; width: 16px; height: 4px; margin: 13px auto 0; background: var(--c); border-radius: 1px; }
#floatbar .swatch.fill::after { height: 14px; margin-top: 3px; }

#palette { position: fixed; z-index: 31; display: grid; grid-template-columns: repeat(10, 22px); gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--menu); box-shadow: 0 6px 24px var(--shadow); }
#palette button { width: 22px; height: 22px; padding: 0; border: 1px solid color-mix(in srgb, var(--strong) 13%, transparent); border-radius: 3px; }
#palette button.on { outline: 2px solid var(--accent); }
#palette label { grid-column: 1 / -1; justify-content: space-between; padding-top: 4px; }
#palette input[type="color"] { width: 34px; height: 22px; padding: 0 2px; }
#palette input[type="range"] { flex: 1; padding: 0; margin-left: 8px; }

main.grid {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 4px;
  padding: 0;
  background: var(--bg);
}
main.grid.n1 { grid-template-columns: 1fr; }
main.grid.n2 { grid-template-columns: 1fr 1fr; }
main.grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
main.grid.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid transparent;
  background: var(--panel);
}
main.grid:not(.n1):not(.split-root) .panel.active, main.grid.split-root:has(.gutter) .panel.active { border-color: var(--accent); }

.phead { display: none; }
.phead-unused {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--line);
}
.phead .title { margin-right: 8px; font-weight: 600; }
.phead .sep { height: 16px; margin: 0 4px; }
.phead .ctype { display: inline-flex; align-items: center; padding: 1px 4px; margin-right: 4px; }
.phead .ctype svg, #ctxmenu .ticon svg { width: 18px; height: 18px; }
.phead button { padding: 1px 6px; border-color: transparent; background: transparent; color: var(--muted); }
header button.on { color: var(--strong); background: #2962ff44; border-color: var(--accent); }
.phead button.on { color: var(--strong); background: var(--hover); }

.chart { flex: 1; min-height: 0; position: relative; }
.chart.cur-move, .chart.cur-move * { cursor: move !important; }
.chart.cur-handle, .chart.cur-handle * { cursor: pointer !important; }
.chart.cur-ind, .chart.cur-ind * { cursor: pointer !important; }
.chart.cur-ns, .chart.cur-ns * { cursor: ns-resize !important; }

/* cum SELL | lot | BUY trong legend tung chart, kieu "vien manh", luon gon: nut trong suot chi co vien mau va chu,
   chart nhin xuyen qua; re chuot / cham thi nen dac. Dung chung cho PC va dien thoai (mobile.css chi noi to vung cham) */
.ttrade { pointer-events: auto; margin: 4px 0 2px; width: fit-content; }
.tone { display: flex; align-items: center; gap: 6px; }
.tone[hidden] { display: none; }
.tone .tsell, .tone .tbuy {
  min-width: 52px; padding: 3px 10px; border: 1px solid; border-radius: 6px; background: color-mix(in srgb, var(--panel) 72%, transparent);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  font: 700 11px/1.2 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: .1em; transition: background .1s, color .1s;
}
.tone .tsell { border-color: var(--down); color: var(--down); }
.tone .tbuy { border-color: var(--accent); color: var(--buy-text); }
.tone .tsell:hover, .tone .tsell:active { background: var(--down); color: #fff; }
.tone .tbuy:hover, .tone .tbuy:active { background: var(--accent); color: #fff; }
.tlot { display: flex; align-items: center; color: var(--text); }
.tlot small { display: none; } /* chu "lot" chi hien o o lot cua lenh dang chinh */
.tlot input {
  width: 46px; padding: 1px 0; border: 0; border-bottom: 1px dashed var(--muted); border-radius: 0; background: none;
  color: var(--text); text-align: center; font: 600 13px ui-monospace, "SF Mono", Menlo, Consolas, monospace; cursor: text;
}
.tlot input:focus { outline: none; border-bottom: 1px solid var(--accent); }
.tlot.auto input { color: var(--muted); border-bottom-style: dotted; cursor: default; }
.tone .tset { padding: 0 4px; border: 0; background: none; color: var(--soft); font-size: 28px; line-height: 24px; }
.tone .tset:hover { color: var(--strong); }
/* dang chinh lenh: Dat lenh | lot | Gia thi truong | Bo SL / TP | Huy */
.tconfirm { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tconfirm[hidden] { display: none; }
.tconfirm button { padding: 4px 10px; box-shadow: 0 1px 4px #0008; }
.tconfirm .ogo { border: 0; color: #fff; font-weight: 600; }
.tconfirm .ogo.buy { background: var(--accent); }
.tconfirm .ogo.sell { background: var(--down); }
.tconfirm .tlot { gap: 4px; padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--panel) 72%, transparent); }
.tconfirm .tlot small { display: inline; font-size: 10px; color: var(--muted); }
.phead .pclose { margin-left: 6px; }
.phead .pclose:hover { color: #f23645; }
.lgroup { pointer-events: none; }

#tradepanel { flex: none; position: relative; margin-top: 4px; background: var(--bar); }
.tpgrip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; z-index: 5; }
.tpgrip:hover { background: #2962ff55; }

.tphead { display: flex; align-items: center; gap: 6px; padding: 3px 8px; }
.tptabs { display: flex; gap: 2px; }
.tphead button { padding: 2px 8px; border-color: transparent; background: none; color: var(--muted); }
.tphead button.on { color: var(--strong); background: var(--hover); }
.tpsum { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tpsum b { color: var(--text); }
.tpbody { height: 150px; overflow: auto; border-top: 1px solid var(--line); }
.tpbody table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; }
.tpbody td { padding: 3px 8px; border-bottom: 1px solid var(--menu); white-space: nowrap; }
.tpbody tr.th td { color: var(--muted); position: sticky; top: 0; background: var(--panel); }
.tpbody tr[data-hist] { cursor: pointer; }
.tpbody tr:not(.th):hover { background: var(--hover); }
.tpbody td button { padding: 0 6px; border: 0; background: none; color: var(--muted); }
.tpbody td button:hover { color: #f23645; }
.tpbody td button[data-editpos]:hover, .tpbody td button[data-editord]:hover { color: var(--accent); }
.tpbody .buy { color: #089981; }
.tpbody .sell { color: #f23645; }
.tpsum .buy { color: #089981; }
.tpsum .sell { color: #f23645; }
.tpempty { padding: 12px; color: var(--muted); }
.tpstats { display: flex; gap: 12px; padding: 6px 8px; align-items: flex-start; }
.stables { display: flex; gap: 12px; flex: none; }
.stables table { width: auto; }
.stables td:last-child { text-align: right; font-weight: 600; }
.scharts { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.schart { border: 1px solid var(--line); border-radius: 4px; }
.stitle { padding: 3px 8px; color: var(--muted); font-size: 11px; }
.stitle .lg { display: inline-block; width: 10px; height: 2px; vertical-align: middle; }
.stitle .lg.b { background: #2962ff; }
.stitle .lg.e { background: #089981; }
.sbody { height: 150px; }
.dsection { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; text-transform: uppercase; }
.dnote { margin-top: -4px; color: var(--muted); font-size: 11px; white-space: normal; }
.dtext { margin: 0 0 10px; line-height: 1.5; }
.dtext.warn { color: #f7a600; }
.dbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.dbtns .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dkeys td { padding: 3px 8px; }
.dkeys kbd { padding: 1px 6px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); font: inherit; white-space: nowrap; }

.chartwrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }

.legend { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.lgroup { position: absolute; left: 6px; right: 70px; overflow-y: auto; scrollbar-width: none; font-size: 12px; font-variant-numeric: tabular-nums; }
.lrow { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; width: fit-content; max-width: 100%; color: var(--text); text-shadow: 0 0 3px var(--panel); }
.lrow:not(.lmain) { pointer-events: auto; }
.lrow.off { opacity: 0.45; }
.lrow.sel { background: #2962ff33; border-radius: 3px; }
.lsym { color: var(--strong); font-weight: 400; font-size: 15px; }
body:not(.m) .lgroup:first-child { font-size: 13px; }
body:not(.m) .lmain { gap: 0 10px; }
.lohlc.up { color: var(--up); }
.lohlc.down { color: var(--down); }
.lohlc i { font-style: normal; color: var(--text); margin-left: 4px; }
.lbtns { display: none; }
.lrow:hover .lbtns { display: inline-flex; gap: 2px; }
.lbtns button { padding: 0 4px; border: 0; background: var(--hover); color: var(--text); font-size: 11px; line-height: 16px; }
.lbtns button:hover { background: var(--accent); color: #fff; }

.golive { position: absolute; z-index: 4; width: 30px; height: 30px; padding: 0 0 3px; border-radius: 50%; background: var(--hover); color: var(--strong); font-size: 18px; line-height: 1; box-shadow: 0 2px 8px #0008; }
.golive:hover { background: var(--accent); }
.golive[hidden] { display: none; }

#ctxmenu { position: fixed; z-index: 30; min-width: 200px; padding: 4px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--menu); box-shadow: 0 6px 24px var(--shadow); }
#ctxmenu button.on { background: #2962ff33; }
#ctxmenu button > span:not(.ticon) { flex: 1; }
#ctxmenu { max-height: 80vh; overflow-y: auto; }
#ctxmenu button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 6px 14px; border: 0; border-radius: 0; background: none; text-align: left; }
#ctxmenu button:hover:not(:disabled) { background: var(--hover); }
#ctxmenu button:disabled { color: var(--disabled); cursor: default; }
#ctxmenu kbd { color: var(--muted); font: inherit; }
#ctxmenu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--line); }

#dlg { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; background: #0006; }
.dlg { width: 480px; max-width: 100%; max-height: 75vh; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; background: var(--menu); box-shadow: 0 8px 32px var(--shadow); }
.dhead { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 15px; }
.dhead button { border: 0; background: none; color: var(--muted); }
.dbody { min-height: 0; display: flex; flex-direction: column; padding: 0 14px 14px; }
.dsearch { width: 100%; margin-bottom: 8px; padding: 7px 10px; background: var(--panel); }
.dlist { overflow-y: auto; min-height: 0; }
.dgroup { padding: 8px 6px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.dcurhead { display: flex; justify-content: space-between; align-items: center; }
.dcurhead button { padding: 1px 8px; font-size: 11px; text-transform: none; }
.dcur { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
.dcur .sw { width: 10px; height: 10px; border-radius: 2px; }
.dcur .dname { flex: 1; }
.dcur button { padding: 0 6px; border: 0; background: none; color: var(--muted); }
.dcur button:hover { color: var(--down); }
.ditem { display: flex; gap: 10px; width: 100%; padding: 6px; border: 0; background: none; text-align: left; }
.ditem:hover { background: var(--hover); }
.ditem b { min-width: 74px; font-weight: 600; }
.ditem span { color: var(--muted); }
.dform { display: flex; flex-direction: column; gap: 8px; }
.dform label { justify-content: space-between; color: var(--text); }
.dform input[type="number"], .dform input.num { width: 110px; }
.dform input.bad { border-color: var(--down); }
.derr { margin-top: -4px; color: var(--down); font-size: 11px; text-align: right; }
.dform input:not([type]) { width: 220px; }
.dform input[type="range"] { width: 140px; padding: 0; }
.dform input[type="checkbox"] { width: 16px; height: 16px; }
.dform textarea { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 6px; font: inherit; resize: vertical; }
.dform label textarea { width: 220px; }
.dform input[type="color"] { width: 44px; height: 28px; padding: 0 2px; }
.dform .primary { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: #fff; }


@media (max-width: 700px) {
  main.grid.n2, main.grid.n3, main.grid.n4 { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: minmax(260px, 1fr); }
  #status { margin-left: 0; width: 100%; }
}

/* hop thoai Du lieu */
.dtab { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 8px; }
.dtab td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.dtab td:last-child { text-align: right; white-space: nowrap; }
.dform input[list], .dform input[name="sym"] { width: 160px; }
.dform input[type="month"] { width: 150px; }
.dlog { max-height: 180px; overflow: auto; margin: 8px 0 0; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.dlog[hidden] { display: none; }

/* icon nut trong bang giao dich: to hon cho de bam */
.tphead button[data-tp="account"], .tphead button[data-tp="toggle"] { font-size: 20px; line-height: 1; padding: 0 8px; }
.tpbody td button { font-size: 20px; line-height: 1; padding: 0 10px; }

/* ---- bo cuc nhieu chart: khung chia keo duoc (may tinh) */
main.grid.split-root { display: flex; gap: 0; overflow: hidden; }
.split { display: flex; min-width: 0; min-height: 0; }
.split.h { flex-direction: row; }
.split.v { flex-direction: column; }
.slot { display: flex; min-width: 0; min-height: 0; }
.slot > .panel { flex: 1; }
.gutter { flex: none; position: relative; z-index: 6; background: var(--bg); transition: background .1s; }
.split.h > .gutter { width: 4px; cursor: col-resize; }
.split.v > .gutter { height: 4px; cursor: row-resize; }
.gutter::after { content: ""; position: absolute; inset: -3px; } /* vung bam rong hon duong ve */
.gutter:hover, .gutter.drag { background: var(--accent); }
body.resizing-h, body.resizing-h * { cursor: col-resize !important; user-select: none; }
body.resizing-v, body.resizing-v * { cursor: row-resize !important; user-select: none; }
#ctxmenu.laymenu { min-width: 0; padding: 6px 8px; }
.layrow { display: flex; align-items: center; gap: 2px; }
.laynum { width: 18px; color: var(--muted); font-size: 12px; text-align: center; }
#ctxmenu .laybtn { width: 36px; height: 34px; padding: 0; justify-content: center; border-radius: 4px; color: var(--text); }
#ctxmenu .laybtn.on { background: #2962ff; color: #fff; }
#ctxmenu .layreset { padding: 6px 8px; border-radius: 4px; }
.laynote { max-width: 260px; padding: 4px 8px 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
