:root {
  --bg: #eef0f3; --card: #ffffff; --line: #e3e6eb; --line2: #f0f2f5;
  --text: #1b1f27; --muted: #6b7280; --faint: #9aa1ac;
  --navy: #1e3a8a; --navy2: #1d4ed8; --navy-soft: #e8edfb;
  --up: #15803d; --down: #dc2626; --up-soft: #e7f6ec; --down-soft: #fdecec;
  --warn: #b45309; --warn-soft: #fff6e5;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --c21: #22a6b3; --c50: #d9952b; --c200: #2b2f36; --crs: #7b5cd6;
  --candle-up: #1e3a8a; --candle-down: #c2185b;
}
body.dark {
  --bg: #0f1218; --card: #171b23; --line: #262c37; --line2: #1d222b;
  --text: #e6e8ec; --muted: #9aa1ac; --faint: #6b7280;
  --navy: #3b6ef5; --navy2: #5b86f7; --navy-soft: #1c2741;
  --up: #22c55e; --down: #f05252; --up-soft: #12301f; --down-soft: #3a1717;
  --warn: #f5b041; --warn-soft: #33270f;
  --c200: #c9ced6; --candle-up: #5b86f7; --candle-down: #e8508a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--sans); }
button, select, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; margin-right: 6px; }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 6px 12px; cursor: pointer; font-weight: 550; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--navy); color: #fff; }
.seg.small button { padding: 4px 9px; font-size: 11px; }
.field { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px;
  padding: 0 4px 0 10px; height: 32px; background: var(--card); }
.field span { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field select { border: 0; background: transparent; height: 30px; padding-right: 4px; font-weight: 550; max-width: 230px; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 6px; height: 32px; padding: 0 12px;
  cursor: pointer; font-weight: 550; display: inline-flex; align-items: center; text-decoration: none; }
.btn:hover { border-color: var(--faint); }
.btn.icon { width: 32px; justify-content: center; padding: 0; font-size: 15px; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.dark-btn { background: #111827; color: #fff; border-color: #111827; }
body.dark .btn.dark-btn { border-color: var(--faint); }
body.stealth .btn.dark-btn { background: var(--navy); border-color: var(--navy); }
.btn.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--navy-soft); color: var(--navy);
  border-radius: 6px; padding: 0 10px; height: 32px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--navy); }
.pill.live .dot { background: var(--up); }
.pill.err { background: var(--down-soft); color: var(--down); } .pill.err .dot { background: var(--down); }

/* layout */
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 12px; padding: 12px;
  height: calc(100vh - 49px); }
.layout.no-right { grid-template-columns: 320px minmax(0, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.main, .right { overflow-y: auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.main > #view { display: flex; flex-direction: column; gap: 12px; }

/* side list */
.side { display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 12px 12px 8px; }
.side-title { font-weight: 650; }
.search { width: 100%; margin-top: 8px; height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px;
  background: var(--card); }
.list-head, .row { display: grid; grid-template-columns: minmax(0, 1fr) 78px 60px 32px; gap: 6px; align-items: center; }
.list-head { padding: 6px 12px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 600; border-bottom: 1px solid var(--line); }
.list-head span:not(:first-child), .row > :not(:first-child) { text-align: right; }
.list { overflow-y: auto; flex: 1; }
.row { padding: 7px 12px; cursor: pointer; border-left: 3px solid transparent; border-bottom: 1px solid var(--line2); }
.row:hover { background: var(--line2); }
.row.sel { background: var(--navy-soft); border-left-color: var(--navy); }
.row .sym { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; min-width: 26px; text-align: center; border-radius: 4px; padding: 2px 4px;
  font: 600 11px var(--mono); background: var(--navy); color: #fff; }
.badge.mid { background: #dbe3f7; color: var(--navy); }
.badge.low { background: var(--line2); color: var(--muted); }
body.dark .badge.mid { background: #26324f; color: #b9c8f5; }

body.stealth .sx { filter: blur(6px); user-select: none; }

/* header */
.head { padding: 14px 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.head .title { font-size: 18px; font-weight: 700; }
.head .title small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.head .price { text-align: right; }
.head .price .big { font: 600 22px var(--mono); }
.head .price .meta { font: 11px var(--mono); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; padding: 0 16px 14px; }
.stat { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.stat .k { font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat .v { font: 600 17px var(--mono); margin: 2px 0; }
.stat .s { font-size: 10px; color: var(--muted); }

/* chart */
.chart-card { padding: 10px 12px; }
.chart-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 6px) !important; }
.chart-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.ohlc { font: 11px var(--mono); color: var(--muted); margin: 8px 0 2px; min-height: 16px; display: flex; gap: 12px; }
#ohlc { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ohlc b { color: var(--text); font-weight: 600; }
.hint { font-size: 10px; color: var(--faint); white-space: nowrap; order: 2; }
@media (max-width: 1600px) { .hint { display: none; } }
.chart-wrap { position: relative; }
#chart { height: 520px; }
.rs-label { position: absolute; left: 6px; font-size: 10px; color: var(--crs); pointer-events: none; z-index: 2; }
.rs-side { position: absolute; right: 70px; font: 10px var(--mono); color: var(--muted); text-align: right; pointer-events: none; z-index: 2; }

/* tables */
.tcard { padding: 12px 14px; }
.tcard h3, .rcard h3 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; }
.tcard h3 span, .rcard h3 span { font-size: 10px; font-weight: 500; color: var(--muted); }
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.t th, table.t td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line2); white-space: nowrap; }
table.t th { font-size: 10px; color: var(--muted); font-weight: 600; }
table.t td { font-family: var(--mono); }
table.t th:first-child, table.t td:first-child { text-align: left; font-family: var(--sans); font-weight: 600; }
table.t tr.sub td:first-child { font-weight: 500; color: var(--muted); }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--line2); }
table.t th.sortable { cursor: pointer; } table.t th.sortable:hover { color: var(--text); }
.foot { font-size: 10px; color: var(--muted); margin-top: 8px; }

/* right column */
.rcard { padding: 12px 14px; }
.segbar { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; margin-bottom: 8px; }
.segbar i { height: 4px; border-radius: 2px; background: var(--line); }
.segbar i.ok { background: var(--up); }
.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 11.5px; border-bottom: 1px solid var(--line2); }
.check .ic { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; flex: none;
  background: var(--down-soft); color: var(--down); }
.check.ok .ic { background: var(--up-soft); color: var(--up); }
.check .val { margin-left: auto; font: 11px var(--mono); }
.okcount { background: var(--up-soft); color: var(--up); border-radius: 4px; padding: 1px 6px; font-size: 10px !important; font-weight: 600 !important; }
.okcount.mid { background: var(--warn-soft); color: var(--warn); }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line2); font-size: 11.5px; gap: 8px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-family: var(--mono); text-align: right; }
.mini-legend { display: flex; gap: 12px; font-size: 10px; color: var(--muted); }
.mini-legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 4px; }
.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.box { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.box .k { font-size: 10px; color: var(--muted); }
.box .v { font: 600 13px var(--mono); }
.box.wide { grid-column: span 2; }

.notice { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--warn); background: var(--warn-soft); color: var(--warn);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty { padding: 60px 30px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 17px; margin: 0 0 8px; }
.empty p { max-width: 460px; margin: 0 auto 18px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 9px 16px; border-radius: 6px; font-size: 12px; z-index: 50; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 320px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 26px;
  display: flex; flex-direction: column; gap: 10px; }
.login-card .brand { margin-bottom: 10px; }
.login-card label { font-size: 12px; color: var(--muted); font-weight: 600; }
.login-card input { height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; background: var(--card); }
.login-card .btn { height: 38px; justify-content: center; }
.login-err { color: var(--down); font-size: 12px; min-height: 16px; }

@media (max-width: 1350px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .right { grid-column: 2; }
  .layout { height: auto; } .main, .right { overflow: visible; } .side { max-height: calc(100vh - 73px); position: sticky; top: 61px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .right { grid-column: 1; } .side { max-height: 320px; position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #chart { height: 420px; }
}

.sectors .list-head, .sectors .row { grid-template-columns: minmax(0, 1fr) 56px 30px 32px; }

.side-foot { border-top: 1px solid var(--line); padding: 8px 12px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--navy2); font-size: 11px; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.upload { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.empty .small { max-width: 520px; margin: 0 auto; }
