:root {
  --bg: #111418; --panel: #181c22; --line: #262b33; --text: #e6e8eb; --muted: #8b939e;
  --up: #e5484d; --down: #30a46c; --accent: #c9a227; --chip: #222831;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); }

header#top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .3px; color: var(--accent); }
nav { display: flex; gap: 4px; }
nav a { padding: 5px 10px; border-radius: 6px; color: var(--muted); }
nav a.on { background: var(--chip); color: var(--text); }
#asof { margin-left: auto; font-size: 12px; }

main { padding: 10px 12px 40px; max-width: 1400px; margin: 0 auto; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.bar input, .bar select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; font-size: 14px;
}
.bar input { flex: 1 1 180px; min-width: 140px; }
.chip { background: var(--chip); border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; font-size: 12px; cursor: pointer; user-select: none; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.state { padding: 3px 8px; border-radius: 4px; font-size: 12px; background: var(--chip); }
.state.big { background: #3a2f0b; color: var(--accent); }

.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: calc(100vh - 150px); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: right; }
th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; cursor: pointer; z-index: 2; font-size: 12px; }
th.sorted { color: var(--accent); }
td.l, th.l { text-align: left; }
td.sticky, th.sticky { position: sticky; left: 0; background: var(--bg); z-index: 1; }
th.sticky { z-index: 3; background: var(--panel); }
tr:hover td { background: #1b2027; }
tr:hover td.sticky { background: #1b2027; }
.name { display: block; font-weight: 500; }
.code { font-size: 11px; color: var(--muted); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--chip); }
.tag.G1 { color: var(--down); border: 1px solid var(--down); }
.tag.R1 { color: var(--up); border: 1px solid var(--up); }
.tag.near-G1 { color: var(--accent); border: 1px solid #5c4b14; }

.stockhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin: 4px 0 10px; }
.stockhead h1 { font-size: 20px; margin: 0; }
.stockhead .px { font-size: 22px; font-weight: 600; }
.ranges { display: flex; gap: 6px; margin-bottom: 6px; }
#chart { width: 100%; height: 60vh; min-height: 340px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.legend { font-size: 12px; margin: 6px 2px; min-height: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.cell { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.cell .k { color: var(--muted); font-size: 11px; }
.cell .v { font-size: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.nav2 { display: flex; justify-content: space-between; margin-top: 12px; }
.btn { background: var(--chip); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; color: var(--text); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.panel h2 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.mchart { width: 100%; height: 240px; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }
@media (max-width: 700px) {
  main { padding: 8px 6px 40px; }
  th, td { padding: 6px 6px; }
  .hide-m { display: none; }
}
