:root {
  --gold: #F59E0B;
  --gold-2: #FBBF24;
  --accent: #8B5CF6;
  --bg: #0A0E17;
  --bg-2: #0F172A;
  --surface: #131A2A;
  --surface-2: #1A2334;
  --muted: #232D42;
  --border: #26324a;
  --fg: #F8FAFC;
  --fg-dim: #94A3B8;
  --fg-mute: #64748B;
  --buy: #12b76a;
  --buy-glow: rgba(18,183,106,.25);
  --sell: #f04438;
  --sell-glow: rgba(240,68,56,.25);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139,92,246,.10), transparent 60%),
    radial-gradient(900px 500px at -5% 0%, rgba(245,158,11,.08), transparent 55%),
    var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
button { font-family: inherit; cursor: pointer; }
b { font-weight: 700; }
.muted { color: var(--fg-dim); font-size: 13px; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ============ TOP BAR ============ */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(19,26,42,.9), rgba(19,26,42,.55));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; color: var(--bg);
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  box-shadow: 0 6px 18px -6px rgba(245,158,11,.6);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-name b { color: var(--gold); }
.brand-sub { font-size: 11px; color: var(--fg-mute); letter-spacing: .3px; text-transform: uppercase; }

.ticker {
  display: flex; align-items: center; gap: 18px;
  padding: 7px 16px; border-radius: 12px;
  background: rgba(10,14,23,.6); border: 1px solid var(--border);
}
.tk-symbol { font-weight: 600; color: var(--fg-dim); font-size: 13px; letter-spacing: .5px; }
.tk-price { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.tk-change { font-family: var(--mono); font-size: 14px; font-weight: 600; padding: 2px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }
.tk-change.up { color: var(--buy); background: var(--buy-glow); }
.tk-change.down { color: var(--sell); background: var(--sell-glow); }
.tk-spread { font-size: 12px; color: var(--fg-mute); font-family: var(--mono); }

.top-actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
/* Nhom nut trong thanh tren: gom theo chuc nang cho gon gang */
.act-group { display: flex; align-items: center; gap: 8px; }
.act-sep { width: 1px; align-self: stretch; min-height: 24px; background: var(--border); }
.btn-lab { white-space: nowrap; }
/* Menu 3 gach + drawer: desktop giu nguyen, #navItems chay inline trong #navHome */
.nav-toggle { display: none; }
.nav-home { display: contents; }
.nav-items { display: contents; }
.nav-drawer { display: none; }
.nav-drawer-head { display: none; }
.nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 55; backdrop-filter: blur(2px); }
.nav-backdrop[hidden] { display: none; }
body.nav-open { overflow: hidden; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-dim); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-mute); box-shadow: 0 0 0 3px rgba(100,116,139,.15); }
.conn.live .dot { background: var(--buy); box-shadow: 0 0 0 3px var(--buy-glow); animation: pulse 2s infinite; }
.conn.err .dot { background: var(--sell); box-shadow: 0 0 0 3px var(--sell-glow); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1a1206; box-shadow: 0 8px 22px -8px rgba(245,158,11,.7); }
.btn-primary:hover { box-shadow: 0 10px 28px -6px rgba(245,158,11,.85); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-ghost { background: var(--surface-2); color: var(--fg); border-color: var(--border); }
.btn-ghost:hover { background: var(--muted); }
/* Nut cong cu (thong bao / MT5 / huong dan / tai khoan / dang xuat): nho gon, icon + chu */
.btn-tool { position: relative; background: var(--surface-2); color: var(--fg-dim); border-color: var(--border); padding: 8px 12px; font-size: 13px; gap: 7px; border-radius: 9px; }
.btn-tool:hover { background: var(--muted); color: var(--gold); }
.btn-tool svg { flex: none; }
/* Nut "Goi y theo Dow": xanh duong de phan biet voi nut vang */
.btn-dow { background: linear-gradient(135deg, #38bdf8, #2563eb); color: #061224; box-shadow: 0 8px 22px -8px rgba(37,99,235,.7); }
.btn-dow:hover { box-shadow: 0 10px 28px -6px rgba(37,99,235,.85); }
.btn-dow:disabled { opacity: .55; cursor: wait; }

/* ============ LAYOUT ============ */
.layout {
  flex: 1; display: grid; grid-template-columns: 1fr 400px;
  gap: 16px; padding: 16px 20px; min-height: 0;
}
.chart-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* Toolbar */
.chart-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.tf-group { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tf-group button {
  border: none; background: transparent; color: var(--fg-dim);
  font-weight: 600; font-size: 13px; padding: 6px 12px; border-radius: 7px; transition: all .15s ease;
}
.tf-group button:hover { color: var(--fg); }
.tf-group button.active { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1a1206; }
.ind-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--fg-dim);
  padding: 6px 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--border);
  cursor: pointer; user-select: none; transition: all .15s;
}
.chip:hover { color: var(--fg); }
.chip input { accent-color: var(--gold); margin: 0; }
.offset-ctl { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-dim); }
.offset-ctl input {
  width: 74px; background: var(--bg-2); border: 1px solid var(--border); color: var(--fg);
  border-radius: 8px; padding: 6px 8px; font-family: var(--mono); font-size: 13px;
}
.offset-ctl input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }

.chart-legend {
  display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px;
  padding: 0 4px; min-height: 18px; color: var(--fg-dim);
}
.chart-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .sw { width: 12px; height: 3px; border-radius: 2px; }
.chart-legend b { color: var(--fg); font-weight: 600; }
.chart-src {
  display: inline-block; margin: 2px 4px 0; font-family: var(--mono); font-size: 11px;
  font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .2px;
}
.chart-src.on { background: var(--buy-glow); color: var(--buy); box-shadow: inset 0 0 0 1px rgba(18,183,106,.4); }
.chart-src.wait { background: rgba(245,158,11,.14); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(245,158,11,.35); }

/* Chart stack */
.chart-stack {
  flex: 1; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-height: 420px;
}
.pane { position: relative; width: 100%; }
.pane-main { flex: 1 1 auto; min-height: 300px; }
.pane-sub { height: 120px; border-top: 1px solid var(--border); }
.pane::before {
  content: attr(data-title);
  position: absolute; top: 6px; left: 10px; z-index: 3;
  font-family: var(--mono); font-size: 11px; color: var(--fg-mute); pointer-events: none;
}

/* ============ SIDEBAR ============ */
.side-col { display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.tab {
  flex: 1; border: none; background: transparent; color: var(--fg-dim);
  font-weight: 600; font-size: 13px; padding: 9px 6px; border-radius: 8px; transition: all .15s;
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--surface-2); color: var(--gold); box-shadow: inset 0 0 0 1px var(--border); }

.tab-panel { display: none; flex: 1; overflow-y: auto; }
.tab-panel.active { display: block; }
.tab-panel::-webkit-scrollbar { width: 8px; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 8px; }

/* Signal card */
.signal-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
  padding: 48px 24px; color: var(--fg-dim); background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.signal-empty .empty-ic { color: var(--fg-mute); }
.signal-empty p { max-width: 260px; line-height: 1.55; }

.sig {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); animation: rise .35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.sig-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.sig-side { display: flex; align-items: center; gap: 10px; }
.sig-badge { font-weight: 800; font-size: 18px; padding: 6px 14px; border-radius: 10px; letter-spacing: .5px; }
.sig-badge.BUY { color: var(--buy); background: var(--buy-glow); box-shadow: inset 0 0 0 1px rgba(18,183,106,.4); }
.sig-badge.SELL { color: var(--sell); background: var(--sell-glow); box-shadow: inset 0 0 0 1px rgba(240,68,56,.4); }
.sig-tf { font-family: var(--mono); font-size: 12px; color: var(--fg-mute); }

.score-ring { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.score-ring .num { font-family: var(--mono); font-weight: 700; font-size: 20px; }
.score-ring .lab { font-size: 10px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .5px; }

.sig-levels { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; background: var(--border); }
.lvl { background: var(--surface); padding: 13px 12px; text-align: center; }
.lvl .k { font-size: 11px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.lvl .v { font-family: var(--mono); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.lvl.entry .v { color: var(--gold); }
.lvl.sl .v { color: var(--sell); }
.lvl.tp .v { color: var(--buy); }

.sig-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.sig-meta { display: flex; gap: 10px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--fg-dim); }
.sig-meta span { background: var(--bg-2); border: 1px solid var(--border); padding: 4px 9px; border-radius: 7px; }
.sig-section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--fg-mute); }
.sig-summary { line-height: 1.6; font-size: 14px; }
/* ---- Khoi phan tich Ly thuyet Dow ---- */
.dow-box { border: 1px solid rgba(56,189,248,.35); background: rgba(37,99,235,.06); border-radius: 12px; padding: 12px 14px; }
.dow-box h4 { color: #38bdf8; }
.dow-trend { font-size: 14px; margin-bottom: 10px; }
.dow-trend.up b { color: var(--buy); }
.dow-trend.down b { color: var(--sell); }
.dow-trend.side b { color: var(--gold); }
.dow-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.dow-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.dow-row .dk { color: var(--fg-mute); }
.dow-row .dv { font-family: var(--mono); color: var(--fg); text-align: right; }
.dow-note { font-size: 13px; line-height: 1.5; color: var(--fg-dim); margin: 6px 0 0; }
.dow-action { font-size: 13.5px; line-height: 1.55; margin: 8px 0 0; }
.dow-warn { font-size: 13px; line-height: 1.5; color: var(--sell); margin: 6px 0 0; }
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.reasons li { display: flex; gap: 8px; font-size: 13px; line-height: 1.45; color: var(--fg-dim); }
.reasons li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--gold); }

.expert-cards { display: flex; flex-direction: column; gap: 10px; }
.ex-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.ex-card .ex-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.ex-card .ex-name .av { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--bg); }
.ex-card .ex-role { font-size: 11px; color: var(--fg-mute); font-weight: 400; }
.ex-card p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--fg-dim); }
.av.tech { background: linear-gradient(135deg,#60a5fa,#3b82f6); }
.av.macro { background: linear-gradient(135deg,#fbbf24,#f59e0b); }
.av.risk { background: linear-gradient(135deg,#a78bfa,#8b5cf6); }

.sig-save { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--buy); }

/* Confidence bar */
.conf-bar { position: relative; height: 22px; background: var(--bg-2); border-bottom: 1px solid var(--border); overflow: hidden; }
.conf-fill { position: absolute; inset: 0 auto 0 0; background: var(--gold); opacity: .22; transition: width .5s ease; }
.conf-txt { position: relative; z-index: 1; display: block; height: 100%; line-height: 22px; text-align: center; font-size: 11px; font-weight: 600; font-family: var(--mono); color: var(--fg-dim); letter-spacing: .3px; }

/* Copy order button */
.btn-copy { width: 100%; justify-content: center; gap: 8px; }
.btn-copy.ok { color: var(--buy); border-color: var(--buy); }

/* Position size calculator */
.pos-calc { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; display: flex; flex-direction: column; gap: 10px; }
.pc-head { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--fg-mute); font-weight: 600; }
.pc-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pc-field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--fg-mute); }
.pc-field input { background: var(--surface); border: 1px solid var(--border); color: var(--fg); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 14px; }
.pc-field input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.pc-out { display: flex; flex-direction: column; gap: 6px; }
.pc-line { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--fg-dim); }
.pc-line b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pc-lot { color: var(--gold); font-size: 15px; }
.pc-pip { color: var(--fg); }
.pc-risk { color: var(--sell); }
.pc-reward { color: var(--buy); }
.pc-note { font-size: 11px; color: var(--fg-mute); line-height: 1.4; }

/* Multi-timeframe confluence strip */
.mtf-strip { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.mtf-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 10px; }
.mtf-consensus { font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 7px; letter-spacing: .3px; }
.mtf-consensus.buy { color: var(--buy); background: var(--buy-glow); }
.mtf-consensus.sell { color: var(--sell); background: var(--sell-glow); }
.mtf-consensus.neutral { color: var(--fg-dim); background: var(--muted); }
.mtf-chips { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.mtf-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 6px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--border); border-bottom: 2px solid var(--fg-mute); }
.mtf-chip.buy { border-bottom-color: var(--buy); }
.mtf-chip.sell { border-bottom-color: var(--sell); }
.mtf-chip.neu { border-bottom-color: var(--fg-mute); }
.mtf-tf { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--fg); }
.mtf-dir { font-size: 14px; font-weight: 700; }
.mtf-chip.buy .mtf-dir { color: var(--buy); }
.mtf-chip.sell .mtf-dir { color: var(--sell); }
.mtf-chip.neu .mtf-dir { color: var(--fg-mute); }

/* Event countdown warning */
.event-warn { display: flex; align-items: center; gap: 10px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); border-radius: 12px; padding: 11px 14px; margin-bottom: 12px; color: var(--gold); font-size: 13px; line-height: 1.4; }
.event-warn svg { flex: none; }
.event-warn.soon { background: rgba(240,68,56,.12); border-color: rgba(240,68,56,.45); color: var(--sell); animation: warnPulse 2s ease-in-out infinite; }
.event-warn .ew-txt { color: var(--fg-dim); }
.event-warn .ew-txt b { color: inherit; }
.event-warn.soon .ew-txt b { color: var(--sell); }
@keyframes warnPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(240,68,56,0); } 50% { box-shadow: 0 0 0 4px rgba(240,68,56,.12); } }

/* Gio vao lenh (phien giao dich XAU/USD) */
.session-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--fg-mute); border-radius: 12px; padding: 11px 13px; margin-bottom: 12px; }
.session-card:empty { display: none; }
.session-card.good { border-left-color: var(--buy); }
.session-card.ok { border-left-color: var(--gold); }
.session-card.caution { border-left-color: #fb923c; }
.session-card.avoid, .session-card.closed { border-left-color: var(--sell); }
.sess-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sess-title { font-size: 13px; font-weight: 700; color: var(--fg); }
.sess-tz { font-weight: 400; color: var(--fg-mute); font-size: 11px; }
.sess-clock { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.sess-now { display: flex; gap: 9px; align-items: flex-start; }
.sess-dot { font-size: 13px; line-height: 1.4; flex: none; }
.sess-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.sess-now.good .sess-name b { color: var(--buy); }
.sess-now.ok .sess-name b { color: var(--gold); }
.sess-now.caution .sess-name b { color: #fb923c; }
.sess-now.avoid .sess-name b { color: var(--sell); }
.sess-advice { font-size: 12.5px; line-height: 1.5; color: var(--fg-dim); margin-top: 2px; }
.sess-next { font-size: 12.5px; color: var(--fg-dim); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.sess-next b { color: var(--fg); }
.sess-warns { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.sess-warn { font-size: 12px; line-height: 1.45; color: var(--gold); background: rgba(245,158,11,.08); border-radius: 7px; padding: 6px 9px; }
.sess-sched { margin-top: 9px; }
.sess-sched summary { cursor: pointer; font-size: 12px; color: var(--fg-mute); list-style: none; user-select: none; padding: 3px 0; }
.sess-sched summary::-webkit-details-marker { display: none; }
.sess-sched summary::before { content: "▸ "; }
.sess-sched[open] summary::before { content: "▾ "; }
.sess-list { margin-top: 7px; display: flex; flex-direction: column; gap: 2px; }
.sess-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 6px; border-radius: 6px; color: var(--fg-dim); }
.sess-row .sess-time { font-family: var(--mono); color: var(--fg-mute); font-variant-numeric: tabular-nums; min-width: 88px; }
.sess-row .sess-rname { color: var(--fg-dim); }
.sess-row.on { background: var(--bg-2); }
.sess-row.on .sess-rname { color: var(--fg); font-weight: 600; }
.sess-foot { font-size: 11px; color: var(--fg-mute); line-height: 1.5; margin-top: 7px; }

/* Ask box */
.ask-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.ask-box textarea {
  width: 100%; resize: vertical; background: var(--surface); border: 1px solid var(--border);
  color: var(--fg); border-radius: 10px; padding: 11px 12px; font-family: inherit; font-size: 14px; line-height: 1.5;
}
.ask-box textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
.expert-out { display: flex; flex-direction: column; gap: 12px; }
.expert-out .answer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; line-height: 1.65; font-size: 14px; white-space: pre-wrap; }

/* News */
.news-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--fg-dim); width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; transition: all .15s; }
.icon-btn:hover { color: var(--gold); transform: rotate(45deg); }
.news-list { display: flex; flex-direction: column; gap: 8px; }
.news-item { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 12px 13px; transition: all .15s; border-left: 3px solid var(--fg-mute); }
.news-item:hover { background: var(--surface-2); transform: translateX(2px); }
.news-item.high { border-left-color: var(--sell); }
.news-item.medium { border-left-color: var(--gold); }
.news-item.low { border-left-color: var(--fg-mute); }
.news-item .ni-title { font-size: 13.5px; font-weight: 500; line-height: 1.45; margin-bottom: 6px; }
.news-item .ni-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--fg-mute); font-family: var(--mono); }
.ni-badge { padding: 2px 7px; border-radius: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.ni-badge.high { color: var(--sell); background: var(--sell-glow); }
.ni-badge.medium { color: var(--gold); background: rgba(245,158,11,.15); }
.ni-badge.low { color: var(--fg-dim); background: var(--muted); }
.ni-explain { margin-left: auto; background: rgba(245,158,11,.12); color: var(--gold); border: 1px solid rgba(245,158,11,.3); border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: 600; font-family: var(--font); cursor: pointer; transition: all .15s; }
.ni-explain:hover { background: rgba(245,158,11,.2); }
.ni-explain:disabled { opacity: .6; cursor: default; }
.ni-explain-out { margin-top: 8px; }
.ni-answer { background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.55; color: var(--fg-dim); white-space: pre-wrap; }

/* Economic calendar */
.cal-list { display: flex; flex-direction: column; gap: 14px; }
.cal-day-head { font-size: 12px; font-weight: 700; text-transform: capitalize; color: var(--gold); margin-bottom: 8px; letter-spacing: .3px; }
.cal-item { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; border-left: 3px solid var(--fg-mute); transition: all .15s; }
.cal-item:hover { background: var(--surface-2); }
.cal-item.high { border-left-color: var(--sell); }
.cal-item.medium { border-left-color: var(--gold); }
.cal-item.past { opacity: .5; }
.cal-item.soon { box-shadow: inset 0 0 0 1px rgba(245,158,11,.4); }
.cal-time { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--fg); min-width: 44px; padding-top: 1px; }
.cal-body { flex: 1; min-width: 0; }
.cal-title { font-size: 13px; font-weight: 500; line-height: 1.4; margin-bottom: 5px; }
.cal-gold { color: var(--gold); }
.cal-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--fg-mute); font-family: var(--mono); }
.cal-badge { padding: 2px 7px; border-radius: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.cal-badge.high { color: var(--sell); background: var(--sell-glow); }
.cal-badge.medium { color: var(--gold); background: rgba(245,158,11,.15); }
.cal-badge.low { color: var(--fg-dim); background: var(--muted); }
.cal-fc, .cal-pv { color: var(--fg-dim); }

/* Record */
.stats-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat .s-lab { font-size: 11px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat .s-val { font-family: var(--mono); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.win .s-val { color: var(--buy); }
.stat.hero { grid-column: span 2; background: linear-gradient(135deg, rgba(245,158,11,.12), rgba(139,92,246,.10)); }
.stat.hero .s-val { font-size: 34px; color: var(--gold); }
.record-head { display: flex; justify-content: flex-end; margin: 4px 0 10px; }
.btn-clear-record { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--sell); background: transparent; border: 1px solid rgba(240,68,56,.4); transition: background .15s, box-shadow .15s; }
.btn-clear-record:hover { background: var(--sell-glow); }
.btn-clear-record:disabled { opacity: .55; cursor: wait; }
.record-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.rec-side { font-weight: 700; font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.rec-side.BUY { color: var(--buy); background: var(--buy-glow); }
.rec-side.SELL { color: var(--sell); background: var(--sell-glow); }
.rec-mid { flex: 1; font-family: var(--mono); color: var(--fg-dim); font-size: 12px; }
.rec-status { font-weight: 700; font-size: 12px; font-family: var(--mono); }
.rec-status.WIN { color: var(--buy); }
.rec-status.LOSS { color: var(--sell); }
.rec-status.OPEN { color: var(--gold); }
.rec-status.EXPIRED { color: var(--fg-mute); }
.rec-del { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--fg-mute); background: transparent; border: 1px solid var(--border); transition: color .15s, background .15s, border-color .15s; }
.rec-del:hover { color: var(--sell); background: var(--sell-glow); border-color: rgba(240,68,56,.4); }
.rec-del:disabled { opacity: .5; cursor: wait; }

/* Disclaimer + toast */
.disclaimer { padding: 12px 20px; font-size: 12px; color: var(--fg-mute); text-align: center; border-top: 1px solid var(--border); line-height: 1.5; }
.disclaimer b { color: var(--fg-dim); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--fg);
  padding: 12px 18px; border-radius: 11px; box-shadow: var(--shadow); font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--sell); }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--fg-dim); font-size: 14px; padding: 20px 4px; }

/* ============ AUTH: user box ============ */
.user-box { display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-size: 13px; font-weight: 600; color: var(--fg-dim);
  padding: 6px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============ OVERLAY (login + admin) ============ */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 20px;
  background: rgba(6,9,16,.72); backdrop-filter: blur(8px);
}
.overlay[hidden] { display: none; }

.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 24px; display: flex; flex-direction: column; gap: 15px;
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 4px; }
.login-title { font-size: 19px; font-weight: 700; }
.login-sub { font-size: 12.5px; color: var(--fg-dim); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; color: var(--fg-dim); font-weight: 500; }
.field input, .admin-create input, .admin-create select {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--fg);
  border-radius: var(--radius-sm); padding: 11px 12px; font-size: 15px; font-family: inherit;
  transition: border-color .15s;
}
.field input:focus, .admin-create input:focus, .admin-create select:focus {
  outline: none; border-color: var(--gold);
}
.btn-block { width: 100%; justify-content: center; margin-top: 4px; }
.login-error, .admin-error {
  font-size: 13px; color: var(--sell); background: var(--sell-glow);
  border: 1px solid rgba(240,68,56,.35); border-radius: var(--radius-sm);
  padding: 8px 11px; margin: 0;
}
.login-note { font-size: 12px; color: var(--fg-mute); text-align: center; margin: 2px 0 0; }

/* ============ ADMIN MODAL ============ */
.admin-card {
  width: 100%; max-width: 460px; max-height: 82vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.admin-head h3 { margin: 0; font-size: 17px; }
.admin-create { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; margin-bottom: 12px; }
.admin-create input { padding: 9px 10px; font-size: 13.5px; }
.admin-create select { padding: 9px 8px; font-size: 13.5px; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-user {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.au-info { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.au-name { font-weight: 600; font-size: 14px; }
.au-role { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--muted); color: var(--fg-dim); }
.au-role.admin { background: rgba(245,158,11,.18); color: var(--gold-2); }
.au-meta { font-size: 12px; color: var(--fg-mute); }
.au-self { font-size: 12px; color: var(--fg-mute); font-style: italic; }
.au-del {
  background: transparent; border: 1px solid var(--border); color: var(--fg-mute);
  width: 28px; height: 28px; border-radius: 7px; font-size: 14px; transition: all .15s;
}
.au-del:hover { color: var(--sell); border-color: var(--sell); }

/* Lien he admin + nut xem tiep (che do khach) */
.login-contact { color: var(--gold-2); font-weight: 700; text-decoration: none; }
.login-contact:hover { text-decoration: underline; }
.login-guest {
  display: block; width: 100%; margin-top: 10px; padding: 9px 12px;
  background: transparent; border: 1px solid var(--border); color: var(--fg-mute);
  border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; transition: all .15s;
}
.login-guest:hover { color: var(--fg); border-color: var(--fg-mute); }

/* ============ NHAT KY QUET (admin) ============ */
.scanlog-card { max-width: 720px; }
.scanlog-head-actions { display: flex; align-items: center; gap: 8px; }
.scanlog-head-actions select { padding: 6px 8px; font-size: 13px; border-radius: 7px; }
.scanlog-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sl-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--fg-dim);
}
.sl-chip b { color: var(--fg); }
.sl-chip.sl-sent { border-color: rgba(34,197,94,.4); color: var(--buy); }
.sl-chip.sl-filter { border-color: rgba(245,158,11,.4); color: var(--gold-2); }
.sl-chip.sl-block { border-color: rgba(240,68,56,.4); color: var(--sell); }
.scanlog-list { display: flex; flex-direction: column; gap: 8px; }
.sl-row {
  background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.sl-row.sl-sent { border-left-color: var(--buy); }
.sl-row.sl-warn { border-left-color: var(--gold-2); }
.sl-row.sl-filter { border-left-color: var(--gold-2); }
.sl-row.sl-block { border-left-color: var(--sell); }
.sl-row-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sl-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: var(--muted); color: var(--fg-dim);
}
.sl-badge.sl-sent { background: rgba(34,197,94,.16); color: var(--buy); }
.sl-badge.sl-warn { background: rgba(245,158,11,.18); color: var(--gold-2); }
.sl-badge.sl-filter { background: rgba(245,158,11,.16); color: var(--gold-2); }
.sl-badge.sl-block { background: rgba(240,68,56,.16); color: var(--sell); }
.sl-side { font-weight: 700; font-size: 13px; }
.sl-side.buy { color: var(--buy); }
.sl-side.sell { color: var(--sell); }
.sl-score { font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: var(--fg); }
.sl-tf { font-size: 12px; color: var(--fg-mute); }
.sl-out { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--muted); color: var(--fg-dim); }
.sl-out.up { background: rgba(34,197,94,.16); color: var(--buy); }
.sl-out.down { background: rgba(240,68,56,.16); color: var(--sell); }
.sl-old { font-size: 10.5px; color: var(--fg-mute); border: 1px dashed var(--border); padding: 1px 6px; border-radius: 5px; }
.sl-time { margin-left: auto; font-size: 12px; color: var(--fg-mute); }
.sl-reason { font-size: 12.5px; color: var(--fg-dim); margin-top: 5px; line-height: 1.45; }
.sl-px { font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--fg-mute); margin-top: 4px; }

/* Tabs trong modal nhat ky */
.scanlog-tabs { display: flex; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.scanlog-tab {
  background: transparent; border: none; color: var(--fg-mute);
  padding: 8px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.scanlog-tab:hover { color: var(--fg); }
.scanlog-tab.active { color: var(--gold-2); border-bottom-color: var(--gold-2); }
.scanlog-pane[hidden] { display: none; }

/* Muc HOC TAP */
.lb-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.lb-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.lb-card-t { font-size: 11.5px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .03em; }
.lb-card-main { font-size: 15px; margin: 4px 0 2px; }
.lb-card-main b { font-size: 18px; }
.lb-card-sub { font-size: 11.5px; color: var(--fg-mute); }
.lb-group { margin-bottom: 14px; }
.lb-group-h { font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--fg-dim); }
.lb-group-h.up { color: var(--buy); }
.lb-group-h.warn { color: var(--gold-2); }
.lb-group-h.down { color: var(--sell); }
.lb-bucket {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 6px;
}
.lb-bucket.prefer { border-left-color: var(--buy); }
.lb-bucket.caution { border-left-color: var(--gold-2); }
.lb-bucket.avoid { border-left-color: var(--sell); }
.lb-bk-lab { font-weight: 600; font-size: 13px; }
.lb-bk-wr { font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: var(--fg); }
.lb-bk-n { font-size: 12px; color: var(--fg-mute); }
.lb-bk-np { margin-left: auto; font-family: "JetBrains Mono", monospace; font-size: 12.5px; }
.learn-box .up { color: var(--buy); }
.learn-box .down { color: var(--sell); }
.lb-empty { font-size: 12.5px; color: var(--fg-mute); font-style: italic; padding: 2px 2px 6px; }
.lb-lesson { font-size: 12.5px; color: var(--fg-dim); line-height: 1.5; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.lb-day { color: var(--fg-mute); font-size: 11.5px; margin-right: 6px; }

/* News: dong tom tat tieng Viet */
.ni-summary { font-size: 12.5px; color: var(--fg-dim); margin-top: 4px; line-height: 1.45; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { min-height: 520px; }
  .ticker { display: none; }
}
@media (max-width: 640px) {
  /* Menu tren gon lai, chi chiem ~1/4 khung hinh */
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .brand { min-width: 0; flex: 1; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .brand-sub { display: none; }
  .layout { padding: 12px; gap: 12px; }

  /* Thanh hanh dong: hang 1 = trang thai + nut menu, hang 2 = 2 nut goi y */
  .top-actions { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .act-sep { display: none; }
  .conn { order: -1; flex: 1 1 auto; justify-content: flex-start; font-size: 11px; }

  /* Nut menu 3 gach: hien tren dien thoai, nam cuoi hang 1 */
  .nav-toggle { display: inline-flex; order: -1; flex: 0 0 auto; padding: 9px; min-height: 40px; }

  /* Nhom goi y: 2 nut chia doi, noi bat, gon */
  .act-primary { flex: 1 1 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .act-primary .btn { justify-content: center; padding: 9px 10px; font-size: 13px; }

  /* Drawer: cong cu + tai khoan truot ngang tu ben phai */
  .nav-drawer {
    display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    position: fixed; top: 0; right: 0; z-index: 60;
    width: min(80vw, 300px); height: 100dvh;
    padding: 14px; padding-top: max(14px, env(safe-area-inset-top));
    overflow-y: auto;
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: -18px 0 40px -12px rgba(0,0,0,.65);
    transform: translateX(100%); transition: transform .25s ease;
  }
  .nav-drawer.open { transform: translateX(0); }
  .nav-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; font-size: 15px; color: var(--fg);
    padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  }
  .nav-drawer .act-sep { display: block; width: 100%; height: 1px; min-height: 0; margin: 4px 0; }
  .nav-drawer .act-group { flex-direction: column; align-items: stretch; width: 100%; gap: 6px; }
  .nav-drawer .btn { justify-content: flex-start; width: 100%; padding: 12px 14px; min-height: 48px; }
  .nav-drawer .btn-lab { display: inline; }
  .nav-drawer .user-chip { display: block; max-width: none; padding: 6px 4px; color: var(--fg-dim); font-size: 13px; }

  /* Vung cham tay thoai mai hon (>=40px) */
  .btn { padding: 11px 16px; }
  .icon-btn { width: 40px; height: 40px; }
  .tab { padding: 12px 6px; font-size: 13.5px; }
  .chip { padding: 11px 12px; font-size: 12.5px; }

  /* Chon khung thoi gian: thanh full-width, 7 nut chia deu, cao ~40px */
  .tf-group { width: 100%; display: flex; }
  .tf-group button { flex: 1; padding: 12px 4px; font-size: 13px; }

  /* Input font 16px de iOS khong tu phong to khi focus */
  input, select, textarea { font-size: 16px; }

  .user-chip { max-width: 120px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .chart-toolbar { gap: 10px; }
  .offset-ctl { margin-left: 0; }
  .admin-create { grid-template-columns: 1fr; }

  /* Chart gon hon, bot chiem man hinh */
  .chart-stack { min-height: 340px; }
  .pane-main { min-height: 240px; }
  .pane-sub { height: 96px; }
  .sig-badge { font-size: 16px; padding: 5px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============ GUIDE MODAL ============ */
.guide-card {
  width: 100%; max-width: 620px; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.guide-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.guide-head h3 svg { color: var(--gold); flex: none; }
.guide-body { padding: 18px 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.guide-body > * { flex-shrink: 0; }
.guide-intro { font-size: 13.5px; line-height: 1.6; color: var(--fg-dim); background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 10px; padding: 12px 14px; }
.guide-intro b { color: var(--fg); }
.guide-steps { display: flex; flex-direction: column; gap: 8px; }
.gstep { display: flex; align-items: flex-start; gap: 11px; font-size: 13.5px; line-height: 1.5; color: var(--fg-dim); }
.gstep b { color: var(--fg); }
.gnum { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #1a1206; background: linear-gradient(135deg, var(--gold-2), var(--gold)); }
.guide-sec { background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.guide-sec summary { cursor: pointer; list-style: none; padding: 12px 14px; font-size: 14px; font-weight: 600; color: var(--fg); display: flex; align-items: center; justify-content: space-between; transition: background .15s; }
.guide-sec summary::-webkit-details-marker { display: none; }
.guide-sec summary::after { content: "+"; font-size: 18px; font-weight: 400; color: var(--gold); line-height: 1; }
.guide-sec[open] summary::after { content: "\2212"; }
.guide-sec summary:hover { background: var(--surface-2); }
.gsec-body { padding: 0 15px 14px; font-size: 13px; line-height: 1.6; color: var(--fg-dim); }
.gsec-body p { margin: 0 0 8px; }
.gsec-body ul, .gsec-body ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.gsec-body li { line-height: 1.55; }
.gsec-body b { color: var(--fg); }
.gsec-body .gtip { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.28); border-radius: 8px; padding: 8px 11px; color: var(--gold); font-size: 12.5px; margin-top: 4px; }
.guide-rules ol { counter-reset: none; }
.guide-know { border-color: rgba(212,175,55,.45); background: linear-gradient(180deg, rgba(212,175,55,.07), var(--bg-2)); }
.guide-know > summary { color: var(--gold); }
.gknow-list { padding-left: 22px; }
.gknow-list > li { margin-bottom: 4px; }
.gknow-list ul { margin-top: 6px; padding-left: 18px; }
.gknow-list ul li { list-style: disc; }
.guide-warn { font-size: 12.5px; line-height: 1.55; color: var(--fg-dim); background: rgba(240,68,56,.1); border: 1px solid rgba(240,68,56,.3); border-radius: 10px; padding: 12px 14px; }
.guide-warn b { color: var(--sell); }
@media (max-width: 640px) {
  .guide-card { max-height: 92vh; }
  .guide-body { padding: 16px; }
}

/* ============ KET NOI MT5 ============ */
.btn-mt5 { background: var(--surface-2); color: var(--fg); border-color: var(--border); gap: 7px; }
.btn-mt5:hover { background: var(--muted); }
.mt5-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-mute); flex: none; }
.mt5-dot.on { background: var(--buy); box-shadow: 0 0 0 3px var(--buy-glow); animation: pulse 2s infinite; }
.mt5-dot.wait { background: var(--gold); box-shadow: 0 0 0 3px rgba(245,158,11,.25); }

/* Nut vao lenh tren the tin hieu */
.btn-mt5-send { width: 100%; justify-content: center; gap: 8px; margin-top: 10px;
  background: linear-gradient(135deg, #1f6feb, #0ea5e9); color: #fff; border: none;
  box-shadow: 0 8px 22px -10px rgba(14,165,233,.8); }
.btn-mt5-send:hover { filter: brightness(1.06); }
.btn-mt5-send:disabled { opacity: .6; cursor: not-allowed; }
.mt5-send-out { font-size: 12.5px; line-height: 1.5; margin-top: 8px; min-height: 0; }
.mt5-send-out:empty { display: none; }
.mt5-send-ok { color: var(--buy); }
.mt5-send-warn { color: var(--sell); }

/* Nut nhap nhay khi du dieu kien (quet nen) — manh, dam, thu hut */
@keyframes blinkBtn {
  0%   { box-shadow: 0 0 0 0 rgba(245,158,11,.85), 0 0 14px 2px rgba(245,158,11,.55); filter: brightness(1.05); transform: scale(1); }
  50%  { box-shadow: 0 0 0 10px rgba(245,158,11,0), 0 0 26px 8px rgba(245,158,11,.9); filter: brightness(1.3) saturate(1.25); transform: scale(1.055); }
  100% { box-shadow: 0 0 0 0 rgba(245,158,11,.85), 0 0 14px 2px rgba(245,158,11,.55); filter: brightness(1.05); transform: scale(1); }
}
.btn.blink { animation: blinkBtn .78s ease-in-out infinite; position: relative; z-index: 1; font-weight: 800; }
.btn-dow.blink { animation: blinkBtnDow .78s ease-in-out infinite; font-weight: 800; }
@keyframes blinkBtnDow {
  0%   { box-shadow: 0 0 0 0 rgba(56,189,248,.85), 0 0 14px 2px rgba(56,189,248,.55); filter: brightness(1.05); transform: scale(1); }
  50%  { box-shadow: 0 0 0 10px rgba(56,189,248,0), 0 0 26px 8px rgba(56,189,248,.95); filter: brightness(1.3) saturate(1.25); transform: scale(1.055); }
  100% { box-shadow: 0 0 0 0 rgba(56,189,248,.85), 0 0 14px 2px rgba(56,189,248,.55); filter: brightness(1.05); transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .btn.blink, .btn-dow.blink { animation: none; box-shadow: 0 0 0 4px rgba(245,158,11,.5), 0 0 18px 4px rgba(245,158,11,.6); }
}

/* Dai goi y khi quet thay co hoi */
.scan-hint { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px;
  padding: 9px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.4;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25); }
.scan-hint:empty { display: none; }
.scan-hint .sh-item { font-weight: 600; }
.scan-hint .sh-item.buy { color: var(--buy); }
.scan-hint .sh-item.dow { color: #38bdf8; }

/* Nut them vao so theo doi (thay cho tu dong luu) */
.sig-add-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-add-record { gap: 7px; background: linear-gradient(135deg, #12b76a, #0ea968);
  color: #fff; border: none; box-shadow: 0 8px 22px -12px rgba(18,183,106,.9); }
.btn-add-record:hover { filter: brightness(1.06); }
.btn-add-record:disabled { opacity: .75; cursor: default; }
.btn-add-record.added { background: rgba(18,183,106,.15); color: var(--buy);
  border: 1px solid rgba(18,183,106,.4); box-shadow: none; }
.sig-add-hint { font-size: 11.5px; color: var(--fg-dim); }
.sig-add-out { font-size: 12.5px; line-height: 1.5; margin-top: 8px; }
.sig-add-out:empty { display: none; }

/* Nut chuong thong bao + cham trang thai */
#btnNotify { position: relative; }
.notify-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: transparent; border: 1px solid transparent; }
.notify-dot.on { background: var(--buy); border-color: rgba(18,183,106,.5);
  box-shadow: 0 0 0 2px rgba(18,183,106,.2); }

/* Modal thong bao */
.ntf-section { padding: 12px 0; border-top: 1px solid var(--border); }
.ntf-section:first-of-type { border-top: none; }
.ntf-title { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; color: var(--fg); }
.ntf-check { display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 6px 0; cursor: pointer; }
.ntf-check input { width: 17px; height: 17px; accent-color: var(--gold); }
.ntf-row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-top: 6px; }
.ntf-select { background: var(--surface-2, #131c2e); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; }
.ntf-status { font-size: 12.5px; color: var(--fg-dim); margin-bottom: 8px; }
.ntf-status.ok { color: var(--buy); }
.ntf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ntf-hint { font-size: 12px; line-height: 1.5; margin-top: 9px; padding: 9px 11px;
  background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.22);
  border-radius: 9px; color: var(--fg); }
.btn-tg { background: linear-gradient(135deg, #29b6f6, #0088cc); color: #fff; border: none;
  box-shadow: 0 8px 22px -12px rgba(0,136,204,.9); }
.btn-tg:hover { filter: brightness(1.06); }

/* Modal ket noi */
.mt5-card { width: 100%; max-width: 620px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mt5-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.mt5-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.mt5-head h3 svg { color: #0ea5e9; flex: none; }
.mt5-body { padding: 18px 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.mt5-body > * { flex-shrink: 0; }

.mt5-chart-toggle {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 12px;
  background: rgba(14,165,233,.08); box-shadow: inset 0 0 0 1px rgba(14,165,233,.28); cursor: pointer;
}
.mt5-chart-toggle input { margin-top: 3px; width: 18px; height: 18px; accent-color: #0ea5e9; flex: 0 0 auto; }
.mt5-chart-toggle small { color: var(--fg-dim); font-weight: 500; line-height: 1.5; }
.mt5-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt5-badge { font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: var(--muted); color: var(--fg-dim); }
.mt5-badge.on { background: var(--buy-glow); color: var(--buy); box-shadow: inset 0 0 0 1px rgba(18,183,106,.4); }
.mt5-badge.wait { background: rgba(245,158,11,.14); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(245,158,11,.4); }
.mt5-acc { font-size: 12.5px; color: var(--fg-dim); font-family: var(--mono); }

.mt5-note-box { font-size: 12.5px; line-height: 1.6; color: var(--fg-dim);
  background: rgba(14,165,233,.09); border: 1px solid rgba(14,165,233,.28); border-radius: 10px; padding: 12px 14px; }
.mt5-note-box b { color: var(--fg); }

.mt5-token-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.mt5-field { flex: 1 1 240px; display: flex; flex-direction: column; gap: 5px; }
.mt5-field label { font-size: 11.5px; color: var(--fg-dim); font-weight: 600; }
.mt5-token { font-family: var(--mono); font-size: 13px; color: var(--gold); word-break: break-all;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.mt5-token-row .btn-ghost { padding: 9px 12px; font-size: 12.5px; }

.mt5-steps { display: flex; flex-direction: column; gap: 10px; }
.mstep { display: flex; gap: 11px; align-items: flex-start; font-size: 13px; line-height: 1.55; color: var(--fg-dim); }
.mstep b { color: var(--fg); }
.mstep i { color: var(--fg); font-style: normal; font-weight: 600; }
.mnum { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #1f6feb, #0ea5e9); }
.mstep code { font-family: var(--mono); font-size: 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; color: var(--gold); }
.mt5-url { display: inline-block; margin-top: 4px; }
.mt5-dl { color: #0ea5e9; font-weight: 700; text-decoration: none; border-bottom: 1px dashed rgba(14,165,233,.5); }
.mt5-dl:hover { color: var(--gold); }

.mt5-orders { border-top: 1px solid var(--border); padding-top: 12px; }
.mt5-orders-head { font-size: 12.5px; font-weight: 700; color: var(--fg-dim); margin-bottom: 8px; }
.mt5-orders-list { display: flex; flex-direction: column; gap: 6px; }
.mt5-order { display: flex; align-items: center; gap: 10px; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px; }
.mo-side { font-weight: 700; font-family: var(--mono); }
.mo-side.BUY { color: var(--buy); }
.mo-side.SELL { color: var(--sell); }
.mo-lot { color: var(--fg); font-family: var(--mono); }
.mo-st { margin-left: auto; font-weight: 600; }
.mo-st.ok { color: var(--buy); }
.mo-st.bad { color: var(--sell); }
.mo-st.wait { color: var(--gold); }
.mo-st.done { color: var(--fg-mute); }
.mo-time { color: var(--fg-mute); font-size: 11px; }

@media (max-width: 640px) {
  .mt5-card { max-height: 92vh; }
  .mt5-body { padding: 16px; }
}

/* ===== KIEN THUC RIENG CUA TAI KHOAN ===== */
.know-card { width: 100%; max-width: 600px; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.know-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.know-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.know-head h3 svg { color: var(--gold); flex: none; }
.know-body { padding: 16px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.know-intro { font-size: 12.5px; line-height: 1.6; color: var(--fg-dim); margin: 0;
  background: linear-gradient(180deg, rgba(212,175,55,.08), transparent); border: 1px solid rgba(212,175,55,.28);
  border-radius: 10px; padding: 11px 13px; }
.know-intro b { color: var(--fg); }
.know-tabs { display: flex; gap: 8px; }
.know-tab { flex: 1; padding: 9px 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; color: var(--fg-dim); transition: all .15s; }
.know-tab.is-active { background: var(--surface-2); color: var(--gold); border-color: rgba(212,175,55,.5); }
.know-pane { display: flex; flex-direction: column; gap: 10px; }
.know-input, .know-textarea { width: 100%; background: var(--bg-2); border: 1px solid var(--border); color: var(--fg);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; font-family: inherit; }
.know-textarea { resize: vertical; line-height: 1.55; min-height: 92px; }
.know-input:focus, .know-textarea:focus { outline: none; border-color: var(--gold); }
.know-add { align-self: flex-start; }
.know-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 120px; padding: 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: 12px; background: var(--bg-2); color: var(--fg-dim); font-size: 12.5px; }
.know-drop:hover { border-color: var(--gold); }
.know-drop img { max-width: 100%; max-height: 200px; border-radius: 8px; }
.know-msg { font-size: 12.5px; padding: 9px 12px; border-radius: 9px; }
.know-msg.is-ok { background: var(--buy-glow); color: var(--buy); box-shadow: inset 0 0 0 1px rgba(18,183,106,.35); }
.know-msg.is-err { background: rgba(240,68,56,.12); color: var(--sell); box-shadow: inset 0 0 0 1px rgba(240,68,56,.35); }
.know-list-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600;
  color: var(--fg); border-top: 1px solid var(--border); padding-top: 12px; margin-top: 2px; }
.know-count { color: var(--fg-dim); font-weight: 500; }
.know-list { display: flex; flex-direction: column; gap: 9px; }
.know-empty { font-size: 12.5px; color: var(--fg-dim); text-align: center; padding: 14px; }
.know-item { background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; }
.know-item.is-off { opacity: .55; }
.know-item-top { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.know-item-title { font-size: 13px; font-weight: 600; color: var(--fg); flex: 1; min-width: 0; }
.know-item-body { font-size: 12.5px; line-height: 1.6; color: var(--fg-dim); white-space: pre-wrap; word-break: break-word;
  max-height: 160px; overflow-y: auto; }
.know-del { color: var(--sell); flex: none; }

/* Cong tac tong "dung kien thuc rieng" */
.know-master { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; cursor: pointer;
  background: rgba(212,175,55,.08); border: 1px solid rgba(212,175,55,.3); border-radius: 11px; }
.know-master input { margin-top: 2px; width: 18px; height: 18px; accent-color: var(--gold); flex: none; }
.know-master span { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--fg); }
.know-master small { font-size: 11.5px; color: var(--fg-dim); line-height: 1.5; font-weight: 400; }
.know-list.kb-off { opacity: .5; pointer-events: none; }

/* Switch bat/tat tung muc */
.know-item-toggle { position: relative; flex: none; cursor: pointer; width: 38px; height: 22px; }
.know-item-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.know-sw { position: absolute; inset: 0; border-radius: 999px; background: var(--muted); transition: background .18s; }
.know-sw::before { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.know-item-toggle input:checked + .know-sw { background: var(--buy); }
.know-item-toggle input:checked + .know-sw::before { transform: translateX(16px); }
@media (max-width: 640px) {
  .know-card { max-height: 93vh; }
  .know-body { padding: 14px 16px 18px; }
}

/* ============ THONG KE LUOT TRUY CAP (admin) ============ */
.stats-body { display: flex; flex-direction: column; gap: 16px; }
.st-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.st-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.st-card.st-hi { border-color: rgba(139,92,246,.45); background: rgba(139,92,246,.08); }
.st-num { font-size: 24px; font-weight: 800; color: var(--fg); line-height: 1.1; font-variant-numeric: tabular-nums; }
.st-lab { font-size: 12px; color: var(--fg-mute); }
.st-sub { margin: 0; font-size: 13px; color: var(--fg-dim); }
.st-sub b { color: var(--fg); }
.st-sec { display: flex; flex-direction: column; gap: 8px; }
.st-sec h4 { margin: 0; font-size: 14px; color: var(--fg-dim); font-weight: 600; }
.st-bars {
  display: flex; align-items: flex-end; gap: 6px; height: 130px; padding: 6px 2px 0;
  overflow-x: auto; border-bottom: 1px solid var(--border);
}
.st-bar { flex: 1 0 26px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.st-bar-v { width: 60%; min-height: 3px; background: linear-gradient(180deg, var(--accent), rgba(139,92,246,.4)); border-radius: 4px 4px 0 0; transition: height .2s; }
.st-bar-n { font-size: 10px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.st-bar-d { font-size: 10px; color: var(--fg-mute); white-space: nowrap; }
.st-rows { display: flex; flex-direction: column; gap: 6px; }
.st-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.st-row-k { font-size: 13px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-row-v { font-size: 13px; color: var(--fg-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 640px) {
  .st-cards { grid-template-columns: repeat(2, 1fr); }
}
