:root {
  --bg: #131722; --panel: #1e222d; --fg: #d1d4dc; --muted: #787b86; --border: #2a2e39;
  --hover: #2a2e39; --active: #2962ff22; --blue: #2962ff; --up: #089981; --down: #f23645;
  --input: #131722; --shadow: 0 8px 24px rgba(0,0,0,.45); --brand: #f7a600;
}
:root[data-theme="light"] {
  --bg: #ffffff; --panel: #ffffff; --fg: #131722; --muted: #6a6d78; --border: #e0e3eb;
  --hover: #f0f3fa; --active: #2962ff1a; --input: #ffffff; --shadow: 0 8px 24px rgba(0,0,0,.15);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, select, input { font: inherit; color: var(--fg); }
button { background: transparent; border: 0; border-radius: 4px; cursor: pointer; }
button:hover { background: var(--hover); }
button.on { color: var(--blue); background: var(--active); }
button:disabled { opacity: .5; cursor: default; }
input, select { background: var(--input); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; }
input:focus, select:focus { outline: 1px solid var(--blue); border-color: var(--blue); }
.btn { height: 34px; padding: 0 14px; background: var(--blue); color: #fff; font-weight: 600; }
.btn:hover { background: #1e53e5; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn.danger { background: var(--down); }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand .mark { width: 24px; height: 24px; border-radius: 6px; display: block; flex: none; }
.auth .brand .mark { width: 32px; height: 32px; border-radius: 8px; }
.brand b { color: var(--brand); }
.muted { color: var(--muted); }
.err { color: var(--down); min-height: 18px; }

/* ---------- App layout ---------- */
#app { display: grid; grid-template-rows: 44px 1fr; grid-template-columns: 56px 1fr auto 48px; height: 100vh; height: 100dvh; overflow: hidden; }
#left { grid-column: 1; grid-row: 2; }
#wrap { grid-column: 2; grid-row: 2; }
#side { grid-column: 3; grid-row: 2; }
#rbar { grid-column: 4; grid-row: 2; }
#top { grid-column: 1 / -1; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#top::-webkit-scrollbar { display: none; }
#top > * { flex: none; }
/* Thanh tren tu thu gon khi man hinh khong du rong (app.js fitTop): c1 an chu tren nut, c2 an Bid/Ask + chu trang thai, c3 an ten thuong hieu */
#top.c1 > button .hide-sm, #top.c1 #typeBtn .hide-sm { display: none; }
#top.c2 #quote, #top.c2 #statusText, #top.c2 #userBtn .un { display: none; }
#top.c3 .brand { font-size: 0; gap: 0; }
#top.c4 #tfs button[data-tf]:not(.on), #top.c4 #favBtn { display: none; }
#top.c5 #undoBtn, #top.c5 #redoBtn, #top.c5 #shotBtn, #top.c5 #fullBtn, #top.c5 .sep, #top.c5 .brand { display: none; }
#top button { height: 32px; padding: 0 8px; }
#top select { height: 30px; padding: 0 6px; }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; flex: none; }
#left { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-right: 1px solid var(--border);
  overflow-y: auto; scrollbar-width: none; }
#left::-webkit-scrollbar { display: none; }
.tg { position: relative; display: flex; flex: none; }
.tg > .main { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; border-radius: 6px; }
.tg > .main > span { font-size: 22px !important; }
/* Mui ten mo nhom: nhu TradingView, hien ro khi re chuot vao nhom */
.tg > .more { position: absolute; right: -7px; top: 50%; transform: translateY(-50%); width: 12px; height: 26px; padding: 0;
  font-size: 13px; line-height: 26px; color: var(--muted); opacity: .45; border-radius: 3px; }
.tg:hover > .more { opacity: 1; background: var(--hover); }
@media (hover: hover) { .tg > .more { opacity: 0; } .tg:hover > .more { opacity: 1; } }
.tg > .main.on { background: var(--active); color: var(--blue); }
#left .gap { height: 1px; width: 32px; background: var(--border); margin: 6px 0; flex: none; }
#top svg, .menu svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#left svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.menu svg { width: 24px; height: 24px; }
.menu button.item { padding: 8px 16px; font-size: 14px; }

#wrap { position: relative; min-width: 0; min-height: 0; }
#chart { position: absolute; inset: 0; }
#draw { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; }
#legend { position: absolute; left: 10px; top: 6px; z-index: 3; pointer-events: none; line-height: 1.7; max-width: calc(100% - 90px); }
#legend .h { font-weight: 600; font-size: 14px; }
#legend .v span { margin-right: 10px; white-space: nowrap; }
.ind-row { display: flex; align-items: center; gap: 6px; pointer-events: auto; width: max-content; max-width: 100%; border-radius: 4px; padding: 0 4px; margin-left: -4px; }
.ind-row:hover { background: var(--hover); }
.ind-row .nm { color: var(--fg); white-space: nowrap; }
.ind-row .vals span { margin-right: 6px; white-space: nowrap; font-size: 12px; }
.ind-row .acts { display: none; gap: 2px; }
.ind-row:hover .acts { display: flex; }
.ind-row .acts button { width: 22px; height: 22px; padding: 0; font-size: 13px; }
.ind-row.hidden .nm, .ind-row.hidden .vals { opacity: .45; }
.pane-legend { position: absolute; left: 10px; z-index: 3; pointer-events: none; }
.leg-toggle { pointer-events: auto; height: 20px; padding: 0 6px; margin-left: -4px; font-size: 12px; color: var(--muted); border: 1px solid var(--border); background: var(--panel); }
#hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: 40px; z-index: 4; background: var(--panel); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 6px; box-shadow: var(--shadow); display: none; white-space: nowrap; }
#quote { margin-left: 6px; font-variant-numeric: tabular-nums; }
#quote .bid { color: var(--down); } #quote .ask { color: var(--up); }
#status { display: flex; align-items: center; gap: 6px; color: var(--muted); padding: 0 8px; }
#dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
#dot.live { background: var(--up); } #dot.off { background: var(--down); }
.spacer { flex: 1 1 auto !important; }
#autoBtn { position: absolute; right: 68px; bottom: 34px; z-index: 3; height: 24px; padding: 0 8px; border: 1px solid var(--border); background: var(--panel); font-weight: 600; }
#empty { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); z-index: 5; background: var(--bg); padding: 16px; line-height: 1.7; }

/* ---------- Menus, popovers, dialogs ---------- */
.menu { position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow);
  padding: 4px 0; min-width: 210px; max-height: 80vh; overflow-y: auto; }
.menu .item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 14px; border-radius: 0; text-align: left; white-space: nowrap; }
.menu .item.on { color: var(--blue); }
.menu .item .key { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu .title { padding: 6px 14px 2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.menu .item:has(.emoji-grid) { padding: 4px 8px; cursor: default; }
.menu .item:has(.emoji-grid):hover { background: transparent; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 34px); gap: 2px; }
.emoji-grid span { font-size: 20px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 4px; cursor: pointer; }
.emoji-grid span:hover { background: var(--hover); }
#wrap.cur-arrow canvas { cursor: default !important; }
#wrap.cur-eraser canvas { cursor: cell !important; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); width: min(520px, 100%);
  max-height: 86vh; display: flex; flex-direction: column; }
.dialog header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; }
.dialog header button { margin-left: auto; width: 30px; height: 30px; font-size: 18px; }
.dialog .body { padding: 12px 16px; overflow-y: auto; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.dialog .search { width: 100%; margin-bottom: 8px; }
.ind-list { min-height: min(56vh, 520px); }
.dialog .body:has(.ind-list) { height: min(70vh, 600px); }
.ind-list .cat { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin: 10px 0 4px; }
.ind-list button { display: block; width: 100%; text-align: left; padding: 8px 10px; }
.form-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.form-row label { flex: 1; }
.form-row input[type=number] { width: 110px; }
.form-row input[type=color] { width: 44px; height: 30px; padding: 2px; }

/* Thanh chinh sua hinh ve */
/* Thanh noi giong TradingView: tay cam | mau net | nen | chu | do day | kieu net | cai dat | canh bao | khoa | xoa | them */
#drawbar { position: absolute; z-index: 6; display: none; align-items: center; gap: 1px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 4px 6px; gap: 2px; user-select: none; }
#drawbar button { position: relative; height: 36px; min-width: 36px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border-radius: 6px; }
#drawbar button.on { color: var(--blue); background: var(--active); }
#drawbar svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
#drawbar svg.fill { fill: currentColor; stroke: none; }
#drawbar .db-grip { display: inline-flex; align-items: center; width: 12px; height: 28px; cursor: grab; color: var(--muted); margin-right: 2px; }
#drawbar .db-grip svg { width: 10px; }
#drawbar .db-c { position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border-radius: 2px; border: 1px solid rgba(128, 128, 128, .35); }
#drawbar .db-t { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* goc phai thanh tren: ngon ngu + profile / dang nhap - dang ky */
#langBtn { display: inline-flex; align-items: center; gap: 4px; }
#langBtn .lb-code { font-size: 12px; font-weight: 600; }
#userBtn { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px 0 4px; border-radius: 16px; }
#userBtn[hidden], #guestBtns[hidden] { display: none; }
#top .av, .menu .av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none; }
#userBtn .un { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.menu .um-h { display: flex; align-items: center; gap: 8px; }
.menu .um-role { display: block; font-size: 11px; margin: 2px 0 0 32px; }
#guestBtns { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
#guestBtns a { text-decoration: none; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
#guestBtns .tb-link { color: var(--fg); }
#guestBtns .tb-link:hover { background: var(--active); }
#guestBtns .tb-cta { background: #2962ff; color: #fff; }
#guestBtns .tb-cta:hover { background: #1e53e5; }
/* khach dung thu het 1 phut -> che chart, yeu cau dang ky */
#guestGate { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 18, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#guestGate .gg-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 28px 24px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
#guestGate .gg-logo { width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 14px; }
#guestGate h2 { margin: 0; font-size: 20px; }
#guestGate p { margin: 0 0 6px; line-height: 1.5; font-size: 13px; }
#guestGate .btn { display: block; text-decoration: none; text-align: center; padding: 10px; }
#guestGate .btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); }
/* dong ho dem nguoc dong nen: ngay duoi nhan gia cuoi */
#barCd { position: absolute; z-index: 4; display: none; pointer-events: none; color: #fff; font-size: 12px; line-height: 18px; height: 18px;
  padding: 0 6px; box-sizing: border-box; font-variant-numeric: tabular-nums; border-radius: 0 0 2px 2px; }
/* nhan gia / thoi gian xanh tren truc cho hinh dang chon */
.dw-axis { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 5; pointer-events: none; }
.dw-axis div { position: absolute; background: #2962ff; color: #fff; font-size: 12px; line-height: 20px; height: 20px; padding: 0 6px; white-space: nowrap;
  font-variant-numeric: tabular-nums; border-radius: 2px; box-sizing: border-box; }
.dw-axis .dw-pl { transform: translateY(-50%); }
.dw-axis .dw-tl { transform: translateX(-50%); margin-top: 2px; }
.db-pop { position: absolute; z-index: 9; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); padding: 8px; min-width: 120px; }
.db-pop .pal { display: grid; grid-template-columns: repeat(10, 20px); gap: 3px; }
.db-pop .pc { width: 20px; height: 20px; padding: 0; border-radius: 3px; border: 1px solid rgba(128, 128, 128, .3); }
.db-pop .pc.on { outline: 2px solid var(--blue); outline-offset: 1px; }
.db-pop .pop-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; }
.db-pop .pop-row input[type=range] { flex: 1; }
.db-pop .pop-row input[type=color] { width: 36px; height: 24px; padding: 0; border: 1px solid var(--border); }
.db-pop .pop-row.chk { margin: 0 0 8px; }
.db-pop .pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; text-align: left; white-space: nowrap; }
.db-pop .pop-item.on { color: var(--blue); background: var(--active); }
.db-pop .pop-item svg { width: 24px; height: 20px; stroke: currentColor; fill: none; }
.db-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
/* Hop Cai dat hinh ve */
.ds-vis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; }
.ds-vis label { display: flex; align-items: center; gap: 6px; }
.ds-tabs { margin-bottom: 12px; }
.ds-trow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ds-trow input[type=color] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--border); }
.ds-tog { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 30px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; user-select: none; }
.ds-tog input { display: none; }
.ds-tog:has(input:checked) { background: var(--active); color: var(--blue); border-color: var(--blue); }
.ds-text { width: 100%; min-height: 96px; resize: vertical; background: var(--input); border: 1px solid var(--border); border-radius: 4px; color: var(--fg); padding: 8px; font: inherit; margin-bottom: 8px; }
.ds-text:focus { outline: 1px solid var(--blue); border-color: var(--blue); }
/* Ngoi sao Yeu thich trong menu cong cu + thanh Yeu thich noi tren chart */
.menu .fav-star { margin-left: auto; padding-left: 12px; color: var(--muted); opacity: 0; font-size: 14px; }
.menu button.item:hover .fav-star, .menu .fav-star.on { opacity: 1; }
.menu .fav-star.on { color: #f7a600; }
.menu .fav-star:hover { color: #f7a600; }
.menu .key + .fav-star { padding-left: 8px; }
#favbar { position: absolute; z-index: 5; top: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 1px; padding: 3px 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
#favbar button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border-radius: 4px; }
#favbar button.on { color: var(--blue); background: var(--active); }
#favbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
#favbar .fb-grip { width: 10px; height: 26px; cursor: grab; opacity: .55; background: radial-gradient(circle, currentColor 1px, transparent 1.3px) 0 0 / 5px 5px; }
@media (hover: none) { .menu .fav-star { opacity: .6; } }
/* Menu khung thoi gian giong TradingView */
.tf-menu { width: 240px; overflow-y: auto; padding: 4px 0; }
.tf-menu .tf-add { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.tf-menu .tf-add:hover { background: var(--hover); }
.tf-menu .tf-form { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tf-menu .tf-form[hidden] { display: none; }
.tf-menu .tf-form input { width: 60px; } .tf-menu .tf-form select { flex: 1; } .tf-menu .tf-form .btn { height: 30px; padding: 0 10px; }
.tf-menu .tf-sec { display: flex; justify-content: space-between; padding: 10px 14px 6px; font-size: 11px; font-weight: 600; letter-spacing: .5px; color: var(--muted); cursor: pointer; border-top: 1px solid var(--border); }
.tf-menu .tf-sec:hover { color: var(--fg); }
.tf-menu .tf-row { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 14px; cursor: pointer; border-radius: 4px; margin: 0 4px; }
.tf-menu .tf-row:hover { background: var(--hover); }
.tf-menu .tf-row.on { background: var(--fg); color: var(--bg); }
.tf-menu .tf-row span:first-child { flex: 1; }
.tf-menu .tf-row.dis { color: var(--muted); cursor: default; }
.tf-menu .tf-soon { font-size: 11px; }
.tf-menu .tf-star, .tf-menu .tf-x { width: 22px; height: 22px; padding: 0; font-size: 15px; color: var(--muted); opacity: 0; background: none; }
.tf-menu .tf-row:hover .tf-star, .tf-menu .tf-row:hover .tf-x, .tf-menu .tf-star.on { opacity: 1; }
.tf-menu .tf-star.on { color: #f7a600; }
.tf-menu .tf-row.on .tf-star, .tf-menu .tf-row.on .tf-x { color: var(--bg); }
#tfs .tf-dd { padding: 0 6px; color: var(--muted); }
.type-menu { overflow-y: auto; }
.menu .dis { color: var(--muted); }
@media (hover: none) { .tf-menu .tf-star, .tf-menu .tf-x { opacity: .6; } }

/* ---------- Login / admin ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px 24px; box-shadow: var(--shadow); }
.card h1 { font-size: 18px; margin: 18px 0 4px; }
.card label { display: block; margin: 14px 0 6px; color: var(--muted); }
.card input { width: 100%; height: 38px; }
.card .btn { width: 100%; height: 40px; margin-top: 18px; }
.card .links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.card a, .err a { color: var(--blue); text-decoration: none; }
.card a:hover { text-decoration: underline; }
.ok { color: var(--up); min-height: 0; margin: 8px 0 0; }
.ok:empty { display: none; }
/* Bang (table.new) cua script */
#scriptTables { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.st-pos { position: absolute; display: flex; flex-direction: column; gap: 6px; max-width: 70%; }
.st-pos table { border-collapse: collapse; pointer-events: auto; }
.st-pos td { padding: 2px 6px; border: 1px solid rgba(120,123,134,.25); white-space: nowrap; }
.st-top_right { top: 6px; right: 70px; } .st-top_left { top: 70px; left: 8px; } .st-top_center { top: 6px; left: 50%; transform: translateX(-50%); }
.st-middle_right { top: 50%; right: 70px; transform: translateY(-50%); } .st-middle_left { top: 50%; left: 8px; transform: translateY(-50%); }
.st-middle_center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.st-bottom_right { bottom: 34px; right: 70px; } .st-bottom_left { bottom: 34px; left: 8px; } .st-bottom_center { bottom: 34px; left: 50%; transform: translateX(-50%); }

/* Replay */
/* Bang dieu khien replay noi giua day chart nhu TradingView (khong lam chart co lai) */
#replayBar { position: absolute; left: 50%; transform: translateX(-50%); bottom: 40px; height: 42px; z-index: 7; display: flex; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  padding: 0 5px; white-space: nowrap; max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; user-select: none; }
#replayBar[hidden] { display: none; }
#replayBar button { height: 32px; min-width: 32px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; border-radius: 4px; }
#replayBar button:disabled { opacity: 0.35; }
#replayBar button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linejoin: round; }
#replayBar button svg.fill { fill: currentColor; stroke: none; }
#replayBar .rp-grip { width: 10px; height: 26px; flex: none; cursor: grab; margin-right: 2px; opacity: 0.55;
  background: radial-gradient(circle, currentColor 1px, transparent 1.3px) 0 0 / 5px 5px; }
#replayBar .rp-sel.on { color: var(--blue); background: rgba(41, 98, 255, 0.14); }
#replayBar .rp-dd { min-width: 18px; padding: 0 3px; margin-left: -2px; }
#replayBar .rp-txt { font-weight: 600; min-width: 40px; }
#replayBar .rp-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; flex: none; }
#replayBar .rp-info { padding: 0 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
#wrap.with-pine #replayBar { bottom: calc(var(--pine-h) + 40px); }
/* Che do chon nen: vach xanh theo chuot + mo phan tuong lai */
#rpShade { position: absolute; top: 0; z-index: 4; pointer-events: none; background: rgba(19, 23, 34, 0.55); border-left: 1px solid var(--blue); }
:root[data-theme="light"] #rpShade { background: rgba(255, 255, 255, 0.6); }
#rpShade[hidden] { display: none; }
#rpShade .rp-cut { position: absolute; left: -13px; top: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; }
#rpShade .rp-cut svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
#wrap.rp-selecting canvas { cursor: pointer !important; }

/* Canh bao */
#alertBtn .cnt:not(:empty) { margin-left: 4px; background: var(--blue); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.alert-pop { width: 340px; padding: 6px 0 8px; }
.alert-pop .ap-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.alert-pop .ap-link { color: var(--fg); padding: 2px 4px; }
.alert-pop .ap-ask { display: flex; gap: 6px; margin: 8px 10px 0; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.alert-pop .ap-ask input { flex: 1; border: 0; background: transparent; min-width: 0; }
.alert-pop .ap-ask input:focus { outline: none; }
.alert-pop .ap-ask button { width: 34px; height: 30px; background: var(--hover); font-size: 16px; }
.alert-pop .ap-err { padding: 4px 14px 0; font-size: 12px; }
.al-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.al-tabs button { padding: 6px 12px; border: 1px solid var(--border); }
.al-row { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.al-row .al-main { flex: 1; min-width: 0; }
.al-row .al-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-row button { padding: 4px 8px; font-size: 12px; }
.al-log { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 6px; padding: 10px 14px;
  box-shadow: var(--shadow); cursor: pointer; animation: toastIn .2s ease-out; }
.toast.alert { border-left-color: #ff9800; font-weight: 600; }
.toast.ok { border-left-color: var(--up); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Pine Editor: khung duoi, chart co lai de khong bi che */
#wrap { --pine-h: 40%; }
#wrap.with-pine #chart { bottom: var(--pine-h); }
#wrap.with-pine #autoBtn { bottom: calc(var(--pine-h) + 34px); }
#wrap.with-pine #credit { bottom: calc(var(--pine-h) + 32px); }
#pine { position: absolute; left: 0; right: 0; bottom: 0; height: var(--pine-h); z-index: 8; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--border); }
#pine[hidden] { display: none; }
#tester { position: absolute; left: 0; right: 0; bottom: 0; height: var(--pine-h); z-index: 8; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--border); }
#tester[hidden] { display: none; }
#tester .pine-bar button.on { color: var(--blue); border-color: var(--blue); }
#testerBody { flex: 1; min-height: 0; overflow: auto; }
.ts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--border); border-bottom: 1px solid var(--border); }
.ts-cell { background: var(--panel); padding: 10px 14px; }
.ts-v { font-size: 18px; font-weight: 600; margin-top: 2px; }
.ts-sub { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); }
#eqCanvas { display: block; width: calc(100% - 24px); height: 140px; margin: 12px; }
.ts-note { padding: 0 14px 10px; font-size: 12px; }
.ts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ts-table th { position: sticky; top: 0; background: var(--panel); text-align: left; color: var(--muted); font-weight: 500; }
.ts-table th, .ts-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ts-table tbody tr { cursor: pointer; } .ts-table tbody tr:hover { background: var(--hover); }
.ts-open td { font-style: italic; }
#pineGrip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; }
.pine-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.pine-bar > * { flex: none; }
.pine-bar button { height: 30px; padding: 0 10px; border: 1px solid var(--border); }
.pine-bar button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.pine-bar select { height: 30px; max-width: 220px; }
.pine-title { margin-right: 6px; }
#pineCode { flex: 1; min-height: 0; resize: none; border: 0; border-radius: 0; padding: 10px 12px; outline: none;
  font: 13px/1.55 Consolas, "Cascadia Mono", "Courier New", monospace; tab-size: 4; background: var(--bg); color: var(--fg); }
.pine-msg { padding: 5px 12px; font-size: 12px; border-top: 1px solid var(--border); min-height: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pine-msg.ok { color: var(--up); } .pine-msg.err { color: var(--down); } .pine-msg.warn { color: #ff9800; }
#credit { position: absolute; left: 8px; bottom: 32px; z-index: 3; font-size: 10px; color: var(--muted); opacity: .7; text-decoration: none; }
#credit:hover { opacity: 1; text-decoration: underline; }
.admin { max-width: 1100px; margin: 0 auto; padding: 16px; }
/* Thong ke truy cap (trang Quan tri) */
.st-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.st-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.st-card .st-n { font-size: 26px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.st-card .st-sub { font-size: 11px; color: var(--muted); }
.st-card .up { color: var(--up); } .st-card .dn { color: var(--down); }
.st-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.st-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; min-width: 0; }
.st-box.st-wide { grid-column: 1 / -1; }
.st-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.st-leg { margin-left: auto; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; }
.st-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }
.st-chart { display: flex; align-items: stretch; gap: 3px; height: 170px; }
.st-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.st-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 1px; }
.st-stack i { width: 30%; min-height: 0; border-radius: 2px 2px 0 0; }
.st-col span { font-size: 10px; color: var(--muted); height: 14px; font-variant-numeric: tabular-nums; }
.st-col em { font-size: 10px; color: var(--muted); font-style: normal; }
.st-col:hover { background: var(--hover); border-radius: 3px; }
.st-list { max-height: 260px; overflow-y: auto; }
.st-on { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.st-on > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-row { display: grid; grid-template-columns: minmax(80px, 40%) 1fr auto; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; }
.st-row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-bar { height: 8px; background: var(--hover); border-radius: 4px; overflow: hidden; }
.st-bar i { display: block; height: 100%; background: #2962ff; border-radius: 4px; }
@media (max-width: 800px) { .st-grid { grid-template-columns: 1fr; } .st-chart { height: 130px; } .st-col span { display: none; } }
.admin header.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.admin table { width: 100%; border-collapse: collapse; }
.admin th, .admin td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin td.note { white-space: normal; }
.admin .tbl { overflow-x: auto; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--hover); }
.badge.ok { color: var(--up); } .badge.off { color: var(--down); }
.admin .new { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.admin .new input { height: 34px; }
.secret { font-family: Consolas, monospace; background: var(--hover); padding: 2px 6px; border-radius: 4px; user-select: all; }

/* ---------- Thanh ben phai (giong TradingView) ---------- */
#rbar { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-left: 1px solid var(--border);
  overflow-y: auto; scrollbar-width: none; }
#rbar::-webkit-scrollbar { display: none; }
#rbar button { position: relative; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; flex: none; border-radius: 6px; }
#rbar svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
#rbar svg.fill { fill: currentColor; stroke: none; }
#rbar button.on { background: var(--active); color: var(--blue); }
#rbar .rb-gap { width: 26px; height: 1px; background: var(--border); margin: 6px 0; flex: none; }
#rbar .badge { position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--down);
  color: #fff; font: 600 10px/16px sans-serif; font-style: normal; text-align: center; display: none; }
#side { position: relative; width: 320px; min-width: 240px; border-left: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#side[hidden] { display: none; }
#sideGrip { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
#sideGrip:hover { background: var(--blue); opacity: .5; }
#sideIn { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.sd-head { display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 8px 0 12px; flex: none; font-size: 15px; }
.sd-head button { height: 30px; min-width: 30px; padding: 0 6px; font-size: 17px; }
.sd-head .sd-btn { font-size: 13px; color: var(--blue); }
.sd-body { flex: 1; overflow-y: auto; min-height: 0; }
.sd-tabs { display: flex; gap: 2px; padding: 0 8px 6px; border-bottom: 1px solid var(--border); flex: none; }
.sd-tabs button { padding: 5px 10px; font-size: 13px; color: var(--muted); }
.sd-tabs button.on { color: var(--fg); background: var(--hover); }
.sd-empty { text-align: center; padding: 28px 16px; line-height: 1.6; }
.sd-note { font-size: 12px; padding: 8px 12px; line-height: 1.5; }
/* Watchlist */
.wl-cols, .wl-row { display: grid; grid-template-columns: minmax(90px, 1.3fr) 1fr .9fr .8fr; align-items: center; column-gap: 6px; padding: 0 22px 0 12px; }
.wl-cols { height: 28px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); flex: none; }
.wl-cols span:not(:first-child) { text-align: right; }
.wl-row { position: relative; height: 34px; cursor: pointer; font-variant-numeric: tabular-nums; border-bottom: 1px solid transparent; }
.wl-row:hover { background: var(--hover); }
.wl-row.on { background: var(--active); box-shadow: inset 2px 0 0 var(--blue); }
.wl-row .sym { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.wl-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-row .num { text-align: right; white-space: nowrap; }
.wl-row .mk { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); flex: none; }
.wl-row .mk.on { background: var(--up); }
.wl-row .hk-b { position: absolute; right: 24px; bottom: 1px; font-size: 9px; display: none; }
.wl-row .x, .wl-sec .x { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; padding: 0; line-height: 18px;
  color: var(--muted); display: none; }
.wl-row:hover .x, .wl-sec:hover .x { display: block; }
.wl-sec { position: relative; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; font-size: 11px; font-weight: 600;
  letter-spacing: .4px; color: var(--muted); cursor: pointer; user-select: none; }
.wl-sec:hover { background: var(--hover); }
.wl-sec .car { width: 10px; }
.sym-ic { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font: 700 9px/1 sans-serif; font-style: normal; }
/* Chi tiet ma */
.dt { border-top: 1px solid var(--border); padding: 12px; }
.dt-h { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.dt-h .sym-ic { width: 28px; height: 28px; font-size: 11px; }
.dt-sub { margin-top: 4px; font-size: 12px; }
.dt-price { font-size: 30px; font-weight: 600; margin-top: 10px; font-variant-numeric: tabular-nums; }
.dt-chg { font-size: 15px; font-weight: 600; margin-top: 2px; }
.dt-mk { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.dt-mk i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dt-mk.on { color: var(--up); } .dt-mk.on i { background: var(--up); }
.dt-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin-top: 14px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dt-grid span:nth-child(even) { text-align: right; }
.dt-rng { margin-top: 12px; font-size: 12px; font-variant-numeric: tabular-nums; }
.dt-rng .lbl { display: flex; justify-content: space-between; }
.dt-rng .bar { position: relative; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--down), var(--up)); margin-top: 6px; opacity: .8; }
.dt-rng .bar i { position: absolute; top: -4px; width: 2px; height: 12px; background: var(--fg); transform: translateX(-1px); }
/* Canh bao */
.al-item { position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.al-item:hover { background: var(--hover); }
.al-item .st { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.al-item .st.run { background: var(--up); } .al-item .st.exp { background: var(--down); } .al-item .st.done { background: var(--brand); }
.al-txt { flex: 1; min-width: 0; line-height: 1.45; } .al-txt b { font-weight: 500; word-break: break-word; } .al-txt .muted { font-size: 12px; }
.al-acts { display: none; gap: 2px; } .al-item:hover .al-acts { display: flex; }
.al-acts button { width: 24px; height: 24px; padding: 0; font-size: 12px; }
#alBody .al-log { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; line-height: 1.45; }
/* Cay doi tuong / cua so du lieu */
.ob-sec { display: flex; align-items: center; padding: 10px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .3px; color: var(--muted); text-transform: uppercase; }
.ob-clr { margin-left: auto; font-size: 11px; color: var(--down); padding: 2px 6px; text-transform: none; }
.ob-row { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 12px; cursor: pointer; }
.ob-row:hover { background: var(--hover); } .ob-row.on { background: var(--active); }
.ob-row.off .ob-nm, .ob-row.off .ob-ic { opacity: .4; }
.ob-ic { width: 22px; text-align: center; font-size: 12px; color: var(--muted); flex: none; }
.ob-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-acts { display: none; gap: 2px; } .ob-row:hover .ob-acts { display: flex; }
.ob-acts button { width: 24px; height: 24px; padding: 0; font-size: 12px; }
.dw-row { display: flex; justify-content: space-between; padding: 3px 12px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
/* Tin tuc - Lich kinh te */
.nw-f { flex: none; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.nw-days { border-bottom: 0; padding-bottom: 4px; }
.nw-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 8px; }
.nw-chips button { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); }
.nw-chips button.on { color: var(--fg); border-color: var(--blue); background: var(--active); }
.nw-chips i { width: 8px; height: 8px; border-radius: 2px; }
.nw-next { display: flex; flex-direction: column; gap: 2px; margin: 8px; padding: 8px 10px; border-radius: 6px; background: var(--active); border-left: 3px solid var(--blue); font-size: 12.5px; }
.nw-next b { font-weight: 600; } .nw-cd { color: var(--blue); }
.nw-day { position: sticky; top: 0; z-index: 1; padding: 6px 12px; font-size: 12px; font-weight: 600; background: var(--hover); text-transform: capitalize; }
.nw-row { display: grid; grid-template-columns: 40px 34px 10px 1fr; align-items: center; column-gap: 6px; padding: 7px 10px 7px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.nw-row.past { opacity: .6; }
.nw-row.next { background: var(--active); opacity: 1; }
.nw-t { font-variant-numeric: tabular-nums; color: var(--muted); }
.nw-cur { font-weight: 700; font-size: 11.5px; }
.nw-imp { width: 8px; height: 14px; border-radius: 2px; }
.nw-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-vals { grid-column: 2 / -1; display: flex; gap: 12px; margin-top: 3px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nw-vals b { color: var(--fg); font-weight: 600; } .nw-vals b.up { color: var(--up); } .nw-vals b.down { color: var(--down); }
.nw-now { position: relative; height: 0; border-top: 2px solid var(--down); margin: 6px 0; }
.nw-now span { position: absolute; right: 8px; top: -9px; font-size: 10.5px; padding: 0 6px; border-radius: 3px; background: var(--down); color: #fff; }
/* Phien giao dich */
.ses-now { padding: 10px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.ses { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ses-h { display: flex; align-items: baseline; gap: 8px; } .ses-h .muted { font-size: 12px; }
.ses-st { margin-left: auto; font-size: 12px; color: var(--muted); } .ses.on .ses-st { color: var(--up); font-weight: 600; }
.ses-t { margin: 8px 0 4px; }
.trk { position: relative; height: 8px; border-radius: 4px; background: var(--hover); overflow: hidden; }
.trk i { position: absolute; top: 0; bottom: 0; opacity: .75; border-radius: 4px; }
.trk .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--fg); }
.ses-l { font-size: 12px; }
.ses-tip { margin: 10px 12px; padding: 8px 10px; border-radius: 6px; background: var(--hover); font-size: 12.5px; line-height: 1.5; }
/* Thong bao */
.nt-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; line-height: 1.45; }
.nt-item .muted { font-size: 11.5px; }
/* Chat */
.ch-msg { padding: 6px 12px; }
.ch-h { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.ch-h button { margin-left: auto; width: 18px; height: 18px; padding: 0; color: var(--muted); display: none; }
.ch-msg:hover .ch-h button { display: block; }
.ch-msg.me .ch-h b { color: var(--blue); }
.ch-t { margin-top: 2px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.ch-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); flex: none; }
.ch-form input { flex: 1; min-width: 0; height: 34px; }
/* Y tuong */
.idea { margin: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.idea:hover { border-color: var(--blue); }
.idea img { width: 100%; border-radius: 4px; display: block; margin-bottom: 8px; }
.idea-t { display: block; line-height: 1.4; }
.idea-m { font-size: 12px; margin-top: 4px; }
.idea-x { font-size: 12.5px; margin-top: 6px; line-height: 1.45; color: var(--muted); }
.idea-f { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 12px; }
.idea-f button { font-size: 12px; padding: 2px 8px; color: var(--muted); }
.idea-f button.on { color: var(--down); }
.help p { line-height: 1.55; margin: 0 0 10px; }
/* Tim ma */
.ss-dlg { width: min(640px, calc(100vw - 24px)) !important; max-width: none !important; }
.ss-f { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.ss-f select { height: 30px; }
.ss-list { height: min(55vh, 460px); overflow-y: auto; border-top: 1px solid var(--border); }
.ss-row { display: grid; grid-template-columns: 20px 24px minmax(80px, auto) 1fr auto auto; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.ss-row:hover { background: var(--hover); }
.ss-fav { font-size: 16px; color: var(--muted); text-align: center; cursor: pointer; }
.ss-fav:hover, .ss-fav.on { color: #f7a600; }
/* Ngoi sao Yeu thich */
#favBtn { font-size: 19px; line-height: 1; color: var(--muted); }
#favBtn.fav-on, #favBtn:hover { color: #f7a600; }
.wl-row .fav { width: 16px; height: 18px; padding: 0; font-size: 14px; line-height: 18px; color: var(--muted); flex: none; opacity: 0; margin-left: -6px; }
.wl-row:hover .fav { opacity: 1; }
.wl-row .fav.on { opacity: 1; color: #f7a600; }
.wl-row .fav:hover { color: #f7a600; background: none; }
.wl-sec.fav { color: #f7a600; }
@media (hover: none) { .wl-row .fav { opacity: .6; } } /* dien thoai: khong re chuot duoc nen luon hien */
.ss-d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-c { font-size: 11px; color: var(--muted); }
.ss-b { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--hover); }
#symSearch svg { width: 18px; height: 18px; }

/* ---------- Cam giac nhu app tren dien thoai ----------
   Trang khong bao gio cuon / nay / keo-de-tai-lai: chi tung thanh cuon theo dung chieu cua no,
   nen keo thanh cong cu khong lam ca man hinh troi theo */
html, body { overscroll-behavior: none; }
body:has(#app) { position: fixed; inset: 0; overflow: hidden; }
#app { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#app input, #app textarea, #app [contenteditable] { -webkit-user-select: text; user-select: text; }
button, a, select, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#top, #rbar, #tfs { touch-action: pan-x; overscroll-behavior: contain; }
#left, #side, #sideIn, .menu, .dialog, .db-pop { touch-action: pan-y; overscroll-behavior: contain; }
#wrap { touch-action: none; }
#drawFab { display: none; }

@media (max-width: 700px) {
  /* Bo cuc app: thanh tren | chart toan chieu ngang | thanh dieu huong duoi (thay cot icon ben phai) */
  #app { grid-template-columns: 50px 1fr; grid-template-rows: calc(44px + env(safe-area-inset-top)) 1fr calc(52px + env(safe-area-inset-bottom)); }
  body.draw-closed #app { grid-template-columns: 0 1fr; }
  #top { padding-top: env(safe-area-inset-top); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  #wrap { grid-column: 2; }
  #rbar { grid-column: 1 / -1; grid-row: 3; flex-direction: row; justify-content: space-between; gap: 0; padding: 0 6px env(safe-area-inset-bottom);
    border-left: 0; border-top: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
  #rbar .rb-gap, #rbar .spacer { display: none; }
  #rbar button { flex: 1 1 0; width: auto; min-width: 34px; max-width: 64px; height: 46px; } #rbar svg { width: 24px; height: 24px; }
  #rbar [data-side-act] { display: none; }
  #rbar button:hover { background: transparent; } #rbar button.on { background: var(--active); }
  /* Watchlist, tin tuc... mo thanh bang tran man hinh giua thanh tren va thanh duoi */
  #side { position: fixed; left: 0; right: 0; top: calc(44px + env(safe-area-inset-top)); bottom: calc(52px + env(safe-area-inset-bottom));
    width: auto !important; min-width: 0; z-index: 30; border-left: 0; }
  #sideGrip { display: none; }
  /* Cong cu ve: hien san ben trai (chart co lai vua phan con lai); bam nut ✏ noi tren chart de an / hien */
  #left { grid-column: 1; padding: 6px 0; gap: 2px; }
  body.draw-closed #left { display: none; }
  #drawFab { display: grid; place-items: center; position: absolute; left: 10px; bottom: 44px; z-index: 7; width: 44px; height: 44px; padding: 0;
    border-radius: 50%; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--blue); }
  #drawFab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  body.draw-closed #drawFab { color: var(--fg); }
  .tg > .main { width: 40px; height: 40px; }
  #left svg { width: 24px; height: 24px; }
  .tg > .more { right: -5px; width: 10px; }
  #quote, .hide-sm { display: none; }
  #legend .h { font-size: 13px; }
  /* o nhap >= 16px: iPhone khong tu phong to trang khi bam vao o nhap */
  input, select, textarea { font-size: 16px; }
  #drawbar { max-width: calc(100vw - 16px); overflow-x: auto; touch-action: pan-x; }
}

/* ---------- Trang SEO: /chart, /chart/<ma>, /gioi-thieu, /blog (trang cuon binh thuong, khong phai app) ---------- */
body.seo { overflow: auto; position: static; }
.seo-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px max(16px, calc((100vw - 1100px) / 2)); background: var(--bg);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.seo-top .brand { color: var(--fg); text-decoration: none; font-size: 16px; }
.seo-top nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.seo-top nav a { color: var(--fg); text-decoration: none; padding: 7px 10px; border-radius: 6px; font-weight: 500; }
.seo-top nav a:hover { background: var(--hover); }
.seo-top nav .seo-cta { background: #2962ff; color: #fff; font-weight: 600; }
.seo-top nav .seo-cta:hover { background: #1e53e5; }
.seo-main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.seo-hero { padding: 28px 0 12px; }
.seo-hero h1 { font-size: clamp(24px, 4vw, 36px); line-height: 1.2; margin: 0 0 12px; }
.seo-lead { font-size: 16px; line-height: 1.6; max-width: 780px; color: var(--muted); }
.seo .btn { display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: 6px; text-decoration: none; }
.seo-crumb { font-size: 12px; color: var(--muted); margin: 6px 0 12px; }
.seo-crumb a { color: var(--muted); }
.seo-sym { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.seo-sym h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); }
.seo-sym h1 small { font-size: 15px; color: var(--muted); font-weight: 500; }
.seo-px { margin: 8px 0; font-variant-numeric: tabular-nums; }
.seo-px b { font-size: clamp(28px, 5vw, 40px); }
.seo-px span { font-size: 16px; font-weight: 600; margin-left: 8px; }
.seo .up { color: var(--up); } .seo .dn { color: var(--down); }
.seo-stats { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.seo-stats b { color: var(--fg); font-variant-numeric: tabular-nums; }
.seo-mini { height: 320px; margin: 16px 0 6px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seo-note { font-size: 12px; }
.seo-text { max-width: 820px; line-height: 1.7; font-size: 15px; }
.seo-text h2, .seo-h2 { font-size: 20px; margin: 28px 0 10px; }
.seo-text h3 { font-size: 17px; margin: 22px 0 8px; }
.seo-text a { color: #2962ff; }
.seo-text details { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 8px 0; background: var(--panel); }
.seo-text summary { cursor: pointer; font-weight: 600; }
.seo-text img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.seo-text blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid #2962ff; background: var(--panel); border-radius: 0 6px 6px 0; }
.seo-text code { background: var(--panel); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.seo-article h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.25; margin: 8px 0; }
.seo-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.seo-tags a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 16px; color: var(--fg); text-decoration: none; font-weight: 600; font-size: 13px; }
.seo-tags a:hover { border-color: #2962ff; color: #2962ff; }
.seo-tbl { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.seo-tbl table { width: 100%; border-collapse: collapse; }
.seo-tbl th, .seo-tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
.seo-tbl th:not(:first-child), .seo-tbl td:not(:first-child) { text-align: right; }
.seo-tbl tr:last-child td { border-bottom: 0; }
.seo-tbl a { color: var(--fg); text-decoration: none; }
.seo-tbl tbody tr:hover { background: var(--hover); }
.seo-feats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 20px 0; }
.seo-feat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.seo-feat h3 { margin: 0 0 6px; font-size: 16px; }
.seo-feat p { margin: 0; color: var(--muted); line-height: 1.55; }
.seo-posts { display: grid; gap: 12px; }
.seo-post { display: block; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--fg); text-decoration: none; }
.seo-post:hover { border-color: #2962ff; }
.seo-post h2 { margin: 0 0 6px; font-size: 18px; }
.seo-post p { margin: 0 0 8px; color: var(--muted); line-height: 1.55; }
.seo-cta-box { margin: 28px 0; padding: 18px; border: 1px solid #2962ff55; background: #2962ff12; border-radius: 10px; }
.seo-cta-box p { margin: 6px 0 12px; }
.seo-foot { max-width: 1100px; margin: 30px auto 0; padding: 20px 16px 40px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); line-height: 1.6; }
@media (max-width: 700px) {
  .seo-top { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; }
  .seo-top .brand { font-size: 0; gap: 0; flex: none; }
  .seo-top nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .seo-top nav::-webkit-scrollbar { display: none; }
  .seo-top nav a { padding: 7px 8px; white-space: nowrap; font-size: 13px; }
  .seo-mini { height: 240px; } .seo-sym .seo-open { width: 100%; justify-content: center; }
}
/* Blog trong trang Quan tri */
.bl-list { margin-bottom: 14px; }
.bl-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bl-item a { color: #2962ff; margin-right: 6px; }
.bl-form { display: flex; flex-direction: column; gap: 8px; }
.bl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bl-row input { flex: 1; min-width: 200px; }
.bl-form textarea { width: 100%; background: var(--input); border: 1px solid var(--border); border-radius: 4px; color: var(--fg); padding: 8px 10px; font: 13px/1.55 Consolas, monospace; resize: vertical; }
