/* =========================================================
 *  合同款项计算器 · 页面样式
 *
 *  公共色板在 hub.css。.tool-page / .card / .note 这几个壳子和其他
 *  小工具一致（各页自带一份，改动互不影响），下面是本页专属的分期表格。
 * ========================================================= */

.tool-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 20px 24px;
}

.tp-head { text-align: center; margin-bottom: 24px; }
.tp-ic {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(52, 199, 89, .16), rgba(52, 199, 89, .06));
  color: var(--ok);
  font-size: 30px;
}
.tp-head h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.tp-sub { margin: 0; color: var(--tx2); font-size: 14.5px; }

.card {
  padding: 26px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.fld-label {
  display: block;
  font-size: 13px;
  color: var(--tx2);
  margin-bottom: 8px;
  font-weight: 500;
}

/* 合同总额输入 */
.amt-wrap {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  transition: border-color .2s var(--ease), box-shadow .2s;
}
.amt-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, .12);
}
.amt-cny { flex: none; margin-right: 8px; color: var(--tx2); font-size: 22px; font-weight: 500; }
.amt-in {
  flex: 1;
  min-width: 0;
  padding: 14px 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--tx);
  font-size: 26px;
  font-weight: 600;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
}
.amt-clear {
  flex: none;
  width: 24px; height: 24px;
  margin-left: 8px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(120, 120, 128, .16);
  color: var(--tx3);
  font-size: 12px;
}
.amt-clear:hover { background: rgba(120, 120, 128, .24); color: var(--tx2); }

.fld-tip {
  margin: 10px 4px 0;
  font-size: 13px;
  color: var(--tx3);
}
.fld-tip.err { color: var(--err); }
/* 总额大写：合同里照抄的就是这一行，得看得见 */
.fld-tip b {
  color: #1f8a3d;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
}
.fld-tip.err b { color: var(--err); }

/* iOS 分段控件 */
.seg-wrap { display: flex; justify-content: center; }
.seg-wrap.mode { margin: 22px 0 18px; }
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  background: rgba(120, 120, 128, .12);
}
.seg button {
  padding: 8px 18px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--tx2);
  font-size: 14px;
  font-family: inherit;
  transition: background .25s var(--ease), color .2s;
}
.seg button.on {
  background: #fff;
  color: var(--tx);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

/* ---------------- 分期表格 ---------------- */

/* 四列：名称 / 输入 / 折算结果 / 删除 */
.rows-head, .prow {
  display: grid;
  grid-template-columns: 1fr 118px 130px 34px;
  gap: 10px;
  align-items: center;
}

.rows-head {
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--line2);
  color: var(--tx3);
  font-size: 12px;
}
.rows-head .rh-money { text-align: right; }

.rows { margin-top: 4px; }
.prow { padding: 8px 0; }

.p-name, .p-in {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--tx);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
.p-name:focus, .p-val:focus-within .p-in {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, .1);
}

.p-val { position: relative; }
.p-val .p-in {
  padding-right: 30px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.p-unit {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tx3);
  font-size: 12.5px;
  pointer-events: none;
}

.p-money {
  text-align: right;
  color: var(--tx);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-del {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: rgba(120, 120, 128, .08);
  color: var(--tx3);
  font-size: 14px;
  transition: background .2s, color .2s;
}
.p-del:hover:not(:disabled) { background: rgba(255, 59, 48, .1); color: var(--err); }
.p-del:disabled { opacity: .35; cursor: default; }

.rows-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1.5px dashed var(--line);
  border-radius: 99px;
  background: none;
  color: var(--tx2);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color .2s, color .2s, background .2s;
}
.btn-add:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn-add .ic { font-size: 14px; }

.sum { color: var(--tx2); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.sum b { color: var(--tx); font-weight: 600; }
.sum.bad, .sum.bad b { color: var(--err); }

/* 常用方案 */
.quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.quick-label { margin-right: 4px; color: var(--tx3); font-size: 12.5px; }
.quick button {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #fff;
  color: var(--tx2);
  font-size: 12.5px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s, color .2s, background .2s;
}
.quick button:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------------- 付款计划 ---------------- */

.out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.out-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.out-tip { color: var(--tx3); font-size: 12.5px; text-align: right; }

/* 每期下面的两个复制按钮 */
.pl-ops { display: flex; gap: 8px; margin-top: 10px; }
.pl-cp {
  padding: 6px 13px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: #fff;
  color: var(--tx);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .2s, color .2s, background .2s, transform .25s var(--ease);
}
.pl-cp:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.pl-cp:active { transform: scale(.96); }

.plan { display: grid; gap: 10px; }

.pl-item {
  padding: 14px 16px;
  border: 1px solid rgba(52, 199, 89, .18);
  border-radius: 14px;
  background: linear-gradient(140deg, rgba(52, 199, 89, .07), rgba(10, 132, 255, .04));
  animation: fadeUp .28s var(--ease);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

.pl-top { display: flex; align-items: center; gap: 9px; }
.pl-idx {
  width: 20px; height: 20px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(52, 199, 89, .18);
  color: #1f8a3d;
  font-size: 11.5px;
  font-weight: 600;
}
.pl-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pl-pct { flex: none; color: var(--tx2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.pl-num {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--tx);
  font-variant-numeric: tabular-nums;
}
/* 大写金额是抄进合同里的那一行，做成醒目的独立一条 */
.pl-cap {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 8px;
  padding: 8px 11px;
  border-left: 3px solid var(--ok);
  border-radius: 4px 10px 10px 4px;
  background: rgba(52, 199, 89, .12);
  word-break: break-all;
}
.plc-tag {
  flex: none;
  color: #1f8a3d;
  font-size: 11.5px;
  font-weight: 600;
  opacity: .8;
}
.pl-cap b {
  color: #177030;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.5;
}

.pl-total {
  margin-top: 4px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--tx2);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.plt-tx { min-width: 0; }
.pl-total .pl-ops { margin-top: 0; }
.pl-total b {
  color: var(--tx);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* 总额行的大写复用 .pl-cap，别被上面的 .pl-total b 抢掉绿色 */
.pl-total .pl-cap { margin-top: 7px; }
.pl-total .pl-cap b { color: #177030; font-size: 15.5px; }
.pl-total .plc-tag { color: #1f8a3d; font-size: 11.5px; }

/* ---------------- 说明 ---------------- */

.note h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.note ul {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--tx2);
  font-size: 14px;
  line-height: 1.8;
}
.note li + li { margin-top: 4px; }
.note b { color: var(--tx); font-weight: 600; }
.note a { color: var(--brand); }

/* ---------------- 深色模式补丁 ---------------- */

@media (prefers-color-scheme: dark) {
  .amt-wrap, .p-name, .p-in, .quick button, .pl-cp { background: #2c2c2e; }
  .seg button.on { background: #48484a; color: #fff; }
  /* 深色底上深绿看不清，换亮绿 */
  .pl-cap { background: rgba(52, 199, 89, .16); }
  .pl-cap b, .pl-total .pl-cap b { color: #6ee68f; }
  .plc-tag, .pl-total .plc-tag { color: #6ee68f; }
  .fld-tip b { color: #6ee68f; }
  .pl-idx { color: #6ee68f; }
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 640px) {
  .tool-page { padding: 24px 14px 16px; }
  .tp-head h1 { font-size: 22px; }
  .tp-sub { font-size: 13.5px; }
  .card { padding: 18px 15px; border-radius: 16px; }
  .amt-in { font-size: 22px; padding: 12px 0; }
  .seg button { padding: 8px 14px; font-size: 13.5px; }

  /* 窄屏三列挤不开，折算结果换到第二行整行显示 */
  .rows-head { display: none; }
  .prow {
    grid-template-columns: 1fr 96px 32px;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line2);
  }
  .prow:last-child { border-bottom: 0; }
  /* 显式排位，不然 p-money 占整行会把删除按钮挤到第三行 */
  .prow > .p-name { grid-column: 1; grid-row: 1; }
  .prow > .p-val  { grid-column: 2; grid-row: 1; }
  .prow > .p-del  { grid-column: 3; grid-row: 1; }
  .p-money {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
    color: var(--tx2);
    font-size: 13px;
  }
  .p-name, .p-in { padding: 9px 10px; font-size: 15px; }
  .p-val .p-in { padding-right: 26px; }
  .p-del { width: 32px; height: 32px; }

  .rows-foot { margin-top: 10px; }
  .pl-num { font-size: 22px; }
  .pl-cap { padding: 7px 9px; gap: 6px; }
  .pl-cap b, .pl-total .pl-cap b { font-size: 14.5px; }
  .fld-tip b { font-size: 14.5px; }
  /* 窄屏两个复制按钮各占一半，够大好点 */
  .pl-cp { flex: 1; padding: 8px 0; }
  .out-tip { display: none; }
  .pl-total { display: block; }
  .pl-total .pl-ops { margin-top: 10px; }
}
