/* ===== 个税·五险一金计算器样式（独立一份；色板与科研导航站、其他子应用完全一致） =====
   本页主角是「两页签 + 输入表单 + 结果卡片网格 + 收入分配条形 + 税率/明细表」：
   ① 顶部两页签（个税计算 / 五险一金），当前页签高亮；
   ② 输入用标签在上、输入在下的垂直栅格，缴费比例做成可编辑小表格；
   ③ 结果用卡片网格铺各项汇总；个税页带到手/五险一金/个税三段收入条；
   ④ 年度税率表与五险一金明细表数字对齐、表头吸顶。 */
:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #f0f2f5;
  --text: #2c3e50;
  --text-sub: #7f8c9b;
  --border: #e8ebef;
  --accent: #0e9f8a;
  --accent-soft: rgba(14, 159, 138, .1);
  --accent-text: #fff;
  --danger: #e2544d;
  --ok: #2f9e5f;
  --shadow: 0 2px 8px rgba(30, 40, 60, .06);
  --bar-bg: #f7f8fa;
  --code-bg: #f4f6f9;
  --tag-bg: #eef2f7;
  --group-line: #dfe5ec;
}

html[data-theme="dark"] {
  --bg: #060a17;
  --bg-card: #0d1424;
  --bg-hover: #1a2336;
  --text: #dce3ec;
  --text-sub: #8794a8;
  --border: #1e2a44;
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, .14);
  --danger: #ff6b64;
  --ok: #4ade80;
  --shadow: 0 2px 10px rgba(0, 0, 0, .5);
  --bar-bg: #0a1120;
  --code-bg: #101a30;
  --tag-bg: #16213a;
  --group-line: #24334f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  transition: background .25s, color .25s;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar .back { color: var(--accent); text-decoration: none; font-size: 14px; white-space: nowrap; }
.topbar .back:hover { text-decoration: underline; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; flex: none; }
.brand-mark img { width: 26px; height: 26px; }
.brand-text h1 { font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text p { font-size: 12px; color: var(--text-sub); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--bg-hover); }
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-btn {
  border: none; background: var(--bg-card); color: var(--text-sub);
  padding: 6px 10px; font-size: 13px; cursor: pointer; text-decoration: none;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn.active { background: var(--accent); color: var(--accent-text); }

/* ===== 主体 / 页签条 ===== */
.tc { max-width: 900px; margin: 0 auto; padding: 14px 16px 4px; }
.calc-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.calc-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  margin-right: auto;
}
.calc-tab {
  border: none; background: transparent; color: var(--text-sub);
  padding: 8px 18px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.calc-tab:hover { background: var(--bg-hover); color: var(--text); }
.calc-tab.active { background: var(--accent); color: var(--accent-text); }

/* ===== 面板 ===== */
.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.sec-head h2 { font-size: 16px; margin-right: auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  border-radius: 8px; padding: 6px 13px; cursor: pointer; font-size: 13.5px;
}
.btn:hover { background: var(--bg-hover); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }

/* ===== 输入表单 ===== */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 18px; margin-bottom: 4px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.fld-label { font-size: 13px; font-weight: 600; color: var(--text); }
.field input[type="number"], .field select {
  width: 100%; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 14px;
}
.field select { cursor: pointer; }
.field input[type="number"]:focus, .field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field-hint { font-size: 12px; color: var(--text-sub); margin-top: 6px; }

/* ===== 快速示例 / 预设 ===== */
.quick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.quick-label { font-size: 12.5px; color: var(--text-sub); }
.chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 12.5px;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ===== 专项附加扣除勾选区（个税页内的折叠表） =====
   details 原生折叠：键盘可达、无需 JS 就能展开，爬虫也能读到整张表 */
.ded-box { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bar-bg); }
.ded-box > summary {
  cursor: pointer; padding: 9px 12px; font-size: 13.5px; font-weight: 600; color: var(--accent);
  list-style-position: inside; user-select: none;
}
.ded-box > summary:hover { background: var(--accent-soft); border-radius: 10px; }
.ded-box[open] > summary { border-bottom: 1px solid var(--border); }
.ded-box .table-wrap { border: none; border-radius: 0; background: var(--bg-card); }
.ded-box .field-hint, .ded-box .result-warn { margin: 8px 12px; }
.ded-box .ded-limits { color: var(--text-sub); }
table.ded td { vertical-align: middle; }
.ded-name { display: block; font-weight: 600; }
.ded-std { display: block; font-size: 11.5px; color: var(--text-sub); font-weight: 400; }
td.num .ded-std { text-align: right; }
.ded-ck { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; margin: 2px 6px 2px 0; white-space: nowrap; }
.ded-ck input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
table.ded .ded-num { width: 46px; }
table.ded .ded-wide { width: 92px; }
table.ded input[type="number"] {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 6px; padding: 3px 5px; font-size: 12.5px; text-align: center;
}
table.ded select {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 6px; padding: 3px 5px; font-size: 12.5px; cursor: pointer;
}
table.ded .ded-sel { width: 88px; }
table.ded .ded-sel-wide { width: 190px; max-width: 46vw; }
table.ded input[type="number"]:focus, table.ded select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
table.ded tbody tr:hover { background: transparent; }
table.ded tfoot tr.sum td { border-bottom: none; }

/* ===== 结果卡片网格 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat {
  display: flex; flex-direction: column; gap: 4px; padding: 11px 13px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
}
.stat-l { font-size: 12.5px; color: var(--text-sub); }
.stat-v { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; word-break: break-all; }
.stat-v b { color: var(--accent); }
.stat-v .ok { color: var(--ok); }
.stat-v .danger { color: var(--danger); }
.result-note { font-size: 12px; color: var(--text-sub); }
/* 输入自检提示：越界/自相矛盾的输入用告警色单独一行说明，别让负数结论静默通过 */
.result-warn { font-size: 12.5px; color: var(--danger); font-weight: 600; margin: 0 0 8px; }
.result-warn[hidden] { display: none; }
.bracket-hint { font-size: 12.5px; color: var(--accent); font-weight: 600; margin: 2px 0 8px; }
/* 年终奖页的结论句：给出更省方案时用绿色，避免和红色告警行混在一起 */
.bracket-hint.ok { color: var(--ok); }

/* ===== 窄屏下的表格：首列钉住 + 溢出提示 + 短表头 + 够大的触摸目标 =====
   横向溢出时后面还藏着「本期个税 / 本期到手」两列，不提示、不钉首列，
   用户在手机上滑两下就既不知道能滑、也不知道正在看哪一行。 */
.table-wrap { position: relative; }
.table-wrap[data-scroll="x"] tr > :first-child {
  position: sticky; left: 0; z-index: 2;
  background-color: var(--bg-card);
  background-image: linear-gradient(var(--accent-soft), var(--accent-soft));
  box-shadow: inset -1px 0 0 var(--border);
}
.table-wrap[data-scroll="x"] thead tr > :first-child { z-index: 3; background-color: var(--bar-bg); }
.table-wrap[data-scroll="x"] tbody tr:hover > :first-child { background-color: var(--bg-hover); }
.table-wrap[data-scroll="x"] tr.sum > :first-child { box-shadow: inset -1px 0 0 var(--accent); }
.scroll-hint {
  display: none; position: sticky; left: 0; font-size: 11.5px; color: var(--text-sub);
  padding: 6px 10px 7px; background: var(--bg-card);
}
.table-wrap[data-scroll="x"] .scroll-hint { display: block; }
.th-short { display: none; }

@media (max-width: 560px) {
  table.data th, table.data td { padding: 8px 9px; font-size: 12.5px; }
  .th-full { display: none; }
  .th-short { display: inline; }
  /* 期数是点选用的按钮，行高原来到手只有 ~20px，够不上触摸目标 */
  .mk { display: inline-block; min-height: 40px; line-height: 40px; padding: 0 8px; margin: -8px -6px; }
  table.ded .ded-num, table.ded .ded-sel, table.ded .ded-wide, table.ded select { min-height: 40px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
}

/* ===== 收入分配条形 ===== */
.income-wrap { margin-bottom: 10px; }
.income-bar { display: flex; height: 20px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg-hover); }
.ib { display: block; height: 100%; transition: width .3s; min-width: 0; }
.ib-net { background: var(--ok); }
.ib-si { background: #6aa9e0; }
.ib-tax { background: #ff9c6e; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 12.5px; color: var(--text-sub); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.d-net { background: var(--ok); } .d-si { background: #6aa9e0; } .d-tax { background: #ff9c6e; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
/* 吸顶只给表头行：逐月表的期数是 tbody 里的 <th scope=row>，跟着吸顶会盖住表头 */
table.data thead th {
  background: var(--bar-bg); color: var(--text-sub); font-weight: 600; font-size: 12px;
  position: sticky; top: 0; z-index: 1;
}
table.data tbody th { background: transparent; color: var(--text); font-weight: 600; text-align: left; position: static; }
table.data th.center, table.data td.center { text-align: center; }
table.data th.left, table.data td.left { text-align: left; }
table.data td.num { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr.sum td, table.data tbody tr.sum th,
table.data tfoot tr.sum td { font-weight: 700; background: var(--accent-soft); border-top: 1px solid var(--accent); }
/* 逐月表：当前所属期整行高亮；▲ 标出跨档月；期数做成素净按钮，保住键盘可达 */
table.data tbody tr.cur td, table.data tbody tr.cur th { background: var(--accent-soft); }
table.data .jump { color: var(--danger); font-weight: 700; }
.mk {
  border: none; background: transparent; color: inherit; font: inherit;
  padding: 0; cursor: pointer; text-align: left; text-decoration: underline dotted var(--group-line);
}
.mk:hover { color: var(--accent); text-decoration-color: var(--accent); }
.mk:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
tr.cur .mk { color: var(--accent); font-weight: 700; text-decoration: none; }
.ex-note { color: var(--text-sub); font-size: 12px; }
.same-rate { text-align: center; }
.same-rate input[type="number"] { width: 68px; text-align: center; }
.same-note { color: var(--text-sub); font-size: 12px; margin-left: 6px; }
/* 缴费比例小表格里的输入框 */
table.rates td input[type="number"] {
  width: 74px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 7px; padding: 4px 6px; font-size: 13px; text-align: center;
}
table.rates td input[type="number"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
table.rates tbody tr:hover { background: transparent; }

/* ===== 说明区（SEO 主体） ===== */
.doc { max-width: 900px; margin: 10px auto 40px; padding: 18px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.doc h2 { font-size: 16px; margin: 18px 0 6px; }
.doc h2:first-child { margin-top: 0; }
.doc h3 { font-size: 14.5px; margin: 12px 0 4px; color: var(--text); }
.doc p { font-size: 14px; margin-bottom: 8px; }
.doc ul, .doc ol { margin: 0 0 8px 20px; font-size: 14px; }
.doc li { margin-bottom: 5px; }
.doc dl.faq dt { font-weight: 600; font-size: 14px; margin-top: 10px; }
.doc dl.faq dd { font-size: 14px; color: var(--text-sub); margin-left: 0; }
.doc .rel-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.doc .rel-links a {
  display: inline-block; padding: 4px 12px; background: var(--tag-bg);
  border-radius: 999px; color: var(--accent); text-decoration: none; font-size: 13px;
}
.doc .rel-links a:hover { background: var(--accent-soft); text-decoration: none; }
.doc .ver { font-size: 12px; color: var(--text-sub); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg-card); padding: 8px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar .back { font-size: 13px; }
  .brand { flex: 1 1 auto; }
  .brand-text p { display: none; }
  .spacer { display: none; }
  .tc { padding: 10px 10px 0; }
  .panel { padding: 12px; }
  .sec-head h2 { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .calc-tab { padding: 7px 14px; font-size: 13px; }
  .stat-v { font-size: 17px; }
}
