:root {
  --bg: #0b0e14;
  --bg2: #0e121a;
  --panel: #10151f;
  --panel2: #151b27;
  --line: rgba(148, 163, 184, 0.12);
  --line2: rgba(148, 163, 184, 0.22);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --dim: #5b6578;
  --amber: #fbbf24;
  --bid: #2dd4bf;
  --ask: #fb7185;
  --blue: #38bdf8;
  --violet: #a78bfa;
  --sans: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: var(--mono); font-size: 0.92em; color: var(--muted); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-rows: 52px 1fr 26px; height: 100vh; }
main { position: relative; min-height: 0; }
main > section { position: absolute; inset: 0; display: none; }
#app[data-view="landing"] #landing, #app[data-view="loading"] #loading { display: flex; }
#app[data-view="viewer"] #viewer { display: grid; }

/* buttons */
.primary { background: var(--amber); color: #1a1405; border: 0; border-radius: 8px; padding: 8px 16px; font-weight: 600; transition: filter .15s, transform .05s; }
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(1px); }
.ghost { background: transparent; border: 1px solid var(--line2); border-radius: 8px; padding: 7px 14px; color: var(--text); transition: border-color .15s, background .15s; }
.ghost:hover { border-color: var(--muted); background: rgba(148, 163, 184, 0.06); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.dayinfo { flex: 1; min-width: 0; display: flex; gap: 18px; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.dayinfo b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 12px; }
.dayinfo .name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 8px; }
#btn-help { width: 34px; padding: 6px 0; }

/* landing */
.landing { flex-direction: column; align-items: center; overflow-y: auto; padding: 48px 24px 64px;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(251, 191, 36, 0.07), transparent 60%), radial-gradient(900px 400px at 85% 10%, rgba(45, 212, 191, 0.05), transparent 60%); }
.hero { width: min(860px, 100%); }
.hero h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.05; margin: 0 0 18px; letter-spacing: -1.2px; font-weight: 750; }
.hero h1 span { background: linear-gradient(90deg, var(--amber), #f97316 40%, var(--ask)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--muted); font-size: 16.5px; max-width: 720px; margin: 0 0 28px; }
.lede b { color: var(--text); font-weight: 600; }
.drop { border: 1.5px dashed var(--line2); border-radius: 16px; background: linear-gradient(180deg, rgba(21, 27, 39, 0.7), rgba(16, 21, 31, 0.7)); transition: border-color .2s, background .2s, transform .2s; }
.drop.over { border-color: var(--amber); background: rgba(251, 191, 36, 0.06); transform: scale(1.01); }
.drop-inner { display: flex; flex-direction: column; align-items: center; padding: 40px 24px; text-align: center; }
.drop svg { width: 44px; height: 44px; color: var(--amber); margin-bottom: 10px; }
.drop-title { font-size: 19px; font-weight: 650; }
.drop-sub { color: var(--dim); font-size: 13px; margin: 4px 0 18px; }
.drop-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.recent { margin-top: 26px; }
.recent h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.recent h3 span { text-transform: none; letter-spacing: 0; color: var(--dim); font-weight: 400; margin-left: 8px; }
.recent-list { display: grid; gap: 8px; }
.recent-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.recent-item .n { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .m { color: var(--dim); font-size: 12.5px; font-family: var(--mono); }
.recent-item button { padding: 5px 12px; font-size: 13px; }
.caps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.cap { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 12.5px; color: var(--muted); }
.cap i { width: 7px; height: 7px; border-radius: 50%; background: var(--bid); box-shadow: 0 0 8px rgba(45, 212, 191, 0.6); }
.cap.off i { background: var(--dim); box-shadow: none; }
.cap.off { color: var(--dim); }
.source { color: var(--dim); font-size: 13px; margin-top: 18px; }
.how { width: min(860px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 40px; }
.step { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.step i { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: rgba(251, 191, 36, 0.12); color: var(--amber); font-style: normal; font-weight: 700; font-size: 12px; }
.step h4 { margin: 10px 0 6px; font-size: 14px; }
.step p { margin: 0; color: var(--muted); font-size: 12.5px; }
@media (max-width: 760px) { .how { grid-template-columns: 1fr 1fr; } }

/* loading */
.loading { align-items: center; justify-content: center; padding: 24px; }
.load-card { width: min(920px, 100%); padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }
.load-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 17px; font-weight: 650; }
.load-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.load-pct { font-family: var(--mono); color: var(--amber); }
.progress { height: 6px; border-radius: 99px; background: var(--panel2); margin: 14px 0 20px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--amber), #f97316); border-radius: 99px; transition: width .15s linear; }
.load-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { padding: 12px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.stat span { display: block; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; }
.stat b { display: block; font-family: var(--mono); font-size: 18px; font-weight: 600; margin-top: 2px; }
#load-chart { width: 100%; height: 150px; margin-top: 18px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.load-foot { margin-top: 12px; color: var(--dim); font-size: 12.5px; }

/* viewer */
.viewer { grid-template-columns: 268px minmax(0, 1fr) 356px; min-height: 0; }
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 8px; }
.panel-head h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); font-weight: 650; }
.panel-head .count, .panel-head .sub { color: var(--dim); font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stocks { border-right: 1px solid var(--line); }
.stock-tools { display: flex; gap: 6px; padding: 0 12px 8px; }
.stock-tools input { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; }
.stock-tools input:focus { border-color: var(--amber); }
.stock-tools select { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; outline: none; }
.list-head, .stocks .row { display: grid; grid-template-columns: 1.1fr 1.2fr 0.9fr 0.8fr; gap: 6px; align-items: center; }
.list-head { padding: 4px 14px 6px; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid var(--line); }
.list-head span:nth-child(n+3) { text-align: right; }
.list { position: relative; flex: 1; overflow-y: auto; }
.list-inner { position: relative; }
.stocks .row { position: absolute; left: 0; right: 0; height: 34px; padding: 0 14px; cursor: pointer; border-bottom: 1px solid rgba(148, 163, 184, 0.04); font-size: 13px; }
.stocks .row:hover { background: rgba(148, 163, 184, 0.06); }
.stocks .row.sel { background: rgba(251, 191, 36, 0.1); box-shadow: inset 2px 0 var(--amber); }
.row .sym { font-weight: 650; font-family: var(--mono); font-size: 12.5px; }
.row .sym i { font-style: normal; font-size: 9px; color: var(--violet); margin-left: 5px; vertical-align: 1px; font-family: var(--sans); font-weight: 700; }
.row .msgs { position: relative; font-family: var(--mono); font-size: 12px; color: var(--muted); padding-left: 2px; }
.row .msgs b { position: absolute; left: 0; bottom: -4px; height: 2px; background: rgba(56, 189, 248, 0.55); border-radius: 2px; }
.row .px, .row .chg { text-align: right; font-family: var(--mono); font-size: 12px; }
.chg.up { color: var(--bid); }
.chg.down { color: var(--ask); }

.center { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; background: var(--bg); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: var(--muted); transition: all .15s; }
.chips button:hover { color: var(--text); border-color: var(--line2); }
.legend { display: flex; gap: 12px; color: var(--dim); font-size: 12px; align-items: center; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .sep { width: 1px; height: 14px; background: var(--line2); }
.map { position: relative; min-height: 0; overflow: hidden; }
.map canvas { position: absolute; left: 0; top: 0; }
.map canvas.overlay { cursor: crosshair; touch-action: none; }

.side { display: grid; grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr); border-left: 1px solid var(--line); min-height: 0; }
.book-panel { border-bottom: 1px solid var(--line); }
.book { flex: 1; overflow-y: auto; padding: 0 12px 10px; }
.empty { color: var(--dim); font-size: 13px; padding: 18px 4px; text-align: center; }
.book-head { padding: 2px 0 10px; }
.quote { font-family: var(--mono); font-size: 22px; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.quote .b { color: var(--bid); }
.quote .a { color: var(--ask); }
.quote .x { color: var(--dim); font-size: 16px; }
.book-head .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--dim); font-size: 12px; margin-top: 4px; }
.book-head .meta b { color: var(--muted); font-family: var(--mono); font-weight: 500; }
.ladder-head, .lvl { display: grid; grid-template-columns: 1fr 1fr 0.6fr; gap: 8px; }
.ladder-head { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.ladder-head span:nth-child(n+2), .lvl span.s, .lvl span.n { text-align: right; }
.lvl { position: relative; padding: 3px 8px; font-family: var(--mono); font-size: 12.5px; cursor: pointer; border-radius: 4px; }
.lvl:hover { background: rgba(148, 163, 184, 0.06); }
.lvl .bar { position: absolute; right: 0; top: 2px; bottom: 2px; border-radius: 3px; opacity: 0.16; pointer-events: none; }
.lvl.bid .bar { background: var(--bid); }
.lvl.ask .bar { background: var(--ask); }
.lvl.bid .p { color: var(--bid); }
.lvl.ask .p { color: var(--ask); }
.lvl .n { color: var(--dim); }
.lvl.open { background: rgba(148, 163, 184, 0.08); }
.orders { margin: 2px 0 6px 10px; border-left: 1px solid var(--line2); padding-left: 8px; }
.ord { display: grid; grid-template-columns: 1.4fr 0.8fr 0.9fr 0.5fr; gap: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); padding: 1px 0; }
.ord span:nth-child(2), .ord .age { text-align: right; }
.ord .ref { color: var(--dim); }
.ord .mp { color: var(--violet); }
.ord.more { display: block; color: var(--dim); font-style: italic; }
.spread-row { text-align: center; color: var(--dim); font-size: 11px; font-family: var(--mono); padding: 4px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); margin: 3px 0; }
.side-empty { color: var(--dim); font-size: 12px; text-align: center; padding: 6px; }
.hint { color: var(--dim); font-size: 11.5px; text-align: center; margin-top: 8px; }

.inspector .body { flex: 1; overflow-y: auto; padding: 0 14px; }
.nav { display: flex; gap: 4px; }
.nav button { width: 30px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 15px; line-height: 1; }
.nav button:hover { color: var(--text); border-color: var(--line2); }
.rec-title { display: flex; align-items: center; gap: 8px; margin: 2px 0 2px; }
.kind { font-weight: 650; font-size: 15px; }
.kind.k0 { color: var(--blue); } .kind.k3, .kind.k4 { color: var(--muted); } .kind.k5 { color: var(--violet); }
.kind.k1, .kind.k2, .kind.k6, .kind.k7 { color: var(--amber); }
.badge { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 4px; letter-spacing: 0.4px; }
.badge.buy { background: rgba(45, 212, 191, 0.14); color: var(--bid); }
.badge.sell { background: rgba(251, 113, 133, 0.14); color: var(--ask); }
.rec-pos { color: var(--dim); font-size: 12px; margin-bottom: 10px; }
.rec-pos b { color: var(--muted); font-family: var(--mono); font-weight: 500; }
.fields { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.f { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; background: var(--panel); font-size: 12.5px; }
.f span { color: var(--dim); }
.f b { font-family: var(--mono); font-weight: 500; text-align: right; word-break: break-all; }
.jump { display: flex; gap: 6px; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.jump input { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: var(--mono); font-size: 12.5px; outline: none; }
.jump input:focus { border-color: var(--amber); }
.jump button { background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; padding: 0 12px; }

.statusbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 14px; border-top: 1px solid var(--line); background: var(--bg2); color: var(--dim); font-size: 11.5px; font-family: var(--mono); white-space: nowrap; overflow: hidden; }
.statusbar .ok { color: var(--bid); }

.modal { position: fixed; inset: 0; background: rgba(5, 7, 11, 0.65); display: grid; place-items: center; z-index: 10; backdrop-filter: blur(3px); }
.modal-card { width: min(440px, 92vw); background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 22px; }
.modal-card h3 { margin: 0 0 12px; }
.modal-card dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 18px; font-size: 13px; }
.modal-card dt { font-family: var(--mono); color: var(--amber); }
.modal-card dd { margin: 0; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line2); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 11; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); max-width: 80vw; }
.toast.error { border-color: rgba(251, 113, 133, 0.5); }

@media (max-width: 1100px) {
  .viewer { grid-template-columns: 220px minmax(0, 1fr) 300px; }
  .legend { display: none; }
}

.link { background: none; border: 0; color: var(--dim); font-size: 12.5px; margin-top: 12px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--muted); }
.chips .cap-btn { border-color: rgba(251, 113, 133, 0.45); color: var(--ask); }
.modal-card.wide { width: min(980px, 94vw); max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.cap-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }
.cap-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-height: 0; flex: 1; }
.cap-cols > div { display: flex; flex-direction: column; min-height: 0; }
.cap-cols h4 { margin: 0 0 8px; font-size: 13px; }
.cap-cols h4 span { color: var(--dim); font-weight: 400; margin-left: 6px; }
.cap-table { overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 52vh; }
.cap-row { display: grid; grid-template-columns: 1.6fr 1fr 1fr 0.7fr; gap: 8px; padding: 5px 10px; font-family: var(--mono); font-size: 12px; border-bottom: 1px solid rgba(148, 163, 184, 0.06); cursor: pointer; }
.cap-row:hover { background: rgba(148, 163, 184, 0.06); }
.cap-row.head { color: var(--dim); cursor: default; position: sticky; top: 0; background: var(--panel); font-family: var(--sans); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.cap-row .miss { color: var(--ask); }
