: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; gap: 14px; }
.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); }

/* ============ 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 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; }
.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-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); } }

/* 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-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); }

/* 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); }

/* 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) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 14px; }
  .layout { padding: 12px; gap: 12px; }
  .brand { min-width: 0; }
  .top-actions { width: 100%; }
  .btn-primary { flex: 1; justify-content: center; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .chart-toolbar { gap: 10px; }
  .offset-ctl { margin-left: 0; }
  .admin-create { grid-template-columns: 1fr 1fr; }
  .user-chip { max-width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
