/* ============================================================
 * app.css —— 视觉样式
 * 只用系统字体与原生 CSS，不引外部依赖，离线可打开。
 * ============================================================ */
:root {
  --ink: #1B2430;
  --ink2: #3E4A58;
  --muted: #74818F;
  --faint: #97A2AE;
  --line: #E5EAF0;
  --line2: #EEF2F6;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --accent: #1F6FB2;
  --accent-soft: #EAF2F9;
  --warn: #C2410C;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 35, 55, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
b { font-weight: 600; }

/* ── 顶栏 ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 28px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 6px;
  height: 34px;
  border-radius: 3px;
  background: linear-gradient(180deg, #1F6FB2, #6FA8D0);
  flex: none;
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.pill {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #D6E6F4;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.btn {
  font-size: 12.5px;
  color: var(--ink2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #C9D6E2; color: var(--ink); background: #FBFCFE; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-icon { padding: 4px 9px; font-size: 12px; }

/* ── 筛选条 ──────────────────────────────────────────────── */
.filterbar {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 28px 9px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 5px 10px;
}

.fg { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.fg-label {
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .4px;
  margin-right: 2px;
}

.fg-opts { display: flex; flex-wrap: wrap; gap: 4px; }

.fopt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px 2px 6px;
  line-height: 1.55;
  transition: .14s;
  white-space: nowrap;
}

.fopt .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.fopt b { font-size: 11px; color: var(--faint); font-weight: 500; }
.fopt:hover { border-color: #C9D6E2; background: #FBFCFE; }

.fopt.is-on {
  background: #1B2430;
  border-color: #1B2430;
  color: #fff;
}

.fopt.is-on b { color: rgba(255, 255, 255, .7); }

.fg-sep { width: 1px; height: 16px; background: var(--line); }
.fg-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sum { font-size: 12px; color: var(--muted); }
.sum b { color: var(--ink); font-size: 13px; }

/* ── 主体与分区 ──────────────────────────────────────────── */
.wrap {
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 28px 0;
}

.view { margin-bottom: 26px; scroll-margin-top: 130px; }

.view-hd { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }

.vno {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #1B2430;
  color: #fff;
  font-size: 13px;
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.vt h2 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.vt p { font-size: 12.5px; color: var(--muted); margin-top: 2px; max-width: 900px; }

/* ── KPI ─────────────────────────────────────────────────── */
.kpi-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0 8px;
}

.kpi-head h4 { font-size: 13px; font-weight: 600; color: var(--ink2); }
.kpi-head span { font-size: 11.5px; color: var(--faint); font-weight: 400; }
.kpi-head p { font-size: 12px; color: var(--faint); margin-left: auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px 13px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #C7D6E4;
}

.kpi-card.tone-h::before { background: #009E73; }
.kpi-card.tone-s::before { background: #1F6FB2; }
.kpi-card.tone-a::before { background: #D1495B; }

.kpi-k { font-size: 12px; color: var(--muted); }
.kpi-v { font-size: 25px; font-weight: 700; line-height: 1.25; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi-s { font-size: 11.5px; color: var(--faint); margin-top: 1px; }

/* ── 卡片网格 ────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px 12px;
  box-shadow: var(--shadow);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-tt { display: flex; align-items: center; gap: 8px; min-width: 0; }

.cno {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 1px 6px;
  flex: none;
}

.card-tt h3 { font-size: 13.5px; font-weight: 700; letter-spacing: .1px; }

.tools { display: flex; align-items: center; gap: 5px; flex: none; }

.tool {
  font-size: 11.5px;
  color: var(--muted);
  background: #FAFBFC;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  transition: .14s;
}

.tool:hover { color: var(--accent); border-color: #C6DCEE; background: var(--accent-soft); }

.card-sub { font-size: 11.5px; color: var(--faint); margin: 3px 0 6px; }

/* 卡片内图例：卡片被单独截图或打印时仍然能读懂颜色 */
.card-lg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: flex-end;
  margin: -2px 0 2px;
  font-size: 11px;
  color: var(--muted);
  min-height: 16px;
}

.card-lg .lg { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.card-lg .lg i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.card-body { flex: 1; min-height: 0; }
.chart { width: 100%; }

.card-note {
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  margin-top: 8px;
  padding-top: 7px;
  line-height: 1.55;
}

.note-k {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 6px;
  font-size: 10.5px;
}

/* ── 数据表视图 ──────────────────────────────────────────── */
.card-tb { overflow: auto; max-height: 400px; }

.tb { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tb th, .tb td { border-bottom: 1px solid var(--line2); padding: 5px 7px; text-align: right; font-variant-numeric: tabular-nums; }
.tb thead th { position: sticky; top: 0; background: #F8FAFC; color: var(--muted); font-weight: 600; z-index: 1; }
.tb .tl { text-align: left; font-weight: 500; color: var(--ink2); }
.tb td.z { color: #D3DAE2; }
.tb td.b, .tb .tot td { font-weight: 600; }
.tb tr.tot td, .tb tr.tot th { background: #F8FAFC; }
.tb tbody tr:hover { background: #FBFCFE; }

/* ── 明细表 ──────────────────────────────────────────────── */
.rec-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--line2); border-radius: 10px; }

.rec { width: 100%; border-collapse: collapse; font-size: 12px; }
.rec th, .rec td { padding: 6px 10px; border-bottom: 1px solid var(--line2); text-align: left; white-space: nowrap; }
.rec thead th {
  position: sticky; top: 0; background: #F8FAFC; z-index: 2;
  font-size: 11.5px; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none;
}
.rec thead th:hover { color: var(--accent); }
.rec thead th.on { color: var(--accent); }
.rec tbody tr:hover { background: #F8FAFC; }
.rec .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: 1px; }
.rec tr.is-focus { background: #FFF8E6; box-shadow: inset 3px 0 0 #E9B949; }
.rec tr.pulse { animation: pulse 1.4s ease-out; }
.rec td.q { color: var(--warn); }
.rec .w1 { width: 52px; }
.rec .w2 { width: 92px; }
.rec .w3 { width: 180px; }

@keyframes pulse {
  0% { background: #FFEFC2; }
  100% { background: #FFF8E6; }
}

.rec-foot { font-size: 11.5px; color: var(--faint); padding: 6px 10px 2px; }

.tag { font-size: 11px; padding: 0 6px; border-radius: 4px; }
.tag-b { background: #EDF4F9; color: #2F6E96; }
.tag-r { background: #FDECEA; color: #B02A20; }
.tag-m { background: #F2F4F6; color: #7B8794; }

.search {
  font-size: 11.5px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  width: 220px;
  color: var(--ink2);
}

.search:focus { outline: none; border-color: #B9D3E8; }
.empty { color: var(--faint); font-size: 12px; padding: 16px; text-align: center; }

/* ── 页脚 ────────────────────────────────────────────────── */
.footer {
  margin-top: 10px;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 24px 0 30px;
}

.foot-grid {
  max-width: 1500px;
  margin: 0 auto 18px;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 26px;
}

.foot-col h3 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: .3px;
}

.foot-col h3.mt { margin-top: 16px; }
.foot-sub, .foot-p { font-size: 11.5px; color: var(--faint); margin-bottom: 8px; }

.finding { border-left: 2px solid #DDE6EE; padding: 0 0 0 10px; margin-bottom: 10px; }
.f-no { font-size: 10.5px; color: var(--accent); letter-spacing: .5px; }
.f-head { font-size: 12.5px; font-weight: 700; margin: 1px 0 2px; }
.f-body { font-size: 11.5px; color: var(--ink2); line-height: 1.65; }

.ints { margin: 0; font-size: 11.5px; }
.ints dt { font-weight: 600; color: var(--ink2); margin-top: 7px; }
.ints dd { margin: 1px 0 0; color: var(--muted); line-height: 1.55; }

.limits { margin: 0; padding-left: 16px; font-size: 11.5px; color: var(--muted); }
.limits li { margin-bottom: 5px; line-height: 1.55; }

.foot-full { grid-column: 1 / -1; }
.dict-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--line2); border-radius: 10px; }
.dict td, .dict th { text-align: left; }
.dict td:nth-child(2) { width: 110px; color: var(--muted); }

.copyright {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 28px 0;
  border-top: 1px solid var(--line2);
  font-size: 11px;
  color: var(--faint);
}

/* ── 配置抽屉 ────────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 392px;
  max-width: 92vw;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(20, 35, 55, .12);
  transform: translateX(102%);
  transition: transform .24s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer.on { transform: translateX(0); }

.drawer-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line2);
}

.drawer-hd h2 { font-size: 14px; font-weight: 700; }
.drawer-lead { font-size: 11.5px; color: var(--muted); padding: 10px 18px 0; line-height: 1.6; }
.drawer-lead code { background: #F4F6F9; padding: 0 4px; border-radius: 3px; font-size: 11px; }
.drawer-body { padding: 8px 18px 22px; overflow: auto; }

.drawer-sec { padding: 12px 0; border-bottom: 1px dashed var(--line2); }
.drawer-sec:last-child { border-bottom: none; }
.drawer-sec h4 { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; }
.sec-p { font-size: 11px; color: var(--faint); margin-bottom: 8px; line-height: 1.55; }

.opt-row { display: flex; gap: 6px; flex-wrap: wrap; }
.opt-col { display: flex; flex-direction: column; gap: 6px; }

.opt {
  text-align: left;
  font-size: 12px;
  color: var(--ink2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  transition: .14s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.opt:hover { border-color: #C6DCEE; }
.opt[aria-pressed="true"] { background: #1B2430; border-color: #1B2430; color: #fff; }
.opt-line { justify-content: center; min-width: 66px; }

.opt-t { font-size: 12px; }
.sw-row { display: flex; gap: 3px; }
.sw-row i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

.sel {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink2);
  background: #fff;
}

.cfg {
  margin: 8px 0 0;
  padding: 10px;
  background: #F7F9FB;
  border: 1px solid var(--line2);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  color: #43536B;
  max-height: 220px;
  overflow: auto;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
}

.mask { position: fixed; inset: 0; background: rgba(18, 28, 40, .28); z-index: 40; }

/* ── 提示 ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1B2430;
  color: #fff;
  font-size: 12.5px;
  padding: 8px 16px;
  border-radius: 999px;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(20, 35, 55, .25);
}

/* ── ECharts 提示框内部样式（tooltip 走 DOM，需全局声明）── */
.tip { font-size: 12px; line-height: 1.6; min-width: 132px; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; }
.tip-k { color: #74818F; }
.tip-v { color: #1B2430; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-note { color: #97A2AE; font-size: 11px; display: block; margin-top: 2px; }
.tip-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: 1px; }

/* ── 响应式 ──────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .span-5, .span-6, .span-7 { grid-column: span 12; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .foot-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar-inner, .filterbar, .wrap, .foot-grid, .copyright { padding-left: 14px; padding-right: 14px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .brand-text h1 { font-size: 16px; }
  .topbar-tools .pill, .topbar-tools #btn-data { display: none; }
}

/* ── 打印 / 截图 ─────────────────────────────────────────── */
@media print {
  .topbar { position: static; }
  .topbar-tools, .tools, .drawer, .mask, .toast { display: none !important; }
  body { background: #fff; }
  .card, .kpi-card { break-inside: avoid; box-shadow: none; }
}
