/* A 股助手 PWA — 深色金融主题（中国习惯：红涨绿跌） */

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

:root {
  --bg: #0a0e1a;
  --bg-2: #131826;
  --bg-3: #1c2236;
  --line: #232a3d;
  --text: #e8eaed;
  --text-2: #9ca3af;
  --text-3: #6b7280;
  --up: #ff4d4f;
  --down: #52c41a;
  --neutral: #9ca3af;
  --accent: #ffd54f;
  --info: #58a6ff;
  --warn: #ff9500;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overscroll-behavior: none;
}

body {
  padding-top: calc(56px + var(--safe-top));
  padding-bottom: calc(70px + var(--safe-bot));
  min-height: 100vh;
}

/* 顶部栏 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(20px);
}
.brand {
  font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, #ff4d4f, #ffd54f);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.status-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-3);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-2);
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--down);
  box-shadow: 0 0 8px var(--down);
  animation: pulse 2s infinite;
}
.status-pill.bad .dot {
  background: var(--up);
  box-shadow: 0 0 8px var(--up);
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

/* 主内容 */
main {
  padding: 12px;
  max-width: 600px;
  margin: 0 auto;
}
.page { display: none; }
.page.active { display: block; }

/* 卡片 */
.card {
  background: var(--bg-2);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  transition: all 0.2s;
}
.card.hero {
  background: linear-gradient(135deg, var(--bg-2) 0%, var(--bg-3) 100%);
  border-color: rgba(255, 213, 79, 0.2);
}

.hero-row {
  display: flex; align-items: center; gap: 14px;
}
.hero-icon {
  font-size: 32px;
  width: 56px; height: 56px;
  background: var(--bg-3);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.hero-text { flex: 1; }
.hero-title {
  font-size: 16px; font-weight: 600; color: var(--text);
  margin-bottom: 4px;
}
.hero-sub {
  font-size: 12px; color: var(--text-2);
}

.countdown-row {
  display: flex; gap: 12px; margin-top: 16px;
  padding-top: 14px; border-top: 1px dashed var(--line);
}
.countdown {
  flex: 1; text-align: center;
}
.cd-label {
  display: block; font-size: 11px; color: var(--text-3); margin-bottom: 4px;
}
.cd-val {
  display: block;
  font-family: "SF Mono", "Roboto Mono", Menlo, monospace;
  font-size: 16px; font-weight: 600;
  color: var(--accent);
}

/* 2 列网格 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.card.mini {
  margin: 0;
  padding: 14px;
  text-align: center;
}
.mini-label {
  font-size: 12px; color: var(--text-2); margin-bottom: 4px;
}
.mini-val {
  font-family: "SF Mono", monospace;
  font-size: 22px; font-weight: 700;
  color: var(--info);
}

/* 标题 */
.section-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-2);
  margin: 18px 4px 8px;
  letter-spacing: 0.5px;
}

/* 服务列表 */
.svc-list { padding: 8px 0; }
.svc-row {
  display: flex; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.svc-row:last-child { border-bottom: 0; }
.svc-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--down);
  margin-right: 12px;
  box-shadow: 0 0 6px var(--down);
}
.svc-dot.bad { background: var(--up); box-shadow: 0 0 6px var(--up); }
.svc-name { flex: 1; font-size: 13px; color: var(--text); }
.svc-meta { font-size: 11px; color: var(--text-3); font-family: monospace; }

/* 推荐卡片 */
.pick-card {
  background: var(--bg-2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.pick-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.pick-name {
  font-size: 16px; font-weight: 600; color: var(--text);
}
.pick-code {
  font-family: monospace; font-size: 12px;
  color: var(--text-2);
  background: var(--bg-3);
  padding: 2px 8px; border-radius: 4px;
}
.pick-score {
  font-family: monospace; font-size: 14px; font-weight: 700;
  color: var(--up);
}
.pick-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; font-size: 12px;
  margin-top: 8px;
  color: var(--text-2);
}
.pick-meta span { color: var(--text); font-weight: 600; }

/* 持仓卡片 */
.holding-card {
  background: var(--bg-2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
}
.holding-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.holding-name { font-size: 16px; font-weight: 600; }
.holding-pnl {
  font-family: "SF Mono", monospace;
  font-size: 18px; font-weight: 700;
}
.holding-pnl.up { color: var(--up); }
.holding-pnl.down { color: var(--down); }
.holding-meta {
  font-size: 12px; color: var(--text-2);
  display: flex; gap: 12px; flex-wrap: wrap;
}
.holding-bar {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  margin-top: 8px;
  position: relative;
  overflow: hidden;
}
.holding-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--down), var(--accent), var(--up));
  border-radius: 2px;
}

/* 事件 */
.evt-row {
  display: flex; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.evt-row:last-child { border-bottom: 0; }
.evt-date {
  width: 70px;
  font-family: monospace;
  font-size: 13px;
  color: var(--accent);
}
.evt-info { flex: 1; min-width: 0; }
.evt-name { font-size: 14px; color: var(--text); margin-bottom: 2px; }
.evt-sectors { font-size: 11px; color: var(--text-3); }
.evt-days {
  font-family: monospace; font-size: 12px;
  color: var(--text-2);
  background: var(--bg-3);
  padding: 2px 8px; border-radius: 4px;
}

/* 主线 */
.theme-row {
  display: flex; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.theme-row:last-child { border-bottom: 0; }
.theme-name { flex: 1; color: var(--text); }
.theme-weight {
  font-family: monospace; font-weight: 700;
  padding: 3px 10px; border-radius: 4px;
  font-size: 12px;
}
.theme-weight.high { background: rgba(255, 77, 79, 0.15); color: var(--up); }
.theme-weight.mid { background: rgba(255, 213, 79, 0.15); color: var(--accent); }
.theme-weight.low { background: rgba(88, 166, 255, 0.15); color: var(--info); }

/* 待办 */
.todo-row {
  display: flex; align-items: start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.todo-row:last-child { border-bottom: 0; }
.todo-pri {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 10px; margin-top: 6px; flex-shrink: 0;
}
.todo-pri.high { background: var(--up); }
.todo-pri.mid { background: var(--accent); }
.todo-pri.low { background: var(--text-3); }
.todo-text { flex: 1; color: var(--text); }

/* 命令输入 */
.cmd-row {
  display: flex; gap: 8px;
}
.cmd-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.cmd-row input:focus {
  outline: none; border-color: var(--accent);
}
.cmd-row button {
  background: var(--up);
  color: white;
  border: 0;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}
.cmd-row button:active { opacity: 0.7; }
.cmd-reply {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text);
  min-height: 30px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.cmd-reply.show { display: block; }
.cmd-reply :is(b, code) {
  color: var(--accent);
  font-weight: 600;
}

/* loading */
.loading {
  padding: 24px; text-align: center; color: var(--text-3);
  font-size: 13px;
}

/* 空状态 */
.empty {
  text-align: center; padding: 30px 16px;
  color: var(--text-3);
}
.empty-emoji { font-size: 36px; margin-bottom: 10px; }

/* 底部 Tab */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(60px + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 100;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 10px;
}
.tab span { font-size: 20px; }
.tab.active {
  color: var(--accent);
}
.tab:active { background: var(--bg-3); }

/* 推荐卡片驱动器（评分依据） */
.pick-drivers {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.driver-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 213, 79, 0.1);
  color: var(--accent);
  border: 1px solid rgba(255, 213, 79, 0.2);
}

/* 空仓声明 */
.empty-declaration {
  background: linear-gradient(135deg, rgba(255, 77, 79, 0.05), rgba(255, 213, 79, 0.05));
  border: 1px dashed var(--up);
  text-align: center;
  padding: 24px 16px;
}
.empty-declaration .big {
  font-size: 18px; font-weight: 700; color: var(--up);
  margin-bottom: 8px;
}
.empty-declaration .desc {
  font-size: 13px; color: var(--text-2); line-height: 1.6;
}
/* v2 新增样式 */

.topbar-right { display: flex; gap: 8px; align-items: center; }
.sentiment-pill {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 99px;
  background: var(--bg-3);
  color: var(--accent);
  font-weight: 600;
}

/* 大盘指数 4 宫格 */
.indices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.idx-card {
  background: var(--bg-2);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--line);
}
.idx-name { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.idx-price {
  font-family: "SF Mono", monospace;
  font-size: 18px; font-weight: 700;
}
.idx-pct {
  font-family: "SF Mono", monospace;
  font-size: 13px;
  margin-top: 2px;
}
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }

/* 板块列表 */
.sector-row {
  display: flex; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.sector-row:last-child { border-bottom: 0; }
.sector-rank {
  width: 24px; text-align: center;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-3);
}
.sector-name { flex: 1; font-size: 13px; color: var(--text); }
.sector-pct {
  font-family: monospace; font-size: 13px; font-weight: 700;
  min-width: 60px; text-align: right;
}
.sector-leader { font-size: 11px; color: var(--text-3); margin-left: 8px; }

/* 分段控件 */
.seg {
  display: inline-flex;
  background: var(--bg-3);
  border-radius: 6px;
  margin-left: 8px;
  padding: 2px;
  font-size: 11px;
  vertical-align: middle;
}
.seg a {
  padding: 3px 10px;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 4px;
}
.seg a.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

/* 涨停池 */
.zt-row {
  display: flex; align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.zt-row:last-child { border-bottom: 0; }
.zt-streak {
  background: var(--up); color: #fff;
  padding: 2px 6px; border-radius: 4px;
  font-weight: 700; font-size: 11px;
  margin-right: 8px;
}
.zt-name { flex: 1; }
.zt-industry { font-size: 10px; color: var(--text-3); }

/* 自选股+预警 */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 80px 60px;
  gap: 6px;
}
.form-grid input, .form-grid select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.form-grid button {
  background: var(--up); color: #fff;
  border: 0; border-radius: 6px;
  font-weight: 600;
}
.watch-card, .alert-card {
  background: var(--bg-2);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.watch-card .del, .alert-card .del {
  color: var(--text-3); padding: 4px 8px;
  font-size: 16px; cursor: pointer;
  background: transparent; border: 0;
}
.watch-card .del:active { color: var(--up); }

/* 个股查询 */
.stock-search {
  display: flex; gap: 8px;
  padding: 12px;
}
.stock-search input {
  flex: 1;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--text); padding: 10px 14px; border-radius: 8px;
  font-size: 14px; font-family: inherit;
}
.stock-search button {
  background: var(--up); color: #fff;
  border: 0; padding: 0 18px; border-radius: 8px;
  font-weight: 600;
}

/* 个股详情卡片 */
.stock-detail-card {
  background: var(--bg-2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}
.stock-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.stock-name { font-size: 20px; font-weight: 700; }
.stock-code { font-family: monospace; color: var(--text-2); font-size: 12px; margin-left: 6px; }
.stock-price {
  font-family: "SF Mono", monospace;
  font-size: 24px; font-weight: 700;
}
.stock-kline {
  height: 280px;
  margin-top: 8px;
}
.stock-f10 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
  margin-top: 10px;
}
.stock-f10 div span {
  color: var(--accent);
  font-weight: 600;
  margin-left: 4px;
}
.stock-news-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.stock-news-item:last-child { border: 0; }
.stock-news-title { color: var(--text); margin-bottom: 2px; }
.stock-news-meta { color: var(--text-3); font-size: 10px; }

/* 龙虎榜 */
.lhb-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.lhb-name { font-weight: 600; color: var(--text); }
.lhb-reason { color: var(--text-3); font-size: 10px; }
.lhb-meta { display: flex; justify-content: space-between; margin-top: 4px; }

/* 下拉刷新 */
.refresh-bar {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 8px;
  display: none;
}
.refresh-bar.show { display: block; }

/* AI 回复块 */
.cmd-reply :is(b) {
  color: var(--accent);
  font-weight: 600;
}
.cmd-reply { font-family: -apple-system, monospace; font-size: 12px; }

.up-bg { background: rgba(255, 77, 79, 0.08); }
.down-bg { background: rgba(82, 196, 26, 0.08); }
