:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --border: #e0e3eb;
  --text: #131722;
  --muted: #787b86;
  --accent: #c8a24a;
  --hover: #f0f3fa;
  --on: #e3effd;
  --on-text: #2962ff;
  --up: #089981;
  --down: #f23645;
  --ref: #f5a623;
}
:root[data-theme="dark"] {
  --bg: #131722;
  --panel: #1e222d;
  --panel-2: #2a2e39;
  --border: #2a2e39;
  --text: #d1d4dc;
  --muted: #868993;
  --hover: #2a2e39;
  --on: #142e61;
  --on-text: #5b8cff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

.topbar {
  height: 48px; display: flex; align-items: center; gap: 24px; padding: 0 16px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.brand { font-size: 17px; letter-spacing: .5px; color: var(--accent); white-space: nowrap; }
.brand b { color: var(--text); }
.logo { font-size: 20px; }
.topbar nav { display: flex; gap: 22px; margin: 0 auto; }
.topbar nav a { color: var(--muted); font-size: 15px; cursor: pointer; text-decoration: none; }
.topbar nav a:not(.disabled):hover { color: var(--text); }
.topbar nav a.active { color: var(--accent); }
.topbar nav a.disabled { opacity: .55; cursor: default; }
.icon-btn { font-size: 18px; width: 32px; height: 32px; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); }

.toolbar {
  height: 40px; display: flex; align-items: center; gap: 4px; padding: 0 8px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
/* che do nhung trong trang Nhieu bieu do: chi giu thanh cong cu + bieu do */
.embed .topbar, .embed .watch, .embed #status, .embed #multiBtn, .embed #clock { display: none !important; }
.embed .toolbar { overflow: hidden; height: 34px; }
.embed #indBtn.own { background: var(--on-bg, rgba(41,98,255,.12)); color: var(--on-text); }
.ind-own { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; margin: 4px 0 6px; border-radius: 6px; background: var(--panel-2); cursor: pointer; font-weight: 600; }
.ind-own .muted { font-weight: 400; font-size: 11px; }
.embed #indBtn { font-size: 0; } .embed #indBtn::before { content: 'ƒx'; font-size: 13px; }
.embed #cmpBtn { font-size: 0; } .embed #cmpBtn::before { content: '⇄'; font-size: 13px; }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.tb-btn { padding: 4px 8px; border-radius: 4px; white-space: nowrap; }
.tb-btn:hover { background: var(--hover); }
.tb-btn.on { color: var(--on-text); }
.tb-btn.small { padding: 2px 6px; font-size: 12px; }
.status { color: var(--muted); font-size: 12px; margin-right: 8px; }
.status.err { color: var(--down); }

.search { position: relative; display: flex; align-items: center; gap: 4px; padding: 0 6px; }
.search-ico { font-size: 16px; color: var(--muted); }
#symbolInput {
  width: 110px; border: 0; outline: 0; background: transparent;
  font-weight: 700; text-transform: uppercase; padding: 6px 2px;
}
.suggest {
  position: absolute; top: 34px; left: 0; z-index: 50; width: 380px; max-height: 360px; overflow: auto;
  margin: 0; padding: 4px 0; list-style: none; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.15);
}
.suggest li { display: grid; grid-template-columns: 70px 1fr 56px; gap: 8px; padding: 6px 12px; cursor: pointer; }
.suggest li.sel, .suggest li:hover { background: var(--hover); }
.suggest .nm { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .ex { color: var(--muted); font-size: 11px; text-align: right; }

.seg { display: flex; gap: 2px; }
.seg button { padding: 4px 8px; border-radius: 4px; }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--on); color: var(--on-text); font-weight: 600; }
.seg.small button { padding: 2px 7px; font-size: 12px; }

.workspace { flex: 1; display: flex; min-height: 0; }
.drawbar {
  width: 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  border-right: 1px solid var(--border); background: var(--panel);
}
.drawbar button { width: 34px; height: 34px; border-radius: 6px; font-size: 17px; }
.drawbar button:hover { background: var(--hover); }
.drawbar button.on { background: var(--on); color: var(--on-text); }
.dsep { width: 26px; height: 1px; background: var(--border); margin: 4px 0; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: #8e24aa; vertical-align: middle; }

.chart-wrap { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
#chart { flex: 1; min-height: 0; }
#overlay { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.legend {
  position: absolute; left: 10px; top: 6px; z-index: 4; pointer-events: none;
  font-size: 12px; line-height: 19px;
  background: color-mix(in srgb, var(--panel) 78%, transparent); border-radius: 4px; padding: 2px 6px;
}
.legend .title { font-size: 14px; font-weight: 600; }
.legend .title .tf { color: var(--muted); font-weight: 400; }
.legend .v { margin-left: 2px; margin-right: 6px; }
.legend .row { white-space: nowrap; }
.legend .lbl { color: var(--text); }
.bottombar {
  height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 8px;
  border-top: 1px solid var(--border); background: var(--panel);
}

.watch {
  width: 270px; border-left: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.watch-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px; }
.watch-head form { flex: 1; }
#watchInput {
  width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--panel-2); outline: 0; text-transform: uppercase;
}
.watch-cols, #watchList li {
  display: grid; grid-template-columns: 1.1fr 1fr .9fr .9fr; gap: 4px; padding: 5px 10px; align-items: center;
}
.watch-cols { color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--border); }
.watch-cols span:not(:first-child), #watchList li span:not(:first-child) { text-align: right; }
#watchList { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 120px; }
.sym-info { border-top: 1px solid var(--border); display: flex; flex-direction: column; flex: 0 0 46%; min-height: 0; }
.sym-info.closed { flex: 0 0 auto; }
.sym-info.closed .si-body { display: none; }
.si-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.si-body { overflow-y: auto; padding: 0 8px 8px; flex: 1; }
.si-body .ev { grid-template-columns: 62px minmax(0, 1fr) auto; font-size: 12px; gap: 6px; }
.si-body .ev .tg { grid-column: 2 / 4; grid-row: 1; }
.si-body .ev .nt { grid-column: 2 / 3; font-size: 11.5px; }
.si-body .nw { font-size: 12px; }
.tb-btn.off { opacity: .4; }
.cmp-wrap { position: relative; }
.cmp-pop { position: absolute; top: 34px; left: 0; z-index: 30; width: 250px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.cmp-pop input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel-2); text-transform: uppercase; }
.cmp-pop ul { list-style: none; margin: 8px 0; padding: 0; }
.cmp-pop li { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.cmp-pop li i { width: 12px; height: 3px; border-radius: 2px; }
.cmp-pop li b { flex: 1; }
.cmp-pop li button { color: var(--muted); }
.cmp-pop li button:hover { color: var(--down); }
#cmpBtn.on { color: var(--on-text); background: var(--on); }
#watchList li { cursor: pointer; position: relative; font-variant-numeric: tabular-nums; }
#watchList li:hover { background: var(--hover); }
#watchList li.cur { background: var(--on); }
#watchList li b { font-weight: 600; }
#watchList .x {
  position: absolute; right: 2px; top: 4px; display: none; color: var(--muted);
  width: 18px; height: 18px; border-radius: 3px; background: var(--panel-2);
}
#watchList li:hover .x { display: block; }
.kn-head { cursor: pointer; user-select: none; }
.kn-head:hover { color: var(--on-text); }
.up { color: var(--up); } .down { color: var(--down); } .ref { color: var(--ref); }

.dialog { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; }
.dialog-box { width: 460px; max-width: calc(100% - 32px); background: var(--panel); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 15px; }
.dialog-body { padding: 8px 14px 14px; max-height: 70vh; overflow: auto; }
.ind-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.ind-row label { flex: 1; cursor: pointer; }
.ind-row input[type=number] { width: 58px; padding: 2px 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel-2); }
.ind-row input[type=color] { width: 28px; height: 22px; padding: 0; border: 0; background: none; }
.ind-group { margin-top: 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }

.mb-burger { display: none; margin-right: -14px; }
.mb-nav { position: fixed; left: 0; right: 0; top: 48px; z-index: 70; background: var(--panel); border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.15); display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); padding: 6px 10px; }
.mb-nav[hidden] { display: none; }
.mb-nav a { padding: 11px 10px; color: var(--text); text-decoration: none; font-size: 15px; border-radius: 6px; }
.mb-nav a:hover { background: var(--hover); }
.mb-nav a.active { color: var(--accent); font-weight: 600; }
@media (max-width: 900px) {
  .watch { display: none; }
  .topbar nav { display: none; }
  .mb-burger { display: inline-flex; align-items: center; justify-content: center; }
}
@media (max-width: 600px) {
  .drawbar { display: none; }
  .toolbar { overflow-x: auto; }
  #indBtn { font-size: 0; } #indBtn::before { content: "ƒx"; font-size: 13px; }
}

/* nut tai khoan (member.js) */
.mb-menu { position: relative; margin-left: 6px; }
.mb-btn { width: 28px; height: 28px; border-radius: 50%; background: var(--on); color: var(--on-text); font-weight: 700; font-size: 13px; border: 2px solid transparent; }
.mb-btn.mb-expiring { border-color: var(--ref); }
.mb-btn.mb-expired, .mb-btn.mb-locked, .mb-btn.mb-nopw { border-color: var(--down); }
.mb-pop { position: absolute; right: 0; top: 36px; z-index: 60; min-width: 230px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; }
.mb-pop[hidden] { display: none; }
.mb-head { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 13px; }
.mb-plan { font-size: 12px; color: var(--up); }
.mb-plan.mb-expiring { color: var(--ref); }
.mb-plan.mb-expired, .mb-plan.mb-locked { color: var(--down); }
.mb-pop a, .mb-pop button { display: block; text-align: left; padding: 7px 8px; border-radius: 4px; color: var(--text); text-decoration: none; font-size: 13px; background: none; }
.mb-pop a:hover, .mb-pop button:hover { background: var(--hover); }
.mb-pop a.mb-warn { color: var(--down); font-weight: 600; }
