/* 五险一金政策速查 —— 无框架样式 */
:root {
  --accent: #2563eb;
  --accent-deep: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: linear-gradient(180deg, #e8f0fb 0%, var(--bg) 420px);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 8px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container > * { flex: 0 0 auto; }

/* ---- 头部 ---- */
header { padding: 8px 4px 20px; }
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.header-text { min-width: 0; }
header h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
header h1::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 24px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), #60a5fa);
}
.subtitle { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.disclaimer { margin: 6px 0 0; color: var(--text-muted); font-size: 0.85rem; }

/* ---- 导出按钮(页面右上角) ---- */
.export-bar {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 4px;
}
.export-bar button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 4px 18px;
  border-radius: 10px;
  border: 1px solid var(--accent-border);
  background: #fff;
  color: var(--accent-deep);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.export-bar button svg { width: 15px; height: 15px; }
.export-bar button:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.18);
}
.export-bar button:active:not(:disabled) { transform: translateY(0); }
.export-bar button:disabled {
  background: #f4f5f7;
  border-color: var(--border);
  color: #b0b7c3;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---- 卡片 ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 20px;
}

/* ---- 表单基础 ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}
.field-head label, .field > label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.field-toggles { display: flex; gap: 10px; }

select,
input[type="number"],
input[type="text"] {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 0.98rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
select:hover, input:hover:not(:disabled):not(:focus) { border-color: #cfd6e0; }
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
select:disabled, input:disabled { background: #f4f5f7; color: var(--text-muted); cursor: not-allowed; }

/* 统一 select 自绘下拉箭头 */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
select:disabled {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23aab2bf' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* 数字输入隐藏原生步进箭头，风格更干净 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* 带单位的输入框 */
.input-unit { position: relative; }
.input-unit input { padding-right: 56px; }
.input-unit .unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

/* ---- 选择区 ---- */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 18px;
  align-items: end;
}

/* ---- 可搜索组合框(省份/城市) ---- */
.combobox { position: relative; }
.combobox input { padding-right: 36px; cursor: pointer; }
.combobox input:focus { cursor: text; }
.combobox::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid #9ca3af;
  border-bottom: 2px solid #9ca3af;
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.18s ease, border-color 0.15s;
  pointer-events: none;
}
.combobox:hover::after { border-color: var(--accent); }
.combobox.open::after { transform: translateY(-20%) rotate(225deg); border-color: var(--accent); }
.combobox.open input { border-color: var(--accent); box-shadow: var(--ring); }

.combobox-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  animation: combo-pop 0.14s ease;
}
@keyframes combo-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.combobox-option {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.combobox-option:hover { background: #f3f5f9; }
.combobox-option.active { background: var(--accent-light); }
.combobox-option.selected { color: var(--accent-deep); font-weight: 600; }
.combobox-option.selected::after { content: "✓"; font-size: 0.85rem; color: var(--accent); }
.combobox-empty { padding: 12px; color: var(--text-muted); font-size: 0.9rem; text-align: center; }

/* ---- 复选框 ---- */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  min-height: 24px;
  white-space: nowrap;
}
.checkbox:hover { color: var(--text); }
.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---- 状态提示 ---- */
.hint {
  color: var(--text-muted);
  text-align: center;
  padding: 18px 0;
  font-size: 0.95rem;
}
.empty-state {
  border: 1.5px dashed #d0d8e6;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.empty-state .empty-icon { font-size: 2.1rem; margin-bottom: 6px; }
.empty-state p { margin: 4px 0; }
.empty-state .empty-sub { font-size: 0.85rem; opacity: 0.85; }
#loading {
  border: 1.5px dashed var(--accent-border);
  border-radius: 14px;
  background: var(--accent-light);
  color: var(--accent-deep);
  padding: 26px;
  margin: 0 0 20px;
  font-size: 0.95rem;
}
#loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 10px;
  vertical-align: -2px;
  border: 2px solid var(--accent-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 14px 0;
  font-size: 0.92rem;
}
.error-box p { margin: 0 0 8px; word-break: break-all; }
.error-box button {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 18px;
  min-height: 36px;
  cursor: pointer;
  font-size: 0.9rem;
}
.error-box button:hover { filter: brightness(1.08); }

/* ---- 概览 chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 2px 0 14px; }
.chips .chip {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: #1e40af;
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 0.86rem;
}
.chips .chip strong { font-variant-numeric: tabular-nums; }

/* ---- 身份档次 tabs ---- */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 10px;
  scrollbar-width: thin;
}
.tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 4px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.tabs button:hover { border-color: var(--accent-border); color: var(--accent-deep); }
.tabs button.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: var(--accent-deep);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* ---- 参数表 ---- */
#result { margin: 0 0 28px; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

table { border-collapse: collapse; width: 100%; min-width: 820px; font-size: 0.9rem; }
th, td { padding: 9px 14px; text-align: right; border-bottom: 1px solid #eef1f5; white-space: nowrap; }
/* 首列 sticky 需不透明背景，横向滚动时遮挡其后内容 */
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
thead th {
  background: #f8fafc;
  color: #4b5563;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
thead th:first-child { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td, tbody tr:hover td:first-child { background: #f8fafc; }
td.num, th.num { font-variant-numeric: tabular-nums; }
/* 参数表列分组竖线(险种|基数|比例|下限金额|上限金额) */
#policy-table tbody td:nth-child(2), #policy-table tbody td:nth-child(4),
#policy-table tbody td:nth-child(6), #policy-table tbody td:nth-child(8) {
  border-left: 1px solid #e8edf3;
}
#policy-table thead tr:first-child th:nth-child(n+2),
#policy-table thead tr:last-child th:nth-child(odd) {
  border-left: 1px solid #e2e8f0;
}
/* 非数字占位文字(按实际工资/固定金额等)弱化显示 */
td .txt { color: var(--text-muted); font-size: 0.82rem; }
tr.housing-fund td, tr.housing-fund td:first-child { background: var(--accent-light); }
tr.housing-fund:hover td, tr.housing-fund:hover td:first-child { background: #dbeafe; }
.muted { color: var(--text-muted); }
.tag {
  font-size: 0.72rem;
  color: var(--accent-deep);
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 6px;
}

/* ---- 试算卡 ---- */
.calculator h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.calculator h2::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), #60a5fa);
}
.calc-tip { margin: 0 0 14px; color: var(--text-muted); font-size: 0.85rem; }
.calc-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.15fr) minmax(180px, 1fr) minmax(200px, 1fr) auto;
  gap: 14px 18px;
  align-items: end;
}
#calc-hf-field.dimmed .input-unit, #calc-hf-field.dimmed .field-toggles { opacity: 0.45; }

/* 试算结果(个人合计/单位合计等)与上方表单拉开间距 */
#calc-result { margin-top: 22px; }
#calc-result .chips { margin-top: 0; }

#calc-submit {
  min-height: 44px;
  padding: 6px 32px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.15s;
}
#calc-submit:hover { filter: brightness(1.06); transform: translateY(-1px); }
#calc-submit:disabled { background: #93c5fd; box-shadow: none; cursor: not-allowed; transform: none; }

/* ---- 页脚 ---- */
footer {
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 16px 0 28px;
}
footer code { background: #e8ecf2; border-radius: 4px; padding: 1px 5px; }

/* ---- 移动端 ---- */
@media (max-width: 760px) {
  .container { padding: 14px 14px 4px; }
  header h1 { font-size: 1.3rem; }
  .header-row { flex-direction: column; }
  .export-bar { padding-top: 2px; }
  .export-bar button { flex: 1; justify-content: center; }
  .controls { grid-template-columns: 1fr; }
  .calc-form { grid-template-columns: 1fr; }
  #calc-submit { width: 100%; }
  select, input, .tabs button { min-height: 46px; }
}

/* ---- 打印(导出 PDF)：只输出 #print-area，横版 A4，还原页面配色 ---- */
@media screen { #print-area { display: none; } }

@media print {
  #screen-area { display: none !important; }
  #print-area { display: block; }
  body { background: #fff !important; }
  .container { max-width: none; padding: 0; min-height: 0; display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 landscape; margin: 10mm; }

  .print-head h1 { margin: 0 0 2px; font-size: 18px; }
  .print-head p { margin: 0 0 10px; color: var(--text-muted); font-size: 12px; }
  .print-section-title {
    font-size: 14px;
    color: var(--accent-deep);
    margin: 14px 0 8px;
    padding-left: 8px;
    border-left: 4px solid var(--accent);
  }
  #print-area .chips { margin: 4px 0 10px; }
  #print-area .chip { font-size: 11px; padding: 3px 12px; }
  #print-area .table-wrap { overflow: visible; box-shadow: none; border-radius: 6px; }
  #print-area table { min-width: 0; font-size: 11px; }
  #print-area th, #print-area td { padding: 5px 8px; }
  #print-area th:first-child, #print-area td:first-child { position: static; }
  #print-area thead th { position: static; }
  tr { page-break-inside: avoid; }
  .print-foot { margin-top: 14px; color: var(--text-muted); font-size: 11px; }
}
