:root {
  --bg: #f5f7fa; --panel: #ffffff; --ink: #1f2937; --muted: #6b7280;
  --line: #e5e7eb; --brand: #c0202e; --brand2: #b45309; --accent: #2563eb;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #0891b2;
  --s: #dc2626; --a: #ea580c; --b: #ca8a04; --obs: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #fca5a533; border-color: var(--brand); }

/* 登录 */
#login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#7f1d1d11,#1e3a8a11); }
.login-card { width: 360px; background: var(--panel); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); }
.login-card input { width: 100%; }
.btn-primary { width: 100%; margin-top: 20px; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 11px; font-weight: 600; }
.btn-primary:hover { background: #a31622; }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* 布局 */
#app-view { display: none; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; position: sticky; top: 0; z-index: 10; }
.topbar .logo { font-weight: 700; font-size: 16px; color: var(--brand); margin-right: 28px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a.active { background: #fde8ea; color: var(--brand); }
.nav a:hover { color: var(--brand); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.userbox button { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--ink); }
.content { padding: 22px; max-width: 1280px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.learn-strip { display:flex; align-items:center; gap:14px; background:var(--panel); border:1px solid var(--line); border-left:4px solid var(--brand); border-radius:12px; padding:12px 16px; margin-bottom:16px; box-shadow:var(--shadow); }
.learn-badge { flex:none; font-size:12px; font-weight:700; color:#fff; background:var(--brand); border-radius:8px; padding:5px 9px; white-space:nowrap; }
.learn-main { flex:1; min-width:0; }
.learn-t { font-size:13px; color:var(--muted); font-weight:600; }
.learn-s { font-size:14px; margin-top:3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.learn-meta { flex:none; display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.learn-status { font-size:12px; font-weight:600; padding:2px 9px; border-radius:999px; white-space:nowrap; }
.st-new { background:#fff7ed; color:var(--warn); }
.st-read { background:#eff6ff; color:var(--info); }
.st-done { background:#f0fdf4; color:var(--ok); }
@media (max-width:600px){
  .learn-strip{ flex-wrap:wrap; gap:10px; }
  .learn-s{ white-space:normal; }
  .learn-meta{ flex-direction:row; align-items:center; flex-basis:100%; justify-content:flex-end; }
}

/* 概览「目标配比」条：宏观环境 → 配置目标，一眼可见 */
.target-strip { display:flex; flex-wrap:wrap; gap:10px; margin-top:14px; }
.tp { flex:1; min-width:96px; background:#f8fafc; border:1px solid var(--line); border-radius:10px; padding:9px 11px; }
.tp-off { border-color:#fecaca; background:#fff5f5; }
.tp-n { font-size:12px; color:var(--muted); font-weight:600; }
.tp-t { font-size:15px; font-weight:700; margin-top:2px; }
.tp-c { font-size:12px; color:#374151; margin-top:1px; }
.tp-d { font-weight:700; margin-left:4px; }
.tp-d.up { color:var(--bad); }
.tp-d.dn { color:var(--ok); }
@media (max-width:600px){ .tp{ min-width:calc(50% - 5px); } }

/* 年金领取卡片：确定性长期现金流，单独列示不混进可调仓桶 */
.ann-card { border-left:3px solid var(--ok); }
.an-row {
  display:flex; gap:12px; align-items:center; flex-wrap:wrap;
  padding:9px 0; border-top:1px solid var(--line);
}
.an-row:first-child { border-top:none; }
.an-l { flex:1; min-width:200px; display:flex; flex-direction:column; }
.an-l .muted { font-size:11.5px; margin-top:1px; }
.an-v { font-size:13px; color:var(--ink); white-space:nowrap; }
.an-p { font-size:12px; color:var(--muted); min-width:130px; text-align:right; }
@media (max-width:600px){ .an-p{ text-align:left; } }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 900px){ .grid2,.grid3{ grid-template-columns:1fr; } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); margin-top: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
tbody tr:hover { background: #fafafa; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.g-S { background:#fee2e2; color:#b91c1c; } .g-A{ background:#ffedd5; color:#c2410c; } .g-B{ background:#fef9c3; color:#a16207; } .g-观察{ background:#f1f5f9; color:#475569; } .g-风险{ background:#fecaca; color:#991b1b; } .g-数据不足{ background:#f1f5f9; color:#94a3b8; }
.pill-ok{ background:#dcfce7;color:#15803d;} .pill-off{ background:#f1f5f9;color:#94a3b8;}
.btn-sm { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.btn-sm.danger { color: var(--bad); border-color: #fecaca; }
.btn-sm.primary { background: var(--brand); color: #fff; border: 0; }
.btn { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 500; }
.btn.primary { background: var(--brand); color: #fff; border: 0; }
.muted { color: var(--muted); }
.bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: 0; padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.modal-bg { position: fixed; inset: 0; background: #0006; display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 540px; max-width: 92vw; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.flex { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.note { background:#fffbeb; border:1px solid #fde68a; color:#92400e; padding:10px 14px; border-radius:10px; font-size:13px; margin-bottom:14px;}
.pos { color: #dc2626; } .neg { color: #16a34a; } /* 遵循国内惯例：涨/盈为红，跌/亏为绿 */
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.advice { white-space: pre-wrap; line-height: 1.7; background:#f8fafc; border:1px solid var(--line); border-radius:10px; padding:14px; }

/* 资产体检 */
.score-ring { width:112px; height:112px; border-radius:50%; position:relative; display:grid; place-items:center;
  background: conic-gradient(var(--ring) calc(var(--v) * 1%), #eef2f7 0); flex: 0 0 auto; }
.score-ring::after { content:''; position:absolute; inset:10px; border-radius:50%; background: var(--panel); }
.score-ring .sv { position:relative; font-size:30px; font-weight:800; line-height:1; }
.score-ring .sg { position:relative; font-size:12px; color:var(--muted); margin-top:2px; }
.dimrow { display:flex; align-items:center; gap:10px; margin:9px 0; font-size:13px; }
.dimrow .dn { width:64px; color:var(--muted); flex:0 0 auto; }
.dimrow .dbar { flex:1; height:9px; background:#eef2f7; border-radius:999px; overflow:hidden; min-width:60px; }
.dimrow .dbar > i { display:block; height:100%; border-radius:999px; background:linear-gradient(90deg,#c0202e,#e2555f); }
.dimrow .dv { width:52px; text-align:right; font-weight:700; flex:0 0 auto; }
.dimrow .dd { display:none; }
.mixrow { display:flex; align-items:center; gap:10px; margin:8px 0; font-size:13px; }
.mixrow .mn { width:44px; color:var(--muted); flex:0 0 auto; }
.mixbar { position:relative; flex:1; height:16px; background:#eef2f7; border-radius:8px; min-width:100px; }
.mixbar > i { position:absolute; left:0; top:0; bottom:0; border-radius:8px; background:linear-gradient(90deg,#2563eb,#60a5fa); }
.mixbar > b { position:absolute; top:-3px; bottom:-3px; width:2px; background:#b45309; }
.mixrow .mv { width:120px; text-align:right; flex:0 0 auto; }
.pri { display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; font-weight:700; }
.pri-高 { background:#fee2e2; color:#b91c1c; } .pri-中 { background:#fef3c7; color:#a16207; } .pri-低 { background:#f1f5f9; color:#64748b; }

/* 财经要闻 */
.news-row { display:flex; gap:12px; padding:11px 2px; border-bottom:1px solid var(--line); }
.news-row:last-child { border-bottom:0; }
.news-score { width:34px; height:34px; border-radius:9px; display:grid; place-items:center; font-weight:800; font-size:14px; flex:0 0 auto; }
.ns-1 { background:#fee2e2; color:#b91c1c; }
.ns-2 { background:#ffedd5; color:#c2410c; }
.ns-3 { background:#fef9c3; color:#a16207; }
.ns-4 { background:#f1f5f9; color:#64748b; }
.news-main { flex:1; min-width:0; }
.news-title { font-weight:600; font-size:14px; line-height:1.5; color:var(--ink); display:block; }
a.news-title:hover { color:var(--brand); }
.news-meta { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-top:4px; font-size:12px; color:var(--muted); }
.news-meta .nsrc { color:var(--accent); }
.ntag { background:#f1f5f9; color:#475569; border-radius:6px; padding:1px 6px; font-size:11px; }
.ntag.mine { background:#dcfce7; color:#15803d; font-weight:600; }
.ntag.scope { background:#e0e7ff; color:#3730a3; }
.news-why { margin-top:4px; font-size:12.5px; color:#374151; background:#f8fafc; border-left:3px solid var(--brand); padding:4px 8px; border-radius:0 6px 6px 0; }
.digest { background:linear-gradient(90deg,#fef2f2,#fff7ed); border:1px solid #fde68a; border-radius:10px; padding:10px 14px; font-size:13px; line-height:1.7; margin:6px 0 8px; }
.nw-filters { flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.btn-sm.on { background:var(--brand); color:#fff; border-color:var(--brand); }

/* ---------- 概览四宫格与告警条 ---------- */
.grid4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }
/* 告警条：黄底但按严重度分色，红色是「已经错了」，绿色不用（无告警时不显示这一块） */
.alertbar { background:#fff; border:1px solid var(--line); border-left:4px solid var(--warn); border-radius:12px; padding:10px 14px; margin-bottom:16px; box-shadow:var(--shadow); }
.alertline { display:flex; gap:10px; align-items:baseline; flex-wrap:wrap; padding:5px 0; font-size:13px; line-height:1.6; border-bottom:1px dashed var(--line); }
.alertline:last-child { border-bottom:0; }
.alertline b { font-weight:700; }
.alertline span { color:#374151; flex:1; min-width:200px; }
.alertline a { white-space:nowrap; font-weight:600; }
.alertline.lv-error b { color:var(--bad); }
.alertline.lv-warn b { color:var(--warn); }
.alertline.lv-info b { color:var(--info); }

/* ---------- 迷你柱状图（按月已实现） ---------- */
.minibars { display:flex; align-items:flex-end; gap:5px; height:56px; }
.minibars .mb { display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:2px; min-width:22px; }
.minibars .mb i { display:block; width:11px; border-radius:3px 3px 0 0; }
.minibars .mb i.up { background:#dc2626; }     /* 盈利=红（国内惯例） */
.minibars .mb i.down { background:#16a34a; }   /* 亏损=绿 */
.minibars .mb span { font-size:9.5px; color:var(--muted); white-space:nowrap; }

/* ---------- 收支双条（上=收入 下=支出） ---------- */
.dualbar { position:relative; height:16px; min-width:70px; }
.dualbar .in { position:absolute; left:0; top:0; height:7px; background:#16a34a99; border-radius:4px; }
.dualbar .out { position:absolute; left:0; top:9px; height:7px; background:#dc262699; border-radius:4px; }

/* 已完成的调仓行压暗，但保留可读性（不做 line-through，金额还要看） */
tbody tr.row-done { background:#f8fafc; }
tbody tr.row-done td { color:#94a3b8; }

/* ---------- 硬约束行 ---------- */
.consrow { display:grid; grid-template-columns:96px 190px 1fr; gap:10px; align-items:start; padding:9px 10px; border-radius:9px; margin-bottom:7px; border-left:3px solid var(--line); background:#fafafa; }
.consrow.ok { border-left-color: var(--ok); background:#f0fdf4; }
.consrow.warn { border-left-color: var(--warn); background:#fffbeb; }
.consrow.block { border-left-color: var(--bad); background:#fef2f2; }
.consrow .cn { font-weight:600; font-size:13px; }
.consrow .cv { font-size:13px; font-weight:600; }
.consrow .cd { font-size:12px; line-height:1.6; }

@media (max-width: 760px) {
  .consrow { grid-template-columns:1fr; gap:3px; }
}

/* ---------- 平板 ---------- */
@media (max-width: 1180px) {
  .grid4 { grid-template-columns:repeat(2,1fr); }
}

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
  body { font-size:14px; }
  /* 顶栏换成两行：第一行 logo+用户，第二行可横向滚动的导航 */
  .topbar { height:auto; flex-wrap:wrap; padding:8px 12px; gap:6px; }
  .topbar .logo { font-size:14.5px; margin-right:auto; }
  .userbox { font-size:12px; gap:6px; }
  .userbox #user-name { max-width:110px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .nav { order:3; width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:2px; scrollbar-width:none; }
  .nav::-webkit-scrollbar { display:none; }
  .nav a { padding:7px 11px; font-size:13px; white-space:nowrap; }
  .content { padding:12px; }
  .grid2, .grid3, .grid4 { grid-template-columns:1fr; }
  .card { padding:14px; border-radius:12px; margin-bottom:12px; }
  .card h2 { font-size:15px; }
  .kpi { padding:12px; }
  .kpi .v { font-size:19px; }
  .kpi .l { font-size:12px; }
  .modal { width:100%; max-width:100vw; max-height:92vh; border-radius:14px 14px 0 0; position:fixed; bottom:0; left:0; }
  .modal-bg.show { align-items:flex-end; }
  .modal-actions .btn, .modal-actions .btn.primary { flex:1; }
  /* 横向滚动的表：在窄屏上给一点惯性滚动提示 */
  .card > div[style*="overflow:auto"], .card > div[style*="overflow: auto"] { -webkit-overflow-scrolling:touch; }
  table { font-size:12.5px; }
  th, td { padding:7px 8px; white-space:nowrap; }
  .dimrow .dn { width:56px; }
  .mixrow .mn { width:34px; }
  .mixrow .mv { width:104px; }
  .news-score { width:30px; height:30px; font-size:13px; }
  .login-card { width:100%; max-width:420px; margin:0 14px; padding:24px; }
  .alertline span { min-width:100%; }
}

