/* ========== 持仓监控台 —— 暗色金融终端风格（移动端优先适配） ========== */
:root {
  --bg: #0a0d10;
  --panel: #11161c;
  --panel-2: #151c24;
  --line: #1f2935;
  --text: #dbe4ec;
  --dim: #7b8a99;
  --up: #ff5c5c;      /* A股习惯：红涨 */
  --down: #3ecf8e;    /* 绿跌 */
  --flat: #8b98a5;
  --amber: #f0b90b;   /* 点缀色：行情终端黄 */
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  background-image:
    radial-gradient(1200px 500px at 80% -10%, rgba(240, 185, 11, .05), transparent),
    radial-gradient(900px 400px at 0% 110%, rgba(62, 207, 142, .04), transparent);
  background-attachment: fixed;
  min-height: 100vh;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 16px 80px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px; margin-bottom: 18px;
}
.title { font-family: var(--serif); font-size: 28px; letter-spacing: 2px; font-weight: 700; }
.title em { color: var(--amber); font-style: normal; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--dim); font-family: var(--mono); }
.status.open { color: var(--up); }
.status.noon { color: var(--amber); }
#quote-time { font-size: 12px; color: var(--dim); font-family: var(--mono); }
#refresh-btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 16px; font-size: 14px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
#refresh-btn:hover { border-color: var(--amber); color: var(--amber); }
#refresh-btn:active { transform: scale(.96); }

/* ---------- 移动端吸顶盈亏条（桌面隐藏） ---------- */
.sticky-pnl {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 8px;
  background: rgba(10, 13, 16, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 15px; font-weight: 600;
  text-align: center;
}

/* ---------- 汇总卡片 ---------- */
.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px; margin-bottom: 22px;
}
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px;
}
.stat-label { font-size: 12px; color: var(--dim); letter-spacing: 1px; margin-bottom: 6px; }
.stat-value { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.stat-wide { grid-column: 1 / -1; font-size: 14px; color: var(--dim); }
.stat-wide b { font-family: var(--mono); font-size: 16px; }

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

/* ---------- 进度条 ---------- */
.progress-track {
  height: 6px; border-radius: 3px; background: #1a222c;
  overflow: hidden; flex: 1;
}
.progress-track.big { margin-top: 8px; height: 8px; }
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #2a7a5b, var(--down));
  transition: width .5s ease;
}
.progress-fill.done { background: linear-gradient(90deg, #b33636, var(--up)); }
.progress-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; }
.progress-label { font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ---------- 持仓卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(370px, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; position: relative; overflow: hidden;
  animation: rise .4s ease both;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(240,185,11,.35), transparent);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.stock-name { font-size: 17px; font-weight: 600; }
.stock-code { font-size: 12px; color: var(--dim); font-family: var(--mono); }
.price-block { text-align: right; flex-shrink: 0; }
.price { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1.1; }
.chg { font-family: var(--mono); font-size: 13px; margin-top: 2px; }

.spark { width: 100%; height: 56px; display: block; margin: 12px 0 4px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.stats div {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px dashed #1a222c; padding-bottom: 5px;
}
.stats dt { font-size: 12px; color: var(--dim); }
.stats dd { font-family: var(--mono); font-size: 14px; text-align: right; }
.stats dd small { font-size: 11px; opacity: .8; }

/* ---------- 预警 / 策略 ---------- */
.alert {
  margin-top: 12px; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; line-height: 1.5;
}
.alert-warn {
  background: rgba(240, 185, 11, .12); color: var(--amber);
  border: 1px solid rgba(240, 185, 11, .35);
}
.alert-stop {
  background: rgba(255, 92, 92, .14); color: var(--up);
  border: 1px solid rgba(255, 92, 92, .45);
  animation: blink 1.2s ease-in-out infinite;
}
.alert-ok {
  background: rgba(62, 207, 142, .1); color: var(--down);
  border: 1px solid rgba(62, 207, 142, .35);
}
@keyframes blink { 50% { opacity: .55; } }

.strategy {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.7; color: var(--dim);
}
.strategy .target { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; color: var(--text); }
.strategy .tag {
  flex-shrink: 0; font-size: 11px; color: var(--amber);
  border: 1px solid rgba(240,185,11,.4); border-radius: 4px;
  padding: 0 5px; line-height: 1.6;
}
.strategy .memo { color: var(--dim); }

/* ---------- 整体策略备忘 ---------- */
.memo-box {
  margin-top: 22px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 0;
}
.memo-box summary {
  cursor: pointer; list-style: none;
  padding: 14px 16px; font-size: 14px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
  user-select: none;
}
.memo-box summary::-webkit-details-marker { display: none; }
.memo-box .chevron { color: var(--amber); transition: transform .2s; }
.memo-box[open] .chevron { transform: rotate(90deg); }
.memo-box ul { padding: 0 16px 14px 32px; }
.memo-box li { font-size: 13px; color: var(--dim); line-height: 1.9; }

/* ---------- 事件日历 ---------- */
.calendar { margin-bottom: 22px; }
.cal-head {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 6px;
  font-size: 15px; font-weight: 600; margin-bottom: 10px;
}
.cal-head span:last-child { font-size: 11px; color: var(--dim); font-weight: 400; }
.cal-list { display: flex; flex-direction: column; gap: 8px; }
.cal-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px;
}
.cal-item.hot { border-color: rgba(240, 185, 11, .55); background: linear-gradient(180deg, rgba(240,185,11,.06), var(--panel)); }
.cal-date {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  color: var(--amber); flex-shrink: 0; padding-top: 1px;
}
.cal-body { flex: 1; font-size: 13px; line-height: 1.5; }
.cal-body b { font-weight: 600; }
.cal-body p { color: var(--dim); font-size: 12.5px; line-height: 1.6; margin-top: 2px; }
.cal-badge {
  flex-shrink: 0; font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line); border-radius: 5px;
  padding: 2px 8px; color: var(--dim);
}
.cal-badge.soon { color: var(--amber); border-color: rgba(240, 185, 11, .5); }
.cal-badge.today {
  color: #fff; background: var(--up); border-color: var(--up);
  animation: blink 1.2s ease-in-out infinite;
}
.cal-badge.done { opacity: .6; }

/* ---------- 每股情报卡 ---------- */
.intel { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.intel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 600; color: var(--amber);
}
.intel-head span:last-child { font-size: 11px; color: var(--dim); font-weight: 400; }
.intel-view {
  margin: 8px 0; padding: 8px 10px;
  background: var(--panel-2); border-left: 2px solid var(--amber);
  border-radius: 0 6px 6px 0;
  font-size: 12.5px; line-height: 1.7; color: var(--text);
}
.intel-next {
  margin: 8px 0; padding: 8px 10px;
  background: rgba(240, 185, 11, .08);
  border: 1px dashed rgba(240, 185, 11, .4); border-radius: 6px;
  font-size: 12.5px; line-height: 1.5;
}
.intel-next p { color: var(--dim); font-size: 12px; line-height: 1.6; margin-top: 2px; }
.intel-news summary {
  cursor: pointer; list-style: none; user-select: none;
  font-size: 12.5px; color: var(--dim); padding: 4px 0;
  display: flex; justify-content: space-between; align-items: center;
}
.intel-news summary::-webkit-details-marker { display: none; }
.intel-news .chevron { color: var(--amber); transition: transform .2s; }
.intel-news[open] .chevron { transform: rotate(90deg); }
.intel-news ul { list-style: none; padding: 4px 0 2px; }
.intel-news li { display: flex; gap: 8px; margin-bottom: 8px; }
.intel-date { font-family: var(--mono); font-size: 11px; color: var(--dim); flex-shrink: 0; padding-top: 2px; }
.intel-news b { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.5; }
.intel-news p { font-size: 12px; color: var(--dim); line-height: 1.6; margin-top: 2px; }

/* ---------- 错误提示与页脚 ---------- */
#error-bar {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 8px;
  background: rgba(255, 92, 92, .1); border: 1px solid rgba(255, 92, 92, .4);
  color: var(--up); font-size: 13px; line-height: 1.6;
}
.footer {
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--dim); line-height: 1.9;
}
.footer code { font-family: var(--mono); color: var(--amber); }

/* ---------- 移动端适配 ---------- */
@media (max-width: 720px) {
  .wrap { padding: 14px 12px 90px; }
  .title { font-size: 22px; }
  .topbar { padding-bottom: 12px; margin-bottom: 14px; }
  #quote-time { display: none; }            /* 吸顶条已有刷新信息，此处省略 */
  .summary { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 17px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px; }
  .price { font-size: 23px; }
  .spark { height: 48px; }
  .sticky-pnl { display: block; }           /* 移动端常驻顶部盈亏 */
  body { padding-top: calc(env(safe-area-inset-top, 0px) + 36px); } /* 给吸顶条让位 */
  #refresh-btn { padding: 8px 14px; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
}
