:root {
  --bg: #f6f7fa;
  --card: #ffffff;
  --line: #e4e7ee;
  --line-soft: #eef0f5;
  --text: #1c2333;
  --text-dim: #66708a;
  --text-faint: #98a1b6;
  --red: #d4232e;
  --red-soft: #fdeced;
  --green: #0e9f6e;
  --green-soft: #e7f6f0;
  --blue: #2563eb;
  --blue-soft: #e8effd;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --purple: #7c3aed;
  --purple-soft: #f1ebfd;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #d4232e, #f0603c);
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff;
  box-shadow: 0 4px 12px rgba(212, 35, 46, .28);
}
.brand-text h1 { margin: 0; font-size: 17px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--text-dim); }

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  font-size: 11px; color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(14, 159, 110, .22);
  padding: 3px 10px; border-radius: 99px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  background: #fff; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; font-family: inherit; cursor: pointer;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- layout ---------- */
.layout {
  max-width: 1280px; margin: 0 auto;
  padding: 20px 22px 50px;
  display: grid; gap: 18px;
  grid-template-columns: 400px 1fr;
  align-items: start;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.inputs { position: sticky; top: 76px; }
.panel-title { font-size: 13.5px; font-weight: 700; margin-bottom: 14px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.field .unit { color: var(--text-faint); font-size: 11px; margin-left: 2px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input[type="number"], select {
  width: 100%; height: 38px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 0 11px; font: inherit; font-size: 14px;
  background: #fff; color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-variant-numeric: tabular-nums;
}
input[type="number"]:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.hint { font-size: 11px; color: var(--text-faint); margin-top: 5px; line-height: 1.6; }

.city-row { display: flex; align-items: center; gap: 10px; }
.city-row select { flex: 1; }
.city-tip { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

.fold { border-top: 1px solid var(--line-soft); padding: 11px 0; }
.fold summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  list-style: none; user-select: none;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before {
  content: ''; width: 0; height: 0;
  border-left: 5px solid var(--text-faint);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .15s;
}
.fold[open] summary::before { transform: rotate(90deg); }
.sum-rate { margin-left: auto; font-size: 11.5px; color: var(--blue); font-weight: 500; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 11px; }
.mini { display: flex; flex-direction: column; gap: 3px; }
.mini label { font-size: 11px; color: var(--text-faint); }
.mini input { height: 32px; font-size: 13px; padding: 0 8px; }

.special-list { margin-top: 11px; display: flex; flex-direction: column; gap: 9px; }
.sp-item {
  display: grid; grid-template-columns: 1fr 84px; gap: 8px; align-items: center;
}
.sp-item label { font-size: 12.5px; }
.sp-item .sp-sub { font-size: 10.5px; color: var(--text-faint); display: block; margin-top: 1px; }

.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.preset {
  font: inherit; font-size: 12px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 99px;
  padding: 5px 12px; color: var(--text-dim);
  transition: all .14s;
}
.preset:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.hero {
  background: linear-gradient(135deg, #fff 0%, #f4f7ff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, .08), transparent 70%);
}
.hero-main { flex: 1; min-width: 240px; }
.hero-label { font-size: 12.5px; color: var(--text-dim); }
.hero-value { font-size: 40px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-value .cur { font-size: 20px; font-weight: 600; color: var(--text-dim); margin-right: 4px; }
.hero-sub { font-size: 12px; color: var(--text-faint); margin-top: 7px; line-height: 1.6; }
.hero-side {
  display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 10px 22px;
  border-left: 1px solid var(--line); padding-left: 24px;
}
@media (max-width: 560px) { .hero-side { border-left: none; padding-left: 0; } }
.hero-item { display: flex; flex-direction: column; gap: 2px; }
.hero-item span { font-size: 11px; color: var(--text-faint); }
.hero-item b { font-size: 17px; font-variant-numeric: tabular-nums; }
.hero-item b.red { color: var(--red); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-sub { font-size: 11px; color: var(--text-faint); font-weight: 400; }

.chart-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-box { flex: 0 0 200px; }
.legend { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 9px; }
.lg-item { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.lg-item i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg-item .lg-name { color: var(--text-dim); }
.lg-item .lg-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.lg-item .lg-pct { color: var(--text-faint); font-size: 11px; width: 44px; text-align: right; }

.bar-box { width: 100%; }
.mini-legend { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 11px; color: var(--text-faint); flex-wrap: wrap; }
.mini-legend .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.mini-legend .dot.green { background: var(--green); }
.mini-legend .dot.red { background: var(--red); }
.mini-legend .ml { margin-left: auto; }

/* bonus compare */
.bonus-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .bonus-compare { grid-template-columns: 1fr; } }
.bc-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 15px 16px;
  position: relative;
}
.bc-card.win { border-color: var(--green); background: var(--green-soft); }
.bc-card .bc-tag {
  position: absolute; top: -9px; left: 14px;
  font-size: 10.5px; background: #fff; border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 99px; color: var(--text-dim);
}
.bc-card.win .bc-tag { color: var(--green); border-color: var(--green); background: #fff; }
.bc-title { font-size: 13px; font-weight: 700; margin: 4px 0 10px; }
.bc-rows { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.bc-row { display: flex; justify-content: space-between; }
.bc-row span { color: var(--text-dim); }
.bc-row b { font-variant-numeric: tabular-nums; }
.bc-final { margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.bc-final span { font-size: 12px; color: var(--text-dim); }
.bc-final b { font-size: 21px; font-variant-numeric: tabular-nums; }
.bc-diff { font-size: 11.5px; margin-top: 8px; color: var(--text-dim); }
.bc-diff b { color: var(--red); }

/* trap table */
.trap-table { display: flex; flex-direction: column; gap: 8px; }
.trap-row {
  display: grid; grid-template-columns: 150px 1fr 1fr; gap: 10px; align-items: center;
  background: var(--amber-soft); border: 1px solid rgba(180, 83, 9, .16);
  border-radius: 10px; padding: 9px 13px; font-size: 12px;
}
.trap-row .t-range { font-weight: 700; color: var(--amber); font-variant-numeric: tabular-nums; }
.trap-row .t-desc { color: var(--text-dim); line-height: 1.5; }
.trap-row .t-avoid { color: var(--text); line-height: 1.5; }
.trap-row .t-avoid b { color: var(--green); }
@media (max-width: 640px) { .trap-row { grid-template-columns: 1fr; gap: 3px; } }

/* month table */
.table-scroll { overflow-x: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th {
  text-align: right; color: var(--text-faint); font-weight: 500; font-size: 11px;
  padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table td {
  padding: 7px 9px; border-bottom: 1px solid var(--line-soft);
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mini-table tr:last-child td { border-bottom: none; }
.mini-table td.red { color: var(--red); }
.mini-table tr.total td { font-weight: 700; border-top: 1px solid var(--line); background: #fafbfd; }

/* ---------- offer panel ---------- */
.drawer-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .45);
  animation: fadein .18s;
}
/* hidden 属性必须压过组件的 display 规则，否则抽屉/toast 会默认可见 */
[hidden] { display: none !important; }

.offer-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95;
  width: min(520px, 100vw);
  background: var(--bg);
  box-shadow: -14px 0 44px rgba(16, 24, 40, .18);
  display: flex; flex-direction: column;
  animation: slidein .22s ease;
}
@keyframes fadein { from { opacity: 0; } }
@keyframes slidein { from { transform: translateX(46px); opacity: 0; } }

.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 16px 20px 12px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 16px; font-weight: 800; }
.drawer-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.icon-btn {
  background: #fff; border: 1px solid var(--line); color: var(--text-dim);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 12px;
}
.icon-btn:hover { color: var(--red); border-color: var(--red); }

.offer-body { padding: 18px 20px 30px; overflow-y: auto; flex: 1; }
.offer-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.offer-col {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.offer-col label { font-size: 11px; color: var(--text-faint); margin-top: 7px; }
.offer-col input { height: 34px; font-size: 13.5px; }
.offer-tag {
  align-self: flex-start; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 99px; margin-bottom: 4px;
}
.offer-tag.a { color: var(--blue); background: var(--blue-soft); }
.offer-tag.b { color: var(--purple); background: var(--purple-soft); }

.offer-result { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.or-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px;
}
.or-row .or-name { font-size: 12.5px; color: var(--text-dim); width: 64px; flex: none; }
.or-bar-wrap { flex: 1; height: 26px; background: var(--line-soft); border-radius: 7px; overflow: hidden; position: relative; }
.or-bar { height: 100%; border-radius: 7px; transition: width .35s ease; display: flex; align-items: center; padding-left: 9px; color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.or-bar.a { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.or-bar.b { background: linear-gradient(90deg, #a78bfa, #7c3aed); }
.or-val { width: 96px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.or-verdict {
  background: var(--green-soft); border: 1px solid rgba(14, 159, 110, .25);
  color: var(--green); border-radius: 12px; padding: 13px 16px;
  font-size: 13.5px; line-height: 1.7;
}
.or-verdict b { font-size: 17px; }
.offer-note { margin-top: 14px; font-size: 11px; color: var(--text-faint); line-height: 1.7; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 130; background: #1c2333; color: #fff;
  border-radius: 10px; padding: 10px 18px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .25);
  animation: toastin .22s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } }

#footer {
  max-width: 1280px; margin: 0 auto; padding: 0 22px 30px;
  font-size: 11px; color: var(--text-faint); line-height: 1.8;
}

@media (max-width: 720px) {
  .layout { padding: 14px 14px 36px; }
  .inputs { position: static; }
  .hero-value { font-size: 32px; }
  .hero { padding: 18px; }
}
