/* Phong cách bảng điện: nền sáng, thanh trên navy, xanh = tăng, đỏ = giảm */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #121a26;
  --muted: #667085;
  --line: #e3e8ef;
  --accent: #1667e0;
  --accent-soft: #e8f0fd;
  --up: #0a9b5a;
  --up-soft: #e3f6ec;
  --down: #d92d45;
  --down-soft: #fdeaed;
  --warn: #c98200;
  --warn-soft: #fdf3dc;
  --bar: #c5cfdc;
  --nav-bg: #0c1b30;
  --nav-text: #e6edf7;
  --nav-muted: #93a4bd;
  --nav-field: #17294a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
}
/* Giao diện tối: theo máy (mặc định) hoặc theo nút sáng/tối ở thanh trên (lưu data-theme trên <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121b2c; --surface-2: #172236; --text: #e7ecf3; --muted: #93a0b4;
    --line: #233149; --accent: #5b9bff; --accent-soft: #17284a;
    --up: #2ebd85; --up-soft: #12302a; --down: #f6465d; --down-soft: #3a1820;
    --warn: #f0b90b; --warn-soft: #382d0e; --bar: #34445e;
    --nav-bg: #070d18; --nav-field: #131f35; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b1220; --surface: #121b2c; --surface-2: #172236; --text: #e7ecf3; --muted: #93a0b4;
    --line: #233149; --accent: #5b9bff; --accent-soft: #17284a;
    --up: #2ebd85; --up-soft: #12302a; --down: #f6465d; --down-soft: #3a1820;
    --warn: #f0b90b; --warn-soft: #382d0e; --bar: #34445e;
    --nav-bg: #070d18; --nav-field: #131f35; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
/* Chừa chỗ cho thanh trên + thanh mục khi nhảy tới một mục (#kqkd...). Đặt trên phần tử đích, KHÔNG dùng
   scroll-padding trên html: trình duyệt sẽ coi ô tìm mã ở thanh trên là bị che và cuộn trang mỗi lần gõ phím. */
[id] { scroll-margin-top: 116px; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "Be Vietnam Pro", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.9rem; line-height: 1.25; margin: .4em 0 .3em; }
/* Tiêu đề xuống dòng cân đối, không để 1 chữ rơi lẻ ở dòng cuối */
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.4em 0 .4em; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger, var(--down)); }
.lead { font-size: 1.08rem; }
.up { color: var(--up); }
.down { color: var(--down); }
strong, td, .num { font-variant-numeric: tabular-nums; }

/* ---------- thanh trên cùng ---------- */
.topbar { background: var(--nav-bg); color: var(--nav-text); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 14px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--nav-text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo-mark { flex: none; display: block; }
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 10px 14px; font: inherit; text-transform: uppercase; }
.search input::placeholder { text-transform: none; }
.search.mini { position: relative; flex: 0 1 240px; min-width: 0; }
.search.mini input { width: 100%; padding: 7px 12px 7px 34px; font-size: .9rem; border-radius: 9px;
  background: var(--nav-field); border-color: transparent; color: var(--nav-text); }
.search.mini input::placeholder { color: var(--nav-muted); }
.search.mini input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.search-ico { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  fill: none; stroke: var(--nav-muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.nav { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: .92rem; }
.nav-link { display: flex; align-items: center; gap: 6px; color: var(--nav-muted); white-space: nowrap; }
.nav-link:hover { color: var(--nav-text); text-decoration: none; }
.theme-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--nav-muted); cursor: pointer; }
.theme-btn:hover { color: var(--nav-text); background: var(--nav-field); }
.theme-btn .ico { width: 20px; height: 20px; }
.theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: block; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .ico-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .ico-moon { display: none; }
}
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pill { border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 3px 11px; font-size: .8rem;
  color: var(--nav-text); white-space: nowrap; }
.pill:hover { text-decoration: none; background: rgba(255,255,255,.06); }
.pill.pro { background: linear-gradient(135deg, #1f7bff, #0aa36a); color: #fff; border-color: transparent; font-weight: 600; }

/* ---------- nút ---------- */
.btn { display: inline-block; white-space: nowrap; border: 0; background: var(--accent); color: #fff; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn.small { padding: 6px 14px; font-size: .9rem; }
.btn.ghost { background: var(--surface); color: var(--accent); border: 1px solid var(--line); }
.btn.wide { width: 100%; text-align: center; }

/* ---------- trang chủ và trang chung ---------- */
.hero { padding: 48px 0 16px; }
.search.big { max-width: 560px; margin: 24px 0 12px; }
.search.big input { font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 12px; font-weight: 600; font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card.link { display: flex; flex-direction: column; color: var(--text); }
.center { text-align: center; padding: 64px 0; }
.narrow { max-width: 620px; margin: 0 auto; }
.narrow.upgrade { max-width: 980px; }
.narrow.upgrade > h1, .narrow.upgrade > p { max-width: 620px; margin-inline: auto; }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto; }
.stack input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font: inherit; background: var(--surface); color: var(--text); }
.spinner { width: 36px; height: 36px; margin: 0 auto; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- báo cáo ---------- */
.report { padding: 20px 0 32px; }
.sec, .summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 14px; }
.sec > :first-child { margin-top: 0; }
.sec > p:last-child { margin-bottom: 0; }
.lbl, .kpi span, .stats span { display: block; font-size: .78rem; color: var(--muted); }

.summary { padding: 22px; }
.sum-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.tk-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.tk-line h1 { margin: 0; font-size: 2rem; letter-spacing: .01em; }
.tag { white-space: nowrap; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.tag.soft { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.co-name { margin: 2px 0 0; color: var(--muted); }
.sum-price { text-align: right; }
.sum-price strong { font-size: 1.7rem; line-height: 1.2; }
.sum-val { margin-top: 18px; }
.sum-val-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.sum-val-line strong { font-size: 1.6rem; }
.badge { font-size: .82rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }
.sum-foot { margin: 12px 0 0; }

/* thanh khoảng giá trị */
.rb { margin: 14px 0 6px; }
.rb-track { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: 44px 6px 14px; }
.rb-fill { position: absolute; top: -1px; bottom: -1px; border-radius: 999px;
  background: linear-gradient(90deg, var(--warn-soft), var(--accent-soft) 50%, var(--up-soft)); border: 1px solid var(--line); }
.rb-dot { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; transform: translate(-50%, -50%);
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.rb-dot.co_so { width: 18px; height: 18px; }
.rb-price { position: absolute; top: -22px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; }
.rb-price em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-style: normal; font-size: .72rem;
  font-weight: 600; white-space: nowrap; background: var(--text); color: var(--surface); padding: 1px 7px; border-radius: 5px; margin-bottom: 2px; }
.than_trong i, .rb-dot.than_trong { background: var(--warn); }
.co_so i, .rb-dot.co_so { background: var(--accent); }
.lac_quan i, .rb-dot.lac_quan { background: var(--up); }
.rb-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rb-item { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.rb-item.co_so { background: var(--accent-soft); }
.rb-key { display: flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--muted); }
.rb-key i, .scen-head i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.rb-item strong { display: block; font-size: 1.02rem; }
.chg { font-size: .8rem; font-weight: 600; color: var(--muted); }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin-top: 18px; border-top: 1px solid var(--line); }
.kpi { padding: 12px 12px 0 0; }
.kpi strong { font-size: 1.12rem; }

/* mục lục dính */
.secnav { position: sticky; top: 56px; z-index: 10; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px 14px; padding: 8px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.secnav::-webkit-scrollbar { display: none; }
.secnav a { flex: none; padding: 6px 14px; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.secnav a:hover { text-decoration: none; color: var(--text); background: var(--surface); }
.secnav a.on { background: var(--accent); color: #fff; }

.stale-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.points { padding-left: 0; list-style: none; margin: 10px 0 0; }
.points li { position: relative; padding: 6px 0 6px 22px; border-bottom: 1px dashed var(--line); }
.points li:last-child { border-bottom: 0; }
.points li::before { content: ""; position: absolute; left: 4px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.points.warn li::before { background: var(--down); }

/* biểu đồ cột bằng HTML: chữ giữ cỡ thật trên điện thoại */
.panel { margin: 14px 0 0; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.panel figcaption { font-size: .85rem; font-weight: 600; margin-bottom: 10px; }
.panel figcaption .muted { font-weight: 400; }
.bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.bar-col { display: flex; flex-direction: column; align-items: stretch; min-width: 0; text-align: center; }
.bar-plot { height: 190px; display: flex; flex-direction: column; }
.bar-pos { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-bottom: 1px solid var(--muted); }
.bar-neg { display: flex; flex-direction: column; align-items: center; }
.bar-fill { width: 70%; max-width: 46px; min-height: 0; background: var(--bar); border-radius: 5px 5px 0 0; transition: filter .15s; }
.bar-fill.neg { background: var(--down); opacity: .75; border-radius: 0 0 5px 5px; }
.bar-col.last .bar-fill:not(.neg) { background: var(--accent); }
.bar-col:hover .bar-fill { filter: brightness(.92); }
.bar-val { font-size: .78rem; font-weight: 700; margin-bottom: 3px; white-space: nowrap; }
.bar-val.neg { color: var(--down); }
.bar-lbl { font-size: .74rem; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.bar-sub { font-size: .74rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.bar-sub.up { color: var(--up); }
.bar-sub.down { color: var(--down); }

details.more { margin-top: 14px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--accent); padding: 6px 0; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸"; display: inline-block; width: 1.1em; transition: transform .15s; }
details.more[open] summary::before { transform: rotate(90deg); }

/* bảng */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: .9rem; }
.table-wrap table { margin: 0; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--muted); font-size: .78rem; background: var(--surface-2); }
tbody tr:hover td { background: var(--surface-2); }
tr.hl td { background: var(--accent-soft); font-weight: 700; }
tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.up { color: var(--up); }
td.down { color: var(--down); }
table.sticky-first th:first-child, table.sticky-first td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface);
  box-shadow: 1px 0 0 var(--line); }
table.sticky-first th:first-child { background: var(--surface-2); }
table.sticky-first tr.hl td:first-child { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent), 1px 0 0 var(--line); }
table.kv td:last-child { font-weight: 600; }

/* đèn tín hiệu sức khỏe tài chính */
.signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 14px 0; }
.signal { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); border-top: 3px solid var(--bar); }
.signal.good { border-top-color: var(--up); }
.signal.mid { border-top-color: var(--warn); }
.signal.bad { border-top-color: var(--down); }
.sig-head { display: flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--muted); }
.sig-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bar); flex: none; }
.good .sig-dot { background: var(--up); }
.mid .sig-dot { background: var(--warn); }
.bad .sig-dot { background: var(--down); }
.signal strong { display: block; font-size: 1.3rem; margin: 4px 0 2px; }
.sig-tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.good .sig-tag { background: var(--up-soft); color: var(--up); }
.mid .sig-tag { background: var(--warn-soft); color: var(--warn); }
.bad .sig-tag { background: var(--down-soft); color: var(--down); }
.sig-hint { margin: 8px 0 0; font-size: .76rem; line-height: 1.45; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.stats > div { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); }

/* kịch bản định giá */
.scenarios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.scen { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--surface-2); }
.scen.co_so { border: 2px solid var(--accent); background: var(--accent-soft); }
.scen-head { display: flex; align-items: center; gap: 7px; font-size: .85rem; font-weight: 600; }
.scen > strong { display: block; font-size: 1.45rem; margin-top: 4px; }
.scen dl { margin: 10px 0 0; border-top: 1px solid var(--line); padding-top: 8px; }
.scen dl div { display: flex; justify-content: space-between; font-size: .82rem; padding: 2px 0; }
.scen dt { color: var(--muted); }
.scen dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.method { padding: 4px 4px 0; }
.method-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.method-row p { margin: 0; }
.method details.more { margin-top: 4px; }
.method-list { margin: 4px 0 0; padding-left: 20px; color: var(--muted); }
.method-list li { margin: 2px 0; }

/* ---------- điện thoại ---------- */
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .scenarios { grid-template-columns: 1fr; }
  .scen { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
  .scen > strong { grid-column: 1; margin: 0; }
  .scen-head { grid-column: 1 / -1; }
  .scen .chg { grid-column: 2; grid-row: 2; }
  .scen dl { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .brand-name, .nav-text { display: none; }
  .topbar-inner { gap: 10px; }
  .search.mini { flex: 1 1 auto; }
  .nav { gap: 10px; }
  .pill { font-size: .72rem; padding: 2px 8px; }
  .plans { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  .report { padding-top: 12px; }
  .sec, .summary { padding: 16px; border-radius: 10px; }
  .tk-line h1 { font-size: 1.6rem; }
  .sum-price strong { font-size: 1.35rem; }
  .sum-val-line strong { font-size: 1.35rem; }
  .rb-legend { gap: 6px; }
  .rb-item { padding: 7px 8px; }
  .rb-item strong { font-size: .92rem; }
  .bars { gap: 3px; }
  .bar-plot { height: 150px; }
  .bar-fill { width: 78%; }
  .bar-val { font-size: .68rem; }
  .bar-lbl, .bar-sub { font-size: .62rem; }
  .signals, .stats { grid-template-columns: 1fr 1fr; }
  .signal strong { font-size: 1.15rem; }
  .panel { padding: 12px 8px; }
}
@media print {
  .topbar, .secnav, .actions, .site-footer { display: none; }
  body { background: #fff; }
  .sec, .summary { box-shadow: none; break-inside: avoid; }
  details.more > *:not(summary) { display: block; }
}

/* ---------- Đợt 2: biểu đồ chuyển chỉ tiêu, so sánh ngành, tự thử định giá ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.panel-head figcaption { margin: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600;
  padding: 5px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.bar-detail { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; font-size: .8rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; margin-bottom: 12px; min-height: 36px; }
.bar-detail > b { color: var(--text); font-size: .85rem; }
.bar-detail b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar-detail i { font-style: normal; font-weight: 600; }
.bar-detail i.up { color: var(--up); }
.bar-detail i.down { color: var(--down); }
.bar-col { cursor: pointer; border-radius: 6px; padding-top: 2px; }
.bar-col.sel { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.bar-col.sel .bar-lbl { color: var(--accent); font-weight: 700; }
.bar-note { font-size: .74rem; margin: 8px 0 0; }

.peer-group { margin: -4px 0 10px; }
.peer-group strong { color: var(--text); }
.peer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 14px 0 0; }
.peer-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); }
.peer-title { font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
.peer-title .muted { font-weight: 400; font-size: .78rem; }
.peer-row { display: grid; grid-template-columns: 44px 1fr 52px; align-items: center; gap: 8px; padding: 3px 0; font-size: .82rem; }
.peer-tk { font-weight: 600; color: var(--muted); }
.peer-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.peer-bar { display: block; height: 100%; border-radius: 999px; background: var(--bar); }
.peer-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.peer-row.me .peer-tk, .peer-row.me .peer-val { color: var(--accent); font-weight: 700; }
.peer-row.me .peer-bar { background: var(--accent); }

.sim { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 16px 0;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.sim-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.sim-head h3 { margin: 0; }
.seg.small button { font-size: .76rem; padding: 4px 10px; }
.sim-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-top: 14px; align-items: center; }
.sim-inputs { display: flex; flex-direction: column; gap: 18px; }
.slider { display: block; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.slider-top output { font-size: 1.05rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.slider-scale { position: relative; display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.slider input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; cursor: pointer; --fill: 50%; }
.slider input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--fill), var(--line) var(--fill)); }
.slider input[type=range]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
.slider input[type=range]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
.slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.slider input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.slider input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.sim-result { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.sim-result > strong { display: block; font-size: 1.9rem; line-height: 1.2; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.sim-result dl { margin: 12px 0 0; border-top: 1px solid var(--line); padding-top: 8px; }
.sim-result dl div { display: flex; justify-content: space-between; font-size: .82rem; padding: 2px 0; }
.sim-result dt { color: var(--muted); }
.sim-result dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.sim-note { margin: 12px 0 0; }
.scale-mark { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; color: var(--accent); font-weight: 600; }
.scale-mark::before { content: ""; position: absolute; left: 50%; top: -9px; width: 2px; height: 6px; background: var(--accent); border-radius: 1px; }

@media (max-width: 640px) {
  .sim-body { grid-template-columns: 1fr; gap: 16px; }
  .sim { padding: 14px 12px; }
  .bar-detail { font-size: .74rem; gap: 2px 12px; }
  .panel-head .seg { width: 100%; }
  .panel-head .seg button { flex: 1; padding: 5px 4px; font-size: .76rem; }
  .peer-grid { grid-template-columns: 1fr; }
}
@media print { .seg, .sim { display: none; } }

/* ---------- Đợt 3: trang chủ, bảng giá, chân trang, đăng nhập ---------- */
.home-hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; padding: 56px 0 36px; }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .02em; color: var(--accent);
  background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; margin: 0 0 14px; }
.home-hero h1 { font-size: 2.6rem; line-height: 1.15; margin: 0 0 14px; letter-spacing: -.01em; }
.grad { background: linear-gradient(90deg, #1f7bff, #0aa36a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-hero .lead { color: var(--muted); max-width: 540px; }
.search.big { max-width: 540px; margin: 22px 0 14px; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 8px 24px rgba(16, 24, 40, .08); }
.search.big input { border: 0; font-size: 1.1rem; font-weight: 600; letter-spacing: .03em; background: transparent; }
.search.big input:focus { outline: none; }
.search.big:focus-within { border-color: var(--accent); }
.chips { margin: 0 0 8px; }
.chip { color: var(--text); }
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.home-hero > * { min-width: 0; }
.hero-demo { position: relative; }
.hero-demo::before { content: ""; position: absolute; inset: -18px 0; border-radius: 28px; z-index: -1;
  background: radial-gradient(60% 60% at 70% 30%, color-mix(in srgb, #1f7bff 18%, transparent), transparent),
              radial-gradient(50% 50% at 20% 90%, color-mix(in srgb, #0aa36a 16%, transparent), transparent); }
.demo-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 14px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, .12); }
.demo-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.demo-tk { font-size: 1.5rem; }
.demo-price { text-align: right; }
.demo-price strong { font-size: 1.3rem; }
.demo-val { font-size: 1.35rem; }
.demo-card .rb-item { padding: 6px 8px; }
.demo-card .rb-item strong { font-size: .92rem; }
.demo-spark { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.demo-spark .spark { width: 100%; height: 48px; }
.demo-cap { text-align: center; margin: 10px 0 0; }

.spark { display: block; width: 100%; height: 36px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--accent); }
.sc-spark.up .spark polyline { stroke: var(--up); }
.sc-spark.up .spark circle { fill: var(--up); }
.sc-spark.down .spark polyline { stroke: var(--down); }
.sc-spark.down .spark circle { fill: var(--down); }

.home-sec { padding: 28px 0; }
.sec-title { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 14px; }
.sec-title h2 { margin: 0; font-size: 1.4rem; }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.stock-card { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); color: var(--text); transition: transform .15s, box-shadow .15s, border-color .15s; }
.stock-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(16, 24, 40, .1); }
.sc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sc-tk { font-size: 1.2rem; }
.sc-name { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.sc-stats { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 6px; }
.sc-stats span { display: block; font-size: .7rem; color: var(--muted); }
.sc-stats strong { font-size: .95rem; }
.sc-foot { display: flex; justify-content: space-between; font-size: .76rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.sc-foot span { color: var(--accent); font-weight: 600; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps li { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.steps p { margin: 4px 0 0; font-size: .88rem; color: var(--muted); }
.step-n { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, #1f7bff, #0aa36a); }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.feature p { margin: 6px 0 0; font-size: .86rem; color: var(--muted); }
.f-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); margin-bottom: 12px; }
.f-ico svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- quản trị: tặng lượt ---------- */
.gift-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; }
.gift-form label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.gift-form input, .gift-form select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-width: 0; }
.notice.ok { background: var(--up-soft); color: var(--up); padding: 10px 14px; border-radius: 8px; }
.notice.err { background: var(--down-soft); color: var(--down); padding: 10px 14px; border-radius: 8px; }

/* Ô tìm mã có danh sách gợi ý (datalist): ẩn mũi tên tam giác của Chrome, gợi ý vẫn hiện khi gõ */
.search input::-webkit-calendar-picker-indicator { display: none !important; opacity: 0; }

/* ---------- cảnh báo doanh nghiệp đang lỗ (đầu trang báo cáo) ---------- */
.loss-alert { background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-left: 4px solid var(--warn); border-radius: var(--radius); padding: 12px 16px; margin: 16px 0 12px; font-size: .92rem; line-height: 1.55; }

/* ---------- dòng ưu đãi ở trang chủ: "3 mã miễn phí mỗi tháng · Sau đó chỉ 7.000đ mỗi mã" ---------- */
.offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0 0; font-size: .92rem; }
.offer-pill { background: var(--up-soft); color: var(--up); font-weight: 700; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.offer-then { color: var(--muted); }
.offer-then b { color: var(--text); font-weight: 700; }

/* ---------- đăng nhập bằng mã email ---------- */
.btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface);
  color: var(--text); border: 1px solid var(--line); margin-top: 18px; }
.btn.google:hover { background: var(--surface-2); text-decoration: none; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 18px 0 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.code-input { text-align: center; font-size: 1.6rem !important; letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.resend { text-align: center; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.notice-inline { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 8px; }

/* ---------- xóa tài khoản ---------- */
.btn.danger { background: var(--down); color: #fff; }
.field-input { display: block; width: 100%; margin-top: 6px; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; }
.my-delete { margin-top: 28px; }

/* ---------- báo cáo của bạn ---------- */
.my-reports { padding: 28px 0 40px; }
.my-reports h1 { margin: 0; }
.my-list { display: grid; gap: 10px; margin-bottom: 14px; }
.my-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.my-main { min-width: 0; flex: 1 1 260px; }
.my-tk { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.my-name { color: var(--muted); font-size: .9rem; }
.my-meta { margin-top: 4px; line-height: 1.5; }
.my-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tag.ok { background: var(--up-soft); color: var(--up); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.notice-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; text-align: left; max-width: 980px; }
@media (max-width: 860px) { .plans { grid-template-columns: 1fr; max-width: 460px; }
  .plans.has-ticker .plan-single { order: -1; } }  /* hết lượt khi đang xem 1 mã: đưa gói mua lẻ lên đầu */
.center .plans { margin: 24px auto 0; }
.plan { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.plan.featured { border: 2px solid var(--accent); box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 18%, transparent); }
.plan-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.plan .price { font-size: 1.8rem; font-weight: 700; margin: 6px 0 4px; }
.plan .price .muted { font-size: .9rem; font-weight: 500; }
.plan .ticks { flex: 1; }
.plan form, .plan > .btn { margin-top: 12px; }
.ticks { list-style: none; padding: 0; margin: 8px 0 0; }
.ticks li { position: relative; padding: 4px 0 4px 26px; }
.ticks li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 14px; height: 14px; border-radius: 50%; background: var(--up-soft); }
.ticks li::after { content: ""; position: absolute; left: 6px; top: 12px; width: 6px; height: 3px; border-left: 2px solid var(--up); border-bottom: 2px solid var(--up); transform: rotate(-45deg); }

.faq { display: grid; gap: 8px; max-width: 760px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.2rem; line-height: 1; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 14px; color: var(--muted); font-size: .92rem; }

.site-footer { margin-top: 40px; background: var(--surface); border-top: 1px solid var(--line); }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-top: 28px; padding-bottom: 12px; }
.footer-brand { max-width: 380px; }
.footer-brand .brand { color: var(--text); }
.footer-brand p { margin: 8px 0 0; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }
.footer-note { color: var(--muted); font-size: .76rem; padding-top: 12px; padding-bottom: 36px; border-top: 1px solid var(--line); }

.auth { display: grid; place-items: center; padding: 56px 0; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; box-shadow: 0 12px 32px rgba(16, 24, 40, .08); }
.auth-card h1 { font-size: 1.5rem; margin: 14px 0 4px; }
.auth-card .stack { max-width: none; margin: 18px 0 12px; }
.dev-note { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }

@media (max-width: 900px) {
  .home-hero { grid-template-columns: 1fr; gap: 28px; padding-top: 32px; }
  .features { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .home-hero h1 { font-size: 1.85rem; }
  .plans { grid-template-columns: 1fr; }
  .search.big .btn { padding: 10px 14px; }
  .features { grid-template-columns: 1fr; }
  .feature { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; }
  .feature .f-ico { grid-row: span 2; margin: 0; }
  .feature p { margin-top: 2px; }
  .auth { padding: 24px 0; }
  .auth-card { padding: 22px 18px; }
}

/* ---------- trang Điều khoản / Bảo mật ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 28px 0 8px; }
.legal h1 { margin-bottom: 4px; }
.legal h2 { font-size: 1.1rem; margin: 1.6em 0 .4em; }
.legal ul { padding-left: 20px; }
.legal li { margin: 4px 0; }
.legal p, .legal li { line-height: 1.7; }
