/* ============================================================
   饮水成本测算工具 — 页面样式（/cost.html 专用）
   与站点 styles.css 的关系：
     · 类名统一加 `ct-` 前缀并挂在 .costtool 作用域下，
       因为站点本身已有 .hero / .wrap / .notes 等同名类，不加前缀会互相污染。
     · 配色不另起一套，直接复用站点 CSS 变量，保证与全站视觉一致。
   ============================================================ */

.costtool {
  max-width: 880px;
  margin: 0 auto;
  /* 页内小配色：省钱=薄荷绿，超支=橙，桶装水=红。站点主色仍走 --c-primary 系列 */
  --ct-good: #0a9c7c;
  --ct-good-d: #077a61;
  --ct-good-l: #e6f8f2;
  --ct-bad: #c0392b;
  --ct-warn: #b26a00;
  --ct-warn-l: #fdf3e2;
}

/* ============ 一、输入区 ============ */

.ct-calc {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: 22px;
  margin-top: 22px;
  box-shadow: var(--shadow);
}

.ct-field { margin-bottom: 20px; }
.ct-field:last-of-type { margin-bottom: 6px; }

.ct-field-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.ct-field-head .ct-fl { font-size: 0.9rem; font-weight: 600; color: var(--c-text); }
.ct-field-head .ct-fv {
  font-size: 1rem; font-weight: 700; color: var(--c-primary);
  font-family: var(--font-mono);
}
.ct-field-head .ct-fv i { font-style: normal; font-size: 0.75rem; font-weight: 400; color: var(--c-text-3); margin-left: 3px; font-family: var(--font-sans); }
/* 单价读数可点击手动输入（滑块只覆盖 12–25 元的常见区间，超出时靠它兜底） */
.ct-field-head .ct-fv.ct-edit { cursor: pointer; border-bottom: 1px dashed currentColor; }
.ct-field-head .ct-fv.ct-edit:hover { color: var(--c-primary-dark); }
.ct-field-head .ct-fv.ct-edit:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 3px; }

.ct-numrow { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ct-step {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--c-border-strong); border-radius: var(--radius);
  background: var(--c-surface-2); color: var(--c-primary);
  font-size: 1.375rem; font-weight: 700; line-height: 1;
  cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s;
}
.ct-step:hover { background: var(--c-primary-light); border-color: var(--c-primary); }
.ct-numrow input[type=number] {
  flex: 1; min-width: 0; height: 46px; text-align: center;
  font-size: 1.25rem; font-weight: 700; color: var(--c-primary-dark);
  font-family: var(--font-mono);
  border: 1px solid var(--c-border-strong); border-radius: var(--radius);
  background: var(--c-surface);
}
.costtool input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 99px; margin: 0; outline: none;
  background: linear-gradient(90deg, var(--c-primary) 0%, var(--c-primary) 50%, var(--c-border-strong) 50%, var(--c-border-strong) 100%);
}
.costtool input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 3px solid var(--c-primary);
  box-shadow: 0 2px 7px rgba(10, 99, 240, .28); cursor: pointer;
}
.costtool input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--c-primary); cursor: pointer;
}
.ct-rlabel { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--c-text-3); margin-top: 6px; font-family: var(--font-mono); }

.ct-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ct-chip {
  flex: 1 1 0; min-width: 72px; text-align: center;
  padding: 9px 6px; font-size: 0.82rem; font-weight: 600; font-family: inherit;
  color: var(--c-primary); background: var(--c-surface-2);
  border: 1px solid var(--c-border-strong); border-radius: var(--radius);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.ct-chip:hover { background: var(--c-primary-light); }
.ct-chip.on { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

.costtool details.ct-adv { margin-top: 16px; border-top: 1px dashed var(--c-border-strong); padding-top: 14px; }
.costtool details.ct-adv summary {
  font-size: 0.85rem; color: var(--c-text); font-weight: 600; cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.costtool details.ct-adv summary::-webkit-details-marker { display: none; }
.costtool details.ct-adv summary::after { content: "▾"; font-size: 0.7rem; transition: transform .2s; }
.costtool details.ct-adv[open] summary::after { transform: rotate(180deg); }
.ct-adv-hint { font-size: 0.78rem; color: var(--c-text-3); margin: 8px 0 14px; }
.ct-adv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ct-adv-grid label { display: block; font-size: 0.75rem; color: var(--c-text-2); margin-bottom: 5px; }
.ct-adv-grid input {
  width: 100%; height: 40px; padding: 0 10px;
  font-size: 0.9rem; font-family: var(--font-mono);
  border: 1px solid var(--c-border-strong); border-radius: var(--radius-s);
  background: var(--c-surface); color: var(--c-text);
  -webkit-appearance: none;
}
.ct-adv-sub { font-size: 0.8rem; font-weight: 700; color: var(--c-primary); margin: 18px 0 10px; }
.ct-btn-reset {
  margin-top: 16px; width: 100%; height: 44px; border-radius: var(--radius);
  font-family: inherit; font-size: 0.85rem; cursor: pointer;
  color: var(--c-primary); background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
}
.ct-btn-reset:hover { background: var(--c-primary-light); }

/* ============ 二、结果卡 ============ */

.ct-hero {
  margin-top: 20px; border-radius: var(--radius-l); overflow: hidden;
  background: var(--grad-brand);
  color: #fff; padding: 22px 20px 20px;
  box-shadow: 0 12px 30px -14px rgba(10, 99, 240, .6);
}
.ct-hero.ct-neg {
  background: linear-gradient(160deg, #b26a00 0%, #8a5200 100%);
  box-shadow: 0 12px 30px -14px rgba(138, 82, 0, .55);
}
.ct-hero-meta { font-size: 0.8rem; color: rgba(255, 255, 255, .82); }
.ct-hero-meta b { color: #fff; font-size: 0.88rem; font-family: var(--font-mono); }

.ct-seg {
  display: flex; gap: 6px; margin: 14px 0 18px; padding: 4px;
  background: rgba(255, 255, 255, .16); border-radius: var(--radius);
}
.ct-seg-btn {
  flex: 1; padding: 9px 6px; border: 0; border-radius: var(--radius-s);
  font-family: inherit; font-size: 0.85rem; font-weight: 600; white-space: nowrap;
  background: transparent; color: rgba(255, 255, 255, .88); cursor: pointer;
}
.ct-seg-btn.on { background: #fff; color: var(--c-primary-dark); font-weight: 700; }

.ct-hero-label { font-size: 0.85rem; color: rgba(255, 255, 255, .9); margin-bottom: 2px; }
.ct-hero-num {
  display: flex; align-items: baseline; gap: 2px; flex-wrap: wrap;
  font-size: clamp(2.25rem, 9vw, 3.75rem); font-weight: 800;
  letter-spacing: -1.5px; line-height: 1.05;
  font-family: var(--font-mono);
}
.ct-hero-num .ct-cur { font-size: .48em; font-weight: 700; opacity: .9; letter-spacing: 0; }
.ct-hero-num .ct-unit { font-size: .26em; font-weight: 500; opacity: .85; letter-spacing: 0; margin-left: 8px; font-family: var(--font-sans); }
.ct-hero-num.ct-small { font-size: clamp(1.7rem, 6vw, 2.5rem); letter-spacing: -.5px; }
.ct-hero-sub { font-size: 0.85rem; color: rgba(255, 255, 255, .9); margin-top: 10px; line-height: 1.8; }
.ct-hero-sub b { color: #fff; }
.ct-hero-hr { height: 1px; background: rgba(255, 255, 255, .22); margin: 16px 0 14px; }

.ct-bars { display: flex; flex-direction: column; gap: 10px; }
.ct-bar-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 9px; align-items: center; }
.ct-bar-name { font-size: 0.78rem; color: rgba(255, 255, 255, .9); white-space: nowrap; }
.ct-bar-track { position: relative; height: 20px; background: rgba(255, 255, 255, .18); border-radius: 6px; overflow: hidden; }
/* 条形用内联 <svg> 画而不是 <i style="width:..%">：
   CSP 不含 'unsafe-inline' 时内联 style 会被丢弃、条形全部塌成 0 宽；
   而 SVG 的 width 是表现属性，不受 CSP 约束，不执行 JS 也能正确渲染。
   圆角交给外层 .ct-bar-track 的 border-radius + overflow 处理。 */
.ct-bar-svg { display: block; width: 100%; height: 100%; }
.ct-bar-svg rect { fill: rgba(255, 255, 255, .5); }
.ct-bar-track.sel .ct-bar-svg rect { fill: #fff; }
.ct-bar-val { font-size: 0.72rem; font-weight: 700; color: #fff; white-space: nowrap; font-family: var(--font-mono); }

.ct-hero-note {
  margin-top: 16px; padding: 13px 15px;
  background: rgba(255, 255, 255, .18); border-left: 4px solid #fff;
  border-radius: var(--radius-s); font-size: 0.85rem; line-height: 1.75;
}

/* ============ 三、区块标题 ============ */

.costtool .ct-sec {
  font-size: 1.05rem; font-weight: 700; color: var(--c-text);
  margin: 34px 0 14px; padding-left: 12px;
  border-left: 4px solid var(--c-primary); line-height: 1.4;
}
.costtool .ct-sec em { display: block; font-style: normal; font-size: 0.78rem; font-weight: 400; color: var(--c-text-3); margin-top: 4px; }

/* ============ 四、三方案卡片 ============ */

.ct-cards3 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ct-pcard {
  position: relative; padding: 18px 18px 12px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-l); box-shadow: var(--shadow-s);
}
.ct-pcard.sel { border: 2px solid var(--ct-good); box-shadow: 0 8px 24px -14px rgba(10, 156, 124, .5); }
.ct-pc-flag {
  position: absolute; top: -10px; right: 16px;
  background: var(--ct-good); color: #fff;
  font-size: 0.7rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.ct-pc-head { display: flex; align-items: center; gap: 7px; font-size: 0.92rem; font-weight: 700; color: var(--c-text); }
.ct-pc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-primary); flex: 0 0 8px; }
.ct-pc-dot.b { background: var(--ct-bad); }
.ct-pc-dot.g { background: var(--ct-good); }
.ct-pc-main {
  margin: 10px 0 2px;
  font-size: clamp(1.5rem, 5vw, 1.9rem); font-weight: 800; letter-spacing: -.5px;
  line-height: 1.15; color: var(--ct-good);
  font-family: var(--font-mono);
}
.ct-pc-main.range { font-size: clamp(1.15rem, 4vw, 1.45rem); letter-spacing: -.8px; }
.ct-pc-main.barrel { color: var(--ct-bad); }
.ct-pc-main .u { font-size: .42em; font-weight: 500; color: var(--c-text-3); margin-left: 5px; letter-spacing: 0; font-family: var(--font-sans); }
.ct-pc-note { font-size: 0.76rem; color: var(--c-text-3); margin-bottom: 10px; }
.ct-pc-list { list-style: none; margin: 0; padding: 0; border-top: 1px dashed var(--c-border-strong); }
.ct-pc-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 9px 0; font-size: 0.8rem; color: var(--c-text-2);
  border-bottom: 1px dashed var(--c-border-strong);
}
.ct-pc-list li:last-child { border-bottom: 0; }
.ct-pc-list li span { flex: 1 1 auto; }
.ct-pc-list b { color: var(--c-text); font-weight: 700; font-size: 0.82rem; white-space: nowrap; font-family: var(--font-mono); }
.ct-pc-list b.save { color: var(--ct-good); }
.ct-pc-list b.bad { color: var(--ct-warn); }

/* ============ 五、档位速查 ============ */

.ct-tiers { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ct-tcard {
  padding: 16px 18px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-l); box-shadow: var(--shadow-s);
}
.ct-tcard-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.ct-tcard-h .ct-tn { font-size: 0.95rem; font-weight: 700; color: var(--c-text); }
.ct-tcard-h .ct-tp { font-size: 0.72rem; color: var(--c-text-3); font-family: var(--font-mono); }
.ct-trow {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; font-size: 0.8rem;
  border-bottom: 1px dashed var(--c-border-strong);
}
.ct-trow:last-child { border-bottom: 0; }
.ct-trow span { color: var(--c-text-2); }
.ct-trow b { color: var(--c-text); font-weight: 700; white-space: nowrap; font-family: var(--font-mono); }
.ct-trow b.b { color: var(--ct-bad); }
.ct-trow b.g { color: var(--ct-good); }
.ct-trow b.save { color: var(--ct-good); font-size: 0.85rem; }

/* ============ 六、成本构成 ============ */

.ct-model-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ct-mcard {
  padding: 16px 18px;
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
}
.ct-mcard h4 { margin: 0 0 12px; font-size: 0.9rem; font-weight: 700; color: var(--c-text); }
.ct-mitem {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; font-size: 0.8rem; color: var(--c-text-2);
  border-bottom: 1px dashed var(--c-border-strong);
}
.ct-mitem b { color: var(--c-text); font-weight: 700; white-space: nowrap; font-family: var(--font-mono); }
.ct-mtotal {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0 0; font-size: 0.88rem; font-weight: 700; color: var(--ct-good);
}
.ct-mtotal span:last-child { font-family: var(--font-mono); }
.ct-mtip { font-size: 0.75rem; color: var(--c-text-3); margin: 10px 0 0; line-height: 1.7; }

/* ============ 七、测算口径 ============ */

.ct-notes {
  padding: 20px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
}
.ct-notes ol { margin: 0; padding-left: 20px; font-size: 0.82rem; color: var(--c-text-2); }
.ct-notes li { margin-bottom: 9px; line-height: 1.8; }
.ct-notes li:last-child { margin-bottom: 0; }

/* ============ 八、手机端悬浮栏 ============ */

.ct-stickybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--c-border-strong);
  box-shadow: 0 -4px 18px rgba(8, 25, 43, .08);
}
.ct-sb-l { flex: 1; min-width: 0; }
.ct-sb-label { font-size: 0.72rem; color: var(--c-text-3); }
.ct-sb-num {
  font-size: 1.15rem; font-weight: 800; color: var(--ct-good);
  letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.ct-sb-num.neg { color: var(--ct-warn); }
.ct-sb-btn {
  flex: 0 0 auto; height: 46px; padding: 0 20px; border: 0; border-radius: var(--radius);
  background: var(--grad-brand); color: #fff;
  font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-glow);
}

/* ============ 九、自适应 ============ */

@media (min-width: 700px) {
  .ct-cards3 { grid-template-columns: repeat(3, 1fr); }
  .ct-tiers { grid-template-columns: repeat(2, 1fr); }
  .ct-model-grid { grid-template-columns: repeat(2, 1fr); }
  .ct-sec em { display: inline; margin-left: 8px; }
}

@media (max-width: 699px) {
  .ct-stickybar { display: flex; }
  .costtool { padding-bottom: 84px; }
  .ct-adv-grid { grid-template-columns: repeat(2, 1fr); }
  .ct-calc { padding: 18px 16px 16px; }
}

@media (min-width: 700px) {
  .ct-stickybar { display: none; }
}

/* ============ 十、打印（客户常把测算结果打印出来内部传阅） ============ */

@media print {
  .ct-calc, .ct-stickybar, .ct-seg, .ct-hero-note { display: none !important; }
  .ct-hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ct-cards3, .ct-tiers, .ct-model-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .ct-sec { page-break-after: avoid; }
  .ct-pcard, .ct-tcard, .ct-mcard, .ct-notes { page-break-inside: avoid; }
}
