:root {
  --mist: #F6F4FB;      /* nền */
  --paper: #FFFFFF;     /* khung */
  --line: #E7E2F3;      /* đường kẻ */
  --lilac: #8E7CC3;     /* nhấn chính – tím nhạt */
  --lilac-soft: #EEE9FA;
  --lilac-deep: #5B4B8A;
  --ink: #231F33;
  --muted: #6E6A80;
  /* màu bảng điện VN */
  --up: #1E9E6A;
  --down: #D9455F;
  --ref: #C9A227;
  --ceil: #9B5DE5;
  --floor: #2F80ED;
  --radius-s: 6px;
  --radius-m: 12px;
  --top-main: 64px;
  --top-sub: 52px;
  --top: calc(var(--top-main) + var(--top-sub));
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; border-radius: 4px; }

/* ---------- thanh trên ---------- */
/* không dùng backdrop-filter: nó làm thanh điều hướng fixed (mobile) bám theo header */
.topbar { position: fixed; inset: 0 0 auto 0; z-index: 20; background: var(--paper); }
.topbar-main {
  height: var(--top-main); display: flex; align-items: center; gap: 36px; padding: 0 28px;
  border-bottom: 1px solid var(--line);
}
.subbar {
  height: var(--top-sub); display: flex; align-items: center; gap: 24px; padding: 0 28px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .7);
}
.topbar-right { display: flex; align-items: center; gap: 20px; margin-left: auto; flex-shrink: 0; }
.btn-dark {
  height: 42px; padding: 0 20px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14.5px; white-space: nowrap;
  transition: background .15s;
}
.btn-dark:hover { background: var(--lilac-deep); }
.btn-text {
  border: 0; background: none; padding: 6px 2px; cursor: pointer; font-size: 15px; color: var(--muted);
  white-space: nowrap; transition: color .15s;
}
.btn-text:hover { color: var(--ink); }
.updated { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; flex-shrink: 0; }
.brand svg { width: 36px; height: 36px; }
.brand rect { fill: var(--lilac); }
.brand path { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.search { position: relative; width: min(340px, 34vw); }
.search input {
  width: 100%; height: 38px; padding: 0 36px 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--mist);
  transition: border-color .15s, background .15s;
}
.search input:focus { outline: none; border-color: var(--lilac); background: #fff; }
.search kbd {
  position: absolute; right: 10px; top: 9px; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: #fff;
}
#search-results {
  position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 12px 32px rgba(91, 75, 138, .14); max-height: 360px; overflow: auto;
}
#search-results li {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
#search-results li[aria-selected="true"], #search-results li:hover { background: var(--lilac-soft); }
#search-results b { font-weight: 600; }
#search-results small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#search-results em { font-style: normal; font-size: 11px; color: var(--muted); }

.ticker { display: flex; gap: 22px; margin-left: auto; overflow: hidden; }
.tick { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; cursor: pointer; }
.tick span { font-size: 12px; color: var(--muted); }
.tick b { font-weight: 600; font-size: 14px; }
.tick i { font-style: normal; font-size: 12px; margin-left: 6px; }

/* ---------- menu: ngang trên desktop, thanh dưới đáy trên điện thoại ---------- */
/* menu co lại (cuộn ngang, ẩn thanh cuộn) khi chật để nút bên phải không bị cắt */
.rail { display: flex; align-items: center; gap: 28px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail a[hidden] { display: none; }
.rail .lock { font-style: normal; }
.rail a {
  position: relative; display: flex; align-items: center; height: 100%;
  font-size: 15px; color: var(--muted); white-space: nowrap; transition: color .15s;
}
.rail a svg { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail a:hover { color: var(--ink); }
.rail a.active { color: var(--lilac-deep); font-weight: 600; }
.rail a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--lilac);
}

/* ---------- hộp thoại mở tài khoản ---------- */
#acct-dlg {
  border: 0; border-radius: 16px; padding: 26px; width: min(420px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(91, 75, 138, .28); color: var(--ink);
}
#acct-dlg[open] { animation: chat-in .16s ease-out; }
#acct-dlg::backdrop { background: rgba(35, 31, 51, .35); }
#acct-dlg h2 { font-size: 19px; margin: 0; padding-right: 28px; }
.dlg-x {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer;
}
.dlg-x:hover { background: var(--mist); color: var(--ink); }
.broker { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-m); }
.broker-head { display: flex; align-items: baseline; gap: 8px; }
.broker-head b { font-size: 16px; }
.broker-head span { font-size: 12.5px; color: var(--muted); }
.ref-code {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--lilac-soft);
}
.ref-code span { font-size: 12.5px; color: var(--lilac-deep); }
.ref-code code { font: 700 16px/1 "Be Vietnam Pro", sans-serif; letter-spacing: .04em; color: var(--ink); user-select: all; }
.ref-code .btn-sm { margin-left: auto; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.broker-how { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.broker-how b { color: var(--ink); font-weight: 600; }
.btn-link { display: inline-flex; align-items: center; margin-top: 12px; }
.acct-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- vùng chính ---------- */
main {
  margin: var(--top) 0 0; padding: 24px 28px 48px;
  min-height: calc(100vh - var(--top)); outline: none;
  transition: opacity .14s ease;
}
main.loading { opacity: .45; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--muted); margin: 4px 0 0; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.market-grid { grid-template-columns: minmax(0, 1fr) 360px; margin-top: 18px; }
.stock-grid { grid-template-columns: minmax(0, 1fr) 300px; margin-top: 18px; }

/* ---------- số liệu, màu ---------- */
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--ref); }
.ceil { color: var(--ceil); } .floor { color: var(--floor); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-weight: 600; font-size: 13px; background: var(--mist);
}
.chip.up { background: #E3F5EC; } .chip.down { background: #FBE6EA; } .chip.flat { background: #FAF3DC; }

/* ---------- nút chuyển ---------- */
.seg { display: inline-flex; padding: 3px; background: var(--mist); border: 1px solid var(--line); border-radius: 10px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer;
  color: var(--muted); font-size: 13px; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--lilac-deep); font-weight: 600; box-shadow: 0 1px 3px rgba(91, 75, 138, .15); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- biểu đồ ---------- */
.chart { position: relative; width: 100%; }
.chart-main { height: 420px; }
.chart-sm { height: 110px; border-top: 1px solid var(--line); }
.legend { position: absolute; top: 6px; left: 8px; z-index: 3; font-size: 12px; color: var(--muted); pointer-events: none; display: flex; gap: 12px; flex-wrap: wrap; }
.legend b { color: var(--ink); font-weight: 600; }
.legend-static { position: static; margin: 0 0 6px; }
.scroll table { min-width: 100%; }
.panel .scroll { max-width: 100%; }
.legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 4px; }

/* ---------- độ rộng thị trường ---------- */
.breadth { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--mist); margin: 6px 0 8px; }
.breadth span { transition: flex-grow .5s ease; }
.breadth-legend { display: flex; justify-content: space-between; font-size: 13px; }

/* ---------- bảng ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); background: var(--paper); }
td { border-bottom: 1px solid #F1EEF8; }
th:first-child, td:first-child { text-align: left; }
tbody tr { transition: background .12s; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--mist); }
.sym { font-weight: 600; }
.name { color: var(--muted); font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; display: block; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th[aria-sort="ascending"]::after { content: " ↑"; } th[aria-sort="descending"]::after { content: " ↓"; }
.scroll { overflow: auto; max-height: 640px; }
.scroll thead th { position: sticky; top: 0; z-index: 1; }

.fin td:first-child, .fin th:first-child { position: sticky; left: 0; background: var(--paper); max-width: 340px; white-space: normal; min-width: 240px; }
.fin tr.lv1 td:first-child { font-weight: 600; }
.fin tr.lv3 td:first-child { padding-left: 26px; color: var(--muted); }
.fin tr.lv4 td:first-child { padding-left: 40px; color: var(--muted); }

/* ---------- thẻ chỉ số ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.stats div { background: var(--paper); padding: 10px 12px; }
.stats span { display: block; font-size: 12px; color: var(--muted); }
.stats b { font-size: 15px; font-weight: 600; }
.signals { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.signals li { padding: 8px 10px; border-radius: 8px; background: var(--lilac-soft); color: var(--lilac-deep); font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--lilac-soft); color: var(--lilac-deep); }

.hero { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.hero .price { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.hero .meta { color: var(--muted); }
.rating { padding: 3px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-chip {
  border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s;
}
.filter-chip[aria-pressed="true"] { background: var(--lilac); border-color: var(--lilac); color: #fff; }
.field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.field input { width: 70px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.bars { display: grid; grid-template-columns: 52px 1fr 70px; gap: 6px 10px; align-items: center; font-size: 13px; }
.bars .bar { height: 8px; border-radius: 4px; }

/* ---------- Ichimoku / khuyến nghị ---------- */
.act { display: inline-block; padding: 2px 10px; border-radius: 8px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.act-buy30 { background: #1E9E6A; color: #fff; }
.act-buy10 { background: #DDF3E8; color: #157452; }
.act-hold { background: var(--lilac-soft); color: var(--lilac-deep); }
.act-trim { background: #FBEFD5; color: #8A6512; }
.act-exit { background: var(--down); color: #fff; }
.act-watch { background: #EFEDF4; color: var(--muted); }
.act-out { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius-m);
  background: var(--paper); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: var(--lilac); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(91, 75, 138, .10); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-top b { font-size: 17px; }
.card .meta { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.score { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.score i { height: 5px; border-radius: 2px; background: #EFEBF7; }
.score i.on-pos { background: var(--up); } .score i.on-neg { background: var(--down); }

.ichi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ichi-head h2 { margin: 0; }
.ichi-big { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ichi-big .act { font-size: 15px; padding: 4px 12px; }
.ichi-list { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; }
.ichi-list li::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 8px; vertical-align: middle; background: currentColor; }
.ichi-note { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.ichi-note p { margin: 0 0 4px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.empty code { background: var(--lilac-soft); color: var(--lilac-deep); padding: 2px 6px; border-radius: 6px; }

.skeleton { background: linear-gradient(90deg, #EFEBF7 0%, #F8F6FC 50%, #EFEBF7 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.foot-note { margin-top: 28px; font-size: 12px; color: var(--muted); max-width: 72ch; }

/* ---------- tài khoản ---------- */
.account { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.account .who { font-size: 13px; color: var(--muted); white-space: nowrap; }
.account .who b { color: var(--ink); font-weight: 600; }
.btn-primary, .btn-ghost {
  height: 36px; padding: 0 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { border: 0; background: var(--lilac); color: #fff; }
.btn-primary:hover { background: var(--lilac-deep); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn-ghost:hover { border-color: var(--lilac); color: var(--lilac-deep); }
#login-dlg {
  border: 0; border-radius: 16px; padding: 26px; width: min(380px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(91, 75, 138, .28); color: var(--ink);
}
#login-dlg[open] { animation: chat-in .16s ease-out; }
#login-dlg::backdrop { background: rgba(35, 31, 51, .35); backdrop-filter: blur(2px); }
#login-dlg h2 { font-size: 19px; margin: 0; }
#login-dlg label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 14px; }
#login-dlg input {
  height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--mist);
  font-size: 14px; color: var(--ink);
}
#login-dlg input:focus { outline: none; border-color: var(--lilac); background: #fff; }
.login-err { color: var(--down); font-size: 13px; margin: 12px 0 0; }
.lead-ok { color: var(--up); font-size: 13.5px; margin: 12px 0 0; font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.text-link { color: var(--lilac-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.locked .btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.status-sel { height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 6px; }
.badge { font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--mist); color: var(--muted); }
.badge.ok { background: #E3F5EC; color: #157452; } .badge.off { background: #FBE6EA; color: var(--down); }
.badge.warn { background: #FAF3DC; color: #8A6512; }
/* khung báo cáo tài chính */
.fin-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin: 0 -2px; }
.fin-tabs::-webkit-scrollbar { display: none; }
.fin-tabs button {
  border: 0; background: transparent; padding: 10px 14px; font-size: 14px; color: var(--muted); cursor: pointer;
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.fin-tabs button:hover { color: var(--ink); }
.fin-tabs button[aria-selected="true"] { color: var(--lilac-deep); font-weight: 600; border-bottom-color: var(--lilac); }
.fin-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 0; }
.fin-ctrl .status-sel { height: 32px; padding: 0 8px; font-weight: 600; color: var(--lilac-deep); }
tr.fin-group td { background: var(--mist); font-weight: 600; color: var(--lilac-deep); position: static; }
/* phân tích cơ bản */
.fund-base { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 520px; }
tr.fund-main td { background: var(--lilac-soft); }
tr.fund-proj td { background: #FAF9FD; color: var(--lilac-deep); }
.fund-ref {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-top: 12px; padding: 12px 14px;
  border-radius: 10px; background: var(--lilac-soft); color: var(--lilac-deep);
}
.fund-ref b { font-size: 20px; color: var(--ink); }
.fund-ref span b { font-size: inherit; color: inherit; }
.fund-mults { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mcard { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-m); }
.mcard .mname { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mcard > b { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.mcard.na > b { font-size: 15px; color: var(--muted); }
.spark { width: 100%; height: 44px; margin-top: 4px; }
.spark-line { fill: none; stroke: var(--lilac); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark-med { stroke: var(--muted); stroke-dasharray: 3 3; stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .6; }
.spark-now { fill: var(--lilac-deep); }
.fund-warn { color: #8A6512; }
a.filter-chip { display: inline-block; }
a.filter-chip[aria-pressed="true"] { background: var(--lilac); border-color: var(--lilac); color: #fff; }
/* kiểm tra bẫy dữ liệu (Quản trị) */
tr.au-on { background: var(--lilac-soft); }
.au-detail { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.au-flags { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.au-trap { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.au-trap ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 8px; font-size: 13px; }
.au-trap p { margin: 8px 0 0; }
.au-trap .sub { font-size: 12px; }
li.au-loi { color: var(--down); } li.au-loi .sub { color: var(--muted); }
@media (max-width: 1000px) { .au-flags { grid-template-columns: minmax(0, 1fr); } }
.contact a { margin-right: 8px; }
.login-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.locked {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 36px 20px; border: 1px dashed #D6CDEE; border-radius: var(--radius-m); background: var(--lilac-soft);
}
.locked svg { width: 34px; height: 34px; fill: none; stroke: var(--lilac-deep); stroke-width: 1.6; }
.locked p { margin: 0; color: var(--lilac-deep); max-width: 46ch; }

/* ---------- hỏi đáp ---------- */
#chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 30; width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--lilac); cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 10px 26px rgba(91, 75, 138, .35); transition: transform .15s, background .15s;
}
#chat-fab:hover { transform: scale(1.05); background: var(--lilac-deep); }
#chat-fab svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
#chat {
  position: fixed; right: 22px; bottom: 88px; z-index: 30; width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 120px)); display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(91, 75, 138, .22); overflow: hidden;
  transform-origin: bottom right; animation: chat-in .16s ease-out;
}
#chat[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: scale(.96) translateY(6px); } }
#chat header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--lilac-soft); }
#chat header b { color: var(--lilac-deep); }
#chat-status { font-size: 12px; color: var(--muted); }
#chat-close { margin-left: auto; border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
#chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; }
.msg.me { align-self: flex-end; background: var(--lilac); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--mist); border-bottom-left-radius: 4px; }
.msg.bot ul { margin: 4px 0; padding-left: 18px; }
.msg.bot p { margin: 0 0 6px; } .msg.bot p:last-child { margin: 0; }
.msg.bot em { color: var(--muted); font-size: 12px; }
.msg a.sym-link { color: var(--lilac-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.msg.typing { color: var(--muted); }
#chat-suggest { display: flex; gap: 6px; padding: 0 14px 10px; flex-wrap: wrap; }
#chat-suggest button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
#chat-suggest button:hover { border-color: var(--lilac); color: var(--lilac-deep); }
#chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
#chat-form input { flex: 1; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--mist); }
#chat-form input:focus { outline: none; border-color: var(--lilac); background: #fff; }
#chat-form button { border: 0; border-radius: 10px; padding: 0 16px; background: var(--lilac); color: #fff; font-weight: 600; cursor: pointer; }

/* ---------- màn hình nhỏ ---------- */
@media (max-width: 1100px) {
  .market-grid, .stock-grid { grid-template-columns: minmax(0, 1fr); }
  .ticker .tick:nth-child(n+3) { display: none; }
}
@media (max-width: 1200px) { .account .who { display: none; } }
@media (max-width: 1120px) {
  .topbar-main { gap: 22px; padding: 0 20px; }
  .subbar { padding: 0 20px; }
  .rail { gap: 18px; }
  .rail a { font-size: 14px; }
  .brand span, .updated { display: none; }
}
@media (max-width: 900px) {
  .topbar-main { gap: 16px; }
  .rail { gap: 12px; }
  .rail a { font-size: 13.5px; }
  .topbar-right { gap: 12px; }
  .btn-dark { padding: 0 14px; font-size: 13.5px; }
}
@media (max-width: 720px) {
  :root { --top-main: 56px; }
  .topbar-main, .subbar { padding: 0 16px; gap: 12px; }
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 64px; gap: 0;
    justify-content: space-around; padding: 6px; background: var(--paper); border-top: 1px solid var(--line);
  }
  .rail a { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 4px; height: auto;
    padding: 6px 1px; border-radius: 10px; font-size: 10.5px; text-align: center; }
  .rail a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .rail .lock { display: none; }
  .rail a svg { display: block; }
  .rail a.active { background: var(--lilac-soft); }
  .rail a.active::after { display: none; }
  main { padding: 16px 16px 90px; }
  .ticker, .account .who { display: none; }
  .topbar-right { gap: 12px; }
  .btn-dark { height: 36px; padding: 0 14px; font-size: 13px; }
  .btn-text { font-size: 14px; }
  .account .btn-primary, .account .btn-ghost { height: 34px; padding: 0 10px; font-size: 12.5px; }
  .search { width: 100%; }
  .chart-main { height: 320px; }
  .panel { padding: 14px; }
  .name { max-width: 110px; }
  #st-lg span:nth-child(n+6) { display: none; }  /* gọn chú thích nến trên điện thoại */
  .hero .price { font-size: 28px; }
  #chat-fab { bottom: 80px; right: 16px; }
  #chat { right: 8px; left: 8px; width: auto; bottom: 72px; height: calc(100vh - 140px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
