/* ===== 指标公式器 formula.css（Tarsign · A股决策台）
   样式对齐全站外壳：卡片用 .card，表头/悬停对齐 holder 族表格，主色靛青蓝 #27548c
   结构：条件行构建器（.fm-r*）→ 固定运算符条（.fm-op*）→ 指标库分组网格（.fm-card / .fm-tag） */

/* --- 小节提示 --- */
.fm-sec-hint { font-size: 11.5px; color: #8a93a5; font-weight: 400; margin-left: 8px; }

/* ===== 条件行构建器 ===== */
.fm-rows { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 0; }
.fm-r {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid #e0e6ee; border-radius: 11px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.fm-r:hover { border-color: #c9d9ea; }
.fm-r-bad { border-color: #f0cfcf; background: #fffdfd; }
.fm-r-con { flex: none; width: 54px; display: flex; align-items: center; }
.fm-r-when { font-size: 12px; color: #8a93a5; padding-left: 4px; }
.fm-r-cond {
  width: 100%; font-size: 12px; font-family: inherit; color: #27548c; font-weight: 700;
  border: 1px solid #cfe0f3; background: #eef5fd; border-radius: 7px; padding: 4px 2px;
  cursor: pointer; text-align: center; text-align-last: center;
}
.fm-r-flags { flex: none; display: flex; gap: 3px; }
.fm-r-lp, .fm-r-rp, .fm-r-not {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; font-weight: 700;
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; padding: 0;
  border: 1px solid #e2e7ee; background: #fff; color: #9aa2b1; line-height: 1;
}
.fm-r-not { width: 32px; font-family: inherit; }
.fm-r-lp.on, .fm-r-rp.on, .fm-r-not.on {
  background: #fdf4e8; border-color: #e6c894; color: #b45309;
}
.fm-r-lp:hover, .fm-r-rp:hover, .fm-r-not:hover { border-color: #b9cfe6; color: #27548c; }
.fm-r-main { flex: 1; display: flex; gap: 6px; align-items: center; min-width: 0; }
.fm-r-f {
  flex: none; width: 178px; font-size: 12.5px; font-family: inherit; color: #1c2333;
  border: 1px solid #dfe3ea; border-radius: 8px; padding: 6px 7px; background: #fff; cursor: pointer;
}
.fm-r-op {
  flex: none; width: 54px; font-size: 13px; font-family: inherit; font-weight: 700; color: #27548c;
  border: 1px solid #dfe3ea; border-radius: 8px; padding: 6px 2px; background: #fff;
  cursor: pointer; text-align: center; text-align-last: center;
}
.fm-r-v {
  flex: 1; min-width: 80px; font-size: 12.5px; font-family: ui-monospace, Menlo, Consolas, monospace;
  color: #1c2333; border: 1px solid #dfe3ea; border-radius: 8px; padding: 6px 9px; background: #fff;
}
.fm-r-vsel { font-family: inherit; cursor: pointer; }
.fm-r-vs {
  flex: none; width: 122px; font-size: 11.5px; font-family: inherit; color: #7c869a;
  border: 1px solid #eef1f5; border-radius: 8px; padding: 6px 5px; background: #fbfcfe; cursor: pointer;
}
.fm-r-vs.on {
  color: #27548c; font-weight: 600; border-color: #b9cfe6; background: #eef5fd;
}
/* 数值框有值时，「或指标」下拉退为次要样式，避免视觉抢戏 */
.fm-r-main:has(.fm-r-v:not(:placeholder-shown)) .fm-r-vs { opacity: .5; }

/* 删除行后的占位行（仅括号 / 非，没有指标） */
.fm-r .fm-r-f:invalid { color: #9aa2b1; }
.fm-r-f:focus, .fm-r-op:focus, .fm-r-v:focus, .fm-r-vs:focus, .fm-r-cond:focus {
  outline: none; border-color: #27548c; box-shadow: 0 0 0 3px rgba(39, 84, 140, .1);
}
.fm-r-act { flex: none; display: flex; gap: 3px; }
.fm-r-btn {
  width: 24px; height: 26px; font-size: 11.5px; border-radius: 7px; cursor: pointer; padding: 0;
  border: 1px solid #eceff4; background: #fff; color: #9aa2b1; line-height: 1;
}
.fm-r-btn:hover { border-color: #b9cfe6; color: #27548c; background: #f5f9fe; }
.fm-r-del:hover { border-color: #e8b8b8; color: #b02a2a; background: #fdf3f3; }

/* 条件行末尾的常驻「＋ 添加条件」 */
.fm-add-more { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; }
.fm-add-more-btn { padding: 6px 15px; font-size: 12.5px; }
.fm-add-more-tip { font-size: 11.5px; color: #9aa2b1; }

/* 空态 */
.fm-empty-row {
  margin: 12px 0 0; padding: 22px 16px; text-align: center;
  border: 1px dashed #d7e0ea; border-radius: 12px; background: #fbfcfe;
}
.fm-empty-txt { font-size: 12.5px; color: #8a93a5; margin-bottom: 10px; }
.fm-add-first { padding: 7px 20px; font-size: 12.5px; }

/* 行填法说明 */
.fm-rowhint {
  margin: 10px 0 0; padding: 7px 11px; border-radius: 9px; background: #f7fafe;
  border-left: 3px solid #cfe0f3; font-size: 11.5px; color: #6b7688; line-height: 1.75;
}
.fm-rowhint b { color: #27548c; font-weight: 600; }

/* ===== 固定运算按钮条 ===== */
.fm-ops {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 10px 0 0; padding: 8px 10px; border-radius: 11px;
  background: #f8fafd; border: 1px solid #e8eef6;
}
.fm-ops-off { opacity: .58; }
.fm-ops-g { display: flex; gap: 4px; }
.fm-op {
  min-width: 34px; height: 28px; padding: 0 9px; font-size: 12px; font-family: inherit;
  font-weight: 600; color: #45506a; background: #fff; border: 1px solid #dfe3ea;
  border-radius: 8px; cursor: pointer; line-height: 1;
}
.fm-op:hover { background: #eef5fd; border-color: #a9c8e8; color: #27548c; }
.fm-op:active { background: #e2edfa; }
.fm-op-w { color: #7c869a; font-weight: 500; font-size: 11.5px; }
.fm-ops-sep { width: 1px; height: 18px; background: #e0e8f2; margin: 0 4px; }
.fm-ops-tip { font-size: 11px; color: #a2aab8; margin-left: auto; }

/* ===== 源码视图 ===== */
.fm-srcwrap { margin: 12px 0 0; }
.fm-srcbtn {
  background: none; border: 0; padding: 2px 0; cursor: pointer; font-family: inherit;
  font-size: 12px; color: #7c869a;
}
.fm-srcbtn:hover { color: #27548c; }
.fm-srcbtn-ar { display: inline-block; width: 12px; font-size: 10px; }
.fm-srcbtn-inline { margin-left: 4px; }
.fm-srcbody { margin: 7px 0 2px; }
.fm-src-hint { font-size: 11.5px; color: #8a93a5; line-height: 1.8; margin-top: 6px; }
.fm-src-hint code {
  background: #eef4fb; color: #27548c; padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
}

.fm-inputrow { display: flex; gap: 10px; align-items: center; }
.fm-inputrow input {
  flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13.5px; padding: 9px 12px; border: 1.5px solid #dfe3ea; border-radius: 10px;
  color: #0a0a0a; background: #fff;
}
.fm-inputrow input:focus { outline: none; border-color: #27548c; box-shadow: 0 0 0 3px rgba(39, 84, 140, .12); }

.fm-actrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.fm-run { flex: none; padding: 9px 22px; }
.fm-clear { padding: 8px 14px; font-size: 12.5px; }

.fm-err {
  margin: 8px 0 4px; font-size: 12.5px; color: #b02a2a; background: #fdf3f3;
  border-left: 3px solid #d64545; border-radius: 8px; padding: 8px 12px;
}

.fm-examples { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 12px 0 0; }
.fm-ex-lab { font-size: 12px; color: #8a93a5; }
.fm-chip {
  border: 1px solid #dfe3ea; background: #f7f9fc; color: #27548c; border-radius: 999px;
  font-size: 12px; font-weight: 600; padding: 5px 12px; cursor: pointer; font-family: inherit;
}
.fm-chip:hover { background: #eaf2fc; border-color: #a9c8e8; }

/* ===== 指标库：分组卡片 + 标签网格 ===== */
.fm-lib { margin-top: 18px; padding-top: 14px; border-top: 1px solid #eef1f5; }
.fm-lib-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.fm-lib-title { font-size: 13px; font-weight: 700; color: #1c2333; }
.fm-lib-cnt { font-weight: 400; font-size: 11.5px; color: #8a93a5; margin-left: 4px; }
.fm-f-search {
  flex: 1; min-width: 180px; max-width: 300px; font-size: 12.5px; padding: 6px 11px;
  border: 1px solid #dfe3ea; border-radius: 9px; color: #0a0a0a; font-family: inherit;
}
.fm-f-search:focus { outline: none; border-color: #27548c; box-shadow: 0 0 0 3px rgba(39, 84, 140, .1); }
.fm-f-mini {
  border: 1px solid #dfe3ea; background: #fff; color: #45506a; border-radius: 8px;
  font-size: 11.5px; padding: 5px 10px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.fm-f-mini:hover { background: #f2f6fb; border-color: #b9cfe6; color: #27548c; }

/* 指标库：分类卡片式折叠面板
   每组一张浅底圆角卡片，标题行（图标徽章 + 组名 + 提示 + 计数），展开后标签以胶囊 chip 流式铺开 */
.fm-lib-flow { display: flex; flex-direction: column; gap: 8px; }
.fm-cat {
  border: 1px solid #e8eef6; border-radius: 12px; background: #fbfcfe;
  overflow: hidden; transition: border-color .15s, background .15s;
}
.fm-cat:hover { border-color: #d3e0ef; }
.fm-cat.on { background: #fff; border-color: #d8e4f2; }
.fm-cat-h {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 12px; background: none; border: 0; cursor: pointer; font-family: inherit;
  font-size: 13px; color: #27548c;
}
.fm-cat-h:hover { background: #f4f8fd; }
.fm-cat-ar { width: 11px; font-size: 10px; color: #9aa2b1; flex: none; }
.fm-cat-ico {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: #eef5fd; border-radius: 8px; font-size: 13.5px; flex: none;
}
.fm-cat.on .fm-cat-ico { background: #e2edfa; }
.fm-cat-h b { font-weight: 700; color: #1c2333; }
.fm-cat-h em { font-style: normal; font-size: 11px; color: #9aa2b1; font-weight: 400; }
.fm-cat-n {
  margin-left: auto; font-size: 10.5px; color: #8a93a5; font-weight: 600;
  background: #f2f6fb; border-radius: 999px; padding: 2px 9px; flex: none;
}
.fm-cat.on .fm-cat-n { background: #eef5fd; color: #27548c; }
.fm-cat.on .fm-cat-ar { color: #27548c; }
.fm-tags {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px 46px;
  align-content: flex-start;
}
.fm-tag {
  font-size: 12px; font-family: inherit; color: #27548c; background: #f5f8fc;
  border: 1px solid #e8eef5; border-radius: 999px; padding: 3px 11px; cursor: pointer;
  white-space: nowrap; line-height: 1.6; font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.fm-tag:hover { background: #eef5fd; border-color: #b9cfe6; color: #17406f; font-weight: 600; }
.fm-tag-lazy { color: #9aa2b1; background: #fafbfd; border-style: dashed; }
.fm-tag-lazy:hover { color: #b45309; background: #fdf4e8; border-color: #f3ddbb; }
.fm-lib-empty .fm-lib-flow { display: none; }

/* 指标悬浮解释浮层（跟随标签下方，只谈指标定义，不做方向性解读） */
.fm-tipbox {
  position: fixed; z-index: 90; display: none; max-width: 340px; pointer-events: none;
  background: #fff; border: 1px solid #d8e4f2; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 32, 52, .16); padding: 9px 12px;
}
.fm-tipbox-t { font-size: 12.5px; font-weight: 700; color: #1c2333; margin-bottom: 4px; }
.fm-tipbox-t span { font-weight: 500; color: #7c869a; margin-left: 6px; }
.fm-tipbox-t i {
  font-style: normal; font-size: 10.5px; color: #27548c; background: #eef5fd;
  border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px;
}
.fm-tipbox-d { font-size: 12px; color: #45506a; line-height: 1.65; }
.fm-tipbox-m { font-size: 11px; color: #9aa2b1; margin-top: 5px; }

/* ===== 结果表 ===== */
.fm-bar { display: flex; gap: 10px; align-items: center; margin: 10px 0 4px; }
.fm-bar input {
  width: 240px; font-size: 12.5px; padding: 7px 11px; border: 1px solid #dfe3ea;
  border-radius: 9px; color: #0a0a0a;
}
.fm-bar input:focus { outline: none; border-color: #27548c; }
.fm-tip { font-size: 11.5px; color: #8a93a5; }

.fm-cols-wrap { position: relative; margin-left: auto; }
.fm-cx {
  position: absolute; right: 0; top: 34px; width: 470px; max-height: 460px; overflow: auto;
  background: #fff; border: 1px solid #dfe3ea; border-radius: 12px; z-index: 20;
  box-shadow: 0 8px 28px rgba(20, 32, 52, .14); padding: 12px 14px;
}
.fm-cx-h { font-size: 11.5px; color: #8a93a5; margin-bottom: 8px; }
.fm-cx-sec { margin-bottom: 10px; }
.fm-cx-sec b { font-size: 11.5px; color: #5a6478; display: block; margin-bottom: 5px; }
.fm-cx-items { display: flex; flex-wrap: wrap; gap: 5px; }
.fm-cx-it {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: #5a6478;
  border: 1px solid #e2e7ee; border-radius: 7px; padding: 4px 9px; cursor: pointer; user-select: none;
}
.fm-cx-it.on { background: #eef5fd; border-color: #b9cfe6; color: #27548c; font-weight: 600; }
.fm-cx-it input { margin: 0; accent-color: #27548c; }
.fm-cx-f { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; border-top: 1px solid #eef1f5; }
.fm-cx-ok { padding: 6px 16px !important; font-size: 12px !important; }

.fm-tbl { max-height: 640px; overflow: auto; border: 1px solid #e8ebf0; border-radius: 12px; }
.fm-tbl table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fm-tbl th { background: #f6f8fb; color: #5a6478; font-weight: 600; text-align: left;
  padding: 8px 10px; border-bottom: 1px solid #e8ebf0; white-space: nowrap;
  position: sticky; top: 0; z-index: 1; cursor: pointer; user-select: none; }
.fm-tbl th.num, .fm-tbl td.num { text-align: right; }
.fm-tbl td { padding: 7px 10px; border-bottom: 1px solid #f1f3f6; color: #1c2333; white-space: nowrap; }
.fm-tbl td.c { color: #8a93a5; }
.fm-tbl td.nm { font-weight: 600; }
.fm-tbl tbody tr:hover td { background: #f7fafe; }
.fm-tbl .up { color: #d64545; }
.fm-tbl .dn { color: #0ca678; }

.fm-more { text-align: center; padding: 10px 0 2px; }
.fm-empty { text-align: center; color: #8a93a5; padding: 34px 0; font-size: 12.5px; }
.fm-src { font-size: 11.5px; color: #8a93a5; line-height: 1.85; margin-top: 10px; }
.fm-src b { color: #3d4658; }

.fm-g-lazy {
  font-size: 10px; color: #b45309; background: #fdf4e8; padding: 1px 6px;
  border-radius: 999px; border: 1px solid #f3ddbb; font-weight: 400;
}

@media (max-width: 900px) {
  .fm-lib-flow { flex-direction: column; }
  .fm-tags { padding-left: 12px; }
  .fm-r { flex-wrap: wrap; }
  .fm-r-main { flex-basis: 100%; }
  .fm-bar input { width: 100%; }
}
