/* ============================================================
 * 个人所得税计算工具 · 专属样式
 * 配色与站点主风格一致（深酒红 + 古典金），自包含无外部依赖
 * 移动优先：<600px 默认 / ≥600px / ≥900px 三档
 * ============================================================ */

:root {
  --red: #9E1B22;
  --red-deep: #7A1418;
  --red-soft: #C25B61;
  --gold: #C5A572;
  --gold-bright: #D4AF37;
  --gold-deep: #B08D3E;
  --focus-ring: #B08D3E;

  --bg: #FFFFFF;
  --bg-warm: #FAF6F0;
  --bg-sunk: #F3EEE6;
  --text: #1A1A1A;
  --text-sub: #5C5C5C;
  --text-faint: #8A8A8A;
  --line: #E6DED2;

  --ok: #2E7D5B;
  --ok-bg: #EAF4EE;
  --warn: #9A6412;
  --warn-bg: #FBF3E2;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(26, 26, 26, .06);
  --shadow-hover: 0 8px 20px rgba(158, 27, 34, .12);

  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --red: #E2604E;
  --red-deep: #C0392B;
  --red-soft: #3A2024;
  --gold: #C9A86A;
  --gold-bright: #D9B978;
  --gold-deep: #A07E3C;
  --focus-ring: #D9B978;

  --bg: #1E1B1F;
  --bg-warm: #2A252A;
  --bg-sunk: #241F24;
  --text: #ECE6DF;
  --text-sub: #A89E95;
  --text-faint: #8B8178;
  --line: #3D3539;

  --ok: #6FC79B;
  --ok-bg: #22342B;
  --warn: #D9AC5E;
  --warn-bg: #352C1D;

  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-hover: 0 8px 22px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  background: var(--red);
  color: #fff;
  padding: 10px 16px;
  text-decoration: none;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- 页头 ---------- */
.hero {
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #fff;
  text-align: center;
  padding: 28px 16px 26px;
  border-bottom: 3px solid var(--gold);
}
.hero__logo {
  font-family: var(--serif);
  font-size: 26px;
  margin: 0;
  letter-spacing: 2px;
}
.hero__logo a { color: #fff; text-decoration: none; }
.hero__slogan {
  font-size: 13px;
  margin: 6px 0 0;
  color: rgba(255, 255, 255, .82);
  letter-spacing: 1px;
}

/* ---------- 主容器 ---------- */
.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-head { padding: 30px 0 8px; }
.page-head__title {
  font-family: var(--serif);
  font-size: 27px;
  color: var(--red);
  margin: 0 0 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gold);
}
.page-head__desc {
  font-size: 15px;
  color: var(--text-sub);
  margin: 0;
}
.update-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--gold-deep);
  background: var(--bg-warm);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 12px;
  margin-bottom: 12px;
}

/* ---------- 模式切换 ---------- */
.mode-switch {
  display: flex;
  gap: 6px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px;
  margin: 22px 0 18px;
}
.mode-switch__btn {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-sub);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
}
.mode-switch__btn:hover { color: var(--red); }
.mode-switch__btn[aria-pressed="true"] {
  background: var(--red);
  color: #fff;
  box-shadow: var(--shadow);
}

/* ---------- 卡片通用 ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-warm);
  border-bottom: 1px solid var(--line);
}
.card__index {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}
.card__title {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text);
  margin: 0;
}
.card__body { padding: 18px; }

/* ---------- 表单 ---------- */
.field-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.field__hint {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
}
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 9px 52px 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  transition: border-color .18s, box-shadow .18s;
}
.input-wrap input:hover { border-color: var(--gold); }
.input-wrap input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(158, 27, 34, .12);
}
.input-wrap__unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-faint);
  pointer-events: none;
}
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}

fieldset.deduct-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 0;
  background: var(--bg-warm);
}
fieldset.deduct-item + fieldset.deduct-item { margin-top: 12px; }
fieldset.deduct-item legend {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 0 6px;
}
.deduct-item__note {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
  margin-top: 2px;
}
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
}
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  min-height: 32px;
}
.radio-row input[type="radio"],
.radio-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  cursor: pointer;
}
.inline-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.inline-input input {
  width: 110px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.inline-input span { font-size: 13px; color: var(--text-faint); }

.notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid rgba(154, 100, 18, .25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 14px;
}
.notice strong { color: inherit; }

/* ---------- 操作按钮 ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 24px;
}
.btn {
  min-height: 44px;
  padding: 9px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, box-shadow .18s, background .18s;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
}
.btn--primary:hover { background: var(--red-deep); box-shadow: var(--shadow-hover); }
.btn--ghost {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-sub);
}
.btn--ghost:hover { border-color: var(--gold); color: var(--text); }

/* ---------- 结果区 ---------- */
.result-card {
  background: var(--bg-warm);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 18px;
}
.result-card__label {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--gold-deep);
  margin: 0 0 4px;
}
.result-card__main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 6px 0 4px;
}
.result-card__number {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 700;
  color: var(--red);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.result-card__unit { font-size: 15px; color: var(--text-sub); }
.result-card__sub {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat__label { font-size: 12px; color: var(--text-faint); }
.stat__value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.stat--highlight { border-color: var(--gold); background: var(--bg-warm); }
.stat--highlight .stat__value { color: var(--red-deep); }
[data-theme="dark"] .stat--highlight .stat__value { color: var(--red); }

/* 计算明细 */
.breakdown { margin-top: 18px; }
.breakdown__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.breakdown__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 14px;
}
.breakdown__row span:first-child { color: var(--text-sub); }
.breakdown__row span:last-child {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.breakdown__row--minus span:last-child { color: var(--red); }
.breakdown__row--total {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 12px;
}
.breakdown__row--total span:last-child { color: var(--red-deep); font-size: 16px; }
[data-theme="dark"] .breakdown__row--total span:last-child { color: var(--red); }

/* ---------- 税率表 ---------- */
.table-scroll { overflow-x: auto; }
table.rate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 520px;
}
.rate-table th, .rate-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.rate-table th {
  background: var(--bg-sunk);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.rate-table td { color: var(--text-sub); }
.rate-table td:nth-child(2) { color: var(--text); }
.rate-table tbody tr.is-active {
  background: var(--ok-bg);
  box-shadow: inset 3px 0 0 var(--ok);
}
.rate-table tbody tr.is-active td { color: var(--ok); font-weight: 700; }
.rate-table tbody tr:last-child td { border-bottom: 0; }
.table-caption {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 0 18px 14px;
}

/* ---------- 说明区 ---------- */
.notes { padding: 18px; }
.notes h3 {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text);
  margin: 0 0 10px;
}
.notes ul { margin: 0; padding-left: 20px; }
.notes li { font-size: 13.5px; color: var(--text-sub); line-height: 1.9; }
.notes code {
  background: var(--bg-sunk);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
  color: var(--red-deep);
}
[data-theme="dark"] .notes code { color: var(--red); }

/* ---------- 面包屑 ---------- */
.breadcrumb { padding: 8px 0 4px; }
.breadcrumb__list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}
.breadcrumb__item:not(:last-child)::after { content: "›"; margin-left: 6px; color: var(--gold); }
.breadcrumb__link { color: var(--gold-deep); text-decoration: none; }
.breadcrumb__link:hover { text-decoration: underline; }
.breadcrumb__item--current { color: var(--text-sub); }

/* ---------- 页脚 ---------- */
.footer {
  background: var(--bg-warm);
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding: 24px 0 30px;
}
.footer__inner { text-align: center; }
.footer__copyright { font-size: 12.5px; color: var(--text-faint); margin: 0 0 10px; }
.footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-bottom: 12px;
}
.footer__nav a { font-size: 12.5px; color: var(--text-sub); text-decoration: none; }
.footer__nav a:hover { color: var(--red); }
.footer__tools { display: flex; justify-content: center; }
.theme-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-sub);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--gold); color: var(--red); }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: block; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式增强 ---------- */
@media (min-width: 600px) {
  .hero__logo { font-size: 32px; }
  .page-head__title { font-size: 30px; }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .result-card__number { font-size: 50px; }
}

@media (min-width: 900px) {
  .hero { padding: 34px 16px 30px; }
  .page-head { padding-top: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .mode-switch, .actions, .footer, .theme-toggle, .toast { display: none !important; }
  .card, .result-card { box-shadow: none; break-inside: avoid; }
}
