:root {
  --primary: #1a6fc4;
  --primary-dark: #14589e;
  --secondary: #2c8ce0;
  --accent: #e74c3c;
  --success: #16a34a;
  --warn: #f59e0b;
  --text: #1f2937;
  --text-sub: #6b7280;
  --line: #e3e8ef;
  --bg: #f2f5f9;
  --card: #ffffff;
  --soft: #f6f8fb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
  padding-bottom: 40px;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px; }

/* ---------------- 顶部城市条 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(26, 111, 196, .25);
}
.topbar-inner {
  max-width: 640px; margin: 0 auto; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .pin { font-size: 18px; line-height: 1; }
.topbar .city-name { font-size: 17px; font-weight: 600; }
.topbar .city-prov { font-size: 12px; opacity: .85; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.btn-city {
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .45);
  color: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.btn-city:hover { background: rgba(255, 255, 255, .3); }

.snapshot {
  max-width: 640px; margin: 0 auto; padding: 0 14px 10px;
  font-size: 12px; color: rgba(255, 255, 255, .82);
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-top: 14px;
}
.card-title {
  font-size: 15px; font-weight: 600; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.card-title .step {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
  flex: none;
}
.card-title .hint { margin-left: auto; font-size: 12px; color: var(--text-sub); font-weight: 400; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.field > label .sub { font-weight: 400; color: var(--text-sub); margin-left: 6px; font-size: 12px; }
.req::after { content: " *"; color: var(--accent); }

input[type="number"], input[type="text"], select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 16px; color: var(--text); background: #fff;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 34px;
}
input:focus, select:focus {
  outline: none; border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(44, 140, 224, .15);
}
input[readonly] { background: var(--soft); color: var(--text); font-weight: 600; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------------- 分段控件 ---------------- */
.seg {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px; background: var(--soft); padding: 4px; border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.seg button {
  border: none; background: transparent; cursor: pointer;
  padding: 8px 2px; border-radius: 6px;
  font-size: 13px; color: var(--text-sub); font-weight: 500;
  transition: all .15s;
}
.seg button.on { background: #fff; color: var(--primary); font-weight: 700; box-shadow: 0 1px 3px rgba(16,24,40,.12); }

/* ---------------- 车型信息条 ---------------- */
.model-info {
  margin-top: 10px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--soft); border: 1px solid var(--line);
  display: none;
}
.model-info.show { display: block; }
.model-info .name { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.model-info .kv { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; }
.model-info .kv span { color: var(--text-sub); }
.model-info .kv b { color: var(--text); font-variant-numeric: tabular-nums; }
.model-info .kv b.deal { color: var(--accent); }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; vertical-align: 1px; margin-left: 6px;
}
.badge.ev { background: #e8f5ec; color: #16794a; }
.badge.fuel { background: #fdf0e3; color: #b45309; }
.badge.noq { background: #fef3c7; color: #b45309; }

.model-info .noquote {
  margin-top: 10px; padding: 8px 10px;
  background: #fffaf0; border: 1px solid #fde8c4; border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.55; color: #92400e;
}
.model-info .noquote b { color: #b45309; }

/* 本地报价覆盖提示条 */
.notice {
  margin-bottom: 14px; padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.6;
  background: #fffaf0; border: 1px solid #fde8c4; color: #92400e;
}
.notice b { color: #b45309; }
.notice .notice-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.notice .notice-actions button {
  border: 1px solid #f0c98a; background: #fff; color: #b45309;
  border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.notice .notice-actions button:hover { background: #fdf3e3; }

/* ---------------- 折叠 ---------------- */
.collapse-head {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  font-size: 13px; font-weight: 600; color: var(--text-sub);
  padding: 10px 0; border-top: 1px dashed var(--line);
}
.collapse-head .arrow { transition: transform .2s; font-size: 11px; }
.collapse-head.open .arrow { transform: rotate(180deg); }
.collapse-body { display: none; padding-top: 4px; }
.collapse-body.open { display: block; }

/* ---------------- 快捷 chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button {
  border: 1px solid var(--line); background: #fff; color: var(--text-sub);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.chips button:hover { border-color: var(--secondary); color: var(--primary); }
.chips button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 购置税口径小字说明（燃油车 / 新能源两套公式的适用条件） */
.tax-note {
  margin-top: 8px; font-size: 11.5px; line-height: 1.6; color: var(--text-sub);
}

/* ---------------- 金融方案 ---------------- */
/* 选中方案后的说明行：方案名 + 年化 + 备注；手改过会多出「已手改 · 按方案重填」 */
.plan-note {
  margin-top: 6px; font-size: 12px; line-height: 1.6; color: var(--text-sub);
}
.plan-note b { color: var(--text); }
.plan-note a { color: var(--primary); text-decoration: underline; cursor: pointer; }

/* 四口径对照：切口径 / 改期数 / 手改系数时实时更新 */
.rate-hint {
  margin-top: 10px; padding: 8px 10px;
  background: var(--soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.6; color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.rate-hint b { color: var(--text); }
.rate-hint.warn { background: #fffaf0; border-color: #fde8c4; color: #92400e; }
.rate-hint.warn b { color: #b45309; }

/* ---------------- 按钮 ---------------- */
.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1; border: none; border-radius: var(--radius-sm);
  padding: 13px 18px; font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--secondary); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-ghost { background: var(--soft); color: var(--primary); border: 1px solid var(--line); }
.btn-ghost:hover { background: #e9eef5; }

/* ---------------- 结果 ---------------- */
.result-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff; border-radius: var(--radius); padding: 18px 16px;
  text-align: center; margin-bottom: 12px;
}
.result-hero .label { font-size: 13px; opacity: .9; }
.result-hero .value { font-size: 36px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.result-hero .value small { font-size: 16px; font-weight: 500; margin-left: 3px; }
.result-hero .sub { font-size: 12px; opacity: .85; margin-top: 2px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.warn-box {
  background: #fffaf0; border: 1px solid #fde8c4; border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 12px;
  font-size: 12.5px; line-height: 1.6; color: #92400e;
}
.warn-box b { color: #b45309; }
.result-cell {
  background: var(--soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.result-cell .k { font-size: 12px; color: var(--text-sub); }
.result-cell .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.result-cell .v.accent { color: var(--accent); }
.result-cell.wide { grid-column: 1 / -1; }

.empty {
  text-align: center; color: var(--text-sub); font-size: 13px;
  padding: 26px 10px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
}

.disclaimer {
  font-size: 11.5px; color: var(--text-sub); line-height: 1.6;
  margin-top: 14px; padding: 10px 12px;
  background: #fffaf0; border: 1px solid #fde8c4; border-radius: var(--radius-sm);
}
.disclaimer b { color: #b45309; }

/* ---------------- 城市选择弹层 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, .45);
  display: none; align-items: flex-end; justify-content: center;
}
.modal.open { display: flex; }
.modal-panel {
  background: #fff; width: 100%; max-width: 640px;
  border-radius: 16px 16px 0 0; max-height: 82vh;
  display: flex; flex-direction: column;
}
.modal-head {
  padding: 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.modal-head button { border: none; background: none; font-size: 22px; line-height: 1; color: var(--text-sub); cursor: pointer; }
.modal-search { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-body { overflow-y: auto; padding: 6px 0 20px; -webkit-overflow-scrolling: touch; }
.prov-group { padding: 10px 16px 4px; font-size: 12px; font-weight: 700; color: var(--text-sub); background: var(--soft); }
.city-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 16px; }
.city-item {
  border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm);
  padding: 9px 4px; font-size: 14px; cursor: pointer; text-align: center;
  position: relative;
}
.city-item:hover { border-color: var(--secondary); }
.city-item.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.city-item.off { color: #c3cad5; background: var(--soft); cursor: not-allowed; border-style: dashed; }
.city-item .n { font-size: 10px; display: block; color: var(--text-sub); }
.city-item.on .n { color: rgba(255, 255, 255, .85); }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(10px);
  background: rgba(17, 24, 39, .92); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 99;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { text-align: center; color: var(--text-sub); font-size: 13px; padding: 30px 0; }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 10px;
  border: 2px solid var(--line); border-top-color: var(--secondary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 380px) {
  .result-hero .value { font-size: 30px; }
  .city-list { grid-template-columns: repeat(2, 1fr); }
}
