:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #eef2f5;
  color: #17212b;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #17212b;
  --muted: #667784;
  --line: #dce4ea;
  --line-soft: #edf2f5;
  --nav: #0f1b25;
  --nav-2: #182734;
  --accent: #1f6f8b;
  --accent-soft: #e8f3f8;
  --rise: #d12f2f;
  --fall: #07824f;
  --warn: #8a5a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #dfe8ee 0, #eef2f5 220px),
    var(--bg);
}

.topbar {
  padding: 0;
  background: var(--nav);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 6px;
  color: #b7c5ce;
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 36px;
  border: 1px solid #b9c7d1;
  border-radius: 6px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover {
  border-color: #8fa7b5;
  background: #f0f5f8;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.mini {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.topbar button {
  border-color: rgba(255, 255, 255, 0.18);
  background: #223543;
  color: #f7fbfd;
}

.topbar button:hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: #2c4353;
}

main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 24px 38px;
}

.tabs {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  overflow: visible;
  padding-top: 10px;
  padding-right: max(24px, calc((100vw - 1360px) / 2 + 24px));
  padding-left: max(24px, calc((100vw - 1360px) / 2 + 24px));
  background: var(--nav);
}

.tab-group {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.tab {
  border-color: transparent;
  border-radius: 6px 6px 0 0;
  background: var(--nav-2);
  color: #d9e5eb;
}

.tab.active {
  background: var(--bg);
  color: var(--ink);
}

.nav-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: center;
  margin-bottom: 6px;
}

.nav-search input {
  width: 240px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 0 10px;
  background: #182734;
  color: #f7fbfd;
  font: inherit;
}

.nav-search input::placeholder {
  color: #9fb2bf;
}

.nav-search input:focus {
  border-color: rgba(255, 255, 255, 0.38);
  outline: 2px solid rgba(255, 255, 255, 0.12);
}

.nav-search button {
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.18);
  background: #223543;
  color: #f7fbfd;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  border: 1px solid #e4ebf0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(15, 27, 37, 0.045);
}

.metric {
  padding: 15px 16px;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 23px;
  letter-spacing: 0;
}

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

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

.panel {
  margin-bottom: 16px;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #ffffff 0, #fbfdfe 100%);
}

.section-head h2 {
  font-size: 16px;
}

.subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.section-head span {
  min-width: 28px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: #31586d;
  text-align: center;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

#view-overview .table-wrap {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#view-overview .table-wrap::-webkit-scrollbar {
  display: none;
}

#view-watchlist .table-wrap {
  overflow-x: visible;
}

.watch-list-panel {
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

.watch-table {
  table-layout: fixed;
  min-width: 0;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid #eef3f6;
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f9fbfc;
}

tbody tr:hover td {
  background: #f8fbfd;
}

td.reason {
  max-width: 340px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
}

.watch-table th,
.watch-table td {
  padding: 11px 8px;
  font-size: 13.5px;
}

.watch-table th:nth-child(1),
.watch-table td:nth-child(1) {
  width: 82px;
}

.watch-table th:nth-child(2),
.watch-table td:nth-child(2) {
  width: 70px;
}

.watch-table th:nth-child(3),
.watch-table td:nth-child(3) {
  width: 84px;
}

.watch-table th:nth-child(4),
.watch-table td:nth-child(4) {
  width: 72px;
}

.watch-table th:nth-child(5),
.watch-table td:nth-child(5),
.watch-table th:nth-child(6),
.watch-table td:nth-child(6) {
  width: 86px;
}

.watch-table th:nth-child(7),
.watch-table td:nth-child(7) {
  width: 86px;
}

.watch-table th:nth-child(8),
.watch-table td:nth-child(8) {
  width: 62px;
}

.watch-table th:nth-child(9),
.watch-table td:nth-child(9) {
  width: 98px;
}

.watch-table th:nth-child(10),
.watch-table td:nth-child(10),
.watch-table th:nth-child(11),
.watch-table td:nth-child(11) {
  width: 82px;
}

.watch-table th:nth-child(12),
.watch-table td:nth-child(12) {
  width: 78px;
}

.watch-table th:nth-child(9),
.watch-table td:nth-child(9),
.watch-table th:nth-child(10),
.watch-table td:nth-child(10) {
  white-space: normal;
}

.watch-scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  background: transparent;
}

.watch-scrim.open {
  display: block;
}

.watch-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(1200px, calc(100vw - 24px));
  height: 100vh;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -18px 0 34px rgba(15, 27, 37, 0.18);
  transform: translateX(104%);
  transition: transform 0.18s ease;
}

.watch-drawer.open {
  transform: translateX(0);
}

.watch-drawer .section-head {
  flex: 0 0 auto;
}

.watch-drawer .quote-board {
  flex: 0 0 auto;
}

.watch-drawer .chart-stage {
  flex: 1 1 auto;
  min-height: 0;
}

.watch-drawer #watchKline {
  height: min(460px, calc(100vh - 300px));
}

td.empty {
  color: var(--muted);
  text-align: center;
}

.position-row {
  cursor: pointer;
}

.watch-row {
  cursor: pointer;
}

.position-row.selected td {
  background: #f1f8fb;
  box-shadow: none;
}

.position-row.selected td:first-child,
.watch-row.selected td:first-child {
  color: var(--accent);
  font-weight: 700;
}

.watch-row.selected td {
  background: #f1f8fb;
}

.detail-row td {
  padding: 0;
  background: #f8fafb;
  text-align: left;
  white-space: normal;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px 14px;
  padding: 16px;
  border-top: 1px solid #edf2f5;
}

.detail-grid div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff;
}

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

.detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.detail-grid .detail-wide {
  grid-column: 1 / -1;
}

.logic-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.logic-list li {
  min-width: 0;
  border: 1px solid #edf2f5;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfdfe;
}

.logic-list span,
.logic-list strong,
.logic-list em {
  display: block;
}

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

.logic-list strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 16px;
}

.logic-list em {
  margin-top: 3px;
  color: #60717d;
  font-style: normal;
  font-size: 12px;
  line-height: 1.35;
}

.chart-box {
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-box canvas {
  display: block;
  width: 100%;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.chart-panel {
  margin-top: -6px;
}

.chart-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-controls label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #43515a;
  font-size: 12px;
}

.chart-controls input[type="checkbox"] {
  accent-color: var(--accent);
}

.chart-period,
.watch-chart-period {
  min-height: 30px;
  border: 0;
  border-radius: 0;
  padding: 0 14px;
  background: #fff;
  color: #405462;
}

.chart-period + .chart-period,
.watch-chart-period + .watch-chart-period {
  border-left: 1px solid #cfd8de;
}

.chart-period.active,
.watch-chart-period.active {
  background: var(--accent);
  color: #fff;
}

.quote-board {
  border-top: 1px solid var(--line-soft);
  padding: 14px 16px 12px;
  background: #fff;
}

.quote-title {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 8px;
}

.quote-title strong {
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
}

.quote-title span {
  color: var(--muted);
  font-size: 15px;
}

.quote-title em {
  border: 1px solid #ccd6dd;
  border-radius: 4px;
  padding: 1px 5px;
  color: #5e6d78;
  font-style: normal;
  font-size: 12px;
}

.quote-layout {
  display: grid;
  grid-template-columns: minmax(180px, 250px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.quote-price strong {
  display: block;
  font-size: 52px;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0;
}

.quote-price span {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  font-weight: 600;
}

.quote-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px 18px;
}

.quote-grid div {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
}

.quote-grid span {
  color: var(--muted);
  font-size: 13px;
}

.quote-grid strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.chart-stage {
  position: relative;
  padding: 0 16px 18px;
}

#mainKline,
#watchKline {
  display: block;
  width: 100%;
  height: 430px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 249, 251, 0.7) 0, rgba(255, 255, 255, 0) 95px),
    #fff;
}

.watch-drawer .quote-layout {
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.watch-drawer .quote-price strong {
  font-size: 42px;
}

.watch-drawer .quote-price span {
  font-size: 17px;
}

.watch-drawer .quote-grid {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px 18px;
}

.chart-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chart-subhead {
  border-top: 1px solid var(--line-soft);
  border-bottom: 0;
  padding-block: 10px 0;
  background: #fff;
}

.empty-inline {
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: #244f66;
  font-size: 12px;
}

.status.warn {
  background: #fff2cc;
  color: var(--warn);
}

.segmented {
  display: inline-flex;
  border: 1px solid #cfd8de;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.period {
  min-height: 30px;
  border: 0;
  border-radius: 0;
  padding: 0 14px;
  background: #fff;
  color: #405462;
}

.period + .period {
  border-left: 1px solid #cfd8de;
}

.period.active {
  background: var(--accent);
  color: #fff;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.timeline {
  max-height: 440px;
  overflow: auto;
}

.item {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.item time {
  color: var(--muted);
  font-size: 12px;
}

.item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.item p {
  color: #405462;
  font-size: 12px;
  line-height: 1.45;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--nav);
  color: #fff;
  box-shadow: 0 8px 28px rgba(23, 32, 38, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
  font-size: 13px;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    padding-inline: 16px;
  }

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

  .watch-search,
  .watch-search input {
    width: 100%;
  }

  .metrics,
  .grid-two {
    grid-template-columns: 1fr;
  }

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

  .logic-list {
    grid-template-columns: 1fr;
  }

  .quote-layout {
    grid-template-columns: 1fr;
  }

  .quote-price strong {
    font-size: 44px;
  }

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

  main {
    padding: 16px;
  }
}
