/* ============ 视图层：统计条 / 页签工具条 / 导出面板 / 配置 / 多厂商 / 打印 ============
   依赖 app.css token 与 tables.css；.tag-off 覆盖需在 .tag 之后加载。 */

/* ---------- 统计条 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 26px 0 24px; border: 1px solid var(--edge-soft); background: var(--panel); }
.stat { padding: 16px 20px 14px; display: flex; flex-direction: column; gap: 5px; border-left: 1px solid var(--edge-soft); }
.stat:first-child { border-left: none; }
.stat-num { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.stat:first-child .stat-num { color: var(--accent); }
.stat-time { font-size: 17px; padding-top: 5px; }
.stat-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2.5px; color: var(--faint); }

/* ---------- 页签与工具条 ---------- */
.tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--edge); margin-bottom: 0; }
.tab {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-family: var(--font-display); font-size: 16px; letter-spacing: 3px;
  padding: 10px 18px 12px; position: relative; transition: color .2s;
}
.tab::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 2px; background: var(--accent); transform: scaleX(0); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { transform: scaleX(1); }
.toolbar { margin-left: auto; display: flex; gap: 10px; padding-bottom: 8px; flex-wrap: wrap; }
.toolbar input[type="search"] { width: 220px; min-width: 150px; }

/* 导出源选择面板 */
.export-box { position: relative; display: inline-block; }
.export-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 250px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 14px 16px; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
}
.export-pop[hidden] { display: none; }
.export-hint { color: var(--muted); font-size: 12px; }
.export-chk { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; cursor: pointer; }
.export-sep { border-top: 1px dashed var(--edge); margin: 2px 0; }

/* 已下线标记（印章红） */
.tag-off { color: var(--seal); border-color: var(--seal); }

/* 05 数据库配置视图 */
.cfg-card { display: grid; grid-template-columns: minmax(300px, 460px) 1fr; gap: 28px; align-items: start; }
.cfg-form {
  display: flex; flex-direction: column; gap: 14px; background: var(--panel-2);
  border: 1px solid var(--edge); border-radius: var(--r); padding: 22px;
}
.cfg-form > label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.cfg-form > label span { letter-spacing: 2px; }
.cfg-chk { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--ink); letter-spacing: 0 !important; }
.cfg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.cfg-side h3 { margin: 0 0 10px; letter-spacing: 3px; }
.cfg-status {
  background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--r);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px;
}
.cfg-status .mono { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.cfg-bad { color: var(--seal); }
.cfg-note { color: var(--muted); font-size: 12px; margin-top: 12px; line-height: 1.7; }

/* ---------- 多厂商：工作台 web 行 / 对比视图 ---------- */
.web-row { margin-top: 14px; align-items: center; }
.web-info { flex: 1; min-width: 260px; color: var(--muted); font-size: 13px; }
.web-info b { color: var(--text-2); font-weight: 600; }
.rate-box { display: flex; flex-direction: column; gap: 6px; }
.rate-line { display: flex; align-items: center; gap: 8px; }
.rate-input { width: 86px; }
.rate-line select { padding: 8px 10px; }
.rate-date { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.compare-note { margin-top: 12px; font-size: 12px; color: var(--cinnabar); font-family: var(--font-mono); }
.cny-val { font-family: var(--font-mono); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.best-badge {
  margin-left: 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  color: var(--seal-ink); background: var(--seal); border-radius: 999px; padding: 2px 8px;
}
.src-filter { margin-left: auto; padding: 8px 12px; }

/* ---------- 06 能力开放 ---------- */
.open-section { display: flex; align-items: center; gap: 12px; margin: 28px 0 10px; flex-wrap: wrap; }
.open-section h3 { font-family: var(--font-display); font-size: 18px; letter-spacing: 4px; margin: 0; flex: 1; min-width: 140px; }

/* ---------- 07 采集策略 ---------- */
.sched-running { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.strat-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.strat-cell input[type="time"] { padding: 3px 6px; font-family: var(--font-mono); }
.strat-cell select { padding: 3px 6px; }
.acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.acct-card { border: 1px solid var(--edge); border-radius: var(--r); padding: 12px 14px; background: var(--panel); }
.acct-card > summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; }
.acct-card > summary::-webkit-details-marker { display: none; }
.acct-status { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.acct-fields { display: grid; gap: 9px; margin-top: 12px; }
.acct-fields label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.acct-fields input { padding: 6px 8px; font-family: var(--font-mono); }
.acct-actions { margin-top: 12px; display: flex; gap: 8px; }

/* ---------- 响应式（视图侧：统计条 / 工具条） ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: none; }
  .stat { border-top: 1px solid var(--edge-soft); }
  .toolbar { margin-left: 0; width: 100%; }
}

/* ---------- 打印：台账留档用，强制白昼且展开宽表 ---------- */
@media print {
  :root, :root[data-theme="night"] {
    --bg: #fff; --panel: #fff; --panel-2: #fff; --panel-3: #fff;
    --text: #000; --text-2: #222; --muted: #444; --faint: #666;
    --edge: #999; --edge-soft: #ccc; --rule: #999; --stripe: transparent; --stripe-cell: #fff;
    --glow: transparent; --grid-line: transparent;
  }
  body::before, body::after, .rail, .toolbar, .pager, .theme-switch, .toasts { display: none !important; }
  .table-wrap.wide { max-height: none; overflow: visible; }
  /* 打印时展开全部列内容：不固定首列、数据格自由折行 */
  .table-wrap.wide th:first-child, .table-wrap.wide td:first-child { position: static; }
  .table-wrap.wide .ledger td { white-space: normal; }
  .ledger .json-cell { max-width: none; }
}
