/* ==========================================================================
   计算器栏目共用样式（房贷 / 借款 / 工资）
   ========================================================================== */

/* 一行并排的控件：.seg 高 36px，而全局 select/input 是 padding 12px 约 50px，
   直接并排会一高一矮，所以在 .opts 这一层统一高度。 */
.opts { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.opts .field { flex: 0 0 auto; margin-bottom: 0; min-width: 0; }
/* 定宽字段：给 field 一个宽度，里面的输入框撑满，几个框才会一样宽 */
.opts .field.fw input,
.opts .field.fw select { width: 100%; }
.opts .seg { height: 36px; box-sizing: border-box; align-items: center; }
.opts .seg button { height: 28px; padding: 0 13px; display: inline-flex; align-items: center; }
.opts select,
.opts input[type="number"],
.opts input[type="text"],
.opts input[type="month"] {
  width: auto; min-width: 104px; height: 36px; box-sizing: border-box;
  padding: 0 10px; font-size: 13px; line-height: 34px;
}
.opts .seg input { height: auto; }

/* 关键数字 */
.kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi > div {
  background: var(--panel-sunken); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; min-width: 0;
}
.kpi .k { font-size: 12px; color: var(--text-dim); font-weight: 550; }
.kpi .v {
  font-size: 19px; font-weight: 700; font-family: var(--mono);
  margin-top: 5px; font-variant-numeric: tabular-nums; word-break: break-all;
}
.kpi .s { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; line-height: 1.5; }
@media (max-width: 980px) { .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 利率对照表 */
.rate-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rate-table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--text-dim);
  padding: 7px 12px; border-bottom: 1px solid var(--border); background: #fafbfd;
}
.rate-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rate-table tr:last-child td { border-bottom: 0; }
.rate-table .n { text-align: right; font-variant-numeric: tabular-nums; }
.rate-table .num { font-family: var(--mono); font-size: 15px; font-weight: 650; }
.rate-table .lead { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.rate-table tr.hl td { background: var(--accent-soft); }
.rate-table tr.hl .num { color: var(--accent-dark); font-size: 17px; }
.rate-table tr.dim td { color: var(--text-dim); }

/* 提示条：黄色是提醒，红色是警告，都不是报错 */
.warn-line,
.bad-line,
.ok-line {
  font-size: 12.5px; line-height: 1.65; border-radius: 8px;
  padding: 9px 12px; margin-top: 12px;
}
.warn-line { color: #93370d; background: #fef0c7; border: 1px solid #f5d597; }
.bad-line { color: #991b1b; background: #fee4e2; border: 1px solid #fda29b; }
.ok-line { color: #065f46; background: #d1fadf; border: 1px solid #a6f4c5; }

/* 大号结论句 */
.verdict {
  margin-top: 14px; padding: 13px 15px; border-radius: 10px;
  background: var(--panel-sunken); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.85; color: var(--text-dim);
}
.verdict b { color: var(--text); font-weight: 650; }
.verdict .big {
  font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--err);
}

/* 表里的小标题行 */
.row-sep { background: #fafbfd; font-weight: 600; color: var(--text-dim); }

/* 图例 */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.legend i {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 5px; vertical-align: middle;
}

/* 说明区里的公式 */
.formula {
  font-family: var(--mono); font-size: 12px; line-height: 1.9;
  background: var(--panel-sunken); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; margin: 8px 0; overflow-x: auto;
  white-space: pre;
}

/* 竖排字段（城市参数那种一堆输入框） */
.fields-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 900px) { .fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* !important：房贷页把列数写在行内 style 上，普通规则压不住 */
@media (max-width: 620px) { .fields-grid { grid-template-columns: 1fr !important; } }

/* ---------- 手机端（≤640px） ----------
   计算器的控件原本靠行内 width（150px/170px）排成一行，窄屏下会挤成
   三四列各 90px，输入框里连「350000」都看不见。这里把定宽字段改成整行，
   同时把字号提到 16px（iOS 聚焦不放大）、高度提到 42px（拇指好点）。 */
@media (max-width: 640px) {
  .opts { gap: 12px; }
  /* 行内 style="width:150px" 优先级高于普通规则，必须 !important */
  .opts .field.fw { flex: 1 1 100%; width: 100% !important; }
  .opts .field:not(.fw) { flex: 0 0 auto; }

  .opts select,
  .opts input[type="number"],
  .opts input[type="text"],
  .opts input[type="month"] {
    height: 42px; font-size: 16px; line-height: 40px; min-width: 0;
  }
  .opts .seg { height: 42px; }
  .opts .seg button { height: 34px; font-size: 13px; padding: 0 11px; }

  /* 4 列在 390px 下每张只剩 70px，数字必截断；2 列刚好。
     !important：有的页面把列数写在行内 style 上（如房贷的三张卡）。 */
  .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  /* 奇数张卡时最后一张独占一行，避免右下角空一格 */
  .kpi > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi > div { padding: 10px 11px; }
  .kpi .k { font-size: 11.5px; }
  .kpi .v { font-size: 16px; margin-top: 4px; }
  .kpi .s { font-size: 11px; }

  .rate-table { font-size: 12px; }
  .rate-table th, .rate-table td { padding: 8px; }
  .rate-table th { font-size: 11px; }

  /* 公式行：固定 116px 的标签列在 320px 宽下占比过大 */
  .formula .f-k { flex: 0 0 84px; font-size: 11.5px; }
  .formula { font-size: 12px; }
}
.fields-grid .field { margin-bottom: 0; min-width: 0; }
.fields-grid input, .fields-grid select { width: 100%; min-width: 0; height: 36px; padding: 0 10px; font-size: 13px; }

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 8px 14px; border-radius: 0; color: var(--text-dim);
  font-size: 13px; font-weight: 550;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
