/* quant_v2 网页 —— 极简样式（无外部依赖） */
:root {
  --bg: #f5f6f8; --card: #fff; --line: #e2e4e8;
  --text: #23272f; --muted: #7a808a; --accent: #2b6cb0; --ok: #2f9e44;
  --warn: #d9480f; --err: #c92a2a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
       background: var(--bg); color: var(--text); }
.topbar { display: flex; justify-content: space-between; align-items: center;
          background: #1e2a3a; color: #fff; padding: 8px 16px;
          position: sticky; top: 0; z-index: 100;
          box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.topbar a { color: #cfe3f7; text-decoration: none; margin-right: 12px; }
.topbar .brand a { color: #fff; font-weight: 700; font-size: 1.05rem; }
.topbar .who { color: #9fb3c8; margin-right: 12px; }
.topbar .navsep { color: #6c8fae; margin: 0 4px 0 10px; font-size: .8rem;
                  font-weight: 700; }
main { max-width: 1080px; margin: 18px auto; padding: 0 16px; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; margin-top: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
        padding: 16px; }
.card.narrow { max-width: 420px; }
label { display: block; margin: 10px 0 4px; font-size: .9rem; color: var(--muted); }
input, select { width: 100%; padding: 7px 9px; border: 1px solid var(--line);
                border-radius: 6px; font: inherit; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 6px;
         padding: 8px 16px; cursor: pointer; font: inherit; margin-top: 10px; }
button.linklike { background: none; color: var(--accent); padding: 0; margin: 0 8px 0 0;
                  font-size: .85rem; }
button.linklike:hover { text-decoration: underline; }
form.inline { display: inline; }
form.inline select { width: auto; padding: 2px 4px; }
table.data { width: 100%; border-collapse: collapse; background: var(--card);
             margin: 8px 0; }
table.data th, table.data td { border: 1px solid var(--line); padding: 6px 8px;
        text-align: left; font-size: .9rem; }
table.data thead th { background: #eef1f5; }
/* 报告列表：短列不折行，长列给最小宽度；去掉状态列后桌面无需横向滚动 */
.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.data { min-width: 900px; }
.table-scroll th.td-name, .table-scroll td.td-name { min-width: 110px; }
.table-scroll th.td-summary, .table-scroll td.td-summary { min-width: 300px; }
.table-scroll td.td-summary { overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.empty { text-align: center; color: var(--muted); padding: 18px 0 !important; }
.tag { border-radius: 10px; padding: 1px 8px; font-size: .78rem; color: #fff; }
.st-queued { background: #868e96; }
.st-running { background: #1971c2; }
.st-success { background: var(--ok); }
.st-failed { background: var(--err); }
.st-a { background: var(--ok); }
.st-b { background: #1971c2; }
.logbox { background: #10151c; color: #d6e2ec; padding: 12px; border-radius: 8px;
          overflow-x: auto; font-size: .8rem; line-height: 1.5; min-height: 200px;
          white-space: pre-wrap; }
.logbox.report-body { background: #fff; color: #23272f; border: 1px solid var(--line);
                      min-height: 400px; }

/* ===== 深度研究报告排版 ===== */
.report-md { background: var(--card); border: 1px solid var(--line);
             border-radius: 8px; padding: 18px 22px; line-height: 1.7; }
.report-md h1, .report-md h2, .report-md h3, .report-md h4 {
  margin: 1.1em 0 .5em; line-height: 1.3; }
.report-md h1 { font-size: 1.35rem; border-bottom: 2px solid var(--line);
                padding-bottom: 6px; }
.report-md h2 { font-size: 1.15rem; border-bottom: 1px solid var(--line);
                padding-bottom: 4px; }
.report-md h3 { font-size: 1.02rem; }
.report-md p { margin: .5em 0; }
.report-md ul, .report-md ol { margin: .4em 0 .6em; padding-left: 1.5em; }
.report-md table { border-collapse: collapse; width: 100%; margin: 10px 0;
                   font-size: .88rem; }
.report-md th, .report-md td { border: 1px solid var(--line);
                               padding: 5px 8px; text-align: left; }
.report-md th { background: #eef1f5; }
.report-md blockquote { margin: .6em 0; padding: 6px 12px;
                        border-left: 3px solid var(--accent);
                        background: #f0f5fb; color: #333; }
.report-md pre { background: #10151c; color: #d6e2ec; border-radius: 6px;
                 padding: 10px; overflow-x: auto; }
.report-md code { background: #eef1f5; border-radius: 4px; padding: 1px 5px;
                  font-size: .85em; }
.report-md pre code { background: none; padding: 0; color: inherit; }
.report-md strong { font-weight: 700; }
.report-md hr { border: none; border-top: 1px solid var(--line);
                margin: 14px 0; }
.flashes { margin: 8px 0; }
.flash { padding: 8px 12px; border-radius: 6px; margin: 4px 0; font-size: .9rem; }
.flash.error { background: #ffe3e3; color: var(--err); border: 1px solid #ffc9c9; }
.flash.message { background: #e6f4ea; color: #1e7a34; border: 1px solid #b7e4c7; }
.filter { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter label { margin: 0; }
.filter input, .filter select { width: auto; }
.filter button { margin: 0; }
.pager { display: flex; gap: 12px; align-items: center; }
a.small { color: var(--accent); }

/* ===== 演示页 ===== */
.demo-banner { background: #fff7e6; border: 1px solid #ffe0a3; color: #8a6d1a;
               border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
               font-size: .85rem; }
.demo-filters { margin: 10px 0; gap: 8px; }
.chip { background: #eef1f5; color: #333; border: 1px solid var(--line);
        border-radius: 999px; padding: 6px 18px; cursor: pointer;
        font-size: .9rem; margin: 0; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.forcebox { display: inline-flex; align-items: center; gap: 4px;
            margin: 0 4px 0 0; font-size: .85rem; color: var(--text); }
.forcebox input { width: auto; margin: 0; }

/* ===== 运行中任务可视化 ===== */
.run-list { display: flex; flex-direction: column; gap: 10px; }
.run-item { background: var(--card); border: 1px solid var(--line);
            border-radius: 8px; padding: 10px 14px; }
.run-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.run-bar { height: 8px; background: #eef1f5; border-radius: 4px;
           margin: 8px 0 4px; overflow: hidden; }
.run-bar div { height: 100%; background: var(--accent); }
.run-log { color: var(--muted); font-size: .8rem; margin-top: 6px;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
           max-width: 100%; }

/* ===== 市场选择大按钮（登录后首页/后台首页） =====
   自适应网格：默认 auto-fit（3 个一行、以后 4 个自动铺开）；
   .cols3 强制 3 列并排、.cols4 强制 2×2（日股加入时用），保证不翻页。 */
.choose-wrap { max-width: 1120px; margin: 8vh auto 0; text-align: center;
               padding: 0 3vw; box-sizing: border-box; }
.choose-title { margin-bottom: 3.5vh; font-size: 1.5rem; }
.choose-grid { display: grid; gap: 2vw 2.5vw;
               grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
               align-items: stretch; }
.choose-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choose-grid.cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choose-card { min-height: clamp(170px, 24vh, 290px);
               border: 0; border-radius: 20px; text-decoration: none !important;
               color: #fff !important; display: flex; flex-direction: column;
               align-items: center; justify-content: center; gap: 1.2vh;
               padding: 4vh 14px; box-sizing: border-box;
               background: linear-gradient(135deg, #2b6cb0 0%, #174b86 100%);
               box-shadow: 0 10px 22px rgba(23, 75, 134, .28); }
/* 美股绿 / 港股琥珀 / 日股暗红（非亮红）——恢复原配色 */
.choose-card.us { background: linear-gradient(135deg, #1e8a4a 0%, #115c30 100%);
                  box-shadow: 0 10px 22px rgba(17, 92, 48, .28); }
.choose-card.hk { background: linear-gradient(135deg, #b7791f 0%, #7c4a0f 100%);
                  box-shadow: 0 10px 22px rgba(124, 74, 15, .28); }
.choose-card.jp { background: linear-gradient(135deg, #c5305a 0%, #8f1d42 100%);
                  box-shadow: 0 10px 22px rgba(143, 29, 66, .28); }
.choose-grid.cols4 { margin-top: 1.5vh; }   /* 四卡整体下移一点（市场选择页/后台首页共用） */
.choose-card:hover { transform: translateY(-3px) scale(1.015); }
.choose-big { font-size: clamp(2.2rem, 6.5vw, 3.8rem); font-weight: 800;
              line-height: 1.1; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.16); }
.choose-sub { color: rgba(255,255,255,.92); font-size: clamp(.8rem, 1.8vw, .95rem); }

/* 窄屏（手机）：并排 3 列太挤，改纵向堆叠，仍在单屏内 */
@media (max-width: 760px) {
  .choose-grid.cols3, .choose-grid.cols4 { grid-template-columns: 1fr; }
  .choose-card { min-height: 150px; padding: 3vh 12px; }
}

/* ===== 后台看板：运行中/排队/今日已完成 ===== */

.live-sec { margin-top: 4px; }
.live-sec h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-chip { background: #eef1f5; color: #495057; border: 1px solid var(--line);
             border-radius: 999px; padding: 1px 10px; font-size: .78rem;
             font-weight: 400; }
.live-chip.ok { background: #e6f4ea; color: #1e7a34; border-color: #b7e4c7; }
.live-chip.err { background: #ffe3e3; color: var(--err); border-color: #ffc9c9; }
.run-item.queued { background: #fbfcfe; }
.demo-slogan { padding: 6px 2px 10px; color: var(--muted); }
.demo-slogan strong { color: var(--text); }
.up { color: var(--ok); }
.down { color: var(--err); }
.coming-grid { display: grid; grid-template-columns: repeat(auto-fill,
               minmax(220px, 1fr)); gap: 12px; margin-top: 20px; }
.card.ghost { border-style: dashed; color: var(--muted); min-height: 110px; }
.card.ghost h3 { margin-top: 0; color: var(--muted); }

/* 选股页“＋ 手动加股”按钮 */
.add-stock-btn { display: inline-block; margin-left: 12px; padding: 4px 14px;
                 border: 1px solid #2b6cb0; color: #2b6cb0;
                 border-radius: 999px; font-size: .85rem;
                 text-decoration: none !important; vertical-align: middle; }
.add-stock-btn:hover { background: #2b6cb0; color: #fff !important; }

/* ===== 报告追问（Q&A）===== */
.report-chat { margin: 28px 0 8px; padding-top: 16px; border-top: 2px dashed #cbd5e0; }
.report-chat h2 { margin: 0 0 10px; }
.report-chat .chat-msgs { max-height: 60vh; overflow-y: auto;
                          display: flex; flex-direction: column; gap: 10px;
                          padding: 4px 2px; }
.report-chat .msg { max-width: 92%; padding: 8px 12px; border-radius: 10px;
                    white-space: pre-wrap; word-break: break-word; }
.report-chat .msg.user { align-self: flex-end; background: #e2e8f0; }
.report-chat .msg.assistant { align-self: flex-start; background: #fff;
                              border: 1px solid #e2e8f0; }
.report-chat .msg-head { font-size: .75rem; color: #718096;
                         margin-bottom: 4px; }
.report-chat .msg-body > :first-child { margin-top: 0; }
.report-chat .msg-body > :last-child { margin-bottom: 0; }
.report-chat .msg-body table { border-collapse: collapse; margin: 8px 0;
                               width: 100%; font-size: .82rem; }
.report-chat .msg-body th, .report-chat .msg-body td { border: 1px solid #e2e4e8;
                          padding: 4px 8px; text-align: left; vertical-align: top; }
.report-chat .msg-body th { background: #f0f3f7; }
.report-chat .msg-body pre { background: #f6f8fa; padding: 8px; border-radius: 6px;
                            overflow-x: auto; font-size: .8rem; }
.report-chat .msg-body code { background: #f0f3f7; padding: 0 4px;
                             border-radius: 4px; }
.report-chat .msg-body blockquote { margin: 6px 0; padding-left: 10px;
                          border-left: 3px solid #cbd5e0; color: #5a6472; }

/* ===== 报告详情页：正文 + 右侧追问窄栏（始终两栏，栏宽自适应）===== */
body.page-report main { max-width: 1560px; }

.report-page { display: flex; gap: clamp(12px, 2vw, 24px);
               align-items: stretch; width: 100%; }
.report-body { flex: 1 1 auto; min-width: 0; max-width: 1180px; }
.chat-rail { flex: 0 0 auto; display: flex; align-self: stretch;
             width: clamp(230px, 24vw, 320px); min-width: 230px; }
.chat-rail-inner { position: sticky; top: 62px; align-self: flex-start;
                  width: 100%; display: flex;
                  height: min(56vh, 760px); }
.chat-rail-inner .report-chat { margin: 0; padding: 0; border: none;
                    width: 100%; height: 100%;
                    display: flex; flex-direction: column;
                    background: var(--card); border: 1px solid var(--line);
                    border-radius: 10px; padding: 12px 14px;
                    box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.chat-rail-inner .report-chat h2 { flex: 0 0 auto;
                    display: flex; flex-wrap: wrap;
                    align-items: baseline; gap: 2px 8px; }
.chat-rail-inner .report-chat h2 a { margin-left: auto; }
.chat-rail-inner .chat-msgs { flex: 1 1 auto; overflow-y: auto;
                              min-height: 60px; }
.chat-rail-inner .chat-form { flex: 0 0 auto; margin-top: 10px; }

/* 输入框在上、按钮在下（纵向） */
.report-chat .chat-form { display: flex; flex-direction: column;
                          align-items: stretch; gap: 8px;
                          margin-top: 12px; }
.report-chat .chat-form textarea { width: 100%; min-height: 110px;
                                   font-size: 1rem; line-height: 1.45;
                                   resize: vertical; }
.report-chat .chat-form button { width: 100%; margin-top: 0; }

/* ===== 用户管理小控件 ===== */
.pw-input { width: 130px; padding: 3px 6px; font-size: .85rem;
            margin-right: 4px; }
button.linklike.danger { color: #c92a2a; }

/* 空态：提示句下方紧跟长输入框，卡片不高半屏 */
.chat-rail-inner:has(.report-chat.no-msgs) { height: auto; }
.report-chat.no-msgs { height: auto !important; }
.report-chat.no-msgs .chat-msgs { flex: 0 0 auto; min-height: 0;
                                  overflow: visible; }

/* ---- 任务终止按钮（后台看板 running 项） ---- */
.run-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px;
               flex-wrap: wrap; }
.run-actions form { margin: 0; }
button.btn-kill { background: #c92a2a; padding: 3px 10px; border-radius: 6px;
                  font-size: .8rem; }
button.btn-kill:hover { background: #a61e1e; }

/* ---- 追问面板：研究/深研进行中提示 ---- */
.chat-busy { background: #fff3bf; border: 1px solid #ffe066; color: #8a6d00;
             padding: 8px 12px; border-radius: 6px; margin: 0 0 10px;
             font-size: .88rem; }


