:root {
  color-scheme: dark;
  --bg: #000000;
  --card: #111111;
  --card-strong: #1a1a1a;
  --line: #333333;
  --line-strong: #4a4a4a;
  --text: #eaeaea;
  --muted: #888888;
  --blue: #00fff5;
  --blue-soft: rgba(0, 255, 245, 0.12);
  --green: #2ed573;
  --green-soft: rgba(46, 213, 115, 0.15);
  --amber: #ffa502;
  --amber-soft: rgba(255, 165, 2, 0.16);
  --red: #ff4757;
  --red-soft: rgba(255, 71, 87, 0.15);
  --rank-top: #ff6b81;
  --shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  --font-size-ui: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-size-ui);
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hero-card,
.hero-tools,
.control-grid,
.snapshot-row,
.table-wrap {
  scrollbar-color: rgba(120, 188, 255, 0.72) rgba(20, 34, 48, 0.35);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.hero-card::-webkit-scrollbar,
.hero-tools::-webkit-scrollbar,
.control-grid::-webkit-scrollbar,
.snapshot-row::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 0;
  height: 6px;
}

html::-webkit-scrollbar:vertical,
body::-webkit-scrollbar:vertical,
.hero-card::-webkit-scrollbar:vertical,
.hero-tools::-webkit-scrollbar:vertical,
.control-grid::-webkit-scrollbar:vertical,
.snapshot-row::-webkit-scrollbar:vertical,
.table-wrap::-webkit-scrollbar:vertical {
  width: 0;
}

html::-webkit-scrollbar:horizontal,
body::-webkit-scrollbar:horizontal,
.hero-card::-webkit-scrollbar:horizontal,
.hero-tools::-webkit-scrollbar:horizontal,
.control-grid::-webkit-scrollbar:horizontal,
.snapshot-row::-webkit-scrollbar:horizontal,
.table-wrap::-webkit-scrollbar:horizontal {
  height: 6px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.hero-card::-webkit-scrollbar-track,
.hero-tools::-webkit-scrollbar-track,
.control-grid::-webkit-scrollbar-track,
.snapshot-row::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: rgba(20, 34, 48, 0.35);
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.hero-card::-webkit-scrollbar-thumb,
.hero-tools::-webkit-scrollbar-thumb,
.control-grid::-webkit-scrollbar-thumb,
.snapshot-row::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(120, 188, 255, 0.72);
  border-radius: 999px;
}

html::-webkit-scrollbar-thumb:vertical,
body::-webkit-scrollbar-thumb:vertical,
.hero-card::-webkit-scrollbar-thumb:vertical,
.hero-tools::-webkit-scrollbar-thumb:vertical,
.control-grid::-webkit-scrollbar-thumb:vertical,
.snapshot-row::-webkit-scrollbar-thumb:vertical,
.table-wrap::-webkit-scrollbar-thumb:vertical {
  background: transparent;
}

html::-webkit-scrollbar-thumb:horizontal,
body::-webkit-scrollbar-thumb:horizontal,
.hero-card::-webkit-scrollbar-thumb:horizontal,
.hero-tools::-webkit-scrollbar-thumb:horizontal,
.control-grid::-webkit-scrollbar-thumb:horizontal,
.snapshot-row::-webkit-scrollbar-thumb:horizontal,
.table-wrap::-webkit-scrollbar-thumb:horizontal {
  background: rgba(120, 188, 255, 0.72);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1560px, calc(100vw - 4px));
  margin: 2px auto 4px;
  display: block;
}

.app-shell > * + * {
  margin-top: 3px;
}

.panel-card,
.hero-card,
.notice-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: none;
}

.hero-card {
  padding: 3px 4px;
  background: #121212;
  border-color: rgba(255, 165, 2, 0.12);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}

.section-title-row h2 {
  margin: 0;
}

.hero-tools {
  width: auto;
  min-width: 0;
  justify-content: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1 1 auto;
}

.section-title-row h2 {
  font-size: var(--font-size-ui);
  line-height: 1;
  color: var(--blue);
}

.panel-card {
  padding: 3px 4px;
  background: #121212;
}

.panel-mini-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(255, 165, 2, 0.12);
}

.panel-mini-title {
  color: var(--blue);
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
}

.panel-mini-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.toggle-button {
  min-height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.toggle-button:hover {
  color: var(--text);
}

.snapshot-panel.is-collapsed {
  padding-bottom: 3px;
}

.snapshot-panel.is-collapsed .panel-mini-bar {
  margin-bottom: 0;
  border-bottom: 0;
}

.snapshot-panel.is-collapsed #snapshotList {
  display: none;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.section-meta {
  color: var(--muted);
  font-size: var(--font-size-ui);
  line-height: 1.1;
}

.section-title-row {
  border-bottom: 1px solid rgba(255, 165, 2, 0.12);
  padding-bottom: 3px;
}

.control-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: end;
  overflow-x: auto;
}

.control-column,
.action-column {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: end;
  white-space: nowrap;
}

.control-column {
  flex: 0 0 auto;
}

.action-column {
  flex: 0 0 auto;
}

.field {
  display: inline-block;
  min-width: 0;
  flex: 0 0 auto;
  vertical-align: bottom;
}

.field span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
  margin-bottom: 1px;
}

.checkbox-field {
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: #0f0f0f;
}

.checkbox-field span {
  color: var(--text);
}

select,
input[type="number"],
button {
  min-height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  border: 0;
  background: #0f0f0f;
  color: var(--text);
  font-size: 11px;
  line-height: 1.1;
}

select:focus,
input[type="number"]:focus,
button:focus {
  outline: 2px solid rgba(37, 99, 235, 0.15);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: #242424;
}

.primary-button {
  background: rgba(255, 165, 2, 0.22);
  color: var(--amber);
}

.primary-button:hover {
  background: rgba(255, 165, 2, 0.3);
  color: #ffd58a;
}

.action-column button {
  min-width: 0;
  flex: 0 0 auto;
}

.control-column .field:nth-child(1) {
  width: 124px;
}

.control-column .field:nth-child(2) {
  width: 40px;
}

.control-column .field:nth-child(3),
.control-column .field:nth-child(4) {
  width: 70px;
}

.control-column .field:nth-child(5) {
  width: auto;
  min-width: 74px;
}

.control-column .field:nth-child(6) {
  width: 36px;
}

.action-column button {
  width: 58px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.concept-chip {
  display: block;
  width: 104px;
  min-height: 34px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: default;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.concept-chip strong {
  display: block;
  font-size: var(--font-size-ui);
  line-height: 1.1;
  margin-bottom: 1px;
}

.concept-chip span {
  display: block;
  font-size: var(--font-size-ui);
  line-height: 1.05;
}

.concept-rank-1 {
  background: rgba(255, 107, 129, 0.16);
  color: var(--rank-top);
  border-color: rgba(255, 107, 129, 0.35);
}

.concept-rank-2 {
  background: rgba(255, 165, 2, 0.14);
  color: var(--amber);
  border-color: rgba(255, 165, 2, 0.3);
}

.concept-rank-3 {
  background: rgba(0, 255, 245, 0.12);
  color: var(--blue);
  border-color: rgba(0, 255, 245, 0.26);
}

.concept-rank-normal {
  background: #111111;
  color: #d8d8d8;
  border-color: var(--line);
}

.snapshot-row {
  display: block;
  white-space: nowrap;
  overflow-x: auto;
  padding-bottom: 0;
}

.snapshot-card {
  display: inline-block;
  width: 108px;
  margin-right: 3px;
  vertical-align: top;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
  background: #111111;
  min-height: 114px;
}

.snapshot-card h3 {
  margin: 0 0 3px;
  font-size: var(--font-size-ui);
  line-height: 1;
}

.snapshot-list {
  display: block;
}

.snapshot-item {
  display: flex;
  justify-content: space-between;
  gap: 3px;
  padding: 2px 4px;
  margin-top: 2px;
  border-radius: 6px;
  font-size: var(--font-size-ui);
  line-height: 1.1;
  cursor: default;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.concept-link-cell {
  cursor: default;
  transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.snapshot-item.rank-1 {
  background: var(--amber-soft);
  color: var(--amber);
}

.snapshot-item.rank-2 {
  background: var(--blue-soft);
  color: var(--blue);
}

.snapshot-item.rank-3 {
  background: var(--green-soft);
  color: var(--green);
}

.snapshot-item.rank-other {
  background: #111111;
  color: #c9c9c9;
}

.concept-hover-active {
  border-color: rgba(255, 165, 2, 0.95) !important;
  box-shadow: 0 0 0 1px rgba(255, 165, 2, 0.45), 0 0 22px rgba(255, 165, 2, 0.24);
  background: rgba(255, 165, 2, 0.2) !important;
  color: #fff3d6 !important;
  transform: translateY(-1px) scale(1.01);
  filter: saturate(1.2) brightness(1.14);
  position: relative;
  z-index: 1;
}

.concept-hover-active strong,
.concept-hover-active span {
  color: inherit;
}

.concept-selected-active {
  border-color: rgba(0, 255, 245, 0.92) !important;
  box-shadow: 0 0 0 1px rgba(0, 255, 245, 0.4), 0 0 16px rgba(0, 255, 245, 0.18);
  background: rgba(0, 255, 245, 0.14) !important;
  color: #dffeff !important;
}

.concept-selected-active strong,
.concept-selected-active span {
  color: inherit;
}

.table-wrap {
  overflow: auto;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111111;
  box-shadow: inset 0 0 0 1px rgba(255, 165, 2, 0.06);
  -ms-overflow-style: none;
}

.table-wrap::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

table {
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  background: #111111;
  table-layout: auto;
}

thead {
  background: var(--card-strong);
}

th,
td {
  padding: 0 1px;
  border-bottom: 1px solid #242a33;
  text-align: left;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  font-size: var(--font-size-ui);
  line-height: 1.02;
  letter-spacing: -0.15px;
}

th {
  background: var(--card-strong);
  color: var(--blue);
  cursor: pointer;
  user-select: none;
  padding-top: 2px;
  padding-bottom: 2px;
  font-weight: 500;
  font-size: var(--font-size-ui);
  border-bottom-color: var(--line-strong);
}

th.numeric,
td.numeric {
  text-align: right;
}

th,
td,
th:nth-child(1),
td:nth-child(1),
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5),
th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7),
th:nth-child(8),
td:nth-child(8),
th:nth-child(9),
td:nth-child(9),
th:nth-child(10),
td:nth-child(10),
th:nth-child(11),
td:nth-child(11),
th:nth-child(12),
td:nth-child(12),
th:nth-child(13),
td:nth-child(13),
th:nth-child(14),
td:nth-child(14),
th:nth-child(15),
td:nth-child(15) {
  width: auto;
}

tbody tr:nth-child(even) {
  background: #0a0a0a;
}

tbody tr:hover {
  background: #2a2a2a;
}

.stock-row {
  cursor: default;
}

.stock-row:hover .stock-name-cell,
.stock-row:hover .stock-code-cell {
  color: var(--blue);
  text-decoration: underline;
}

.stock-name-cell,
.stock-code-cell {
  cursor: pointer;
  font-weight: 500;
  font-size: var(--font-size-ui);
}

.concept-link-cell {
  cursor: default;
}

.concept-link-cell.concept-rank-1,
.concept-link-cell.concept-rank-2,
.concept-link-cell.concept-rank-3 {
  font-weight: 600;
}

.stock-code-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.rise {
  color: var(--red);
}

.fall {
  color: var(--green);
}

.flat {
  color: #b5b5b5;
}

.table-empty,
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 10px 8px;
}

.footer-status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted);
  font-size: var(--font-size-ui);
  line-height: 1.1;
}

@media (max-width: 1400px) {
  .control-column .field:nth-child(1) {
    width: 124px;
  }

  .control-column .field:nth-child(2) {
    width: 40px;
  }

  .control-column .field:nth-child(3),
  .control-column .field:nth-child(4) {
    width: 70px;
  }

  .control-column .field:nth-child(5) {
    width: auto;
    min-width: 74px;
  }

  .control-column .field:nth-child(6) {
    width: 36px;
  }

  .action-column button {
    width: 58px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 4px, 100%);
    margin: 2px auto 4px;
  }

  .section-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .control-grid {
    gap: 2px;
  }

  .control-column .field:nth-child(1) {
    width: 116px;
  }

  .control-column .field:nth-child(2) {
    width: 38px;
  }

  .control-column .field:nth-child(3),
  .control-column .field:nth-child(4) {
    width: 66px;
  }

  .control-column .field:nth-child(5) {
    width: auto;
    min-width: 68px;
  }

  .control-column .field:nth-child(6) {
    width: 34px;
  }

  .action-column button {
    width: 56px;
  }
}
