:root {
  color-scheme: dark;
  --bg: #050608;
  --panel: #0a0d11;
  --panel-2: #0f1419;
  --panel-glass: rgba(8, 11, 15, 0.94);
  --line: #1b232c;
  --line-2: #26313c;
  --text: #dfe4ea;
  --text-2: #a9b3bd;
  --muted: #74808c;
  --dim: #4a5560;
  --amber: #ffa028;
  --amber-2: #ffc46b;
  --amber-dim: #8a5a1c;
  --up: #2fd07a;
  --down: #ff5a5f;
  --flat: #9aa4ae;
  --blue: #5aa2ff;
  --font: 'IBM Plex Mono', Consolas, 'Cascadia Mono', ui-monospace, monospace;
  --top: 44px;
  --strip: 28px;
  --foot: 24px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  display: grid;
  grid-template-rows: var(--top) var(--strip) 1fr var(--foot);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
kbd {
  font: 500 10px var(--font); color: var(--muted); border: 1px solid var(--line-2); border-radius: 3px;
  padding: 0 4px; line-height: 15px; display: inline-block;
}
[hidden] { display: none !important; }
::selection { background: var(--amber); color: #000; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #1f2933; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }
.muted { color: var(--muted); }
.amber { color: var(--amber); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

@keyframes flashUp { from { background: rgba(47, 208, 122, 0.35); } to { background: transparent; } }
@keyframes flashDown { from { background: rgba(255, 90, 95, 0.35); } to { background: transparent; } }
.flash-up { animation: flashUp 0.9s ease-out; }
.flash-down { animation: flashDown 0.9s ease-out; }
@keyframes newItem { from { background: rgba(255, 160, 40, 0.22); } to { background: transparent; } }

/* ---- top bar ------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 12px 0 0;
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { display: flex; align-items: stretch; height: 100%; font-weight: 600; letter-spacing: 0.08em; }
.brand-mark { color: var(--amber); padding: 0 4px 0 14px; display: flex; align-items: center; }
.brand-mark svg { height: 21px; width: auto; display: block; }
.brand:hover .brand-mark { color: var(--amber-2); }
.brand-word { padding: 0 14px 0 8px; display: flex; align-items: center; color: var(--amber); font-size: 13px; letter-spacing: .18em; border-right: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; }
.tabs a {
  padding: 6px 10px; color: var(--text-2); font-weight: 500; letter-spacing: 0.04em; border-radius: 3px;
  display: flex; gap: 6px; align-items: center; white-space: nowrap;
}
.tabs a:hover { background: var(--panel-2); color: var(--text); }
.tabs a.active { background: #1a1307; color: var(--amber); box-shadow: inset 0 -2px 0 var(--amber); }
.cmd { flex: 1; min-width: 200px; max-width: 560px; position: relative; display: flex; align-items: center;
  background: #06080b; border: 1px solid var(--line-2); border-radius: 3px; height: 28px; padding: 0 8px; gap: 8px; }
.cmd:focus-within { border-color: var(--amber-dim); box-shadow: 0 0 0 1px rgba(255,160,40,.25); }
.cmd-prompt { color: var(--amber); font-weight: 600; }
.cmd input { flex: 1; background: transparent; border: 0; outline: 0; text-transform: none; min-width: 0; }
.cmd input::placeholder { color: var(--dim); }
.cmd-menu {
  position: absolute; top: 32px; left: -1px; right: -1px; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 3px; box-shadow: 0 12px 30px rgba(0,0,0,.6); max-height: 360px; overflow: auto; z-index: 50;
}
.cmd-item { display: grid; grid-template-columns: 46px 80px 1fr auto; gap: 8px; padding: 6px 10px; cursor: pointer; align-items: center; }
.cmd-item:hover, .cmd-item.sel { background: #1a1307; }
.cmd-item .tag { font-size: 10px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 2px; text-align: center; padding: 0 2px; }
.cmd-item .key { color: var(--amber); font-weight: 600; }
.cmd-item .label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clocks { display: flex; gap: 12px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.clocks b { color: var(--text-2); font-weight: 500; }
.clocks .open b { color: var(--up); }
.live { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.live.on { color: var(--up); }
.live.on .dot { background: var(--up); box-shadow: 0 0 0 0 rgba(47,208,122,.6); animation: pulse 2s infinite; }
.live.off { color: var(--amber); }
.live.off .dot { background: var(--amber); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,208,122,.55); } 70% { box-shadow: 0 0 0 7px rgba(47,208,122,0); } 100% { box-shadow: 0 0 0 0 rgba(47,208,122,0); } }

/* ---- scrolling market strip ---------------------------------------------- */
.strip { overflow: hidden; background: #07090c; border-bottom: 1px solid var(--line); position: relative; z-index: 10; }
.strip-track { display: flex; width: max-content; height: 100%; align-items: center; animation: marquee 120s linear infinite; }
.strip:hover .strip-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tick { display: flex; gap: 7px; align-items: baseline; padding: 0 16px; border-right: 1px solid var(--line); white-space: nowrap; cursor: pointer; font-size: 12px; }
.tick:hover { background: var(--panel-2); }
.tick .sym { color: var(--amber); font-weight: 600; }
.tick .px { color: var(--text); }

/* ---- main / views ------------------------------------------------------------ */
main { position: relative; overflow: hidden; min-height: 0; }
.view { position: absolute; inset: 0; overflow: hidden; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line);
  font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; flex-shrink: 0;
}
.panel-head .title { color: var(--amber); font-weight: 600; }
.panel-head .spacer { flex: 1; }
.panel-body { overflow: auto; min-height: 0; flex: 1; }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  font-size: 10.5px; letter-spacing: .05em; padding: 2px 7px; border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--text-2); cursor: pointer; text-transform: uppercase; white-space: nowrap; background: transparent;
}
.chip:hover { border-color: var(--amber-dim); color: var(--text); }
.chip.active { background: var(--amber); border-color: var(--amber); color: #050608; font-weight: 600; }
.chip.small { font-size: 10px; padding: 0 4px; }

/* news list (shared) */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-item { padding: 8px 10px; border-bottom: 1px solid #12181e; display: grid; gap: 3px; }
.news-item.is-new { animation: newItem 4s ease-out; }
.news-item:hover { background: #0e1318; }
.news-meta { display: flex; gap: 8px; align-items: center; font-size: 10.5px; color: var(--muted); }
.news-meta .src { color: var(--amber); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.news-meta .time { color: var(--text-2); }
.news-meta .older { color: var(--dim); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 4px; }
.news-meta .tags { display: flex; gap: 3px; margin-left: auto; }
.news-title { color: var(--text); font-size: 12.5px; line-height: 1.38; }
.news-title:hover { color: var(--amber-2); text-decoration: underline; text-underline-offset: 2px; }
.news-desc { color: var(--muted); font-size: 11.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { padding: 24px 14px; color: var(--muted); text-align: center; font-size: 12px; }
.loading::after { content: '▍'; animation: blink 1s steps(1) infinite; color: var(--amber); margin-left: 4px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- globe view ------------------------------------------------------------------ */
#view-globe { background: radial-gradient(ellipse at 50% 50%, #0b1520 0%, #050608 70%); }
.globe-canvas { position: absolute; inset: 0; }
.globe-canvas canvas { outline: none; }
.globe-hud {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none;
  display: grid; gap: 6px; justify-items: center; z-index: 2;
  max-width: calc(100% - min(380px, 30vw) - min(440px, 34vw) - 60px); text-wrap: balance;
}
.globe-hud .headline { font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.globe-hud .headline b { color: var(--amber); font-weight: 600; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.legend .ramp { width: 140px; height: 6px; border-radius: 2px; }
.globe-panel { position: absolute; top: 12px; bottom: 12px; background: var(--panel-glass); backdrop-filter: blur(6px); z-index: 3; }
.globe-panel.left { left: 12px; width: min(380px, 30vw); }
.globe-panel.right { right: 12px; width: min(440px, 34vw); }
.globe-hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); color: var(--dim); font-size: 11px; letter-spacing: .06em; pointer-events: none; z-index: 2; white-space: nowrap; }
.globe-tip { background: rgba(5, 6, 8, .92); border: 1px solid var(--amber-dim); padding: 6px 9px; border-radius: 3px; font: 12px var(--font); color: var(--text); white-space: nowrap; }
.globe-tip b { color: var(--amber); }

.hot-row { display: grid; grid-template-columns: 22px 1fr 110px 40px; gap: 8px; align-items: center; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #12181e; }
.hot-row:hover { background: #0e1318; }
.hot-row .rank { color: var(--dim); font-size: 11px; }
.hot-row .bar { height: 6px; border-radius: 0 3px 3px 0; background: var(--amber); }
.hot-row .bar-wrap { background: #141b22; border-radius: 3px; overflow: hidden; }
.section-label { padding: 10px 10px 4px; font-size: 10.5px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }

.place-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.place-title { display: flex; align-items: baseline; gap: 10px; }
.place-title h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: .02em; }
.place-title .code { color: var(--amber); font-size: 11px; border: 1px solid var(--amber-dim); padding: 0 5px; border-radius: 2px; }
.place-title .close { margin-left: auto; color: var(--muted); font-size: 16px; padding: 0 4px; }
.place-title .close:hover { color: var(--text); }
.place-stats { display: flex; gap: 14px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.place-stats b { color: var(--text); font-weight: 600; }
.mkt-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mkt-card { background: #070a0d; border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; display: grid; gap: 2px; cursor: pointer; }
.mkt-card:hover { border-color: var(--amber-dim); }
.mkt-card .lbl { font-size: 10px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.mkt-card .val { font-size: 15px; font-weight: 600; }
.mkt-card .row { display: flex; justify-content: space-between; align-items: end; gap: 6px; }
.tabbar { display: flex; gap: 0; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tabbar button { padding: 8px 12px; font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; border-bottom: 2px solid transparent; }
.tabbar button.active { color: var(--amber); border-bottom-color: var(--amber); }
.tabbar button:hover { color: var(--text); }

/* ---- NDX board ------------------------------------------------------------------- */
.board-view { display: grid; grid-template-rows: auto minmax(220px, 34%) 1fr; gap: 8px; padding: 8px; }
.ndx-header { display: flex; flex-direction: row; align-items: center; gap: 22px; padding: 8px 12px; flex-wrap: wrap; }
.ndx-header .idx-name { color: var(--amber); font-weight: 600; letter-spacing: .06em; }
.ndx-header .idx-px { font-size: 24px; font-weight: 600; }
.ndx-header .idx-chg { font-size: 15px; font-weight: 500; }
.kv { display: grid; gap: 1px; font-size: 11px; }
.kv .k { color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-size: 10px; }
.kv .v { color: var(--text); font-weight: 500; }
.breadth { width: 160px; height: 6px; border-radius: 3px; overflow: hidden; display: flex; gap: 2px; background: transparent; }
.breadth span { display: block; height: 100%; }
.ndx-top { display: grid; grid-template-columns: 1.5fr 1fr 1.2fr; gap: 8px; min-height: 0; }
.chart-box { position: relative; flex: 1; min-height: 0; }
.chart-readout { position: absolute; top: 6px; left: 10px; z-index: 2; font-size: 11px; color: var(--text-2); pointer-events: none; display: flex; gap: 10px; }
.chart-readout b { color: var(--text); font-weight: 500; }
.movers { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; flex: 1; }
.movers > div { min-height: 0; overflow: auto; }
.movers > div + div { border-left: 1px solid var(--line); }
.mover { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 5px 10px; cursor: pointer; border-bottom: 1px solid #12181e; }
.mover:hover { background: #0e1318; }
.mover .s { color: var(--amber); font-weight: 600; }
.mover .n { color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1; }
.mover .pc { font-weight: 600; grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; }
.mover .pc small { display: block; font-weight: 400; color: var(--text-2); font-size: 10.5px; }
.ndx-main .panel-head input {
  background: #06080b; border: 1px solid var(--line-2); border-radius: 3px; padding: 2px 8px; width: 180px; outline: 0; text-transform: none; letter-spacing: 0;
}
.treemap { position: relative; flex: 1; min-height: 0; margin: 2px; }
.tile {
  position: absolute; overflow: hidden; cursor: pointer; border: 1px solid var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; line-height: 1.15; color: #fff; transition: filter .15s;
}
.tile:hover { filter: brightness(1.3); z-index: 2; outline: 1px solid var(--amber); }
.tile .ts { font-weight: 600; }
.tile .tp { opacity: .92; }
.tile .tn { opacity: .6; font-size: 10px; max-width: 95%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sector-label {
  position: absolute; font-size: 10px; letter-spacing: .08em; color: var(--text-2); text-transform: uppercase; padding: 1px 4px;
  pointer-events: none; z-index: 3; background: rgba(5, 6, 8, .7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
table.grid th {
  position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 500; font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line-2); cursor: pointer; white-space: nowrap; user-select: none; z-index: 1;
}
table.grid th.num { text-align: right; }
table.grid th:hover { color: var(--text); }
table.grid th.sorted { color: var(--amber); }
table.grid td { padding: 4px 8px; border-bottom: 1px solid #11171d; white-space: nowrap; }
table.grid tr { cursor: pointer; }
table.grid tbody tr:hover { background: #0e1318; }
table.grid td.sym { color: var(--amber); font-weight: 600; }
table.grid td.name { color: var(--text-2); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.grid td.sec { color: var(--muted); font-size: 11px; }
.spark path { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark.up path { stroke: var(--up); }
.spark.down path { stroke: var(--down); }
.spark.flat path { stroke: var(--flat); }
.spark-base { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 2 2; }

/* ---- stock view -------------------------------------------------------------------- */
#view-stock { display: grid; grid-template-rows: auto 1fr; gap: 8px; padding: 8px; }
.stock-header { display: flex; flex-direction: row; align-items: center; gap: 22px; padding: 10px 14px; flex-wrap: wrap; }
.stock-header .sym { font-size: 26px; font-weight: 600; color: var(--amber); letter-spacing: .03em; }
.stock-header .nm { display: grid; }
.stock-header .nm b { font-size: 14px; font-weight: 500; }
.stock-header .nm span { font-size: 11px; color: var(--muted); }
.stock-header .px { font-size: 26px; font-weight: 600; }
.stock-header .chg { font-size: 15px; font-weight: 500; }
.stock-header .back { margin-left: auto; }
.stock-body { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 8px; min-height: 0; }
.stock-left { display: grid; grid-template-rows: minmax(260px, 1fr) auto; gap: 8px; min-height: 0; }
.stock-right { display: grid; grid-template-rows: 1.4fr 1fr; gap: 8px; min-height: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 7px 10px; border-right: 1px solid #12181e; border-bottom: 1px solid #12181e; display: grid; gap: 2px; min-width: 0; }
.stat .k { font-size: 10px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.range-bar { position: relative; height: 4px; background: #1b232c; border-radius: 2px; margin-top: 4px; }
.range-bar i { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--amber); }

/* ---- news view ------------------------------------------------------------------------ */
#view-news { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; padding: 8px; }
#view-news .panel-head input, #view-news .panel-head select {
  background: #06080b; border: 1px solid var(--line-2); border-radius: 3px; padding: 2px 8px; outline: 0; text-transform: none; letter-spacing: 0; color: var(--text);
}

/* ---- status bar & tooltip ------------------------------------------------------------- */
.statusbar { display: flex; gap: 16px; align-items: center; padding: 0 12px; font-size: 10.5px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.statusbar b { color: var(--text-2); font-weight: 500; }
.statusbar .ok { color: var(--up); }
.statusbar .warn { color: var(--amber); }
.statusbar .spacer { flex: 1; }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: rgba(5, 6, 8, .96); border: 1px solid var(--line-2); border-radius: 3px;
  padding: 8px 10px; font-size: 11.5px; min-width: 180px; box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.tooltip .tt-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.tooltip .tt-head b { color: var(--amber); font-size: 13px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.tooltip .tt-row span:last-child { color: var(--text); }

@media (max-width: 1280px) {
  .clocks .clk-extra { display: none; }
  .ndx-top { grid-template-columns: 1.4fr 1fr; }
  .ndx-top > .panel:nth-child(3) { display: none; }
}
@media (max-width: 980px) {
  .clocks, .brand-word { display: none; }
  .tabs kbd { display: none; }
  .globe-panel.left { display: none; }
  .globe-panel.right { width: min(420px, calc(100% - 24px)); }
  .stock-body { grid-template-columns: 1fr; overflow: auto; }
  #view-stock { overflow: auto; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-news { grid-template-columns: 1fr; }
}

/* ---- disclaimer ---------------------------------------------------------------------- */
.statusbar .disclaimer-link { color: var(--amber); text-decoration: underline; text-decoration-color: var(--amber-dim); text-underline-offset: 2px; }
.statusbar .disclaimer-link:hover { color: var(--amber-2); }
.notice {
  position: fixed; left: 50%; bottom: calc(var(--foot) + 12px); transform: translateX(-50%); z-index: 60;
  width: min(680px, calc(100% - 32px)); display: flex; gap: 14px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--amber-dim); border-radius: 4px; padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .6); font-size: 12px; line-height: 1.45; color: var(--text-2);
}
.notice b { color: var(--text); font-weight: 600; }
.notice a { color: var(--amber); text-decoration: underline; text-underline-offset: 2px; }
.notice .chip { flex-shrink: 0; }
.modal-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .65); display: grid; place-items: center; padding: 16px; }
.modal-card {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .7);
}
.modal-title { color: var(--amber); font-weight: 600; letter-spacing: .04em; margin-bottom: 10px; }
.modal-card p { margin: 0 0 10px; color: var(--text-2); font-size: 12.5px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
