/* 聚展 AI 控制台 · 只用浅色（产品统一浅色，不加深色模式） */
:root {
  --page: #f3f5f8; --surface: #ffffff; --raise: #f8fafc;
  --ink: #17202c; --ink-2: #47515e; --muted: #66707c;
  --line: #e2e7ed; --grid: #e8ecf1; --axis: #c3cbd4;
  --steel: #1b2d3b; --steel-2: #24394a; --steel-ink: #c9d5df; --steel-mute: #8ba0b1;
  --accent: #b5561a; --accent-soft: #fbf1ea;
  --s1: #2a78d6; --s2: #eb6834;
  --crit: #d03b3b; --serious: #ec835a; --warn: #fab219; --info: #7b8794; --good: #006300;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.55 "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--page); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- 框架 ---------- */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--steel); color: var(--steel-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand b { display: block; color: #fff; font-size: 16px; letter-spacing: .02em; }
.brand span { font-size: 12px; color: var(--steel-mute); }
.nav { padding: 8px 0 16px; }
.nav h6 { margin: 16px 20px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--steel-mute); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 20px 8px 17px; color: var(--steel-ink);
  text-decoration: none; border-left: 3px solid transparent; font-size: 14px; }
.nav a:hover { background: var(--steel-2); color: #fff; }
.nav a.on { background: var(--steel-2); color: #fff; border-left-color: #e08a4a; font-weight: 600; }
.nav a svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav .badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px;
  line-height: 18px; text-align: center; background: var(--crit); color: #fff; font-weight: 600; }
.nav .ext { margin-left: auto; font-size: 11px; color: var(--steel-mute); }
.side-foot { margin-top: auto; padding: 14px 20px; font-size: 12px; color: var(--steel-mute);
  border-top: 1px solid rgba(255,255,255,.07); }
.side-foot b { color: var(--steel-ink); font-weight: 600; }
.side-foot .who { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.07); color: var(--steel-ink); }
.side-foot .who a { color: var(--steel-mute); }
.side-foot .who a:hover { color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; background: rgba(243,245,248,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 14px 28px 12px; }
.title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.title-row h1 { margin: 0; font-size: 20px; font-weight: 700; }
.title-row .sub { color: var(--muted); font-size: 13px; }
.title-row .data-tag { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.pill.sample { background: #fff7e6; border-color: #f2d7a4; color: #7a5208; font-weight: 600; }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #0ca30c; }
.filters { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.seg button:hover { background: var(--raise); }
.seg button.on { background: var(--steel); color: #fff; }
.range-txt { font-size: 13px; color: var(--muted); }
.range-txt input { border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; background: var(--surface); }
.content { padding: 20px 28px 48px; transition: opacity .15s; }
.content.loading { opacity: .55; pointer-events: none; }

/* ---------- 卡片与网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; min-width: 0; }
.wide { grid-column: 1 / -1; }
.card-h { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-h .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-h .tools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 2px 9px;
  font-size: 12px; cursor: pointer; color: var(--ink-2); }
.mini:hover { border-color: var(--axis); }
.mini.on { background: var(--raise); color: var(--ink); border-color: var(--axis); font-weight: 600; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.src { font-size: 11px; color: var(--muted); margin-top: 8px; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; font-size: 13px; }

/* ---------- 关键数字 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; }
.stat { padding: 4px 16px 4px 0; border-right: 1px solid var(--line); margin-right: 16px; }
.stat:last-child { border-right: 0; margin-right: 0; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 600; line-height: 1.25; margin-top: 4px; white-space: nowrap; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-left: 3px; }
.stat .d { font-size: 12px; margin-top: 2px; color: var(--muted); }
.stat .d b { font-weight: 600; }
.stat .d .up-good, .stat .d .down-good { color: var(--good); }
.stat .d .up-bad, .stat .d .down-bad { color: var(--crit); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: var(--raise); color: var(--ink-2); font-weight: 600; font-size: 12px;
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.t { max-width: 280px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f6f9fc; }
.neg { color: var(--crit); }

/* ---------- 图表 ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axisline { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart text.val { fill: var(--ink-2); font-size: 11px; }
.chart text.cat { fill: var(--ink-2); font-size: 12px; }
.chart .hit { fill: transparent; cursor: default; }
.chart g:hover .bar { filter: brightness(1.12); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin: 0 0 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(16,24,40,.12); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 120px; display: none; }
.tip .tl { color: var(--muted); margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .row i { width: 12px; height: 3px; border-radius: 2px; }
.tip .row b { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tip .row span { color: var(--muted); }

/* ---------- 提醒 ---------- */
.lv { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px 1px 6px;
  border-radius: 999px; white-space: nowrap; }
.lv svg { width: 14px; height: 14px; }
.lv.critical { background: #fbeaea; color: #a32626; }
.lv.serious { background: #fdf0ea; color: #9a4518; }
.lv.warning { background: #fff6e0; color: #7a5208; }
.lv.info { background: #eef1f4; color: #47515e; }
.alist { display: flex; flex-direction: column; }
.arow { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--grid); cursor: pointer; }
.arow:last-child { border-bottom: 0; }
.arow:hover { background: var(--raise); }
.arow .at { flex: 1; min-width: 0; }
.arow .at b { font-weight: 600; }
.arow .at div { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow .cnt { font-size: 20px; font-weight: 600; min-width: 48px; text-align: right; }
.arow .cnt small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.acard { border-left: 3px solid var(--line); }
.acard.critical { border-left-color: var(--crit); }
.acard.serious { border-left-color: var(--serious); }
.acard.warning { border-left-color: var(--warn); }
.acard .rule { font-size: 13px; color: var(--ink-2); margin: 2px 0 10px; }
.ok-line { color: var(--good); font-size: 13px; padding: 4px 0; }

/* ---------- 待接入 ---------- */
.pend { background: var(--raise); border: 1px dashed var(--axis); border-radius: var(--radius); padding: 16px 18px; }
.pend h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.pend p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.pend .need { font-size: 12px; color: var(--muted); margin-top: 8px; }
.tag-pend { font-size: 11px; font-weight: 600; color: #47515e; background: #e6eaef; border-radius: 999px; padding: 1px 8px; }

/* ---------- AI 定制分析 ---------- */
.ask-box textarea { width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: var(--surface); }
.ask-box textarea:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px rgba(42,120,214,.12); }
.ask-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 20px; cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--raise); border-radius: 999px; padding: 3px 11px; font-size: 12px;
  cursor: pointer; color: var(--ink-2); }
.chip:hover { border-color: var(--axis); color: var(--ink); }
.lock { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: flex-start; }
.lock svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.explain { background: var(--raise); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
pre.sql { background: #0f1b26; color: #d6e2ec; border-radius: 8px; padding: 12px; font-size: 12px; white-space: pre-wrap;
  word-break: break-all; margin: 10px 0 0; max-height: 300px; overflow: auto; }
.err { background: #fbeaea; color: #8f2020; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--s1);
  border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,27,38,.45); z-index: 40; display: none; align-items: flex-start;
  justify-content: center; padding: 6vh 16px; }
.modal.on { display: flex; }
.modal .box { background: var(--surface); border-radius: 12px; width: min(1000px, 100%); max-height: 86vh; overflow: auto;
  padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .box h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; }
.modal .box h3 button { margin-left: auto; }
.drill-h { margin: 18px 0 6px; font-size: 14px; color: var(--ink); }

@media (max-width: 1100px) { .grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; padding: 6px 8px; }
  .nav h6 { display: none; }
  .nav a { border-left: 0; padding: 6px 10px; border-radius: 6px; }
  .side-foot { display: none; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .stat { border-right: 0; margin-right: 0; padding-bottom: 10px; }
}

/* ---------- 五个问题 ---------- */
.qgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.qcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--raise);
  display: flex; flex-direction: column; gap: 6px; }
.qcard .qh { display: flex; gap: 8px; align-items: flex-start; }
.qcard .qn { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--steel); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.qcard .qq { font-size: 13px; color: var(--ink-2); flex: 1; }
.qcard .qa { font-size: 17px; font-weight: 700; line-height: 1.4; }
.qcard ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.qcard .qf { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-top: auto; }
.qcard .qf a { margin-left: auto; color: var(--accent); text-decoration: none; font-size: 12px; cursor: pointer; }
.st { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.st.answered { background: #e7f4e7; color: #1d5e1d; }
.st.partial { background: #fff6e0; color: #7a5208; }
.st.missing { background: #eef1f4; color: #47515e; }

/* ---------- AI 每日分析 ---------- */
.brief .sum { font-size: 15px; font-weight: 600; margin: 2px 0 12px; }
.bcols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.bcol h4 { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.bcol h4 i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.bitem { border-top: 1px solid var(--grid); padding: 8px 0; }
.bitem b { display: block; font-size: 13.5px; }
.bitem p { margin: 3px 0 5px; font-size: 13px; color: var(--ink-2); }
.refs { display: flex; flex-wrap: wrap; gap: 4px; }
.ref { font-size: 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 1px 6px;
  color: var(--ink-2); cursor: pointer; }
.ref:hover { border-color: var(--axis); color: var(--ink); }
.bnone { font-size: 13px; color: var(--muted); padding: 8px 0; }
@media (max-width: 1100px) { .bcols { grid-template-columns: 1fr; } }
