:root {
  --bg: #06070a; --bg2: #0c0e12; --bg3: #13161b; --line: #1f242c; --text: #cfd6df; --dim: #6f7986;
  --amber: #ffb000; --up: #1fd16b; --down: #ff4747; --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--mono); display: flex; flex-direction: column; overflow-x: hidden; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--amber); }

.bar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.brand { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.logo { color: var(--amber); font-weight: 800; letter-spacing: .12em; font-size: 15px; }
.logo b { color: var(--amber); animation: blink 1.2s steps(1) infinite; font-weight: 400; }
@keyframes blink { 50% { opacity: 0; } }
.what { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { position: relative; width: 320px; }
.search input { width: 100%; background: var(--bg); border: 1px solid var(--line); padding: 7px 10px; outline: none; border-radius: 2px; }
.search input:focus { border-color: var(--amber); }
#results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none; background: var(--bg2); border: 1px solid var(--amber); max-height: 60vh; overflow-y: auto; }
#results li { display: flex; gap: 10px; padding: 6px 10px; cursor: pointer; align-items: baseline; }
#results li[aria-selected="true"], #results li:hover { background: var(--bg3); }
#results .tk { color: var(--amber); font-weight: 600; min-width: 64px; }
#results .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tabs { display: flex; gap: 0; border: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 7px 14px; cursor: pointer; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.tabs button[aria-selected="true"] { background: var(--amber); color: #000; font-weight: 600; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 6px 16px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.controls select { background: var(--bg); border: 1px solid var(--line); padding: 3px 4px; text-transform: none; letter-spacing: 0; color: var(--text); }
.scale { display: flex; align-items: center; gap: 6px; }
.scale .bar-grad { width: 120px; height: 8px; }
.status { margin-left: auto; text-transform: none; letter-spacing: 0; }
.status b { color: var(--amber); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.legend button { flex: none; display: flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); padding: 3px 8px; cursor: pointer; font-size: 11px; color: var(--text); white-space: nowrap; }
.legend button .sw { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.legend button[aria-pressed="false"] { opacity: .35; }
.legend button.all { color: var(--amber); }

main { position: relative; flex: 1; min-height: 0; display: flex; }
.view { position: relative; flex: 1; min-width: 0; min-height: 420px; }
#treemap { display: block; width: 100%; height: 100%; }
#treemap .node { cursor: pointer; }
#treemap .node rect { stroke: var(--bg); stroke-width: 1px; }
#treemap .node:hover rect, #treemap .node.sel rect { stroke: var(--amber); stroke-width: 2px; }
#treemap text { font-family: var(--mono); pointer-events: none; fill: #fff; }
#treemap .sector-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
#starmap { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#starmap:active { cursor: grabbing; }
.hint { position: absolute; left: 16px; bottom: 10px; color: var(--dim); font-size: 11px; pointer-events: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); text-align: center; padding: 16px; }

.panel { width: 400px; flex: none; border-left: 1px solid var(--line); background: var(--bg2); overflow-y: auto; padding: 14px 16px 24px; }
.panel .close { float: right; background: none; border: 1px solid var(--line); cursor: pointer; padding: 2px 8px; color: var(--dim); }
.panel .close:hover { color: var(--amber); border-color: var(--amber); }
.panel h2 { margin: 0; font-size: 26px; color: var(--amber); letter-spacing: .04em; }
.panel .name { font-size: 13px; margin: 2px 0 8px; }
.panel .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; font-size: 11px; color: var(--dim); }
.panel .chip { border: 1px solid var(--line); padding: 1px 6px; }
.panel .quote { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 14px; }
.panel .quote div { background: var(--bg); padding: 8px; }
.panel .quote small { display: block; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.panel .quote span { font-size: 15px; font-weight: 600; }
.panel table { width: 100%; border-collapse: collapse; font-size: 12px; }
.panel th { text-align: left; color: var(--dim); font-weight: 400; padding: 5px 0; border-bottom: 1px solid var(--line); }
.panel td { text-align: right; padding: 5px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.panel td.per { color: var(--dim); font-size: 10px; padding-left: 8px; }
.panel h3 { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin: 16px 0 6px; font-weight: 400; }
.panel .nopx { font-size: 11px; color: var(--dim); margin: -8px 0 12px; }
.panel .notes { margin: 10px 0 0; padding: 0; list-style: none; font-size: 11px; color: var(--amber); }
.panel .notes li { margin: 4px 0; padding-left: 12px; position: relative; }
.panel .notes li::before { content: "!"; position: absolute; left: 0; font-weight: 800; }
.panel .links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.panel .links a { border: 1px solid var(--amber); padding: 6px 10px; text-decoration: none; font-size: 12px; }
.panel .links a:hover { background: var(--amber); color: #000; }
.panel details { margin-top: 14px; font-size: 11px; }
.panel summary { cursor: pointer; color: var(--dim); }
.panel .src { margin: 6px 0; padding: 6px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.panel .src b { color: var(--text); font-weight: 600; }
.panel .src span { color: var(--dim); }
.up { color: var(--up); } .down { color: var(--down); } .na { color: var(--dim); }

.tip { position: fixed; z-index: 40; pointer-events: none; background: rgba(12,14,18,.96); border: 1px solid var(--amber); padding: 6px 9px; font-size: 12px; max-width: 280px; }
.tip b { color: var(--amber); }
.foot { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 6px 16px; border-top: 1px solid var(--line); font-size: 10px; color: var(--dim); }

@media (max-width: 900px) {
  .what { display: none; }
  .panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: -12px 0 30px rgba(0,0,0,.6); }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .brand { flex: 1 1 auto; }
  .search { order: 3; width: 100%; }
  .what { display: none; }
  .controls { gap: 4px 6px; padding: 6px 16px; }
  .controls label { font-size: 0; }
  .controls select { font-size: 11px; max-width: 31vw; }
  .scale { display: none; }
  .status { width: 100%; margin-left: 0; font-size: 10px; }
  .legend { flex-wrap: nowrap; overflow-x: auto; }
  .view { min-height: 66vh; }
  .foot { padding: 4px 16px; font-size: 9px; gap: 0 10px; }
  .foot .long { display: none; }
  .panel { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 78vh; border-left: 0; border-top: 1px solid var(--amber); padding: 12px 16px 24px; }
  .panel .quote { grid-template-columns: repeat(3, 1fr); }
  .hint { display: none; }
}
