:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --up: #ef232a;      /* 涨：红 */
  --down: #14b143;    /* 跌：绿 */
  --blue: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* 顶栏 */
.topbar {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo { font-size: 34px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 700; }
.brand .sub { margin: 2px 0 0; font-size: 12px; opacity: .85; }

.search-wrap { position: relative; flex: 1; max-width: 460px; min-width: 260px; }
#searchInput {
  width: 100%;
  padding: 11px 72px 11px 16px;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.analyze-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  padding: 0 18px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
  transition: all .15s ease;
}
.analyze-btn:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); transform: translateY(-1px); }
.analyze-btn:active { transform: translateY(0); }
.analyze-btn:disabled { background: #93c5fd; cursor: not-allowed; }
.search-panel {
  position: absolute;
  top: 46px; left: 0; right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
}
.hidden { display: none !important; }
.search-panel.hidden { display: none; }
.search-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #f1f1f1;
}
.search-item:hover, .search-item.active { background: #eef4ff; }
.search-item .si-name { font-weight: 600; }
.search-item .si-code { color: var(--muted); font-size: 12px; }

/* 免责声明 */
.disclaimer {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12.5px;
  padding: 9px 24px;
}

/* 容器 */
.container { max-width: 1080px; margin: 20px auto; padding: 0 16px; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-emoji { font-size: 52px; margin-bottom: 12px; }
.empty-hint { font-size: 12px; margin-top: 8px; }

.loading { text-align: center; padding: 60px; color: var(--muted); }
.loading.mini {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 16px; margin-bottom: 14px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
  color: #1e40af; font-size: 13px;
}
.spinner {
  width: 38px; height: 38px; margin: 0 auto 14px;
  border: 4px solid #dbeafe; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.spinner-mini {
  width: 16px; height: 16px;
  border: 2px solid #bfdbfe; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.countdown { color: var(--muted); font-size: 12px; margin-left: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 14px 18px; border-radius: 12px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.retry-btn {
  border: 1px solid #b91c1c; background: #fff; color: #b91c1c;
  padding: 6px 16px; border-radius: 16px; cursor: pointer; font-size: 13px;
  white-space: nowrap;
}
.retry-btn:hover { background: #b91c1c; color: #fff; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card-title {
  font-weight: 700; font-size: 15px; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}

/* 行情卡片 */
.quote-head { display: flex; justify-content: space-between; align-items: baseline; }
.q-name { font-size: 20px; font-weight: 700; margin-right: 8px; }
.q-code { color: var(--muted); font-size: 13px; }
.q-time { color: var(--muted); font-size: 12px; }
.q-source { font-size: 12px; margin-top: 4px; display: inline-block; }
.q-source.src-primary { color: #16a34a; }
.q-source.src-fallback { color: #d97706; font-weight: 600; }
.quote-main { display: flex; align-items: baseline; gap: 14px; margin: 10px 0 16px; }
.q-price { font-size: 38px; font-weight: 700; line-height: 1; }
.q-change { font-size: 17px; font-weight: 600; }
.quote-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 12px;
}
.quote-grid > div { display: flex; flex-direction: column; }
.quote-grid label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.quote-grid span { font-size: 14px; font-weight: 600; }

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

/* K线图 */
.chart { width: 100%; height: 460px; }
.period-tabs { display: flex; gap: 6px; }
.pbtn {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 4px 12px; border-radius: 16px; cursor: pointer; font-size: 12px;
}
.pbtn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* 预测卡片 */
.predict-body { display: flex; gap: 24px; flex-wrap: wrap; }
.predict-left { flex: 1; min-width: 240px; }
.predict-right { flex: 1.4; min-width: 260px; }
.p-direction {
  font-size: 26px; font-weight: 800; padding: 6px 0;
  display: inline-block;
}
.p-direction.bull { color: var(--up); }
.p-direction.bear { color: var(--down); }
.p-direction.neutral { color: var(--muted); }
.confidence { margin: 12px 0; }
.confidence label { font-size: 12px; color: var(--muted); }
.bar { height: 10px; background: #eef2f7; border-radius: 6px; overflow: hidden; margin: 4px 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg,#34d399,#2563eb); width: 0%; transition: width .6s; }
.confidence span { font-size: 13px; font-weight: 600; }
.score-line { font-size: 14px; margin: 8px 0; }
.target {
  margin-top: 10px; padding: 10px 14px; background: #f8fafc;
  border-radius: 10px; font-size: 13px;
}
.target strong { font-size: 16px; color: var(--blue); margin-left: 6px; }
.signals-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.signals { list-style: none; padding: 0; margin: 0; }
.signals li {
  padding: 7px 10px; margin-bottom: 6px; background: #f8fafc;
  border-left: 3px solid var(--blue); border-radius: 6px; font-size: 13px;
}
.predict-summary {
  margin-top: 16px; padding: 12px 14px; background: #eff6ff;
  border-radius: 10px; font-size: 13.5px; line-height: 1.7; color: #1e3a8a;
}

/* 指标网格 */
.ind-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.ind-item {
  background: #f8fafc; border-radius: 10px; padding: 12px;
}
.ind-item .ind-name { font-size: 12px; color: var(--muted); }
.ind-item .ind-val { font-size: 18px; font-weight: 700; margin-top: 4px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

/* ===== ETF 成分股拆解分析 ===== */
.etf-btn {
  position: absolute;
  right: 74px; top: 4px; bottom: 4px;
  padding: 0 16px;
  border: none; border-radius: 20px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 6px rgba(217, 119, 6, .35);
  transition: all .15s ease;
}
.etf-btn:hover { background: linear-gradient(135deg, #d97706, #b45309); transform: translateY(-1px); }
.etf-btn:active { transform: translateY(0); }

.etf-overview .q-track { font-size: 12px; color: var(--muted); margin-left: 10px; }
.etf-verdict {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
}
.etf-verdict .p-direction { font-size: 22px; font-weight: 800; }
.etf-verdict .score-line { font-size: 14px; }
.etf-verdict .score-line strong { font-size: 18px; }
.etf-verdict .target { font-size: 14px; }
.etf-verdict .target strong { font-size: 18px; color: var(--blue); }

.etf-table-wrap { overflow-x: auto; }
.etf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.etf-table th, .etf-table td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.etf-table th { background: #f8fafc; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.etf-table tbody tr:hover { background: #f1f5f9; }
.etf-name { font-weight: 600; }
.etf-code { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--muted); font-weight: 400; }
.etf-sig { white-space: normal; min-width: 220px; color: #334155; line-height: 1.4; }
.etf-table .up { color: var(--up); font-weight: 600; }
.etf-table .down { color: var(--down); font-weight: 600; }

.dist-bar {
  display: flex; height: 30px; border-radius: 8px; overflow: hidden;
  margin-top: 12px; font-size: 12px; font-weight: 600; color: #fff;
}
.dist-seg { display: flex; align-items: center; justify-content: center; min-width: 0; }
.dist-seg.up { background: var(--up); }
.dist-seg.down { background: var(--down); }
.dist-seg.flat { background: #94a3b8; }

/* T+0 日内买卖点 */
.intraday-card { border-left: 4px solid var(--blue); }
.intraday-box { margin-top: 8px; }
.intraday-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 14px;
}
.in-col { background: #f8fafc; border-radius: 10px; padding: 12px; text-align: center; }
.in-col label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.in-price { font-size: 22px; font-weight: 800; }
.in-price.down { color: var(--down); }
.in-price.up { color: var(--up); }
.intraday-status {
  font-size: 15px; font-weight: 700; padding: 10px 14px; border-radius: 10px;
  margin-bottom: 10px; background: #f1f5f9; color: var(--muted);
}
.intraday-status.down { background: #ecfdf5; color: var(--down); }
.intraday-status.up { background: #fef2f2; color: var(--up); }
.intraday-status.neutral { background: #f1f5f9; color: var(--muted); }
.intraday-advice { font-size: 13.5px; line-height: 1.7; color: #334155; margin-bottom: 10px; }
.intraday-levels { display: flex; flex-wrap: wrap; gap: 8px; }
.intraday-levels span {
  font-size: 12px; background: #eef2f7; color: #475569;
  padding: 4px 10px; border-radius: 20px;
}

@media (max-width: 720px) {
  .quote-grid { grid-template-columns: repeat(3, 1fr); }
  .ind-grid { grid-template-columns: repeat(2, 1fr); }
  .brand h1 { font-size: 16px; }
  .etf-btn { right: 70px; padding: 0 10px; font-size: 12px; }
}
