:root {
  --bg: #f6efe3;
  --card: #fffaf0;
  --ink: #172532;
  --primary: #b21f2d;
  --gold: #c8a96a;
  --line: #e6d9c5;
  --up: #d8392b;   /* 涨 / 正收益 */
  --down: #1a8a4f; /* 跌 / 负收益 */
  --muted: #8a7f6d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: 2px; font-weight: 700; }
.topbar .sub { font-size: 11px; opacity: .85; margin-top: 2px; }

.wrap { max-width: 720px; margin: 0 auto; padding: 12px; }

/* 人物切换 */
.profile-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  -webkit-overflow-scrolling: touch;
}
.profile-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.profile-desc {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

/* 概览卡片 */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.summary .cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.summary .label { font-size: 11px; color: var(--muted); }
.summary .value { font-size: 16px; font-weight: 700; margin-top: 3px; }
.summary .value.small { font-size: 13px; }

/* 区块标题 */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin: 14px 2px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-title select {
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

/* 净值曲线 */
.curve-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
canvas { display: block; width: 100%; }

/* 月历 */
.calendar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 4px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: #f3ead8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.cell.empty { background: transparent; cursor: default; }
.cell.has { background: #fff; border: 1px solid var(--line); }
.cell .d { font-size: 13px; font-weight: 600; }
.cell .r { font-size: 10px; margin-top: 1px; }
.cell .asset { font-size: 9px; color: var(--muted); }
.cell .flow {
  position: absolute; bottom: 2px; font-size: 8px; padding: 0 3px; border-radius: 4px;
}
.flow.in { background: #e8f3ec; color: var(--down); }
.flow.out { background: #fbe9e7; color: var(--up); }
.up { color: var(--up); }
.down { color: var(--down); }

/* 详情底部面板 */
.mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 50; display: none;
}
.mask.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  z-index: 60;
  transform: translateY(100%);
  transition: transform .25s ease;
  padding: 16px 14px 24px;
}
.sheet.show { transform: translateY(0); }
.sheet .handle { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 12px; }
.sheet .close {
  position: absolute; top: 12px; right: 14px; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1;
}
.detail-head { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.detail-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; }
.focus-text { font-size: 13px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }

/* 持仓 */
.positions { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.pos {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.pos.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.pos .name { font-weight: 600; font-size: 14px; }
.pos .rate { font-size: 14px; font-weight: 700; }

/* K线 */
.kline-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin: 8px 0; }
.kline-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.kline-msg { font-size: 12.5px; color: var(--muted); padding: 18px 6px; text-align: center; }

/* 证据图 */
.evi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.evi-grid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; background: #eee; }

/* 灯箱 */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 80;
  display: none; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 96%; max-height: 82%; object-fit: contain; }
.lightbox .lb-close { position: absolute; top: 14px; right: 18px; color: #fff; font-size: 30px; cursor: pointer; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 34px; cursor: pointer; padding: 10px; }
.lightbox .lb-prev { left: 6px; }
.lightbox .lb-next { right: 6px; }
.lightbox .lb-count { position: absolute; bottom: 16px; color: #fff; font-size: 13px; }

.footer-note { font-size: 11px; color: var(--muted); text-align: center; padding: 18px 0 30px; }

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

/* 极窄屏（老款小屏手机，≤360px）微调，避免概览数字过挤 */
@media (max-width: 360px) {
  html, body { font-size: 14px; }
  .summary .value { font-size: 14px; }
  .summary .value.small { font-size: 12px; }
  .summary .label { font-size: 10px; }
  .cell .d { font-size: 12px; }
  .cell .r { font-size: 9px; }
  .cell .asset { font-size: 8px; }
  .topbar h1 { font-size: 16px; }
  .chip { padding: 6px 11px; font-size: 13px; }
}
