:root{
  --bg:#f4f6fb; --panel:#ffffff; --ink:#1f2430; --sub:#6b7280; --line:#e6e9f0;
  --up:#e0392b; --down:#15a86b; --up-soft:#fdecea; --down-soft:#e7f7ef;
  --brand:#2b59ff; --brand-d:#1f44cc; --warn:#d98a00; --chip:#eef1fb;
  --shadow:0 2px 10px rgba(20,30,60,.06);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg); color:var(--ink); font-size:14px; line-height:1.5;
}
.up{color:var(--up)} .down{color:var(--down)} .muted{color:var(--sub)}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 16px; background:linear-gradient(90deg,#1f44cc,#2b59ff); color:#fff;
  position:sticky; top:0; z-index:20;
}
.brand{display:flex; align-items:center; gap:10px}
.logo{font-size:22px}
.title{font-weight:700; font-size:17px}
.subtitle{font-size:11px; opacity:.85}
.topbar-right{display:flex; align-items:center; gap:10px}
.market-status{font-size:12px; background:rgba(255,255,255,.18); padding:4px 10px; border-radius:20px}
.market-status.closed{background:rgba(255,255,255,.12)}

.layout{
  display:grid; grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);
  gap:14px; padding:14px; max-width:1280px; margin:0 auto; align-items:start;
}
@media (max-width:900px){ .layout{grid-template-columns:1fr} }

.panel{background:var(--panel); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); margin-bottom:14px; overflow:hidden}
.panel-head{display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--line)}
.panel-head h2{margin:0; font-size:15px}

.btn{cursor:pointer; border:none; border-radius:9px; padding:8px 14px; font-size:13px; font-weight:600; transition:.15s}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn-sm{padding:5px 10px; font-size:12px}
.btn-primary{background:var(--brand); color:#fff} .btn-primary:hover{background:var(--brand-d)}
.btn-ghost{background:#eef1fb; color:var(--brand)} .btn-ghost:hover{background:#e2e8fb}

.holdings{padding:10px 12px; display:flex; flex-direction:column; gap:10px}
.empty{color:var(--sub); text-align:center; padding:24px 0; font-size:13px}
.hcard{display:grid; grid-template-columns:1fr auto; grid-template-areas:"name act" "prc chg" "meta meta"; gap:6px 10px; padding:11px 12px; border:1px solid var(--line); border-radius:11px; cursor:pointer; transition:.15s; background:#fff}
.hcard:hover{border-color:#c7d0f5; box-shadow:var(--shadow)}
.hcard.active{border-color:var(--brand); background:#f5f8ff}
.hcard .name{grid-area:name; font-weight:700; font-size:15px}
.hcard .code{color:var(--sub); font-size:12px}
.hcard .price{grid-area:prc; font-weight:700; font-size:17px}
.hcard .chg{grid-area:chg; align-self:end; padding-bottom:2px; text-align:right; font-size:12px; font-weight:600}
.hcard .meta{grid-area:meta; grid-column:1 / -1; display:flex; justify-content:space-between; font-size:12px; color:var(--sub); border-top:1px dashed var(--line); padding-top:6px; margin-top:2px}
.hcard .pl{font-weight:700}
.hact{grid-area:act; display:flex; gap:2px; justify-self:end}
.hact button{border:none; background:none; cursor:pointer; color:#b9c0cf; font-size:13px; line-height:1; padding:3px 5px; border-radius:6px}
.hact button:hover{background:#eef1fb; color:var(--brand)}
.hact .delx:hover{background:var(--up-soft); color:var(--up)}
.badge{display:inline-block; font-size:11px; font-weight:700; padding:1px 7px; border-radius:20px; margin-left:6px; vertical-align:middle}
.badge.buy{background:var(--up-soft); color:var(--up)}
.badge.hold{background:#fff4e0; color:var(--warn)}
.badge.sell{background:var(--down-soft); color:var(--down)}

.period-tabs{display:flex; gap:4px}
.period{border:1px solid var(--line); background:#fff; color:var(--sub); padding:4px 10px; border-radius:8px; font-size:12px; cursor:pointer}
.period.active{background:var(--brand); color:#fff; border-color:var(--brand)}

.metrics{display:grid; grid-template-columns:repeat(auto-fit,minmax(96px,1fr)); gap:8px; padding:10px 14px}
.metric{background:#f8f9fd; border:1px solid var(--line); border-radius:9px; padding:7px 9px}
.metric .k{font-size:11px; color:var(--sub)}
.metric .v{font-size:13px; font-weight:700; margin-top:2px}

.chart-wrap{position:relative; padding:0 8px}
.crosstip{position:absolute; display:none; background:rgba(28,32,40,.94); color:#fff; font-size:11px; padding:7px 9px; border-radius:7px; pointer-events:none; z-index:30; line-height:1.5; min-width:136px; box-shadow:0 4px 14px rgba(0,0,0,.22)}
.crosstip .ct-date{font-weight:700; font-size:11.5px; margin-bottom:4px; padding-bottom:4px; border-bottom:1px solid rgba(255,255,255,.16); letter-spacing:.3px}
.crosstip .ct-grid{display:grid; grid-template-columns:auto 1fr auto 1fr; gap:1px 7px; font-variant-numeric:tabular-nums}
.crosstip .ct-grid span{color:#9aa3b2}
.crosstip .ct-grid b{font-weight:600; text-align:right}
.crosstip .ct-ma{margin-top:5px; padding-top:5px; border-top:1px solid rgba(255,255,255,.16); display:grid; grid-template-columns:1fr 1fr; gap:1px 8px; font-variant-numeric:tabular-nums}
#chart{width:100%; height:340px; display:block; touch-action:none}
@media (max-width:900px){ #chart{height:300px} }

.signal{padding:10px 14px 14px}
.signal .head{display:flex; align-items:center; gap:10px; margin-bottom:8px}
.signal .act{font-size:16px; font-weight:800; padding:3px 12px; border-radius:8px}
.act.buy{background:var(--up); color:#fff}
.act.hold{background:var(--warn); color:#fff}
.act.sell{background:var(--down); color:#fff}
.act.watch{background:#eef1fb; color:var(--brand)}
.signal .score{color:var(--sub); font-size:12px}
.reasons{display:flex; flex-direction:column; gap:5px}
.reason{display:flex; gap:8px; font-size:12.5px; align-items:flex-start}
.reason .dot{flex:0 0 auto; width:8px; height:8px; border-radius:50%; margin-top:5px}
.dot.bull{background:var(--up)} .dot.bear{background:var(--down)} .dot.neu{background:#c4cad6}

.col-right .panel{display:flex; flex-direction:column; height:calc(100vh - 92px); min-height:520px}
@media (max-width:900px){ .col-right .panel{height:78vh} }
.chat-panel .panel-head{border-bottom:1px solid var(--line)}
.chat-context{font-size:11px; color:var(--brand); background:var(--chip); padding:3px 9px; border-radius:20px}
.chat-box{flex:1; overflow-y:auto; padding:14px; display:flex; flex-direction:column; gap:12px}
.msg{display:flex; gap:8px; max-width:100%}
.msg .bubble{padding:9px 13px; border-radius:13px; font-size:13.5px; white-space:pre-wrap; word-break:break-word}
.msg.ai .bubble{background:#eef1fb; border-top-left-radius:3px}
.msg.me{justify-content:flex-end}
.msg.me .bubble{background:var(--brand); color:#fff; border-top-right-radius:3px}
.msg .bubble.thinking{opacity:.7}

.chat-input{display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--line)}
.chat-input textarea{flex:1; resize:none; border:1px solid var(--line); border-radius:10px; padding:8px 10px; font-family:inherit; font-size:13px}
.chat-input textarea:focus{outline:none; border-color:var(--brand)}
.quick-row{display:flex; gap:6px; flex-wrap:wrap; padding:0 12px 12px}
.chip{background:var(--chip); color:var(--brand); border:none; border-radius:20px; padding:5px 11px; font-size:12px; cursor:pointer}
.chip:hover{background:#e2e8fb}

.modal{position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(15,20,40,.45); display:flex; align-items:center; justify-content:center; z-index:50; padding:16px}
.modal-box{background:#fff; border-radius:14px; width:100%; max-width:420px; box-shadow:0 12px 40px rgba(0,0,0,.2)}
.modal-head{display:flex; justify-content:space-between; align-items:center; padding:14px 16px; border-bottom:1px solid var(--line)}
.modal-head h3{margin:0; font-size:15px}
.modal-close{border:none; background:none; font-size:22px; cursor:pointer; color:var(--sub); line-height:1}
.modal-body{padding:14px 16px; display:flex; flex-direction:column; gap:11px}
.modal-body label{display:flex; flex-direction:column; font-size:12px; color:var(--sub); gap:4px}
.modal-body input, .modal-body select{border:1px solid var(--line); border-radius:8px; padding:8px 10px; font-size:13px; color:var(--ink); font-family:inherit}
.modal-body input:focus, .modal-body select:focus{outline:none; border-color:var(--brand)}
.modal-body input:disabled{background:#f3f4f7; color:var(--sub); cursor:not-allowed}
.hint{font-size:11.5px; color:var(--sub); background:#f8f9fd; border-radius:8px; padding:8px 10px}
.modal-foot{display:flex; justify-content:flex-end; gap:8px; padding:12px 16px; border-top:1px solid var(--line)}

.foot{text-align:center; color:var(--sub); font-size:11px; padding:18px 14px 28px; max-width:900px; margin:0 auto; line-height:1.7}

/* ---------- 研究栏 ---------- */
.research-row{display:flex; gap:8px; padding:10px 14px 4px}
#researchInput{flex:1; border:1px solid var(--line); border-radius:9px; padding:8px 11px; font-size:13px; font-family:inherit; color:var(--ink)}
#researchInput:focus{outline:none; border-color:var(--brand)}
#researchHint{padding:2px 14px 12px; font-size:11.5px; color:var(--sub)}

/* ---------- 数据面板（资金/财务/选股）---------- */
.extra{border-top:1px solid var(--line); padding:10px 0 14px}
.tabs{display:flex; gap:6px; padding:0 14px 8px}
.tab{border:1px solid var(--line); background:#fff; color:var(--sub); padding:5px 13px; border-radius:8px; font-size:12.5px; cursor:pointer}
.tab.active{background:var(--brand); color:#fff; border-color:var(--brand)}
.extra-body{padding:0 14px}

.flow-summary{display:grid; grid-template-columns:repeat(5,1fr); gap:8px; margin-bottom:12px}
@media (max-width:900px){ .flow-summary{grid-template-columns:repeat(2,1fr)} }
.fs-item{background:#f8f9fd; border:1px solid var(--line); border-radius:9px; padding:8px 9px; text-align:center}
.fs-item .fv{font-size:15px; font-weight:800; margin-top:3px}
.fs-item .fsub{font-size:11px; color:var(--sub); margin-top:2px}
.flow-cap{font-size:11.5px; color:var(--sub); margin:4px 0 6px}
.flowbars{display:flex; flex-direction:column; gap:3px; max-height:280px; overflow-y:auto}
.flowbar-row{display:grid; grid-template-columns:46px 1fr 78px; align-items:center; gap:6px}
.flowbar-d{font-size:10.5px; color:var(--sub); text-align:right}
.flowbar-track{background:#f0f2f8; border-radius:4px; height:12px; overflow:hidden}
.flowbar-fill{height:100%; border-radius:4px; min-width:1px}
.flowbar-fill.up{background:var(--up)} .flowbar-fill.down{background:var(--down)}
.flowbar-v{font-size:11px; text-align:right; font-variant-numeric:tabular-nums}

.fin-cap{font-size:12px; font-weight:700; color:var(--ink); margin-bottom:6px}
.fin-table{width:100%; border-collapse:collapse; font-size:12px; font-variant-numeric:tabular-nums}
.fin-table th, .fin-table td{border-bottom:1px solid var(--line); padding:6px 8px; text-align:right}
.fin-table th{color:var(--sub); font-weight:600; background:#f8f9fd}
.fin-table td:first-child, .fin-table th:first-child{text-align:left}
.fin-table tr:hover{background:#f5f8ff}

.screen-ctrl{display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:10px}
.screen-ctrl label{font-size:12px; color:var(--sub); display:flex; align-items:center; gap:5px}
.screen-ctrl select{border:1px solid var(--line); border-radius:8px; padding:5px 8px; font-size:12px; font-family:inherit; color:var(--ink)}
.screen-cap{font-size:11.5px; color:var(--sub); margin:-2px 0 8px}
.scr-table tr[data-sym]{cursor:pointer}
.scr-table tr[data-sym]:hover{background:#eef1fb}

/* ---------- 云同步 ---------- */
.sync-block{margin:12px 0}
.sync-h{font-size:12px; font-weight:700; color:var(--ink); margin-bottom:6px}
.sync-row{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.sync-row input{flex:1; min-width:130px; border:1px solid var(--line); border-radius:9px; padding:8px 11px; font-size:13px; font-family:inherit; color:var(--ink); letter-spacing:1px; text-transform:uppercase}
.sync-row input:focus{outline:none; border-color:var(--brand)}
.sync-code{display:flex; align-items:center; gap:10px; background:#f0f6ff; border:1px solid #cfe0f7; border-radius:10px; padding:10px 12px; margin-bottom:8px}
.sync-code-l{font-size:12px; color:var(--sub)}
.sync-code b{font-size:19px; letter-spacing:3px; color:var(--brand); font-variant-numeric:tabular-nums}
.sync-code button{margin-left:auto}
.sync-meta{font-size:11.5px; color:var(--sub); margin-bottom:10px}
.sync-auto{display:flex; align-items:center; gap:6px; font-size:12px; color:var(--sub); margin-top:10px}
.sync-auto input{width:auto}
.sync-warn{margin:6px 0 0; padding:7px 9px; background:#fff7e6; border:1px solid #f0d9a8; border-radius:8px; color:#8a5a00; line-height:1.6}
.hint.ok{color:#0f7a45}
.hint.err{color:#b3261e}
