/* ==========================================================================
   综合所得年度汇算 — 页内组件
   复用 styles.css 的设计令牌，只补这个页面独有的结构
   ========================================================================== */

/* ---------- 四类收入 ---------- */
.inc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.inc {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 15px 13px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-pane);
  background: var(--surface);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.inc:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.inc__label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.inc__label em {
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}

.inc__field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inc__cur {
  font-size: 15px;
  color: var(--text-3);
}

.inc__field input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
  padding: 2px 0;
  outline: none;
}

.inc__field input::placeholder {
  color: var(--text-3);
  font-weight: 400;
}

.inc__calc {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-height: 16px;
}

.inc__calc b {
  font-weight: 500;
  color: var(--text-2);
}

/* ---------- 收入合计对账 + 已预缴 ---------- */
.recon {
  margin-top: 14px;
  padding: 12px 14px 4px;
  border-radius: 14px;
  background: var(--inset);
}

.recon__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.recon__k {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.recon__v {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.recon__hint {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
}

/* 提示卡里没有整行分隔线，说明文字另起一行，窄屏才挤不到输入框 */
.recon .ded-row {
  min-height: 0;
  padding: 12px 0 8px;
  border-bottom: 0;
  flex-wrap: wrap;
  row-gap: 3px;
}

.recon .ded-row__hint {
  width: 100%;
  text-align: left;
}

/* ---------- 扣除项 ---------- */
.ded-list {
  margin-top: 6px;
  border-top: 1px solid var(--hair);
}

.ded {
  border-bottom: 1px solid var(--hair);
}

.ded__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  cursor: pointer;
  user-select: none;
}

.ded__label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
}

.ded__std {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.ded.is-on .ded__std {
  color: var(--text-2);
}

.ded__body {
  display: none;
  padding: 0 2px 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.ded.is-on .ded__body {
  display: flex;
}

.ded__field {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
}

/* [hidden] 压不住 display:flex，条件是动态求值的，必须显式关掉 */
.ded__field[hidden] {
  display: none !important;
}

.ded__field input[type="number"] {
  width: 62px;
  padding: 6px 8px;
  border: 1px solid var(--hair-strong);
  border-radius: 9px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  outline: none;
  text-align: right;
}

.ded__field input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.ded__field .select-wrap select {
  padding: 6px 26px 6px 9px;
  font-size: 12.5px;
}

.ded__amount {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.ded__note {
  width: 100%;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.5;
}

/* iOS 风格开关 */
.switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 25px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--inset-strong);
  transition: background 0.2s var(--ease);
  pointer-events: none;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-thumb);
  transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch__track {
  background: var(--accent);
}

.switch input:checked + .switch__track::after {
  transform: translateX(17px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 结论条 ---------- */
.verdict {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--inset);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-2);
}

.verdict__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--text-3);
}

.verdict.is-refund .verdict__dot { background: #248a3d; }
.verdict.is-pay .verdict__dot { background: #c93400; }

.verdict b {
  color: var(--text);
  font-weight: 500;
}

/* 结果大数字下方的动作行 */
.res-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ---------- 口径表 ---------- */
.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.calc-table caption {
  caption-side: top;
  text-align: left;
  font-size: 12px;
  color: var(--text-3);
  padding-bottom: 10px;
}

.calc-table th,
.calc-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}

.calc-table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.calc-table td.num,
.calc-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.calc-table tbody tr:last-child td {
  border-bottom: 0;
}

.calc-table code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  color: var(--text);
}

/* ---------- 响应式 ---------- */
@media (max-width: 780px) {
  .inc-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .inc {
    padding: 12px 13px 11px;
  }

  .inc__field input {
    font-size: 19px;
  }

  .ded__head {
    gap: 10px;
    padding: 12px 0;
  }

  .ded__std {
    display: none;
  }

  .calc-table,
  .calc-table tbody,
  .calc-table tr,
  .calc-table td {
    display: block;
    width: 100%;
  }

  .calc-table thead {
    display: none;
  }

  .calc-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--hair);
  }

  .calc-table td {
    border: 0;
    padding: 2px 0;
    text-align: left !important;
  }

  .calc-table td[data-label]::before {
    content: attr(data-label) "：";
    color: var(--text-3);
  }
}

@media (max-width: 360px) {
  .ded__field {
    font-size: 12px;
  }

  .ded__field input[type="number"] {
    width: 54px;
  }
}

/* ---------- 本页布局：结果面板随滚动跟随 ---------- */
.calc--annual .calc__body {
  align-items: start;
}

.calc--annual .calc__result {
  position: sticky;
  top: 84px;
}

.calc--annual .calc__input {
  padding-bottom: 12px;
}

.subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 26px 0 2px;
}

.subhead:first-child {
  margin-top: 4px;
}

.subhead h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.2px;
}

.subhead span {
  font-size: 11.5px;
  color: var(--text-3);
}

@media (max-width: 960px) {
  .calc--annual .calc__result {
    position: static;
  }
}

/* ---------- 计算器顶部说明条 ---------- */
.calc__note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 11px;
  border-radius: 999px;
  background: var(--inset);
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: 0.1px;
}

.calc__note .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

/* ---------- 扣除区：非七项的输入行 ---------- */
.ded-ext {
  margin-top: 2px;
}

.ded-list + .ded-ext--foot {
  border-top: 1px solid var(--hair);
}

.ded-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--hair);
}

.ded-row__k {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
}

.ded-row__field {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  width: 108px;
  padding: 5px 9px;
  border: 1px solid var(--hair-strong);
  border-radius: 9px;
  background: var(--bg-elevated);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.ded-row__field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.ded-row__field input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  padding: 0;
}

.ded-row__field input::placeholder {
  color: var(--text-3);
}

.ded-row__hint {
  flex: 0 0 auto;
  width: 116px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-3);
  text-align: right;
}

/* 只读行（减除费用）的数值，占住输入框的位置右对齐 */
.ded-row--ro .ded-row__v {
  flex: 0 0 auto;
  width: 108px;
  font-size: 13.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 深色下输入框底色与卡片太接近，抬一档才看得出是个可填的框 */
[data-theme="dark"] .ded-row__field {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .ded-row__field:focus-within {
  border-color: var(--accent);
}

.ded-row--mark .ded-row__k {
  font-weight: 500;
}

/* ---------- 表格下方注记 ---------- */
.panel__note {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-3);
}

@media (max-width: 780px) {
  .ded-row {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 9px 0;
  }

  .ded-row__k {
    flex: 1 1 100%;
  }

  .ded-row__field {
    width: 118px;
  }

  .ded-row__hint {
    flex: 1 1 auto;
    width: auto;
    text-align: left;
  }

  .calc__note {
    font-size: 11.5px;
  }
}

@media (max-width: 360px) {
  .ded-row__field {
    width: 104px;
  }
}

/* ---------- 两列表（步骤 / 说明）在窄屏不卡片化 ----------
   7 行拆成 7 张卡片太碎，改成一张清单：行间细线分隔 */
@media (max-width: 780px) {
  .table-wrap--plain {
    overflow: visible;
    border: 1px solid var(--hair);
    background: var(--bg-elevated);
    border-radius: var(--radius-pane);
  }

  .table-wrap--plain thead {
    display: none;
  }

  .table-wrap--plain table,
  .table-wrap--plain tbody {
    display: block;
    width: 100%;
  }

  .table-wrap--plain tbody tr {
    display: block;
    margin: 0;
    padding: 10px 15px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--hair);
    border-radius: 0;
  }

  .table-wrap--plain tbody tr:last-child {
    border-bottom: 0;
  }

  .table-wrap--plain tbody td {
    display: block;
    border: 0;
    padding: 0;
    text-align: left !important;
  }

  .table-wrap--plain tbody td[data-label]::before {
    content: none;
  }

  .table-wrap--plain tbody td:first-child {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
  }

  .table-wrap--plain tbody td:last-child {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--text-2);
  }
}

/* 深色下 --inset-strong 与卡片底色几乎同色，开关轨道会消失成一排白点 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .switch__track {
    background: rgba(255, 255, 255, 0.16);
  }
}

:root[data-theme="dark"] .switch__track {
  background: rgba(255, 255, 255, 0.16);
}

/* 极窄屏优先让合计金额与标题同排，实在放不下才换行 */
@media (max-width: 380px) {
  .recon__row {
    gap: 8px;
  }

  .recon__v {
    font-size: 14.5px;
  }
}

/* ---------- 全年免税额度 ---------- */
.quota {
  margin-top: 14px;
  padding: 13px 14px 12px;
  border-radius: 14px;
  background: var(--inset);
}

.quota__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.quota__t {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.quota__v {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.quota__bar {
  position: relative;
  height: 6px;
  margin: 9px 0 8px;
  border-radius: 999px;
  background: var(--inset-strong);
  overflow: hidden;
}

.quota__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.quota__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.quota__foot b {
  font-weight: 500;
  color: var(--text-2);
}

.quota__foot em {
  font-style: normal;
  margin-left: 2px;
}

.quota__note {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-3);
}

/* 极窄屏：收紧间距，让标题与金额尽量同排；放不下才换行 */
@media (max-width: 380px) {
  .quota__head,
  .quota__foot {
    row-gap: 4px;
  }

  .quota__head {
    gap: 8px;
  }

  .quota__t {
    font-size: 12.5px;
  }

  .quota__v {
    font-size: 15.5px;
  }

  .quota__foot {
    font-size: 11.5px;
  }
}

/* ---------- 三险一金按城市估算 ---------- */
.si-est__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--hair);
}

.si-est__hint {
  flex: 1 1 260px;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
  overflow-wrap: anywhere;
}

.si-est__btn {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 6px 12px;
  font-size: 12px;
}
