/* ============================================================
 *  style.css —— 市场日报
 *  浅色金融风；A 股配色：涨红跌绿
 * ============================================================ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ec;
  --border-2: #d5d9e0;

  --text: #14181f;
  --text-2: #5a6270;
  --text-3: #8b93a1;

  /* A 股：涨红跌绿 */
  --up: #d93a2b;
  --up-bg: #fdf2f0;
  --down: #12855a;
  --down-bg: #eef8f3;
  --flat: #7a828f;
  --flat-bg: #f2f3f5;

  --brand: #1f4fd8;
  --brand-bg: #eef2fd;

  --r: 14px;
  --r-sm: 9px;
  --sh: 0 1px 2px rgba(20,24,31,.04), 0 4px 14px rgba(20,24,31,.04);

  --mono: "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 16px 56px;
}

/* 数字等宽对齐 */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ================= 页头 ================= */
.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 30px 2px 18px;
}

.head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -.2px;
}

.head-sub {
  margin: 3px 0 0;
  color: var(--text-3);
  font-size: 13px;
}

.datebox { text-align: right; line-height: 1.2; }

.d-num {
  display: block;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.3px;
}

.d-wd { font-size: 12px; color: var(--text-3); }

/* ================= 卡片 ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--sh);
  margin-bottom: 14px;
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-t {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-t::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--brand);
}

.card-note { font-size: 12px; color: var(--text-3); }

/* ================= 加载态 ================= */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 0;
  color: var(--text-3);
  font-size: 13px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 组合概况 ================= */
.pnl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--sh);
  margin-bottom: 14px;
}

.pnl-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.pnl-label { font-size: 13px; color: var(--text-2); }

.pnl-val {
  font-family: var(--mono);
  font-size: 29px;
  font-weight: 500;
  letter-spacing: -1px;
  line-height: 1.1;
}

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

.pnl-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

.pnl-split {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text-2);
}

.pnl-split b { font-weight: 500; font-family: var(--mono); }

/* 四项汇总数字 */
.pnl-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 16px;
  background: var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.ps {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.ps-l { font-size: 11.5px; color: var(--text-3); }
.ps-v { font-size: 14.5px; font-weight: 500; letter-spacing: -.2px; }

@media (max-width: 520px) {
  .pnl-stats { grid-template-columns: repeat(2, 1fr); }
  .pnl-val { font-size: 25px; }
}

/* ================= 持仓明细 ================= */
.pos-list { display: flex; flex-direction: column; }

.pos-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.pos-row:last-child { border-bottom: 0; }

.pos-main {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.pos-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pos-code {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: .3px;
  flex-shrink: 0;
}

.pos-num {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.pos-price { font-size: 13.5px; font-variant-numeric: tabular-nums; }

.pos-tag {
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.pos-val {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 92px;
}

.pos-asset { font-size: 13.5px; font-variant-numeric: tabular-nums; }

.pos-pnl {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

@media (max-width: 520px) {
  .pos-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "main val"
      "num  val";
    row-gap: 2px;
  }
  .pos-main { grid-area: main; }
  .pos-num  { grid-area: num; justify-content: flex-start; }
  .pos-val  { grid-area: val; }
  .pos-code { display: none; }
}

/* ================= 资产曲线 ================= */
.spark-wrap {
  margin: 4px -2px 0;
}

.spark {
  display: block;
  width: 100%;
  height: 86px;
}

.spark-line {
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark-area {
  fill: var(--brand-bg);
  stroke: none;
}

.spark-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.spark-foot b { font-weight: 500; font-family: var(--mono); }

/* ================= 行情表 ================= */
.q-list { display: flex; flex-direction: column; }

.q-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.q-row:last-child { border-bottom: 0; padding-bottom: 0; }
.q-row:first-child { padding-top: 0; }

.q-name { font-size: 13.5px; }
.q-code {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .3px;
}

.q-price {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.q-chg {
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: right;
  min-width: 74px;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12px;
}
.tag.up { background: var(--up-bg); }
.tag.down { background: var(--down-bg); }
.tag.flat { background: var(--flat-bg); }

/* ================= 市场温度 ================= */
.temp-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}

.temp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.temp-badge.cold { background: #eef4fd; color: #185fa5; }
.temp-badge.warm { background: #fdf1ef; color: #a32d2d; }
.temp-badge.mid  { background: var(--flat-bg); color: #5f5e5a; }
.temp-badge.unknown { background: var(--flat-bg); color: var(--text-3); }

.temp-note {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.7;
  width: 100%;
}

/* ================= 逐只建议 ================= */
.adv-list { display: flex; flex-direction: column; gap: 12px; }

.adv-item {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.adv-h {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.adv-name { font-size: 13.5px; font-weight: 500; }

.adv-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}

.adv-act {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.adv-act.hold    { background: var(--flat-bg); color: #5f5e5a; }
.adv-act.wait    { background: #f5f2e8; color: #854f0b; }
.adv-act.buy     { background: var(--up-bg); color: var(--up); }
.adv-act.sell    { background: var(--down-bg); color: var(--down); }

.adv-reason {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
}

/* ================= 总动作 ================= */
.action-box {
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--brand-bg);
  border: 1px solid #dbe3fb;
}

.action-label {
  font-size: 12px;
  color: var(--brand);
  margin-bottom: 4px;
  letter-spacing: .3px;
}

.action-text {
  margin: 0;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.6;
}

.watch-text {
  margin: 16px 0 0;
  padding-top: 15px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.85;
  white-space: pre-wrap;
}

.watch-text::before {
  content: "接下来观察";
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
  letter-spacing: .3px;
}

/* ================= 历史 ================= */
.hist { display: flex; flex-direction: column; }

.hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.hist-row:last-child { border-bottom: 0; padding-bottom: 0; }

.hist-date {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  min-width: 78px;
}

.hist-temp { font-size: 12px; color: var(--text-3); }

.hist-pct {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.hist-row:hover .hist-date { color: var(--brand); }

/* ================= 空态 / 提示 ================= */
.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--text-3);
}

.empty h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}

.empty p { margin: 0; font-size: 13px; line-height: 1.7; }

.empty code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.err-box {
  padding: 16px;
  border-radius: var(--r-sm);
  background: #fdf2f0;
  border: 1px solid #f7d7d1;
  color: #a32d2d;
  font-size: 13px;
}

/* ================= 示例数据提示 ================= */
.demo-banner {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: #fdf8ec;
  border: 1px solid #f0e2c0;
  color: #6b4a11;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 14px;
}

.demo-banner b { font-weight: 500; }

/* ================= 页脚 ================= */
.foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.8;
}

.foot p { margin: 0 0 4px; }

/* ================= 窄屏 ================= */
@media (max-width: 520px) {
  .wrap { padding: 0 12px 44px; }
  .head { padding: 22px 2px 14px; align-items: flex-start; }
  .head h1 { font-size: 19px; }
  .d-num { font-size: 15px; }
  .card, .pnl-card { padding: 15px; border-radius: 12px; }
  .pnl-val { font-size: 26px; }
  .q-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .q-chg { grid-column: 1 / -1; text-align: left; min-width: 0; padding-left: 0; }
  .adv-act { margin-left: 0; }
  .hist-date { min-width: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}