:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --ink: #141a22;
  --muted: #667483;
  --line: #dbe3ec;
  --accent: #007f8a;
  --accent-2: #b98100;
  --accent-3: #2f6fed;
  --accent-ink: #ffffff;
  --red: #d92d3a;
  --green: #07946b;
  --chip: #eef8f7;
  --shadow: 0 18px 48px rgba(20, 32, 48, 0.1);
  --chart-bg: #ffffff;
  --chart-grid: #e5ebf2;
  --chart-text: #667483;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(0, 127, 138, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 127, 138, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, #fbfdff 0%, #eef4f8 48%, #f8fafc 100%);
  background-size: 30px 30px, 30px 30px, 100% 100%;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.topbar {
  min-height: 76px;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(219, 227, 236, 0.86);
  box-shadow: 0 10px 28px rgba(20, 32, 48, 0.06);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
}

h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
  color: #101820;
}

p {
  margin: 0;
}

.icon-btn,
.tab,
.link-btn,
.filter-btn,
.chart-btn,
.sort-btn,
.mode-btn,
.choice-btn,
.pager-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 127, 138, 0.04);
}

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.searchbox {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 127, 138, 0.24);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.searchbox:focus-within {
  border-color: rgba(0, 127, 138, 0.74);
  box-shadow: 0 0 0 3px rgba(0, 127, 138, 0.12), var(--shadow);
}

.searchbox span {
  color: var(--accent);
  font-size: 20px;
}

.searchbox input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink);
}

.searchbox input::placeholder {
  color: #8a97a6;
}

.tabs {
  display: inline-flex;
  border: 1px solid rgba(0, 127, 138, 0.22);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(20, 32, 48, 0.06);
}

.tab {
  min-width: 82px;
  height: 42px;
  border-width: 0 1px 0 0;
  border-color: var(--line);
  font-size: 14px;
}

.tab:last-child {
  border-right: 0;
}

.tab.active,
.filter-btn.active,
.mode-btn.active {
  background: linear-gradient(135deg, #008d96, #006c76);
  color: var(--accent-ink);
  border-color: #007f8a;
  box-shadow: 0 10px 24px rgba(0, 127, 138, 0.22);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 19px;
  line-height: 1.2;
  color: var(--accent-2);
  font-family: Consolas, "Courier New", monospace;
  overflow-wrap: anywhere;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 16px;
}

.hot-hero {
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(0, 127, 138, 0.12), transparent 44%),
    linear-gradient(90deg, rgba(185, 129, 0, 0.1), transparent),
    var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hot-hero h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.hot-hero p,
.hot-hero span {
  color: var(--muted);
  font-size: 13px;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
}

.rank-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.rank-panel h3 {
  margin: 0;
  padding: 12px 14px;
  color: #111827;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f4f8fb);
}

.rank-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 72px;
  grid-template-areas:
    "idx name val"
    "idx sub sub";
  gap: 2px 8px;
  padding: 10px 12px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(219, 227, 236, 0.72);
}

.rank-row:hover {
  background: rgba(0, 127, 138, 0.055);
}

.rank-index {
  grid-area: idx;
  color: var(--accent-2);
  font-family: Consolas, "Courier New", monospace;
}

.rank-row strong {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row em {
  grid-area: val;
  text-align: right;
  font-style: normal;
  font-family: Consolas, "Courier New", monospace;
}

.rank-row small {
  grid-area: sub;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stock-filter {
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(0, 127, 138, 0.075), transparent 36%),
    linear-gradient(180deg, #ffffff, #f7fbfd);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stock-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stock-filter h2 {
  margin: 0 0 4px;
  color: #111827;
  font-size: 17px;
}

.stock-filter span {
  color: var(--muted);
  font-size: 12px;
}

.mode-switch {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid rgba(0, 127, 138, 0.22);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.mode-btn {
  min-width: 68px;
  height: 34px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  font-size: 13px;
}

.mode-btn:last-child {
  border-right: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(198px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.choice-btn {
  min-height: 62px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 9px 11px;
  border-radius: 8px;
  text-align: left;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(20, 32, 48, 0.045);
}

.choice-top {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.choice-top strong {
  min-width: 0;
  overflow: hidden;
  color: #111827;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-top em {
  color: #005f68;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  font-style: normal;
}

.choice-btn small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-btn:hover {
  border-color: rgba(0, 127, 138, 0.52);
  box-shadow: 0 8px 20px rgba(0, 127, 138, 0.1);
}

.choice-btn.active {
  border-color: rgba(0, 127, 138, 0.72);
  background:
    linear-gradient(90deg, rgba(0, 127, 138, 0.1), transparent 34%),
    linear-gradient(180deg, #ffffff, #edf8f7);
  box-shadow: inset 0 0 0 1px rgba(0, 127, 138, 0.14), 0 10px 24px rgba(0, 127, 138, 0.12);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap + .pager {
  padding: 0 2px;
}

.pager-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.pager-actions i {
  color: #94a3b8;
  font-style: normal;
}

.pager-btn {
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  color: #344256;
  font-size: 12px;
}

.pager-btn.icon {
  padding: 0;
  font-size: 17px;
}

.pager-btn.active {
  border-color: rgba(0, 127, 138, 0.72);
  background: linear-gradient(135deg, #008d96, #006c76);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 127, 138, 0.18);
}

.pager-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.filter-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
}

.table-wrap,
.detail,
.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(219, 227, 236, 0.82);
  font-size: 13px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #ffffff, #f3f7fb);
  color: #4b5867;
  font-weight: 600;
  z-index: 1;
}

tr:hover td {
  background: rgba(0, 127, 138, 0.045);
}

.sort-btn {
  width: 100%;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.sort-btn span {
  flex: 0 0 auto;
  color: #94a3b8;
  font-family: Consolas, "Courier New", monospace;
}

.sort-btn.active {
  color: #005f68;
}

.sort-btn.active span {
  color: var(--accent);
}

.code {
  font-family: Consolas, "Courier New", monospace;
  color: #005f68;
}

.name-link {
  color: #111827;
  font-weight: 700;
  text-decoration: none;
}

.name-link:hover {
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  background: var(--chip);
  color: #006b75;
  border: 1px solid rgba(0, 127, 138, 0.18);
  border-radius: 999px;
  font-size: 12px;
  text-decoration: none;
}

.chip:nth-child(3n) {
  color: #9b6b00;
  border-color: rgba(185, 129, 0, 0.2);
  background: rgba(185, 129, 0, 0.08);
}

.chip:nth-child(4n) {
  color: #2f6fed;
  border-color: rgba(47, 111, 237, 0.18);
  background: rgba(47, 111, 237, 0.07);
}

.detail {
  padding: 18px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.detail-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-title h2 {
  margin: 0;
  font-size: 24px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.meta-item {
  padding: 10px 12px;
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.meta-item b {
  color: #111827;
}

.up {
  color: var(--red) !important;
}

.down {
  color: var(--green) !important;
}

.chart-panel {
  padding: 14px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.chart-head h3 {
  margin: 0;
  font-size: 16px;
  color: #111827;
}

.chart-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.chart-btn {
  width: 32px;
  height: 30px;
  border-radius: 8px;
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
}

.chart-btn:hover,
.icon-btn:hover,
.link-btn:hover,
.filter-btn:hover,
.tab:hover,
.mode-btn:hover,
.pager-btn:not(:disabled):hover {
  border-color: rgba(0, 127, 138, 0.55);
  box-shadow: 0 8px 22px rgba(0, 127, 138, 0.12);
}

canvas {
  width: 100%;
  height: 380px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chart-bg);
  cursor: grab;
  touch-action: none;
}

canvas:active {
  cursor: grabbing;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.link-btn {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

@media (max-width: 840px) {
  .topbar {
    padding: 14px 16px;
  }

  main {
    padding: 16px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .summary,
  .meta-grid,
  .rank-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hot-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .stock-filter-head {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-btn {
    flex: 1 1 0;
    min-width: 0;
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pager {
    align-items: flex-start;
    flex-direction: column;
  }

  .pager-actions {
    justify-content: flex-start;
  }

  .chart-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-tools {
    justify-content: flex-start;
  }

  th,
  td {
    padding: 10px;
  }

  canvas {
    height: 310px;
  }
}

@media (max-width: 560px) {
  .summary,
  .meta-grid,
  .rank-grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }
}
