/* ============================================================
   components/table.css — v315 表格组件（白卡范式 + 红涨绿跌 + sticky）
   ------------------------------------------------------------
   起源：v315/main_future.html 的 .future-table 范式被用户认可，
        table_vpm30 完整复用并改名为 .qt，2026-07-12 抽取为公共组件。
   范式：白卡 + 圆角 12px + 阴影 + 渐变头 + sticky thead
   依赖：tokens.css（设计令牌）、scrollbar.css（滚动条皮肤）
   公共件入口：templates/v315/base_footer.html（页脚）
   ============================================================ */

/* ---- 卡片容器 ---- */
.qt {
  width: 90vw;
  max-width: 1560px;
  min-width: 720px;
  /* 上 margin 收紧到 0.75rem：消除颈部栏与表格之间的过大空白 */
  margin: 0.25rem auto 0;
  background: transparent;
  border: 1px solid var(--border, #e3e6ef);
  border-radius: var(--r-lg, 12px);
  box-shadow: var(--sh-1, 0 1px 3px rgba(24, 28, 45, .06));
  overflow: hidden;
}

/* ---- 卡片头：标题 + 右侧表单 ---- */
.qt__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  font-size: var(--fs-base, 15px);
  font-weight: 600;
  color: var(--text, #181c2d);
  border-bottom: 1px solid var(--border, #e3e6ef);
  background: transparent;
}

.qt__title {
  font-size: var(--fs-lg, 16px);
  font-weight: 600;
  color: var(--text, #181c2d);
}

/* ---- 表单（嵌入卡片头右侧）---- */
.qt-form {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.qt-form label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm, 13px);
  font-weight: 400;
  color: var(--text-muted, #8b919c);
}

.qt-form input {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border, #e3e6ef);
  border-radius: 4px;
  font-size: var(--fs-sm, 13px);
  color: var(--text, #181c2d);
  background: #fff;
  outline: none;
  transition: border-color var(--transition-fast, 150ms ease),
    box-shadow var(--transition-fast, 150ms ease);
}

.qt-form input:focus {
  border-color: var(--brand, #ef6a4c);
  box-shadow: 0 0 0 3px rgba(239, 106, 76, .12);
}

/* <button> 与 <a> 共用同一套外观：显式对齐 flex 居中 / 字体 / 宽度 / 行高，
   避免 button 吃到 base_head 里的 legacy button 规则（width:70px、margin-left:10px、
   hover 放大 1.05）而与同排的 <a class="go-btn"> 长得不一样 */
.qt-form .go-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-sizing: border-box;
  width: auto;
  min-width: 60px;
  height: 26px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: var(--fs-sm, 13px);
  font-weight: 500;
  line-height: 1;
  color: #fff;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  background: var(--brand, #ef6a4c);
  box-shadow: none;
  cursor: pointer;
  transition: background-color var(--transition-fast, 150ms ease),
    box-shadow var(--transition-fast, 150ms ease),
    transform var(--transition-fast, 150ms ease);
}

/* 悬停：加深底色 + 品牌色投影 + 轻微抬起；:active 回落，点击有反馈 */
.qt-form .go-btn:hover {
  background: var(--brand-strong, #c2451c);
  box-shadow: 0 2px 8px rgba(239, 106, 76, .35);
  transform: translateY(-1px);
}

.qt-form .go-btn:active {
  box-shadow: none;
  transform: translateY(0) scale(.97);
}

.qt-form .go-btn:focus-visible {
  outline: 2px solid var(--brand, #ef6a4c);
  outline-offset: 2px;
}

/* ---- 表格体：一屏高度锁定 + 横向滚动兜底 ----
   关键：max-height + overflow-y:auto 让 sticky th 真正吸顶
   滚动条皮肤由 components/scrollbar.css 接管（Firefox / WebKit 双兼容） */
.qt__scroll {
  width: 100%;
  max-height: calc(100vh - 7.5rem);
  overflow-y: auto;
  overflow-x: auto;
}

.qt table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: var(--fs-sm, 13px);
  color: var(--text, #1f2430);
  font-variant-numeric: tabular-nums;
}

/* ---- 表头：sticky + 浅灰底 + 浅底边 ---- */
.qt thead th {
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-muted, #8b919c);
  background: #fcfbf9;
  border-bottom: 1px solid var(--border, #e3e6ef);
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: pointer;
  user-select: none;
}

.qt thead th:first-child,
.qt thead th.is-center {
  text-align: center;
}

/* 排序指示（▲▼ 角标，v315 范式） */
.qt thead th.is-sorted-asc::after {
  content: " \25B2";
  color: var(--brand, #ef6a4c);
  font-size: 10px;
  margin-left: 4px;
}

.qt thead th.is-sorted-desc::after {
  content: " \25BC";
  color: var(--brand, #ef6a4c);
  font-size: 10px;
  margin-left: 4px;
}

/* ---- 单元格：基础 ----
   默认行底色暖白 #fcfbf9；强势行（is-signal-strong）覆盖为纯白 */
.qt tbody td {
  padding: 9px 12px;
  text-align: right;
  white-space: nowrap;
  color: var(--text, #1f2430);
  border-bottom: 1px solid var(--border, #eef0f3);
  background: transparent;
}

.qt tbody td:first-child,
.qt tbody td.is-center {
  text-align: center;
  color: var(--text-muted, #8b919c);
}

.qt tbody tr:last-child td {
  border-bottom: none;
}

.qt tbody tr:hover td {
  background: transparent;
}

/* 行底色：强势行（3-强势/趋势向上）→ 透明底；其他行 → 透明底
   .qt tbody td 已默认透明，is-signal-strong 也改为透明。 */
.qt tbody tr.is-signal-strong td {
  background: transparent;
}

.qt tbody tr.is-signal-strong:hover td {
  background: transparent;
}

/* ---- 涨跌着色（红涨绿跌）---- */
.qt .is-up {
  color: var(--up, #d93030);
  font-weight: var(--fw-medium, 500);
}

.qt .is-down {
  color: var(--down, #15803d);
  font-weight: var(--fw-medium, 500);
}

.qt .is-zero {
  color: var(--text-muted, #8b919c);
}

/* ---- 阈值预警（高值红 / 低值蓝，规范 §10.7）----
   同时以全局 + .qt 作用域双写，确保既能在 .qt tbody td 中覆盖默认文字色，
   也能在 .memo 图例说明中复用。色值走令牌（--up 红 / --info 蓝）。 */
.is-warn-high,
.qt .is-warn-high {
  color: var(--up, #d93030);
  font-weight: var(--fw-medium, 500);
}

.is-warn-low,
.qt .is-warn-low {
  color: var(--info, #2563eb);
  font-weight: var(--fw-medium, 500);
}

/* ---- 链接 ---- */
.qt td a {
  color: var(--text-muted, #8b919c);
  text-decoration: none;
  transition: color var(--transition-fast, 150ms ease);
}

.qt td a:hover {
  color: var(--brand, #ef6a4c);
}

/* K线图标 */
.qt .kchart-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #8b919c);
}

.qt .kchart-link:hover {
  color: var(--brand, #ef6a4c);
}

.qt .kchart-link svg {
  width: 15px;
  height: 15px;
}

/* ---- 仪表盘明细表 .rcm-table（rcm5x / mbt1x 页面共用）----
   2026-09-09 从 templates/v315/main_rcm5x.html 内嵌 <style> 抽取为公共件：
   原样式仅内嵌于 rcm 页面，/mbt(main_mbt1x.html) 复用了 .rcm-table 结构却拿不到
   样式导致表格裸奔；抽取后两页同引 table.css，单一来源、渲染一致。
   与 .qt 的差异：去掉纵向滚动限制（max-height + overflow-y），让表格内容自然撑开。 */

.rcm-table {
  width: 90vw;
  max-width: 1560px;
  min-width: 720px;
  margin: 0.75rem auto 0;
  background: transparent;
  border: 1px solid var(--border, #e3e6ef);
  border-radius: var(--r-lg, 12px);
  box-shadow: var(--sh-1, 0 1px 3px rgba(24, 28, 45, .06));
  overflow: hidden;
}

.rcm-table__head {
  padding: 10px 16px;
  font-size: var(--fs-base, 15px);
  font-weight: 600;
  color: var(--text, #1f2430);
  border-bottom: 1px solid var(--border, #e3e6ef);
  background: linear-gradient(180deg, #ffffff 0%, #fff7f3 100%);
}

/* 横向滚动兜底（窄屏下列多时），纵向不做限制 */
.rcm-table__scroll {
  width: 100%;
  overflow-x: auto;
}

.rcm-table table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: var(--fs-sm, 13px);
  font-variant-numeric: tabular-nums;
}

.rcm-table th {
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-muted, #8b919c);
  background: #faf9f7;
  border-bottom: 1px solid var(--border, #e3e6ef);
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: pointer;
  user-select: none;
}

.rcm-table th:first-child,
.rcm-table th.is-center {
  text-align: center;
}

.rcm-table td {
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
  color: var(--text, #1f2430);
  border-bottom: 1px solid var(--border, #eef0f3);
  background: transparent;
}

.rcm-table td:first-child,
.rcm-table td.is-center {
  text-align: center;
  color: var(--text-muted, #8b919c);
}

.rcm-table tbody tr:last-child td {
  border-bottom: none;
}

/* hover 保留品牌橙淡底（与阈值染色文字色叠加不冲突） */
.rcm-table tbody tr:hover td {
  background: rgba(239, 106, 76, .04);
}

/* 友好行（常态·状态友好）：整行白底，hover 不变色保持"安全"语义 */
.rcm-table tbody tr.is-signal-friendly td {
  background: #ffffff;
}

.rcm-table tbody tr.is-signal-friendly:hover td {
  background: #ffffff;
}

.rcm-table td a {
  color: var(--text-muted, #8b919c);
  text-decoration: none;
  transition: color var(--transition-fast, 150ms ease);
}

.rcm-table td a:hover {
  color: var(--brand, #ef6a4c);
}

/* 排序指示（▲▼ 角标，与 .qt 范式一致） */
.rcm-table th.is-sorted-asc::after {
  content: " \25B2";
  color: var(--brand, #ef6a4c);
  font-size: 10px;
  margin-left: 4px;
}

.rcm-table th.is-sorted-desc::after {
  content: " \25BC";
  color: var(--brand, #ef6a4c);
  font-size: 10px;
  margin-left: 4px;
}