:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #667085;
  --line: #d9e0ea;
  --blue: #2563eb;
  --green: #15803d;
  --red: #dc2626;
  --amber: #b45309;
  --teal: #0f766e;
  --soft: #eef2f7;
}

:root[data-theme="dark"] {
  --bg: #111827;
  --panel: #18212f;
  --ink: #eef2f7;
  --muted: #aab4c3;
  --line: #314052;
  --blue: #6ea8ff;
  --green: #4ade80;
  --red: #fb7185;
  --amber: #fbbf24;
  --teal: #2dd4bf;
  --soft: #223044;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.2;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 7px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--blue);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 36, 48, 0.06);
}

.metric {
  padding: 16px;
  min-height: 94px;
}

.label,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.value {
  margin-top: 9px;
  font-size: 25px;
  font-weight: 780;
}

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

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

.layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  padding: 18px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.signal-list {
  display: grid;
  gap: 10px;
}

.signal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 86%, var(--soft));
}

.signal.warn {
  border-left-color: var(--amber);
}

.signal.buy {
  border-left-color: var(--green);
}

.signal strong {
  display: block;
}

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

.signal .metric-text {
  font-weight: 760;
  color: var(--ink);
  white-space: nowrap;
}

.market-grid {
  display: grid;
  gap: 14px;
}

.market-grid strong {
  display: block;
  margin: 7px 0 2px;
  font-size: 28px;
}

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

.topic-list {
  display: grid;
  gap: 12px;
}

.topic-row {
  display: grid;
  grid-template-columns: 150px 1fr 86px;
  align-items: center;
  gap: 12px;
}

.topic-name {
  font-weight: 700;
}

.track {
  height: 12px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0;
  background: var(--teal);
}

.topic-row.high .fill {
  background: var(--amber);
}

.topic-row.low .fill {
  background: var(--blue);
}

.topic-pct {
  text-align: right;
  font-weight: 760;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-weight: 680;
}

tr:last-child td {
  border-bottom: 0;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(420px, calc(100% - 32px));
  box-shadow: 0 20px 60px rgba(31, 36, 48, 0.22);
}

.dialog-body {
  padding: 20px;
}

.dialog-body input {
  width: 100%;
  height: 42px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.dialog-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

#saveToken {
  background: var(--ink);
  color: white;
}

@media (max-width: 860px) {
  .metrics,
  .layout {
    grid-template-columns: 1fr;
  }

  .topic-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .topic-pct {
    text-align: left;
  }

  h1 {
    font-size: 28px;
  }
}
