/* 线上监控站 · 设计系统（手机优先，桌面自适应）
   约定：涨=红，跌=绿（A股惯例） */
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e6eaf1;
  --text: #1f2937;
  --muted: #6b7280;
  --up: #d93025;      /* 涨-红 */
  --down: #0a9950;    /* 跌-绿 */
  --accent: #4f6ef7;
  --accent-soft: #eef1fe;
  --warn: #b45309;
  --ok: #16a34a;
  --danger: #c62828;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 4px 14px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  padding-bottom: calc(58px + env(safe-area-inset-bottom)); /* 底部导航 */
}
a { color: var(--accent); text-decoration: none; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, #1e2a56 0%, #2b3a7a 60%, #4f6ef7 100%);
  color: #fff; padding: 10px 14px 8px;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.topbar .sub { font-size: 11px; opacity: .82; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.topbar .dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; display: inline-block; margin-right: 4px; box-shadow: 0 0 0 3px rgba(52,211,153,.25); }

/* 页面导航 chips（桌面 / 移动通用） */
.navchips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.navchips::-webkit-scrollbar { display: none; }
.navchips a {
  flex: 0 0 auto; padding: 6px 13px; border-radius: 999px; font-size: 13px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--shadow); white-space: nowrap;
}
.navchips a.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* 底部 Tab（移动端主入口） */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: 7px 0 6px; font-size: 10.5px; color: var(--muted); }
.tabbar a .ic { font-size: 19px; display: block; line-height: 1.15; }
.tabbar a.on { color: var(--accent); font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 10px 12px 20px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 13px 14px; margin-bottom: 10px;
}
.card h2 { margin: 0 0 10px; font-size: 14.5px; display: flex; align-items: center; justify-content: space-between; }
.card h2 .t { display: flex; align-items: center; gap: 6px; }
.card h2 .ts { font-size: 10.5px; color: var(--muted); font-weight: 400; }

/* 统计块 */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.stat .k { font-size: 11.5px; color: var(--muted); }
.stat .v { font-size: 21px; font-weight: 800; margin-top: 4px; line-height: 1.2; }
.stat .n { font-size: 11px; color: var(--muted); margin-top: 2px; }
.up-c { color: var(--up); } .down-c { color: var(--down); }

/* 大盘指数实时条 */
.idxbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.idxtile { text-align: center; padding: 9px 4px; border-radius: var(--radius); background: var(--bg, #f6f8fb); border: 1px solid var(--border); min-width: 0; }
.idxtile .nm { font-size: 12px; color: var(--muted); }
.idxtile .px { font-size: 17px; font-weight: 800; margin-top: 3px; line-height: 1.2; }
.idxtile .pc { font-size: 12.5px; margin-top: 2px; }
.mkt-weak { margin-top: 8px; font-size: 12px; padding: 7px 10px; border-radius: var(--radius); background: #fdf3e7; color: #b45309; font-weight: 600; }

/* 个股详情 · 五维评分条 */
.dimrow { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; }
.dimrow .dn { flex: 0 0 56px; color: var(--muted); }
.dimrow .dbar { flex: 1; height: 8px; border-radius: 99px; background: #eef1f6; overflow: hidden; }
.dimrow .dbar i { display: block; height: 100%; border-radius: 99px; }
.dimrow .dv { flex: 0 0 28px; text-align: right; }

/* 详情页 · 日报列行 */
.kv { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f0f3f8; font-size: 12.5px; align-items: flex-start; }
.kv:last-child { border-bottom: none; }
.kv .k { flex: 0 0 76px; color: var(--muted); font-size: 11.5px; padding-top: 2px; }
.kv .v { flex: 1; min-width: 0; line-height: 1.55; }
.cellbody { font-size: 12.5px; }

/* 涨跌色 */
.chg-up { color: var(--up); font-weight: 600; }
.chg-down { color: var(--down); font-weight: 600; }

/* 表格 */
table.tb { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tb th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 11.5px; }
table.tb td { padding: 7px 8px; border-bottom: 1px solid #f0f3f8; vertical-align: top; }
table.tb tr:last-child td { border-bottom: none; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; }
.b-buy { background: #e8f7ee; color: var(--ok); }
.b-sell { background: #fdeaea; color: var(--danger); }
.b-wait { background: #fff4e0; color: var(--warn); }
.b-watch { background: #eef1fe; color: var(--accent); }
.b-no { background: #f1f5f9; color: #475569; }
.b-dim { background: #f1f5f9; color: var(--muted); font-weight: 500; }
.b-ref { background: #f1f5f9; color: #64748b; font-weight: 500; font-size: 10px; padding: 3px 8px; border: 1px dashed #cbd5e1; }
.b-flag { background: #fdeaea; color: var(--danger); }

/* 通用小元素 */
.dim { color: var(--muted); }
.small { font-size: 11.5px; }
.hr { border: none; border-top: 1px dashed var(--border); margin: 10px 0; }
.chip { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 3px 9px; font-size: 11.5px; margin: 2px 4px 2px 0; }
.chip.gray { background: #f1f5f9; color: var(--muted); }
.chip.red { background: #fdeaea; color: var(--danger); }
.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 8px 16px;
  background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.btn:active { opacity: .8; }
input, select, textarea {
  font: inherit; border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px;
  background: #fff; color: var(--text); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.formrow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.formrow > * { flex: 1 1 130px; }
.formrow > .w2 { flex: 2 1 200px; }

/* 股票卡片（监控页） */
.stk { position: relative; }
.stk .top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stk .sym { font-weight: 800; font-size: 15.5px; }
.stk .nm { font-size: 12.5px; color: var(--muted); }
.stk .px { margin-left: auto; text-align: right; }
.stk .px b { font-size: 15.5px; }
.stk .rows { margin-top: 8px; font-size: 12px; line-height: 1.75; color: #374151; }
.stk .rows b { font-weight: 600; }
.stk .meta { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 4px; }
.err { background: #fff4e0; border: 1px solid #f5d0a9; color: #92400e; border-radius: 10px; padding: 10px 13px; font-size: 12.5px; }
.skl { color: var(--muted); font-size: 12px; padding: 24px 0; text-align: center; }

/* 聊天 */
.chatwrap { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.chatlog { flex: 1; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 86%; margin: 7px 0; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.user { margin-left: auto; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.msg .who { font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.chiprow { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.chiprow::-webkit-scrollbar { display: none; }
.chatinput { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.chatinput textarea { flex: 1; resize: none; height: 44px; }
.chatinput .btn { align-self: flex-end; }

/* iframe 容器 */
.framebox { height: calc(100vh - 190px); min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.framebox iframe { width: 100%; height: 100%; border: none; }

/* 排行/榜单行 */
.rk { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #f0f3f8; font-size: 13px; }
.rk:last-child { border-bottom: none; }
.rk .idx { width: 22px; height: 22px; border-radius: 7px; background: #f1f5f9; color: var(--muted); font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 22px; }
.rk:nth-child(1) .idx { background: #fdeaea; color: var(--danger); }
.rk:nth-child(2) .idx { background: #fff4e0; color: var(--warn); }
.rk:nth-child(3) .idx { background: #e8f7ee; color: var(--ok); }
.rk .grow { flex: 1; min-width: 0; }
.rk .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk .t2 { font-size: 11px; color: var(--muted); }

/* 快捷入口宫格 */
.grid-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.grid-links a { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 6px 10px; text-align: center; color: var(--text); }
.grid-links a .ic { font-size: 21px; display: block; margin-bottom: 5px; }
.grid-links a .lb { font-size: 12px; font-weight: 600; }
.grid-links a .ds { font-size: 10px; color: var(--muted); margin-top: 2px; display: block; }

/* 分段选择 */
.segsel { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; width: max-content; }
.segsel button { border: none; background: #fff; padding: 7px 16px; font-size: 13px; cursor: pointer; color: var(--muted); }
.segsel button.on { background: var(--accent); color: #fff; font-weight: 600; }

footer.foot { text-align: center; color: var(--muted); font-size: 10.5px; padding: 14px 0 6px; line-height: 1.7; }

@media (min-width: 720px) {
  html { font-size: 15.5px; }
  body { padding-bottom: 20px; }
  .tabbar { display: none; }
  main { padding: 14px 20px 30px; }
  .card { padding: 15px 18px; }
}
