:root {
  --bg: #f2f4f6;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7280;
  --line: #e7e9ec;
  --up: #d92d20;
  --up-soft: #fdecea;
  --down: #0f9d58;
  --down-soft: #e6f6ee;
  --accent: #0e7a6e;
  --accent-soft: #e5f4f2;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}
.app-header {
  background: var(--card);
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.app-header h1 { font-size: 22px; font-weight: 700; letter-spacing: 0; }
.header-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.countdown {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.closed-tag {
  display: none;
  background: #eceef1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.page-wrap { flex: 1; overflow-y: auto; padding: 14px 16px 110px; }
.page { display: none; }
.page.active { display: block; }
.section-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 10px;
}
.empty {
  background: var(--card);
  border: 1px dashed #cbd0d6;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 26px 16px;
}
.fund-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.fund-head { display: flex; justify-content: space-between; align-items: flex-start; }
.fund-name { font-size: 15px; font-weight: 600; }
.fund-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fund-status { font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.fund-status.todo { color: var(--muted); background: #eceef1; }
.chart-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.mini-chart { flex: 1; height: 40px; min-width: 0; }
.est-box { text-align: right; flex: 0 0 auto; }
.est-label { font-size: 10px; color: var(--muted); }
.est-value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.est-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }
.up { color: var(--up); }
.down { color: var(--down); }
.closed-note {
  display: none;
  flex: 1;
  background: #f3f4f6;
  border: 1px dashed #cbd0d6;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
  text-align: center;
}
.body-closed .est-box { display: none; }
.body-closed .closed-note { display: block; }
.form-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.seg-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 8px;
  cursor: pointer;
}
.seg-btn.sel-up { background: var(--up-soft); border-color: var(--up); color: var(--up); }
.seg-btn.sel-down { background: var(--down-soft); border-color: var(--down); color: var(--down); }
.seg-btn.sel-flat { background: #f1f2f4; border-color: #9aa1a9; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.chip.sel { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
textarea, input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
}
textarea { min-height: 62px; resize: none; }
textarea:focus, input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.quant-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.field { flex: 1; }
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.input-wrap { position: relative; }
.input-wrap input { padding: 9px 8px 9px 24px; font-weight: 600; }
.input-wrap .suffix { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); }
.confidence { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding-bottom: 4px; }
.dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}
.dot.sel { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.conf-caption { font-size: 10px; color: var(--muted); margin-top: 3px; text-align: right; }
.submit-bar {
  position: sticky;
  bottom: 76px;
  padding: 10px 0 4px;
  background: linear-gradient(180deg, rgba(242,244,246,0), #f2f4f6 34%);
}
.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 14px 0;
  cursor: pointer;
}
.primary-btn:disabled { background: #b9bec5; color: #f4f5f7; }
.primary-btn.locked { background: #eceef1; color: var(--muted); }
.ghost-btn {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 0;
  cursor: pointer;
  margin-top: 4px;
}
.ghost-btn.danger { border-color: var(--up); color: var(--up); }
.summary-card { background: var(--accent-soft); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.summary-title { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 8px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; color: var(--muted); }
.review-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.review-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.badge { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.badge.hit { background: var(--down-soft); color: var(--down); }
.badge.miss { background: var(--up-soft); color: var(--up); }
.badge.wait { background: #eceef1; color: var(--muted); }
.verdict-row { display: flex; gap: 8px; font-size: 12px; margin-bottom: 10px; }
.verdict { flex: 1; background: #f8f9fa; border-radius: 8px; padding: 9px; }
.verdict .v-label { color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.verdict .v-value { font-weight: 600; font-size: 13px; }
.ai-note { font-size: 12px; color: #374151; line-height: 1.6; }
.ai-note .ai-tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; margin-right: 6px; }
.ai-block { background: var(--accent-soft); border-radius: 8px; padding: 14px; margin: 10px 0; }
.ai-block h3 { font-size: 13px; color: var(--accent); margin-bottom: 8px; }
.ai-block p { font-size: 12px; line-height: 1.7; color: #225c55; margin-bottom: 8px; white-space: pre-wrap; }
.ai-block p:last-child { margin-bottom: 0; }
.fund-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fund-row .f-name { font-size: 14px; font-weight: 600; }
.fund-row .f-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fund-row .f-right { text-align: right; }
.fund-row .f-val { font-size: 15px; font-weight: 700; }
.fund-row .f-sub2 { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fund-row .del-btn { border: 0; background: transparent; color: #c0c5cc; font-size: 18px; cursor: pointer; padding: 0 4px; }
.add-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}
.add-form h3 { font-size: 14px; margin-bottom: 10px; }
.add-form input { margin-bottom: 8px; }
.row2 { display: flex; gap: 8px; }
.row2 input { flex: 1; }
.bar-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 130px; padding: 6px 0 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 10px 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; }
.bar { width: 100%; max-width: 30px; border-radius: 4px 4px 0 0; background: var(--accent); opacity: 0.85; }
.bar-col .b-label { font-size: 10px; color: var(--muted); }
.bar-col .b-val { font-size: 10px; font-weight: 600; }
.history-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-row .h-name { font-size: 13px; font-weight: 600; }
.history-row .h-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.history-row .h-right { text-align: right; font-size: 12px; font-weight: 600; }
.note-box { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 5;
}
.tab-btn {
  border: 0;
  background: transparent;
  color: #9aa1a9;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.tab-btn.sel { color: var(--ink); font-weight: 600; }
.tab-btn.sel .tab-dot { background: var(--accent); }
.tab-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(27, 31, 36, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 86%;
  text-align: center;
}
#toast.show { opacity: 1; }
