:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-2: #f4f5f7;
  --border: #e2e5ea;
  --text: #1a1d24;
  --muted: #6b7280;
  --accent: #2f6fed;
  --up: #1a8f4c;
  --up-bg: #e7f6ee;
  --down: #d1392b;
  --down-bg: #fbeae8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161b; --card: #1d2027; --card-2: #22262e; --border: #2b2f38; --text: #ecedf0; --muted: #9aa0ab; --up-bg: #123322; --down-bg: #3a1e1c; }
}
:root[data-theme="dark"] { --bg: #14161b; --card: #1d2027; --card-2: #22262e; --border: #2b2f38; --text: #ecedf0; --muted: #9aa0ab; --up-bg: #123322; --down-bg: #3a1e1c; }
:root[data-theme="light"] { --bg: #f5f6f8; --card: #ffffff; --card-2: #f4f5f7; --border: #e2e5ea; --text: #1a1d24; --muted: #6b7280; --up-bg: #e7f6ee; --down-bg: #fbeae8; }

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }

/* ── Navbar ─────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 54px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.brand-accent { color: var(--accent); }
.topnav { display: flex; gap: 20px; flex: 1; }
.topnav a { font-size: 13px; font-weight: 500; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--text); }
.topnav a.nav-active { color: var(--accent); border-bottom-color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { font-size: 12px; color: var(--muted); white-space: nowrap; }
.theme-toggle { border: 1px solid var(--border); background: var(--card-2); color: var(--text); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.status { font-weight: 400; font-size: 12px; color: var(--muted); }
.market-closed-badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; background: var(--down-bg); color: var(--down); border-radius: 999px; padding: 2px 8px; margin-right: 6px; }
.dot-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text); margin: 26px 0 10px; }
.dot-title .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* ── Tool tiles ─────────────────────────────────────────────────── */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; transition: box-shadow .15s, transform .15s; }
.tile-live:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-2px); }
.tile-soon { opacity: .55; cursor: default; }
.tile-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.tile-desc { font-size: 12px; color: var(--muted); }
.badge { position: absolute; top: 10px; right: 10px; font-size: 10px; background: var(--border); color: var(--muted); padding: 2px 6px; border-radius: 999px; }

/* ── Top tables ─────────────────────────────────────────────────── */
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.col-title { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.col-title.gain { color: var(--up); }
.col-title.loss { color: var(--down); }
.col-title.active { color: var(--accent); }
.col-sub { font-size: 10px; font-weight: 500; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; margin-left: 6px; cursor: help; text-transform: none; }

.data-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 13px; }
.data-table th { text-align: left; padding: 8px 10px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); }
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: rgba(127,127,127,.06); }
.up { color: var(--up); }
.down { color: var(--down); }

@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }

.ib-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.ib-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; background: var(--card); color: var(--muted); font-size: 12px; padding: 6px 12px; cursor: pointer; }
.seg-btn.seg-active { background: var(--accent); color: #fff; }

/* ── Market sentiment ───────────────────────────────────────────── */
.sentiment-block { margin-top: 26px; }
.sentiment-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.sentiment-label { font-weight: 600; }
.sentiment-pcts b { font-weight: 700; }
.sentiment-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--border); }
.sentiment-up { background: var(--up); }
.sentiment-down { background: var(--down); }

/* ── Sector overview bar chart ─────────────────────────────────── */
.sector-overview { display: flex; align-items: stretch; gap: 4px; height: 260px; padding: 10px 8px 34px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; position: relative; }
.sob-col { display: flex; flex-direction: column; min-width: 46px; flex: 1; cursor: pointer; position: relative; }
.sob-top { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.sob-bottom { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; }
.sob-baseline { height: 1px; background: var(--border); width: 100%; }
.sob-val { font-size: 10px; font-weight: 600; margin: 0 0 3px; white-space: nowrap; }
.sob-val.down-val { margin: 3px 0 0; }
.sob-bar { width: 70%; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--up), #2fbf6d); }
.sob-bar.down { border-radius: 0 0 3px 3px; background: linear-gradient(0deg, var(--down), #ef6a5c); }
.sob-label { position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%) rotate(-40deg); transform-origin: top left; font-size: 9px; color: var(--muted); white-space: nowrap; }

/* ── Sector cards (two-column gainers/losers) ──────────────────── */
.sector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; margin-top: 14px; }
.sector-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; transition: box-shadow .2s; }
.sector-card.sector-highlight { box-shadow: 0 0 0 2px var(--accent); }
.sector-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; background: var(--card-2); border-bottom: 1px solid var(--border); }
.sector-name-wrap { display: flex; align-items: baseline; gap: 6px; }
.sector-name { font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.sector-avg { font-size: 11px; font-weight: 600; }
.sector-counts { font-size: 11px; font-weight: 600; }
.sector-counts .up { margin-right: 8px; }

.sector-body { padding: 4px 0; }
.pair-row { display: flex; align-items: center; padding: 4px 12px; font-size: 11.5px; cursor: pointer; }
.pair-row:hover { background: rgba(127,127,127,.07); }
.pair-side { display: flex; align-items: center; gap: 5px; width: 118px; flex-shrink: 0; min-width: 0; }
.pair-side.loser-side { flex-direction: row-reverse; }
.avatar { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: #fff; }
.pair-sym { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); min-width: 0; }
.pair-pct { flex-shrink: 0; font-weight: 700; font-variant-numeric: tabular-nums; margin-left: auto; }
.loser-side .pair-pct { margin-left: 0; margin-right: auto; }
.pair-track { flex: 1; height: 13px; background: var(--border); border-radius: 3px; position: relative; overflow: hidden; margin: 0 8px; }
.pair-fill { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.pair-fill.up { right: 50%; background: var(--up); }
.pair-fill.down { left: 50%; background: var(--down); }
.sector-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }

/* ── Market Pulse ───────────────────────────────────────────────── */
.mp-tagline { color: var(--muted); font-size: 13px; margin: -6px 0 20px; }
.dot-title .dot.up { background: var(--up); }
.dot-sub { text-transform: none; font-weight: 400; color: var(--muted); letter-spacing: 0; font-size: 11px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.deal-client { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) { .cols2 { grid-template-columns: 1fr; } }

.pos-badge { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pos-badge.pos-flat { background: var(--border); color: var(--muted); }
.pos-badge.pos-hold-up { background: var(--up-bg); color: var(--up); }
.pos-badge.pos-hold-down { background: var(--down-bg); color: var(--down); }

.setup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.setup-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.setup-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.setup-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.setup-symbol { font-weight: 700; font-size: 13px; }
.setup-kind { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 6px; }
.setup-tag { margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.setup-tag.up { background: var(--up-bg); color: var(--up); }
.setup-tag.down { background: var(--down-bg); color: var(--down); }
.setup-card-new { box-shadow: 0 0 0 2px var(--accent); }
.new-badge { font-size: 9.5px; font-weight: 700; letter-spacing: .03em; background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 7px; white-space: nowrap; animation: new-pulse 1.8s ease-in-out infinite; }
.trend-badge { font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.trend-badge.trend-up { background: var(--up-bg); color: var(--up); }
.trend-badge.trend-down { background: var(--down-bg); color: var(--down); }
.trend-badge.trend-sideways { background: var(--card-2); color: var(--muted); }
.news-badge { font-size: 11px; padding: 5px 8px; border-radius: 6px; margin-bottom: 8px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-badge.news-has { background: var(--card-2); color: var(--text); border-left: 3px solid var(--accent); cursor: help; }
.news-badge.news-none { color: var(--muted); }
.news-badge.news-unknown { color: var(--muted); font-style: italic; }
@keyframes new-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

.alert-log-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.alert-log-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 6px; }
.alert-log-clear { cursor: pointer; text-transform: none; font-weight: 500; font-size: 11px; }
.alert-log-clear:hover { color: var(--accent); }
.alert-log { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.alert-log-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.alert-log-row:last-child { border-bottom: none; }
.alert-log-time { color: var(--muted); font-size: 10.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.alert-log-sym { font-weight: 700; }
.alert-log-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }

/* ── Market Depth ───────────────────────────────────────────────── */
.depth-search { display: flex; gap: 8px; margin: 4px 0 22px; max-width: 420px; }
.depth-search input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font-size: 14px; }
.depth-search input:focus { outline: none; border-color: var(--accent); }
.depth-search button { padding: 9px 16px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }

.depth-header { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; cursor: pointer; margin-bottom: 16px; font-size: 14px; }
.depth-header:hover { box-shadow: 0 2px 10px rgba(0,0,0,.06); }

.depth-strength { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.depth-strength-label { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.strength-verdict { font-weight: 700; }
.strength-verdict.flat { color: var(--muted); }

.depth-ladder { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.depth-ladder-head { margin-bottom: 4px; }
.depth-col-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.depth-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 3px 0; }
.depth-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; font-size: 12px; position: relative; padding: 3px 4px; border-radius: 4px; overflow: hidden; }
.depth-row.sell { grid-template-columns: auto auto 1fr; }
.depth-bar-track { position: absolute; inset: 0; }
.depth-bar { position: absolute; top: 0; bottom: 0; opacity: .16; }
.depth-bar.up { background: var(--up); }
.depth-bar.down { background: var(--down); }
.depth-price { font-weight: 700; font-variant-numeric: tabular-nums; z-index: 1; }
.depth-qty { color: var(--muted); font-variant-numeric: tabular-nums; z-index: 1; }
.depth-orders { color: var(--muted); font-size: 10.5px; z-index: 1; }
.depth-row.sell .depth-price { order: 3; text-align: right; }
.depth-row.sell .depth-qty { order: 2; text-align: right; }
.depth-row.sell .depth-orders { order: 1; text-align: left; }

.depth-totals { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; margin-top: 10px; }

.trend-block { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.trend-sparkline { flex-shrink: 0; }
.trend-verdict { font-size: 12px; font-weight: 700; }
.trend-verdict.flat { color: var(--muted); }
.trend-label { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.setup-client { font-size: 12px; color: var(--muted); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-detail { font-size: 11.5px; margin-bottom: 8px; }
.sl-tp-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sl-tp-chip { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.sl-tp-chip.sl-chip { background: var(--down-bg); color: var(--down); }
.sl-tp-chip.tp-chip { background: var(--up-bg); color: var(--up); }
.sl-tp-chip.tp-hit { outline: 1px solid var(--up); font-weight: 800; }
.sl-tp-risk { font-size: 10.5px; color: var(--muted); }
.fresh-extreme-warn { font-size: 11.5px; font-weight: 700; padding: 5px 8px; border-radius: 6px; margin-bottom: 8px; background: #4a2e00; color: #ffb020; border: 1px solid #ffb020; }
.since-flagged { font-size: 11.5px; font-weight: 700; padding: 5px 8px; border-radius: 6px; margin-bottom: 8px; }
.since-flagged.pnl-up { background: var(--up-bg); color: var(--up); }
.since-flagged.pnl-down { background: var(--down-bg); color: var(--down); }
.setup-nums { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.order-flow-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 11px; color: var(--muted); }

/* Order-flow visual gauge + delta chart (orderflow_demo.html) */
.oflow-gauge { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 16px; }
.oflow-gauge-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.oflow-gauge-time { font-size: 12px; color: var(--muted); }
.oflow-gauge-verdict { font-size: 15px; font-weight: 700; }
.oflow-gauge-verdict.up { color: var(--up); }
.oflow-gauge-verdict.down { color: var(--down); }
.oflow-gauge-bar { display: flex; width: 100%; height: 38px; border-radius: 8px; overflow: hidden; background: var(--card-2); }
.oflow-gauge-buy, .oflow-gauge-sell { display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; transition: width 0.4s ease; white-space: nowrap; overflow: hidden; }
.oflow-gauge-buy { background: var(--up); justify-content: flex-end; padding-right: 8px; }
.oflow-gauge-sell { background: var(--down); justify-content: flex-start; padding-left: 8px; }
.oflow-gauge-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 4px; letter-spacing: 0.04em; }

.oflow-delta-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 10px 6px 0; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.oflow-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.oflow-bar-track { flex: 1; width: 100%; max-width: 26px; display: flex; flex-direction: column; justify-content: center; }
.oflow-bar { width: 100%; min-height: 2px; border-radius: 3px; }
.oflow-bar-up { background: var(--up); }
.oflow-bar-down { background: var(--down); }
.oflow-bar-zero { height: 1px; width: 100%; background: var(--border); }
.oflow-bar-time { font-size: 9.5px; color: var(--muted); margin-top: 6px; }

.announcement-toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.announcement-toast { background: var(--card); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 14px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); font-size: 13px; color: var(--text); position: relative; animation: toast-in 0.25s ease; }
.announcement-toast b { color: var(--accent); }
.announcement-toast .toast-desc { display: block; margin: 4px 0 2px; }
.announcement-toast .toast-time { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.announcement-toast .toast-close { position: absolute; top: 6px; right: 8px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.announcement-toast .toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.market-news-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 20px; }
.market-news-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.market-news-item a { color: var(--text); text-decoration: none; flex: 1; }
.market-news-item a:hover { color: var(--accent); text-decoration: underline; }
.market-news-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.market-news-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.mood-trend { font-size: 12px; color: var(--muted); margin-top: 4px; }
