:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #17201b;
  --muted: #68726d;
  --line: #d9ded7;
  --panel: #ffffff;
  --green: #198754;
  --red: #c94242;
  --blue: #2864c7;
  --gold: #9a6a16;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  margin-bottom: 12px;
}

h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

h3 {
  font-size: 16px;
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.form,
.setting {
  display: grid;
  gap: 10px;
}

.auto-note {
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.auto-note strong {
  color: var(--ink);
  font-size: 18px;
}

.auth-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.hidden {
  display: none !important;
}

.small {
  font-size: 13px;
}

label span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
button {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

input,
select {
  padding: 0 12px;
  background: #fff;
}

button {
  border-color: #1f5fbf;
  background: #1f5fbf;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:disabled,
input:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.ghost {
  background: #fff;
  color: #1f5fbf;
}

.fund-list {
  display: grid;
  gap: 8px;
}

.fund-item {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 8px;
}

.fund-item button {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  padding: 0 12px;
  font-weight: 600;
}

.fund-code {
  font-variant-numeric: tabular-nums;
  color: var(--blue);
}

.fund-short {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-badge {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fund-item button.active {
  border-color: #1f5fbf;
  box-shadow: inset 3px 0 0 #1f5fbf;
}

.fund-item .remove {
  padding: 0;
  text-align: center;
  color: var(--red);
}

.content {
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

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

.topbar a {
  color: #1f5fbf;
  font-weight: 700;
}

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

.metrics div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics div {
  padding: 16px;
}

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

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.health-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.health-card.warn {
  border-left-color: var(--gold);
}

.health-card.bad {
  border-left-color: var(--red);
}

.health-title span,
.health-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.health-title strong {
  display: block;
  font-size: 17px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
}

.health-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.health-wide {
  grid-column: span 2;
  min-width: 0;
}

.panel {
  overflow: hidden;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

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

.change-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.change-summary div {
  min-width: 0;
}

.change-summary span,
.threshold-control span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.change-summary strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.summary-wide strong {
  font-size: 14px;
  line-height: 1.45;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.summary-wide {
  grid-column: span 2;
}

.table-controls {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.segmented button {
  width: auto;
  height: 34px;
  padding: 0 12px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.segmented button.active {
  border-color: #1f5fbf;
  background: #eaf1fb;
  color: #1f5fbf;
}

.threshold-control {
  flex: 0 0 142px;
}

.threshold-control select {
  height: 34px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef1ee;
}

.tag.new,
.tag.up {
  color: var(--green);
  background: #e8f5ee;
}

.tag.down,
.tag.out {
  color: var(--red);
  background: #fbebeb;
}

.tag.same {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  background: #fafbf9;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.delta-up {
  color: var(--green);
  font-weight: 700;
}

.delta-down {
  color: var(--red);
  font-weight: 700;
}

.bars {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.bar {
  display: grid;
  grid-template-columns: 150px 1fr 58px;
  gap: 12px;
  align-items: center;
}

.track {
  height: 10px;
  background: #edf0ec;
  border-radius: 999px;
  overflow: hidden;
}

.fill {
  height: 100%;
  background: linear-gradient(90deg, #1f5fbf, #2b8a67);
}

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

.compact-empty {
  padding: 12px;
  text-align: left;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px;
  }

  .content {
    padding: 18px;
  }

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

  .health-card {
    grid-template-columns: 1fr;
  }

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

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

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

  .table-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .threshold-control {
    flex: auto;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 24px;
  }

  .fund-item {
    grid-template-columns: 1fr 38px;
  }

  .fund-item button {
    grid-template-columns: 62px minmax(0, 1fr) 36px;
  }

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

  .health-grid,
  .change-summary {
    grid-template-columns: 1fr;
  }

  .health-wide,
  .summary-wide {
    grid-column: 1 / -1;
  }

  .bar {
    grid-template-columns: minmax(82px, 120px) 1fr 52px;
  }
}
