/* ============================================================
   北京薪资计算器 — 设计令牌与组件
   配色:经 CVD/对比度校验的图表调色板(light/dark 双套)
   ============================================================ */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --hairline: #e1e0d9;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #256abf;          /* blue 500:控件/链接文本级 */
  --accent-strong: #1c5cab;
  --accent-soft: #cde2fb;     /* blue 100 */
  --accent-washed: rgba(42, 120, 214, 0.08);
  --s1: #2a78d6;  /* 到手 */
  --s2: #eb6834;  /* 个税 */
  --s3: #1baf7a;  /* 社保 */
  --s4: #eda100;  /* 公积金 */
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --warn-wash: rgba(250, 178, 25, 0.12);
  --crit-wash: rgba(208, 59, 59, 0.10);
  --shadow: 0 1px 2px rgba(11,11,11,.04), 0 4px 16px rgba(11,11,11,.05);
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --hairline: #2c2c2a;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-strong: #6da7ec;
    --accent-soft: #184f95;
    --accent-washed: rgba(57, 135, 229, 0.14);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --good-text: #0ca30c;
    --shadow: none;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.65 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 72px; }
b { font-weight: 600; }

/* ---------- 头部 ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.top h1 { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.tagline { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.badge {
  flex-shrink: 0; font-size: 12.5px; font-weight: 600; color: var(--accent);
  background: var(--accent-washed); border: 1px solid transparent;
  padding: 4px 12px; border-radius: 999px; margin-top: 4px; white-space: nowrap;
}

/* ---------- 分段控件 ---------- */
.seg {
  position: relative; display: inline-flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 3px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.seg button {
  position: relative; z-index: 1; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 500; color: var(--ink-2);
  padding: 8px 22px; border-radius: 9px; transition: color .18s;
}
.seg button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.seg-glider {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0;
  background: var(--accent-washed); border: 1px solid var(--ring);
  border-radius: 9px; transition: left .22s cubic-bezier(.4,0,.2,1), width .22s cubic-bezier(.4,0,.2,1);
}
.seg.mini { margin-bottom: 18px; }
.seg.mini button { padding: 6px 16px; font-size: 13.5px; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 372px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
/* 轨道必须 minmax(0,1fr):默认 auto 轨道按 max-content 测宽,
   会被 .tbl-scroll 里 nowrap 表格的完整宽度撑爆整栏 */
.col-input { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.col-result { display: grid; gap: 18px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
/* 桌面:左右两栏各自限高、独立滚动 */
@media (min-width: 901px) {
  .col-input, .col-result {
    position: sticky; top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: var(--hairline) transparent;
  }
  .col-input::-webkit-scrollbar, .col-result::-webkit-scrollbar { width: 6px; }
  .col-input::-webkit-scrollbar-thumb, .col-result::-webkit-scrollbar-thumb {
    background: var(--hairline); border-radius: 3px;
  }
  .col-input::-webkit-scrollbar-thumb:hover, .col-result::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
  .col-input::-webkit-scrollbar-track, .col-result::-webkit-scrollbar-track { background: transparent; }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow);
}
.card h2 { font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 16px; letter-spacing: .01em; }
.h-note { font-weight: 400; color: var(--ink-3); font-size: 12.5px; margin-left: 6px; }
.card + .card { margin-top: 0; }

/* ---------- 表单 ---------- */
label { font-size: 13.5px; font-weight: 550; color: var(--ink); }
label em, .ratio-head em { font-style: normal; font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; }
select {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--page); border: 1px solid var(--hairline); border-radius: var(--r-md);
}
select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.money-field { margin-bottom: 20px; }
.money-field > label { display: block; margin-bottom: 7px; }
.money-input {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--page); border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 8px 14px; transition: border-color .15s;
}
.money-input:focus-within { border-color: var(--accent); }
.money-input .cur { color: var(--ink-3); font-size: 15px; }
.money-input .unit { color: var(--ink-3); font-size: 12.5px; }
.money-input input {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--ink);
  font: 600 20px/1.3 system-ui, -apple-system, sans-serif;
  letter-spacing: -0.01em;
}
.money-input input:focus { outline: none; }
.money-input input::-webkit-outer-spin-button, .money-input input::-webkit-inner-spin-button { -webkit-appearance: none; }
.money-input input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- 滑杆 ---------- */
.slider {
  --p: 50%;
  width: 100%; height: 28px; margin-top: 10px;
  -webkit-appearance: none; appearance: none; background: none; cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--p), color-mix(in oklab, var(--hairline) 80%, var(--ink-3)) var(--p));
}
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: color-mix(in oklab, var(--hairline) 80%, var(--ink-3)); }
.slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%; background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(11,11,11,.18);
  transition: transform .12s;
}
.slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(11,11,11,.18);
}
.slider:active::-webkit-slider-thumb, .slider:hover::-webkit-slider-thumb { transform: scale(1.12); }
.slider:disabled { opacity: .38; cursor: not-allowed; }
.slider:disabled::-webkit-slider-thumb { transform: none; }
.scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: -2px; font-variant-numeric: tabular-nums; }

.ratio-field { margin-bottom: 18px; }
.ratio-head { display: flex; justify-content: space-between; align-items: baseline; }
.ratio-head output {
  font-size: 15px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- 基数滑轨(上下限可视化) ---------- */
.base-field { margin-bottom: 20px; }
.base-track { position: relative; height: 34px; margin-top: 12px; }
/* range 透明叠在可视化轨道上,只保留一条轨道的视觉 */
.base-track + .slider {
  position: relative; z-index: 2; height: 34px; margin: -34px 0 0; opacity: 0;
}
.base-track .rail {
  position: absolute; left: 0; right: 0; top: 14px; height: 6px; border-radius: 3px;
  background: color-mix(in oklab, var(--hairline) 80%, var(--ink-3));
}
.base-track .rail-fill { position: absolute; top: 14px; height: 6px; border-radius: 3px; background: var(--accent); }
.base-track .cap { position: absolute; top: 9px; width: 2px; height: 16px; border-radius: 1px; background: var(--ink-3); }
.base-track .marker {
  position: absolute; top: 4px; width: 26px; height: 26px; margin-left: -13px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(11,11,11,.2);
  display: grid; place-items: center; font-size: 0;
  transition: left .18s cubic-bezier(.4,0,.2,1);
}
.base-track .marker.clamped { border-color: var(--warning); }
.base-track .marker::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.base-track .marker.clamped::after { background: var(--warning); }
.base-limits { margin-top: 2px; }
.base-limits b { font-weight: 600; color: var(--ink-2); }
.base-value { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.base-value b { font-variant-numeric: tabular-nums; color: var(--ink); }
.clamp-badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--warn-wash); color: color-mix(in oklab, var(--warning) 60%, var(--ink)); margin-left: 6px;
  vertical-align: 1px;
}

/* ---------- 基数模式 chips ---------- */
.mode-chips { display: inline-flex; gap: 4px; }
.mode-chips button {
  font: inherit; font-size: 12px; font-weight: 550; cursor: pointer;
  color: var(--ink-2); background: none;
  border: 1px solid var(--hairline); border-radius: 999px; padding: 2px 10px;
  transition: all .14s;
}
.mode-chips button:hover { border-color: var(--accent); color: var(--accent); }
.mode-chips button.on {
  background: var(--accent); border-color: var(--accent); color: var(--surface);
}

/* ---------- 开关 ---------- */
.switch-wrap { display: inline-flex; align-items: center; gap: 7px; }
.switch-wrap input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 36px; height: 21px; border-radius: 999px; background: var(--hairline);
  position: relative; cursor: pointer; transition: background .18s; display: inline-block;
}
.switch::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(11,11,11,.25);
  transition: left .18s cubic-bezier(.4,0,.2,1);
}
.switch-wrap input:checked + .switch { background: var(--accent); }
.switch-wrap input:checked + .switch::after { left: 17.5px; }
.switch-wrap input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-txt { font-size: 12.5px; color: var(--ink-2); }

/* ---------- 快捷 chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chips button {
  font: inherit; font-size: 12.5px; color: var(--accent); background: none;
  border: 1px solid var(--hairline); border-radius: 999px; padding: 3px 11px; cursor: pointer;
  transition: all .14s;
}
.chips button:hover { border-color: var(--accent); background: var(--accent-washed); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.chips button.clear { color: var(--ink-3); }

details.adv summary {
  font-size: 13px; color: var(--accent); cursor: pointer; user-select: none;
  margin: 4px 0 14px; list-style: none;
}
details.adv summary::before { content: '▸ '; transition: transform .15s; }
details.adv[open] summary::before { content: '▾ '; }

/* ---------- 提示 ---------- */
.note { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; margin-top: 10px; }
.warn-box {
  display: flex; gap: 8px; font-size: 13px; line-height: 1.55;
  background: var(--warn-wash); border-radius: var(--r-md); padding: 10px 13px; margin-top: 12px;
  color: var(--ink);
}
.warn-box .ic { flex-shrink: 0; }

/* ---------- Hero ---------- */
.hero { padding: 26px 24px 22px; }
.hero-label { font-size: 13.5px; color: var(--ink-2); font-weight: 550; }
.hero-num { display: flex; align-items: baseline; gap: 4px; margin: 6px 0 14px; }
.hero-cur { font-size: 24px; font-weight: 600; color: var(--ink-3); }
#hero-net, #i-hero, #l-hero, #h-hero {
  font-size: 52px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.05;
  font-feature-settings: normal;
}
.hero-row { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13px; color: var(--ink-2); }
.hero-row b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 650; }

/* ---------- 统计瓦片 ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 14px 16px 12px; box-shadow: var(--shadow); }
.tile .k { font-size: 12.5px; color: var(--ink-2); }
.tile .v { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; line-height: 1.45; }

/* ---------- 组成条(收入去向) ---------- */
.comp-bar { display: flex; gap: 2px; height: 30px; border-radius: 6px; overflow: hidden; }
.comp-bar .seg-i { min-width: 3px; cursor: default; transition: flex .25s cubic-bezier(.4,0,.2,1); }
.comp-bar .seg-i:first-child { border-radius: 6px 0 0 6px; }
.comp-bar .seg-i:last-child { border-radius: 0 6px 6px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -0.5px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 650; }

/* ---------- 柱状图 ---------- */
.colchart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 22px; }
.colchart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; cursor: default; position: relative; }
.colchart .bar {
  width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: var(--s1);
  min-height: 2px; transition: height .3s cubic-bezier(.4,0,.2,1);
}
.colchart .col:hover .bar { background: var(--accent-strong); }
.colchart .xl { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.colchart .dl {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* 首尾直标贴边对齐,避免溢出卡片 */
.colchart .col:first-child .dl { left: 0; transform: none; }
.colchart .col:last-child .dl { left: auto; right: 0; transform: none; }

/* ---------- 表格 ---------- */
.tbl-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
th { color: var(--ink-3); font-weight: 550; font-size: 12px; letter-spacing: .02em; }
th:first-child, td:first-child { text-align: left; }
td { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tr.total td { font-weight: 700; border-top: 1.5px solid var(--ink-3); }
td .sub { color: var(--ink-3); font-size: 12px; }
.pos { color: var(--good-text); font-weight: 600; }
.neg { color: var(--critical); font-weight: 600; }

details.tbl-details { margin-top: 14px; }
details.tbl-details summary { font-size: 13px; color: var(--accent); cursor: pointer; user-select: none; }

/* ---------- 年终奖对比 ---------- */
.bonus-duel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .bonus-duel { grid-template-columns: 1fr; } }
.duel-opt {
  border: 1.5px solid var(--hairline); border-radius: var(--r-md); padding: 14px 16px;
  position: relative;
}
.duel-opt.best { border-color: var(--accent); background: var(--accent-washed); }
.duel-opt .t { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.duel-opt .n { font-size: 24px; font-weight: 700; margin: 4px 0 2px; letter-spacing: -0.02em; }
.duel-opt .d { font-size: 12.5px; color: var(--ink-3); }
.duel-opt .crown {
  position: absolute; top: 12px; right: 14px; font-size: 11.5px; font-weight: 700;
  color: var(--accent); background: var(--surface); border: 1px solid var(--accent);
  padding: 1px 9px; border-radius: 999px;
}

/* ---------- 雇主成本 ---------- */
.cost-hero { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cost-hero .n { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; }
.cost-hero .r { font-size: 13px; color: var(--ink-2); }
.cost-meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; margin: 4px 0 16px; }
.cost-meter > div { height: 100%; border-radius: 4px; background: var(--accent); }

/* ---------- 步骤列表 / 规则列表 ---------- */
.steps { list-style: none; counter-reset: st; }
.steps li { counter-increment: st; display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--hairline); font-size: 14px; align-items: baseline; }
.steps li:last-child { border-bottom: none; }
.steps li::before {
  content: counter(st); flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-washed); color: var(--accent); font-size: 12px; font-weight: 700;
  display: grid; place-items: center; align-self: center;
}
.steps li .amt { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 650; }
.rules { list-style: none; font-size: 13.5px; color: var(--ink-2); }
.rules li { padding: 7px 0 7px 18px; position: relative; line-height: 1.6; }
.rules li::before { content: ''; position: absolute; left: 2px; top: 15px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- 页脚 ---------- */
.foot { margin-top: 44px; font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.foot summary { cursor: pointer; color: var(--ink-2); font-weight: 550; margin-bottom: 8px; }
.foot ul { padding-left: 18px; margin: 6px 0 12px; }
.foot li { margin-bottom: 3px; }
.disclaim { margin-top: 10px; }

/* ---------- Tooltip ---------- */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--page);
  font-size: 12.5px; line-height: 1.5; padding: 7px 11px; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(11,11,11,.25);
  max-width: 240px; font-variant-numeric: tabular-nums;
  transform: translate(-50%, calc(-100% - 10px));
}
.tip b { font-weight: 650; }

@media (max-width: 540px) {
  .top { flex-direction: column; gap: 8px; }
  .top h1 { font-size: 22px; }
  .badge { margin-top: 0; align-self: flex-start; }
  #hero-net, #i-hero, #l-hero, #h-hero { font-size: 42px; }
  .page { padding: 20px 14px 56px; }
  .card { padding: 18px 16px; }
  /* 12 根月份柱:窄屏只显示奇数月标签,收紧列距 */
  .colchart { gap: 3px; }
  .colchart .col:nth-child(even) .xl { visibility: hidden; }
  .seg button { padding: 8px 16px; }
  /* 基数模式 chips 允许换行 */
  .ratio-head { flex-wrap: wrap; gap: 6px; }
}

/* 触屏:加大滑杆热区与拇指 */
@media (pointer: coarse) {
  .slider { height: 36px; }
  .slider::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9px; }
  .slider::-moz-range-thumb { width: 20px; height: 20px; }
  .base-track + .slider { height: 34px; margin-top: -34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
