/* ============================================================
   水处理工具库（tools.html）— 首页卡片 + 工具详情页
   主站配色：深蓝 #002f5d / 浅灰蓝底 / 橙色强调
   ============================================================ */

.tools-body {
  min-width: 0; background: var(--c-bg-soft);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.tools-head {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 20px;
  background: linear-gradient(180deg, #003a70, #002f5d); color: #fff;
  box-shadow: 0 1px 6px rgba(0, 40, 80, .18);
}
.th-left, .th-right { display: flex; align-items: center; gap: 9px; }
.th-logo { display: inline-flex; align-items: center; gap: 7px; color: #fff; text-decoration: none; }
.th-logo .rf-mark { width: 26px; height: 26px; color: #fff; }
.th-logo .rf-word { font-size: 16px; color: #fff; }
.th-sep { opacity: .35; }
.th-title { font-size: 13px; color: #cfe2f5; text-decoration: none; }
.th-title:hover { color: #fff; }
.th-crumb { font-size: 13px; color: #fff; }
.th-crumb::before { content: "/"; margin-right: 9px; color: rgba(255,255,255,.3); }
.th-crumb:empty { display: none; }
.th-link {
  display: inline-flex; align-items: center; height: 27px; padding: 0 11px;
  border-radius: 14px; border: 1px solid rgba(255,255,255,.22);
  color: #cfe2f5; font-size: 12px; text-decoration: none;
}
.th-link:hover { color: #fff; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.45); }
.th-count { font-size: 11.5px; color: #9dc0e0; }

/* ---------- 容器 ---------- */
.tools-shell { flex: 1 1 auto; width: 100%; max-width: 1360px; margin: 0 auto; padding: 22px 24px 48px; }

/* ============================================================
   首页：工具卡片
   ============================================================ */
.home-hero { margin-bottom: 22px; }
.home-hero h1 { font-size: 24px; color: var(--c-primary); font-weight: 700; letter-spacing: .5px; }
.home-hero .sub { margin-top: 8px; font-size: 13px; color: var(--c-text-sub); line-height: 1.75; max-width: 780px; }
.home-hero .meta { margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: #7d8fa3; }
.home-hero .meta b { color: var(--c-primary); }

.home-search {
  position: relative; display: flex; align-items: center; gap: 8px;
  margin: 18px 0 8px; max-width: 420px; color: #94a5b8;
}
.home-search input {
  flex: 1 1 auto; height: 36px; padding: 0 14px 0 34px;
  border: 1px solid var(--c-border); border-radius: 18px; font-size: 13px; background: #fff;
}
.home-search svg { position: absolute; left: 12px; }
.home-search input:focus { border-color: #7aa9d0; box-shadow: 0 0 0 3px rgba(0,89,150,.08); }

.hg { margin-top: 26px; }
.hg-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #e2ebf4;
}
.hg-head .ico { font-size: 16px; }
.hg-head .name { font-size: 14.5px; font-weight: 700; color: #24435f; }
.hg-head .cnt { font-size: 11px; color: #4a7bb5; background: #e6f1fa; border: 1px solid #d8e9f7; border-radius: 9px; padding: 1px 8px; font-weight: 600; }
.hg-head .line { flex: 1 1 auto; height: 1px; background: linear-gradient(90deg, #e2ebf4, transparent); }

.hcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }
.hcard {
  display: flex; flex-direction: column; gap: 8px;
  padding: 15px 16px 13px; border: 1px solid #d5e3f0; border-radius: 10px;
  background: #fff; cursor: pointer; text-align: left;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.hcard:hover { transform: translateY(-3px); border-color: #8fb8d8; box-shadow: 0 8px 22px rgba(16, 48, 80, .12); }
.hcard-top { display: flex; align-items: center; gap: 9px; }
.hcard-ico {
  flex: 0 0 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  font-size: 17px; background: linear-gradient(145deg, #eaf3fb, #dcecf9); border: 1px solid #d3e5f5;
}
.hcard-name { font-size: 13.3px; font-weight: 700; color: #1f3d5a; line-height: 1.35; }
.hcard-sub { font-size: 10.8px; color: #8a9aad; margin-top: 2px; }
.hcard-desc {
  font-size: 11.6px; color: #61758b; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 4px; }
.hcard-tag { font-size: 10.5px; color: #4a7bb5; background: #f0f7fd; border: 1px solid #e0edf8; border-radius: 9px; padding: 1px 7px; }
.hcard-go { font-size: 11.5px; color: var(--c-accent); font-weight: 600; opacity: .55; transition: opacity .15s; }
.hcard:hover .hcard-go { opacity: 1; }

/* ============================================================
   工具详情页
   ============================================================ */
.tool-top {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.tt-back {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 15px;
  border: 1px solid var(--c-border); background: #fff;
  font-size: 12.3px; color: #46617c; text-decoration: none;
}
.tt-back:hover { border-color: #7aa9d0; color: var(--c-primary); background: #f6fbff; }

.tool-head { margin-bottom: 16px; }
.tool-head h1 {
  display: flex; align-items: center; gap: 9px;
  font-size: 21px; color: var(--c-primary); font-weight: 700; margin-bottom: 7px;
}
.tool-head h1 .th-ico { font-size: 22px; }
.tool-head .tool-desc { font-size: 12.8px; color: var(--c-text-sub); line-height: 1.75; max-width: 940px; }

.tool-grid { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }

.card { background: #fff; border: 1px solid #cbdcec; border-radius: 10px; box-shadow: 0 3px 12px rgba(16, 48, 80, .06); }
.card-h {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 15px; border-bottom: 1px solid var(--c-border-light);
  background: linear-gradient(180deg, #f9fcff, #f1f7fd);
  border-radius: 10px 10px 0 0; font-size: 12.8px; font-weight: 600; color: #24435f;
}
.card-b { padding: 16px; }

/* ---------- 参数（数值框 + 滑条） ---------- */
.param { position: relative; padding: 12px 0 15px; border-bottom: 1px dashed #edf2f8; }
.param:last-child { border-bottom: 0; padding-bottom: 4px; }
.param-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.param-name { font-size: 12.6px; color: #2c4a66; font-weight: 600; }
.num-wrap { display: flex; align-items: center; gap: 4px; }
.num-wrap input {
  width: 80px; height: 28px; text-align: right; padding: 0 7px;
  border: 1px solid var(--c-border); border-radius: 5px; font-size: 12.8px;
  font-variant-numeric: tabular-nums; color: var(--c-primary); font-weight: 700;
}
.num-wrap input:focus { border-color: #7aa9d0; box-shadow: 0 0 0 2px rgba(0,89,150,.08); }
.num-wrap .num-unit { font-size: 11px; color: #8a9aad; min-width: 36px; }
.param-desc { font-size: 10.9px; color: #93a3b5; line-height: 1.5; margin-bottom: 3px; }

/* 滑条：input 保留 20px 高度容纳滑块，轨道用双层背景（底轨 + 已选进度） */
.param input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px; margin: 3px 0 0; cursor: pointer;
  background-color: transparent;
  background-image:
    linear-gradient(90deg, #0a5aa0, #0a5aa0),
    linear-gradient(90deg, #d7e3ef, #d7e3ef);
  background-repeat: no-repeat;
  background-size: var(--pct, 50%) 6px, 100% 6px;
  background-position: left center, left center;
  border-radius: 3px;
  outline: none;
}
.param input[type=range]::-webkit-slider-runnable-track { height: 6px; background: transparent; border-radius: 3px; }
.param input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 2px solid #0a5aa0;
  box-shadow: 0 1px 5px rgba(0, 47, 93, .35);
  transition: transform .12s, box-shadow .12s;
}
.param input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.08); box-shadow: 0 2px 9px rgba(0, 47, 93, .45); }
.param input[type=range]:active::-webkit-slider-thumb { transform: scale(1.16); }
.param input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(10, 90, 160, .18); }
.param input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #d7e3ef; }
.param input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: #0a5aa0; }
.param input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  border: 2px solid #0a5aa0; box-shadow: 0 1px 5px rgba(0, 47, 93, .35);
}

/* 拖动数值气泡 */
.range-tip {
  position: absolute; bottom: 26px; transform: translateX(-50%);
  padding: 3px 9px; border-radius: 5px; background: #002f5d; color: #fff;
  font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 40, 80, .28);
}
.range-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: #002f5d; border-bottom: 0;
}
.range-tip.on { opacity: 1; }

.range-ends {
  display: flex; justify-content: space-between;
  margin-top: 1px; font-size: 10px; color: #a9b8c8;
  font-variant-numeric: tabular-nums;
}
.param select {
  width: 100%; height: 30px; border: 1px solid var(--c-border); border-radius: 5px;
  background: #fff; font-size: 12.8px; padding: 0 7px; color: #2c4a66;
}

/* ---------- 结果卡片 ---------- */
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 11px; }
.res {
  position: relative; overflow: hidden;
  border: 1px solid #e0eaf4; border-radius: 9px; padding: 12px 14px 11px;
  background: linear-gradient(180deg, #ffffff, #f7fbfe);
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.res:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(16, 48, 80, .08); border-color: #cddff0; }
.res::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c-primary); opacity: .5; }
.res .res-k { font-size: 11.5px; color: #6b7f95; margin-bottom: 5px; line-height: 1.35; }
.res .res-v { font-size: 19px; font-weight: 700; color: var(--c-primary); font-variant-numeric: tabular-nums; line-height: 1.1; }
.res .res-v small { font-size: 11.9px; font-weight: 400; color: #7d8fa3; margin-left: 4px; }
.res:nth-child(-n+3) .res-v { font-size: 22px; }
.res:nth-child(-n+3)::before { opacity: .9; }
.res.warn { background: linear-gradient(180deg, #fffbf8, #fdf3ee); border-color: #f0d5ca; }
.res.warn::before { background: #d2691e; opacity: .8; }
.res.warn .res-v { color: #b8501f; }
.res.ok::before { background: #1f8a5b; opacity: .8; }
.res.ok .res-v { color: #176c48; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 12px; font-size: 11.5px; font-weight: 600; line-height: 1.5; }
.badge.ok { background: #e8f7ef; color: #1f8a5b; border: 1px solid #cfe9da; }
.badge.warn { background: #fff5e8; color: #a8620a; border: 1px solid #f6dcb6; }
.badge.bad { background: #fdecea; color: #b3261e; border: 1px solid #f5c6c1; }

/* ---------- 图表 ---------- */
.chart-tabs { display: flex; gap: 6px; padding: 10px 12px 0; flex-wrap: wrap; border-bottom: 1px solid var(--c-border-light); }
.chart-tab {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid transparent; border-bottom: none; background: #f2f7fc; color: #61758b;
  font-size: 12.3px; padding: 7px 14px 8px; border-radius: 7px 7px 0 0; cursor: pointer;
  transition: background .14s, color .14s;
}
.chart-tab:hover { background: #e6f1fa; color: var(--c-primary); }
.chart-tab.on {
  background: #fff; color: var(--c-primary); font-weight: 700;
  border-color: var(--c-border-light);
  box-shadow: 0 -2px 0 var(--c-accent) inset;
  margin-bottom: -1px;
}
.chart-tab .ct-ico { font-size: 12px; opacity: .8; }
.chart-pane { display: none; }
.chart-pane.on { display: block; }
.chart-box svg { width: 100%; height: auto; display: block; }
/* 膜断面可视化放进图表 tab 后：canvas 与 SVG 图表同等对待，去掉卡片内边距 */
.viz-box { padding: 0; overflow: hidden; border-radius: 8px; background: #04203a; }
.viz-box canvas { display: block; width: 100%; }
.chart-cap { font-size: 11.2px; color: #8a9aad; margin-top: 8px; text-align: center; line-height: 1.65; }

@keyframes drawLine { from { stroke-dashoffset: var(--len, 2000); } to { stroke-dashoffset: 0; } }
.chart-box svg path.line-anim { stroke-dasharray: var(--len, 2000); animation: drawLine .85s cubic-bezier(.4, 0, .2, 1) forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.chart-box svg .fade-in { animation: fadeUp .4s ease-out .45s both; }

/* 累计图表卡片（详情页右侧堆叠） */
.chart-card { margin-top: 16px; }

/* ---------- 说明（全宽，置于两栏下方） ---------- */
.notes { margin-top: 26px; }
.notes h3 {
  display: flex; align-items: center; gap: 7px;
  font-size: 14px; color: #24435f; margin: 20px 0 10px;
  padding-left: 10px; border-left: 3px solid var(--c-accent);
}
.notes p { font-size: 12.6px; color: #4f6a85; line-height: 1.85; margin-bottom: 8px; }
.notes ul { margin: 4px 0 8px 20px; }
.notes li { font-size: 12.6px; color: #4f6a85; line-height: 1.8; }
.notes b, .notes strong { color: #1f3d5a; }
.formula { background: #f7fafd; border: 1px solid #e2ecf5; border-left: 3px solid #8fb8d8; border-radius: 7px; padding: 12px 15px; margin: 10px 0; }
.formula code { font-family: Consolas, Menlo, monospace; font-size: 12.5px; color: #123c5e; line-height: 2; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.2px; margin: 6px 0; }
.tbl th, .tbl td { border: 1px solid #e6eef6; padding: 7px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.tbl th { background: #f2f7fc; color: #2c4a66; font-weight: 600; text-align: center; }
.tbl tbody tr:nth-child(even) { background: #fbfdff; }
.tbl td:first-child, .tbl th:first-child { text-align: left; }

/* ---------- 切换工具下拉：已移除（工具间通过首页卡片墙切换） ---------- */

.hidden { display: none !important; }

/* ---------- 页脚 ---------- */
.tools-body .icp-footer { margin-top: auto; background: #fff; border-top: 1px solid var(--c-border-light); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
  .tools-shell { padding: 18px 14px 40px; }
  .hcards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}
@media (max-width: 640px) {
  .home-hero h1 { font-size: 20px; }
  .hcards { grid-template-columns: minmax(0, 1fr); }
  .th-count { display: none; }
}
