/* NIW 获批大盘 —— 手写轻量 CSS（无构建、无 Tailwind 运行时）。
   颜色全部是 :root 上的 token，暗色在 prefers-color-scheme 下重定义；ECharts 通过 getComputedStyle 读取同一组 token。 */

:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2de;
  --grid: #ebeae6;
  --axis: #c9c8c2;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --other: #b4b3ad;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e4effc;
  --mark-bg: #fff1b8;
  --mark-ink: #3d2e00;
  --good: #0ca30c;
  --warn: #d97a00;
  --critical: #d03b3b;
  --pp: #eb6834;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 12px;
  --gutter: 16px;
  --topbar-h: auto;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151514;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --grid: #2a2a28;
    --axis: #4a4a46;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #8f8e86;
    --other: #6b6a64;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #1b2a3d;
    --mark-bg: #5c4a00;
    --mark-ink: #fff3c4;
    --warn: #fab219;
    --critical: #e66767;
    --pp: #d95926;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151514; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c; --grid: #2a2a28; --axis: #4a4a46;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86; --other: #6b6a64; --accent: #3987e5; --accent-ink: #86b6ef;
  --accent-soft: #1b2a3d; --mark-bg: #5c4a00; --mark-ink: #fff3c4; --warn: #fab219; --critical: #e66767; --pp: #d95926;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--text-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pad { padding: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner, .tabs, main { max-width: 1440px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.topbar-inner { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: .01em; }

.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--other); }
.conn[data-state="sse"] .conn-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); animation: pulse 2.4s ease-in-out infinite; }
.conn[data-state="poll"] .conn-dot { background: var(--warn); }
.conn[data-state="offline"] .conn-dot { background: var(--critical); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .conn-dot { animation: none !important; } }

.stats { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; flex: 1; justify-content: flex-end; }
.stat { display: flex; flex-direction: column; min-width: 56px; position: relative; }
.stat dt { font-size: 11px; color: var(--text-3); }
.stat dd { margin: 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-time dd { font-size: 13px; font-weight: 500; color: var(--text-2); line-height: 1.8; }
.stat.is-alert dd { color: var(--critical); }
.stat.is-alert dt::before { content: "⚠ "; color: var(--critical); }
.progress { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }

.tabs { display: flex; gap: 4px; }
.tabs button {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 10px 14px; font-size: 14px; color: var(--text-2); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 650; }
.tabs button:hover { color: var(--text); }

main { padding-top: 16px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 36px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.icon-btn { appearance: none; border: 0; background: none; cursor: pointer; width: 40px; height: 40px; border-radius: 8px; font-size: 16px; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
.count { color: var(--accent-ink); font-weight: 650; }

select, input[type="date"], input[type="number"], input[type="search"] {
  min-height: 36px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 100%; min-width: 0;
}
select { padding-right: 28px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: 12px; color: var(--text-2); padding: 0; margin-bottom: 4px; }
.inline-select { flex-direction: row; align-items: center; }
.inline-select select { width: auto; }

/* ---------- 分析：筛选栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-height: 0; }
.n-summary { margin: 0; color: var(--text-2); font-size: 13px; }
.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filterbar > label { width: 170px; }
.filter-actions { display: flex; gap: 8px; }
.drawer-head, .drawer-toggle, .drawer-done { display: none; }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.section-title { font-size: 15px; font-weight: 650; margin-top: 8px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 14px 10px; box-shadow: var(--shadow); min-width: 0;
}
.card header { margin-bottom: 6px; }
.card h3 { font-size: 14px; font-weight: 650; }
.card .sub { margin: 2px 0 0; font-size: 12px; color: var(--text-3); min-height: 18px; }
.card .sub b { color: var(--text); font-weight: 650; }
.card-head-row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.chart { width: 100%; height: 300px; }
.chart-sm { height: 260px; }
.chart-tall { height: 420px; }
.chart-xl { height: 640px; }
.empty-state {
  display: none; position: absolute; inset: 64px 14px 14px; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 13px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface);
}
.card.is-empty .empty-state { display: flex; }
.card.is-empty .chart { visibility: hidden; }
#view-analysis.is-loading .grid { opacity: .55; transition: opacity .2s; }

/* ---------- 案例检索 ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search { flex: 1; position: relative; flex-direction: row; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { min-height: 44px; padding-left: 36px; font-size: 15px; border-radius: 10px; }

.cases-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.filters {
  display: flex; flex-direction: column; gap: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: sticky; top: 130px;
  max-height: calc(100vh - 150px); overflow: auto;
}
.range { display: flex; align-items: center; gap: 6px; }
.range span { color: var(--text-3); font-size: 12px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; flex-direction: row; gap: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { flex: 1; text-align: center; padding: 7px 0; font-size: 13px; color: var(--text-2); }
.seg label + label span { border-left: 1px solid var(--border); }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.results { min-width: 0; }
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.results-bar .total { margin: 0; color: var(--text-2); }
.results-bar .total b { color: var(--text); }
.results-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--grid); }
th { font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
th.num { text-align: right; }
table.cases tbody tr { cursor: pointer; }
table.cases tbody tr:hover { background: var(--surface-2); }
table.cases tbody tr:last-child td { border-bottom: 0; }
.c-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-2); }
.c-main { min-width: 260px; max-width: 520px; }
.c-subject { font-weight: 600; }
.c-pos { color: var(--text-2); font-size: 12px; }
.snippet, .summary { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: var(--mark-bg); color: var(--mark-ink); border-radius: 3px; padding: 0 2px; }
.c-badges { white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); margin: 0 4px 2px 0; }
.badge-pp { color: var(--pp); background: color-mix(in srgb, var(--pp) 14%, transparent); }
.badge-rfe { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.list-empty, .list-loading { padding: 40px 16px; text-align: center; color: var(--text-3); }
.list-loading { position: absolute; inset: 0; background: color-mix(in srgb, var(--surface) 70%, transparent); padding-top: 60px; }

.pager { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.pg { min-width: 40px; min-height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-variant-numeric: tabular-nums; }
.pg:hover:not(:disabled) { background: var(--surface-2); }
.pg.is-current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
.pg:disabled { opacity: .4; cursor: default; }
.pg-gap { align-self: center; color: var(--text-3); padding: 0 4px; }

/* ---------- 详情弹窗 ---------- */
dialog#detail {
  width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); overflow: hidden;
}
dialog#detail[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.d-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 18px; border-bottom: 1px solid var(--border); font-size: 12px; }
.d-body { overflow: auto; padding: 18px; overscroll-behavior: contain; }
.d-head { margin-bottom: 12px; }
.d-head h2 { font-size: 18px; margin: 6px 0 2px; }
.d-head p { margin: 0 0 10px; }
.d-group { margin-top: 18px; }
.d-group h3 { font-size: 13px; color: var(--text-3); font-weight: 600; letter-spacing: .04em; padding-bottom: 6px; border-bottom: 1px solid var(--grid); margin-bottom: 8px; }
.d-group dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.kv { min-width: 0; }
.kv-wide { grid-column: 1 / -1; }
.kv dt { font-size: 11.5px; color: var(--text-3); }
.kv dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.kv .null { color: var(--text-3); }
.prose { margin: 0; white-space: pre-wrap; }
.d-raw { margin-top: 18px; }
.d-raw summary { cursor: pointer; color: var(--text-2); min-height: 32px; }
.d-raw pre { white-space: pre-wrap; font-size: 12.5px; background: var(--surface-2); padding: 12px; border-radius: 8px; max-height: 50vh; overflow: auto; }

/* ---------- 成本 ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi-k { font-size: 12px; color: var(--text-3); }
.kpi-v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-n { font-size: 11px; color: var(--text-3); }
table.plain td, table.plain th { font-size: 13px; white-space: nowrap; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 60; }

/* ---------- 中等宽度 ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { justify-content: flex-start; }
}

/* ---------- 窄屏（<768px）：抽屉筛选、卡片列表、全屏详情 ---------- */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .topbar-inner { gap: 6px; padding-top: 8px; }
  .brand { width: 100%; justify-content: space-between; }
  .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 8px; width: 100%; }
  .stat dd { font-size: 16px; }
  .stat-time { grid-column: span 2; }
  .stat-time dd { font-size: 12px; line-height: 1.6; }
  .tabs { justify-content: stretch; }
  .tabs button { flex: 1; }

  .trio { grid-template-columns: minmax(0, 1fr); }
  .chart { height: 280px; }
  .chart-tall { height: 380px; }
  .chart-xl { height: 600px; }
  .card { padding: 12px 10px 8px; }

  .drawer-toggle { display: inline-flex; min-height: 44px; }
  .drawer {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; top: auto;
    max-height: 85vh; overflow: auto; margin: 0;
    background: var(--surface); border-radius: 16px 16px 0 0; border: 0;
    padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; align-items: stretch; gap: 14px;
    transform: translateY(105%); transition: transform .25s ease; visibility: hidden;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .25);
  }
  .drawer.is-open { transform: none; visibility: visible; }
  .drawer > label { width: 100%; }
  .drawer-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--surface); padding: 8px 0; z-index: 1; }
  .drawer-head h2 { font-size: 16px; }
  .drawer-done { display: inline-flex; flex: 1; }
  .filter-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
  .filter-actions .btn { min-height: 44px; flex: 1; }
  select, input[type="date"], input[type="number"] { min-height: 44px; font-size: 16px; } /* 16px 防 iOS 聚焦缩放 */
  .search input { font-size: 16px; }
  .seg span { padding: 11px 0; }

  .cases-layout { grid-template-columns: minmax(0, 1fr); }
  .filters { position: fixed; top: auto; max-height: 85vh; }
  .results-actions { width: 100%; }
  .results-actions .inline-select { flex: 1; }
  .results-actions .inline-select select { width: 100%; }

  /* 表格 → 卡片 */
  .table-wrap { background: none; border: 0; overflow: visible; }
  table.cases thead { display: none; }
  table.cases, table.cases tbody { display: block; }
  table.cases tbody tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow);
  }
  table.cases tbody tr:hover { background: var(--surface); }
  table.cases tbody tr:active { background: var(--surface-2); }
  table.cases td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  table.cases td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-3); }
  table.cases td.c-date { grid-column: 1 / 3; order: -2; font-size: 13px; }
  table.cases td.c-date::before { display: none !important; }
  table.cases td.c-badges { grid-column: 3; order: -2; text-align: right; white-space: normal; }
  table.cases td.c-main { grid-column: 1 / -1; order: -1; max-width: none; min-width: 0; margin-bottom: 4px; }
  .c-subject { font-size: 15px; }
  .list-loading { position: fixed; inset: auto 0 0 0; padding: 12px; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; }

  dialog#detail { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; margin: 0; }
  .d-bar { padding-top: calc(6px + env(safe-area-inset-top)); }
  .d-body { padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
  .d-group dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-v { font-size: 19px; }
  table.plain thead { display: none; }
  table.plain, table.plain tbody, table.plain tr { display: block; }
  table.plain tr { padding: 8px 0; border-bottom: 1px solid var(--grid); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  table.plain td { border: 0; padding: 2px 0; text-align: left; }
  table.plain td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-3); }
}

@media (hover: none) {
  .btn, .icon-btn, .pg { min-height: 44px; }
}

/* ---------- RFE 分析器（rfe.js） ---------- */
.rfe-card.is-loading .rfe-plot, .rfe-card.is-loading .rfe-kpi { opacity: .55; transition: opacity .2s; }
.rfe-conds { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 12px; }
.ms { position: relative; }
.ms-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 10px; max-width: 260px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font-size: 13px; cursor: pointer;
}
.ms-btn:hover { background: var(--surface-2); }
.ms-btn .ms-label { color: var(--text-3); }
.ms-btn .ms-val { color: var(--text-2); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-btn .ms-caret { color: var(--text-3); font-size: 10px; }
.ms-btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.ms-btn.is-active .ms-val { color: var(--accent-ink); font-weight: 650; }
.ms-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-panel {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 300px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}
.ms-panel[hidden] { display: none; }
.ms-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.ms-hint { font-size: 11px; color: var(--text-3); }
.ms-list { max-height: 280px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.ms-item { flex-direction: row; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.ms-item:hover { background: var(--surface-2); }
.ms-item input { margin: 0; accent-color: var(--accent); flex: none; }
.ms-item .ms-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-item .ms-n { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.ms-item.is-small .ms-name { color: var(--text-2); }
.ms-empty { margin: 6px 4px; font-size: 12px; color: var(--text-3); }
.ms-foot { display: flex; justify-content: flex-end; gap: 8px; }
.ms-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
.link-btn { appearance: none; border: 0; background: none; color: var(--accent-ink); font-size: 13px; cursor: pointer; padding: 4px; }
.link-btn:hover { text-decoration: underline; }

.rfe-kpi { display: flex; gap: 16px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); margin-bottom: 12px; }
.rfe-big { display: flex; flex-direction: column; align-items: flex-start; min-width: 110px; }
.rfe-rate { font-size: 34px; line-height: 1.05; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.rfe-big.is-small .rfe-rate { color: var(--text-3); }
.rfe-cap { font-size: 12px; color: var(--text-3); }
.rfe-facts { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--text-2); min-width: 0; }
.rfe-facts b { color: var(--text); }
.rfe-diff.is-up b { color: var(--critical); }
.rfe-diff.is-down b { color: var(--accent-ink); }
.rfe-cond { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.rfe-error { margin: 0; color: var(--critical); font-size: 13px; }
.badge-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); font-weight: 650; }

.rfe-controls { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.rfe-controls .inline-select { white-space: nowrap; min-width: 0; }
.rfe-note { margin: 6px 0 4px; }
.rfe-plot { position: relative; }
.rfe-empty {
  position: absolute; inset: 0; min-height: 120px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px;
  color: var(--text-3); font-size: 13px; border: 1px dashed var(--border); border-radius: 8px;
}
.rfe-empty[hidden] { display: none; }
.rfe-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 12px; color: var(--text-3); margin-top: 6px; }
.rfe-legend:empty { display: none; }
.rfe-scale { display: inline-flex; align-items: center; gap: 6px; }
.rfe-scale i { display: inline-block; width: 120px; height: 10px; border-radius: 3px; }
.rfe-smallkey { display: inline-flex; align-items: center; gap: 6px; }
.rfe-smallkey i { display: inline-block; width: 14px; height: 10px; border: 1px dashed var(--axis); border-radius: 2px; }

@media (max-width: 767px) {
  .rfe-conds { gap: 6px; }
  .ms { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .ms-btn { width: 100%; max-width: none; min-height: 44px; }
  .ms-btn .ms-val { flex: 1; min-width: 0; text-align: left; }
  /* 窄屏：多选面板变为底部抽屉 */
  .ms-panel {
    position: fixed; z-index: 50; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none;
    max-height: 80vh; border-radius: 14px 14px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .ms-list { max-height: 50vh; }
  .ms-item { min-height: 44px; font-size: 15px; }
  .ms-foot .btn { flex: 1; min-height: 44px; }
  .rfe-kpi { gap: 12px; padding: 10px 12px; }
  .rfe-rate { font-size: 28px; }
  .rfe-big { min-width: 84px; }
  .rfe-controls .inline-select { flex: 1 1 calc(50% - 8px); }
  .rfe-controls .inline-select select { width: 100%; min-width: 0; }
  .rfe-scale i { width: 80px; }
}
