:root {
  --bg: #06090e;
  --bg2: #0a0f16;
  --panel: #0d141d;
  --panel2: #101925;
  --line: #1b2735;
  --line2: #243345;
  --txt: #c3d0de;
  --muted: #5f7186;
  --dim: #3d4c5e;
  --amber: #ffb020;
  --amber2: #ff8a00;
  --up: #12d68b;      /* 涨 = 绿 */
  --up-bg: rgba(18, 214, 139, 0.12);
  --down: #ff4d5e;    /* 跌 = 红 */
  --down-bg: rgba(255, 77, 94, 0.12);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Noto Sans SC", "Archivo", system-ui, sans-serif;
  --disp: "Archivo", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(255, 138, 0, 0.05), transparent 60%),
    radial-gradient(1000px 600px at -10% 110%, rgba(18, 214, 139, 0.04), transparent 55%),
    var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.u { color: var(--up); }
.d { color: var(--down); }

/* faint scanline atmosphere */
.scan {
  pointer-events: none; position: fixed; inset: 0; z-index: 99;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- topbar ---------- */
.topbar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 18px; padding: 8px 16px; border-bottom: 1px solid var(--line2);
  background: linear-gradient(180deg, #0c121b, #080c12);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 4px;
  background: conic-gradient(from 210deg, var(--amber), var(--amber2), #1a1206, var(--amber));
  box-shadow: 0 0 16px rgba(255, 138, 0, 0.45), inset 0 0 6px rgba(0,0,0,0.6);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px; border-radius: 2px; background: #06090e;
  box-shadow: inset 0 0 0 2px rgba(255, 176, 32, 0.5);
}
.brand-text b { font-family: var(--disp); font-weight: 900; letter-spacing: 0.5px; font-size: 16px; color: #f2f6fb; display: block; line-height: 1; }
.brand-text small { font-family: var(--mono); font-size: 9px; letter-spacing: 2.5px; color: var(--amber); }

.ticker { overflow: hidden; border-left: 1px solid var(--line); border-right: 1px solid var(--line); height: 30px; display: flex; align-items: center; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.ticker-track { display: inline-flex; gap: 30px; white-space: nowrap; padding-left: 100%; animation: scroll 42s linear infinite; font-family: var(--mono); font-size: 12px; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes scroll { to { transform: translateX(-100%); } }
.tk { display: inline-flex; gap: 8px; }
.tk b { color: #dfe8f2; font-weight: 600; }
.tk .px { color: var(--txt); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.mkt-status { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; color: var(--up); display: inline-flex; align-items: center; gap: 6px; }
.mkt-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 8px var(--up); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.clock { font-size: 14px; color: var(--amber); letter-spacing: 1px; }

/* ---------- main grid ---------- */
.grid {
  display: grid; grid-template-columns: 288px 1fr 336px; gap: 10px;
  padding: 10px; min-height: 0;
}
.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 6px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px rgba(0,0,0,0.35);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,176,32,0.05), transparent);
}
.panel-head h2 { font-family: var(--disp); font-weight: 800; font-size: 12.5px; letter-spacing: 1px; color: #e7eef6; }
.panel-head h2::before { content: "▸ "; color: var(--amber); }
.tag { font-size: 9px; letter-spacing: 1.5px; color: var(--dim); border: 1px solid var(--line2); padding: 1px 6px; border-radius: 3px; }
.panel-foot { padding: 6px 12px; font-size: 9.5px; color: var(--dim); border-top: 1px solid var(--line); }

/* ---------- watchlist ---------- */
.wl-cols { padding: 6px 12px; font-size: 9px; letter-spacing: 0.6px; color: var(--dim); border-bottom: 1px solid var(--line); }
.wl-list { list-style: none; overflow-y: auto; flex: 1; }
.wl-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  padding: 8px 12px; border-bottom: 1px solid rgba(27, 39, 53, 0.6);
  cursor: pointer; position: relative; transition: background 0.12s;
}
.wl-item:hover { background: var(--panel2); }
.wl-item.on { background: linear-gradient(90deg, rgba(255,176,32,0.14), transparent); }
.wl-item.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--amber); }
.wl-name { font-weight: 600; color: #e3ebf4; font-size: 13px; }
.wl-code { font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.wl-px { font-family: var(--mono); font-size: 13.5px; text-align: right; font-weight: 600; }
.wl-pct { font-family: var(--mono); font-size: 11px; text-align: right; padding: 1px 6px; border-radius: 3px; justify-self: end; }
.wl-pct.u { background: var(--up-bg); }
.wl-pct.d { background: var(--down-bg); }
.wl-sub { grid-column: 1 / -1; display: flex; gap: 10px; font-family: var(--mono); font-size: 9px; color: var(--muted); margin-top: 3px; }

/* ---------- charts ---------- */
.charts { padding: 0; }
.sym-head { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; padding: 10px 14px 8px; border-bottom: 1px solid var(--line); }
.sym-id { display: flex; align-items: baseline; gap: 10px; }
.sym-id h1 { font-family: var(--disp); font-weight: 900; font-size: 19px; color: #f3f7fb; letter-spacing: 0.5px; }
.sym-code { color: var(--amber); font-size: 12px; }
.src { font-size: 9px; color: var(--dim); border: 1px solid var(--line2); padding: 1px 6px; border-radius: 3px; }
.sym-price { text-align: right; }
.sym-price .last { font-size: 26px; font-weight: 700; line-height: 1; }
.sym-price .chg { font-size: 13px; margin-left: 8px; }
.sym-stats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 10.5px; color: var(--muted); padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 2px; }
.sym-stats b { color: var(--txt); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 14px; font-size: 10px; color: var(--muted); border-bottom: 1px solid var(--line); }
.legend span b { font-weight: 600; }
.chart-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chart { width: 100%; }
.chart.all { flex: 1 1 auto; min-height: 380px; }
.chart.k { flex: 1 1 auto; min-height: 220px; }
.chart.sub { flex: 0 0 132px; }

/* ---------- right column ---------- */
.right-col { display: grid; grid-template-rows: auto auto 1fr; gap: 10px; min-height: 0; }
.north-body, .signal-body { padding: 10px 12px; }
.flow-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-family: var(--mono); font-size: 11.5px; }
.flow-row:last-child { border-bottom: 0; }
.flow-row .lab { color: var(--muted); font-family: var(--sans); }
.flow-row .val { font-weight: 600; }
.flow-bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 2px; }
.flow-bar i { display: block; height: 100%; }

.signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.sig { border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; background: rgba(255,255,255,0.012); }
.sig .k { font-size: 9px; letter-spacing: 1px; color: var(--muted); }
.sig .v { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 2px; }
.sig.up .v { color: var(--up); }
.sig.down .v { color: var(--down); }
.sig .z { font-size: 9px; color: var(--dim); }

.heat { min-height: 0; }
.heat-tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.heat-tabs button { flex: 1; background: transparent; border: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: 1px; padding: 5px 0; border-radius: 4px; cursor: pointer; transition: 0.12s; }
.heat-tabs button.on { background: rgba(255,176,32,0.12); border-color: var(--amber); color: var(--amber); }
.heat-body { padding: 10px; overflow-y: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; min-height: 0; }
.heat-cell { border-radius: 4px; padding: 8px 9px; position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,0.05); }
.heat-cell .n { font-size: 11px; font-weight: 600; color: #eef3f9; }
.heat-cell .p { font-family: var(--mono); font-size: 13px; font-weight: 700; margin-top: 3px; }

/* ---------- statusbar ---------- */
.statusbar { display: flex; justify-content: space-between; gap: 16px; padding: 5px 14px; border-top: 1px solid var(--line2); background: #080c12; font-size: 10px; color: var(--muted); }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.loading { color: var(--dim); padding: 16px; font-family: var(--mono); font-size: 11px; }

@media (max-width: 1180px) {
  body { overflow: auto; }
  .grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .right-col { grid-template-rows: none; }
  .chart.k { min-height: 340px; }
}
