/* ---------- 步骤条 ---------- */
.steps {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 0.9rem;
}
.step + .step::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--border);
  margin-right: 4px;
}
.step-no {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
}
.step.is-active { color: var(--text); font-weight: 500; }
.step.is-active .step-no { background: var(--info); border-color: var(--info); color: #fff; }
.step.is-done { color: var(--stable); }
.step.is-done .step-no { background: var(--stable-soft); border-color: transparent; color: var(--stable); }
@media (prefers-color-scheme: dark) {
  .step.is-active .step-no { color: #0b0f14; }
}

/* ---------- 上传区 ---------- */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 240px;
  padding: 40px 24px;
  border: 1.5px dashed var(--border);
  box-shadow: none;
  text-align: center;
  cursor: pointer;
  transition: border-color 200ms var(--ease-out), background-color 200ms var(--ease-out);
}
.drop:hover, .drop.is-over {
  border-color: var(--info);
  background: var(--info-soft);
}
.drop-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--info-soft);
  color: var(--info);
  margin-bottom: 4px;
  transition: transform 300ms var(--ease-out);
}
.drop:hover .drop-icon, .drop.is-over .drop-icon { transform: translateY(-3px); }
.drop-icon svg { width: 26px; height: 26px; }
.drop-title { font-size: 1.05rem; font-weight: 500; }
.drop-title u { color: var(--info); text-decoration: none; }
.drop-hint { color: var(--text-3); font-size: 0.86rem; }

.busy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  color: var(--text-2);
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--info);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-on-btn {
  width: 16px;
  height: 16px;
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}
.btn[disabled] { opacity: 0.75; cursor: progress; }
.drop.is-disabled { pointer-events: none; opacity: 0.55; }
.actionbar + .alert { margin-top: 10px; }

.alert {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--leak-soft);
  color: var(--leak);
  font-size: 0.92rem;
}

/* ---------- 文件条 ---------- */
.filebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 18px;
}
.file-icon {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--stable-soft);
  color: var(--stable);
}
.file-icon svg { width: 20px; height: 20px; }
.file-meta { flex: 1; min-width: 0; }
.file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-sub { font-size: 0.84rem; }

/* ---------- 数字卡 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.stat { padding: 16px 18px; }
.stat-label { color: var(--text-2); font-size: 0.84rem; }
.stat-value {
  margin-top: 4px;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.stat-accent { border-color: transparent; background: var(--stable-soft); box-shadow: none; }
.stat-accent .stat-label, .stat-accent .stat-value { color: var(--stable); }
.stat-unit { font-size: 0.9rem; font-weight: 500; margin-left: 2px; }

/* ---------- 操作条 ---------- */
.actionbar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 14px 14px 18px;
}
.download-note { margin: 10px 2px 0; font-size: 0.84rem; }
.download-note b { font-weight: 500; color: var(--text-2); }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background-color 200ms var(--ease-out);
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 200ms var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--info); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--info); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; line-height: 1.35; }
.switch-text strong { font-weight: 500; }
.switch-text .faint { font-size: 0.82rem; }

/* ---------- 表格 ---------- */
.section-lead { margin: -4px 0 12px; font-size: 0.9rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 10px 18px; text-align: left; white-space: nowrap; }
th {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid var(--border-soft); }
.r { text-align: right; }
tbody tr:last-child td { border-bottom: none; }

.sum-table .co td {
  background: var(--surface-2);
  font-weight: 600;
  border-bottom: none;
}
.sum-table .co .co-count { font-weight: 400; color: var(--text-3); font-size: 0.84rem; margin-left: 6px; }
.sum-table .item td:first-child { padding-left: 34px; color: var(--text-2); }
.sum-table .rate-label { color: var(--text-3); font-size: 0.8rem; margin-left: 6px; }
.sum-table tfoot td {
  border-top: 1px solid var(--border);
  border-bottom: none;
  font-weight: 600;
  color: var(--stable);
  padding-top: 14px;
  padding-bottom: 14px;
}

.list-table td:first-child { white-space: normal; word-break: break-all; }
.more { width: 100%; height: 44px; border-radius: 0 0 var(--radius) var(--radius); border-top: 1px solid var(--border-soft); }

/* ---------- 规则 ---------- */
.rules { padding: 0; }
.rules summary {
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rules summary::-webkit-details-marker { display: none; }
.rules summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg);
  transition: transform 200ms var(--ease-out);
  margin-right: 4px;
}
.rules[open] summary::before { transform: rotate(45deg); }
.rules-body { padding: 0 18px 18px; display: grid; gap: 14px; }
.rule { padding-top: 14px; border-top: 1px solid var(--border-soft); }
.rule-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rule-type { font-weight: 600; }
.rule-rate { color: var(--info); font-size: 0.88rem; font-weight: 500; }
.rule-basis { color: var(--text-3); font-size: 0.84rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 0.8rem;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
}

/* ---------- 进场动画 ---------- */
#result:not([hidden]) > * { animation: rise 420ms var(--ease-out) both; }
#result > *:nth-child(2) { animation-delay: 40ms; }
#result > *:nth-child(3) { animation-delay: 80ms; }
#result > *:nth-child(n+4) { animation-delay: 120ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 手机 ---------- */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .actionbar { flex-direction: column; align-items: stretch; }
  .actionbar .btn-primary { width: 100%; }
  th, td { padding: 10px 12px; }
  .sum-table .item td:first-child { padding-left: 22px; }
  .steps { gap: 6px; font-size: 0.85rem; }
  .step + .step::before { width: 8px; margin-right: 0; }
  .sum-table .rate-label { display: none; }
  .stat-value { font-size: 1.3rem; }
}

/* ---------- 政策说明 / 提示 ---------- */
.policy { display: flex; align-items: center; gap: 12px; min-width: 0; }
.policy-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--info-soft);
  color: var(--info);
}
.policy-icon svg { width: 18px; height: 18px; }
.policy-text { display: flex; flex-direction: column; line-height: 1.45; min-width: 0; }
.policy-text strong { font-weight: 500; }
.policy-text .faint { font-size: 0.82rem; }

.notes { display: grid; gap: 8px; margin-top: 12px; }
.note {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.6;
}
.note b { font-weight: 600; }
.note-info { background: var(--info-soft); color: var(--text); }
.note-warn { background: var(--leak-soft); color: var(--leak); }
.link-btn {
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--info);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- 汇总表里的逐家减半开关 ---------- */
.mini-switch { display: inline-flex; vertical-align: middle; cursor: pointer; }
.mini-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mini-switch .switch-track { width: 32px; height: 18px; }
.mini-switch .switch-thumb { top: 2px; left: 2px; width: 14px; height: 14px; }
.mini-switch input:checked + .switch-track { background: var(--info); }
.mini-switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); }
.mini-switch input:focus-visible + .switch-track { outline: 2px solid var(--info); outline-offset: 2px; }
.badge-off {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 500;
  background: var(--leak-soft);
  color: var(--leak);
}

/* ---------- 规则里的税率版本 ---------- */
.rule-rates { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; font-size: 0.88rem; }
.rate-ver b { color: var(--info); font-weight: 600; }
.actionbar .btn-primary { flex: none; white-space: nowrap; }
