:root {
  color-scheme: light dark;
  --red: #e5484d;
  --green: #0f9f6e;
  --accent: #0e7490;
}

body[data-theme="light"] {
  --background: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: rgba(15, 23, 42, 0.08);
}

body[data-theme="dark"] {
  --background: #09090b;
  --surface: rgba(24, 24, 27, 0.82);
  --surface-2: rgba(39, 39, 42, 0.68);
  --text: #fafafa;
  --muted: #a1a1aa;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", sans-serif;
  transition: background 180ms ease, color 180ms ease;
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at 12% 0%, rgba(14, 116, 144, 0.18), transparent 28rem),
    linear-gradient(180deg, #0c0c10 0%, var(--background) 44%);
}

button {
  font: inherit;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.segmented-control {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 0.25rem;
}

.segmented-control.compact .theme-button {
  min-width: 3.25rem;
  padding-inline: 0.65rem;
}

.mode-button,
.theme-button {
  min-width: 6rem;
  border: 0;
  border-radius: 5px;
  padding: 0.55rem 0.85rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.mode-button:hover,
.mode-button.active,
.theme-button:hover,
.theme-button.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px rgba(14, 116, 144, 0.22);
}

.kpi-card,
.metric-tile,
aside.rounded-md,
section.rounded-md {
  border-color: var(--border) !important;
  background: var(--surface) !important;
  box-shadow: 0 18px 48px var(--shadow) !important;
}

.kpi-card {
  min-height: 7.5rem;
  padding: 1rem;
}

.metric-tile {
  padding: 0.9rem;
  background: var(--surface-2) !important;
}

.kpi-card span,
.metric-tile span,
.valuation span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.kpi-card strong,
.metric-tile strong {
  display: block;
  margin-top: 0.55rem;
  color: var(--text);
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.25;
}

.kpi-card em {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  line-height: 1.35;
}

.valuation {
  min-width: 9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 0.9rem 1rem;
  text-align: right;
}

.valuation strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.fund-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.fund-group {
  padding: 0.85rem 0.75rem 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.fund-item:hover,
.fund-item.active {
  background: var(--surface-2);
  border-color: var(--border);
}

.fund-item.active {
  border-color: rgba(14, 116, 144, 0.55);
  transform: translateY(-1px);
}

.fund-title {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.35;
}

.fund-sub,
.quote-sub {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.fund-metric {
  font-weight: 750;
  white-space: nowrap;
  text-align: right;
}

.fund-metric span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.up,
.valuation.up strong,
.fund-metric.up {
  color: var(--red) !important;
}

.down,
.valuation.down strong,
.fund-metric.down {
  color: var(--green) !important;
}

.pending,
.missing {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.82rem 1rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0;
}

td {
  color: var(--text);
  font-size: 0.86rem;
}

.weight {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.source {
  color: var(--muted);
  white-space: nowrap;
}

.nav-compare {
  display: grid;
  gap: 0.75rem;
}

.nav-compare > div {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 0.85rem;
}

.nav-compare span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.nav-compare strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
}

body .text-white,
body .text-zinc-100,
body .text-zinc-400,
body .text-zinc-500,
body .text-cyan-200,
body .text-cyan-300 {
  color: inherit !important;
}

body .text-zinc-400,
body .text-zinc-500 {
  color: var(--muted) !important;
}

body .border-white\/10 {
  border-color: var(--border) !important;
}

body .bg-zinc-950\/70,
body .bg-zinc-900\/70,
body .bg-white\/\[0\.03\] {
  background: var(--surface) !important;
}

@media (max-width: 760px) {
  .valuation {
    width: 100%;
    text-align: left;
  }

  .mode-button {
    min-width: 5.2rem;
  }

  th:nth-child(5),
  td:nth-child(5),
  th:nth-child(6),
  td:nth-child(6) {
    display: none;
  }

  th,
  td {
    padding: 0.75rem 0.7rem;
  }
}
