:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #1a1d23;
  --muted: #77808f;
  --up: #d33a3a;
  --down: #12855a;
  --accent: #1f6feb;
  --dark: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.logo {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2f81f7, #7c5cff);
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; letter-spacing: .5px;
}

.brandtext { min-width: 0; overflow: hidden; }
.brandtext h1 { font-size: 18px; font-weight: 700; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandtext p { font-size: 12px; color: #9aa5b8; margin-top: 3px; }

.status { display: flex; align-items: center; gap: 12px; font-size: 12px; flex-shrink: 0; }

.pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
  font-weight: 600;
  white-space: nowrap;
}
.pill.live { background: rgba(211, 58, 58, .18); border-color: rgba(211, 58, 58, .45); color: #ff9a9a; }
.pill.live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #ff5c5c; margin-right: 7px; vertical-align: 1px;
  animation: blink 1.4s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.topbar .muted { color: #9aa5b8; font-variant-numeric: tabular-nums; }
.src { color: #7f8a9e; }

/* ---------------- layout ---------------- */
main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 40px; }

.cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .k { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.card .s { font-size: 11px; color: var(--muted); margin-top: 6px; }
.card.hot .v { color: var(--up); }

/* ---------------- view switch ---------------- */
.viewswitch { display: inline-flex; background: #e9edf3; border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.viewswitch button { border: 0; background: transparent; padding: 8px 18px; border-radius: 8px; font-size: 14px; color: #4b5563; }
.viewswitch button.on { background: #fff; color: #111827; font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

/* ---------------- toolbar ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.search {
  display: flex; align-items: center; gap: 8px;
  background: #f2f4f7;
  border-radius: 9px;
  padding: 0 12px;
  height: 36px;
  min-width: 200px;
  color: var(--muted);
}
.search input {
  border: 0; background: transparent; outline: none;
  font-size: 14px; width: 100%; color: var(--text);
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  color: #48505e;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  transition: .15s;
}
.tabs button:hover { border-color: #c9d1de; }
.tabs button.on { background: var(--dark); border-color: var(--dark); color: #fff; font-weight: 600; }

.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); user-select: none; }
.count { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------- table ---------------- */
.tablewrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 250px);
  position: relative;
}

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

thead th {
  position: sticky; top: 0; z-index: 2;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-align: right;
  padding: 11px 12px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:first-child { text-align: left; padding-left: 18px; }
thead th.nosort { cursor: default; }
thead th:hover:not(.nosort) { color: var(--text); }
thead th .arrow { font-size: 10px; margin-left: 3px; color: var(--accent); }

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f3f6;
  text-align: right;
  font-size: 13.5px;
  white-space: nowrap;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }
tbody td:first-child { text-align: left; padding-left: 18px; }

.nm { font-weight: 600; }
.cd { font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.tagst { font-size: 10px; color: #b26a00; background: #fff4e0; border-radius: 4px; padding: 1px 4px; margin-left: 5px; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

.rps { border-radius: 6px; padding: 2px 8px; font-weight: 600; display: inline-block; min-width: 46px; }
.rps.r90 { background: rgba(211, 58, 58, .13); color: #b02525; }
.rps.r80 { background: rgba(230, 126, 34, .13); color: #b2620e; }
.rps.r70 { background: rgba(202, 160, 20, .12); color: #8a6d08; }
.rps.rna { color: #c2c8d2; font-weight: 400; }

.star {
  border: 0; background: transparent; font-size: 16px; line-height: 1;
  color: #d6dbe3; padding: 2px 4px; border-radius: 6px;
}
.star.on { color: #f0b429; }
.star:hover { background: #f2f4f7; }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---------------- pager ---------------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 16px 0 4px; }
.pager button {
  border: 1px solid var(--line); background: #fff; color: #48505e;
  min-width: 34px; height: 32px; border-radius: 8px; font-size: 13px; padding: 0 10px;
}
.pager button:disabled { opacity: .4; cursor: default; }
.pager button.on { background: var(--dark); color: #fff; border-color: var(--dark); }

/* ---------------- drawer ---------------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 100vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(16, 24, 40, .12);
  transform: translateX(105%);
  transition: transform .22s ease;
  z-index: 60;
  padding: 20px 22px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.drawer.open { transform: translateX(0); }

.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h2 { font-size: 21px; }
.drawer-head p { font-size: 12px; margin-top: 4px; }
.close {
  border: 0; background: #f2f4f7; width: 32px; height: 32px;
  border-radius: 8px; font-size: 20px; line-height: 1; color: #606a7b;
}

.drawer-price { display: flex; align-items: baseline; gap: 12px; }
.drawer-price #d-price { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.drawer-price #d-pct { font-size: 15px; font-weight: 600; }
.drawer-price .star { margin-left: auto; font-size: 22px; }

.rpsgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rpsgrid .cell { background: #f7f8fa; border-radius: 10px; padding: 10px; text-align: center; }
.rpsgrid .cell .lbl { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.rpsgrid .cell .val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f2f4f7; color: #48505e; }
.badge.red { background: rgba(211, 58, 58, .12); color: #b02525; font-weight: 600; }
.badge.grey { background: #f2f4f7; color: var(--muted); }

#d-chart { width: 100%; height: 380px; display: block; }
.d-tip { font-size: 11px; }

.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 50; }

/* ---------------- footer ---------------- */
.foot {
  max-width: 1440px; margin: 0 auto; padding: 0 24px 30px;
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  font-size: 11.5px; color: #98a1b0;
}

/* ---------------- responsive ---------------- */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .logo { width: 36px; height: 36px; font-size: 13px; border-radius: 9px; }
  .brandtext h1 { font-size: 16px; white-space: nowrap; }
  .brandtext p { display: none; }
  .status .muted, .status .src { display: none; }
  .topbar { flex-wrap: wrap; }
  .status { width: 100%; justify-content: flex-start; }
  main { padding: 14px 12px 30px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 11px 12px; }
  .card .v { font-size: 19px; }
  .toolbar { padding: 10px; gap: 10px; flex-direction: column; align-items: stretch; }
  .search { width: 100%; min-width: 0; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; }
  .chk { font-size: 12px; }
  .count { margin-left: 0; }
  .tablewrap { max-height: none; }
  .drawer { width: 100%; padding: 16px; }
  .foot { padding: 0 12px 24px; }
  tbody td, thead th { padding: 9px 8px; }
  tbody td:first-child, thead th:first-child { padding-left: 12px; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .tabs button { padding: 6px 10px; font-size: 12px; }
}
