/* ============================================================
   社会保险计算器 - 独立项目样式
   基础样式 + 计算器组件（含暗黑模式）
   ============================================================ */

:root {
	--color-primary: #3b82f6;
	--color-primary-dark: #2563eb;
	--color-border: #e5e7eb;
	--color-text: #374151;
	--color-text-dark: #111827;
	--color-text-muted: #9ca3af;
	--color-bg: #ffffff;
	--color-bg-soft: #f9fafb;
	--font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
		"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
	font-family: var(--font-body);
	font-size: 16px;
	line-height: 1.8;
	color: var(--color-text);
	background: var(--color-bg-soft);
}
a { color: var(--color-primary-dark); text-decoration: none; }
a:hover { color: var(--color-primary); }

/* ---- 页头 ---- */
.site-header {
	background: #1a1a2e;
	border-bottom: 1px solid var(--color-border);
	position: sticky;
	top: 0;
	z-index: 100;
}
.header-inner {
	max-width: 860px;
	margin: 0 auto;
	padding: 16px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { display: block; flex: none; }
.brand-name { font-size: 18px; font-weight: 700; color: #fff; }
.brand-sub {
	font-size: 12px; color: #9fb3c8; font-weight: 500;
	letter-spacing: .5px; margin-left: 2px;
}

.theme-toggle {
	background: none; border: none; cursor: pointer; padding: 6px;
	border-radius: 8px; color: var(--color-text); transition: all .2s;
	display: flex; align-items: center;
}
.theme-toggle:hover { background: rgba(0,0,0,.06); }

/* ---- 主内容 ---- */
.container { max-width: 860px; margin: 0 auto; padding: 40px 24px; }
main h1 {
	font-size: 28px; font-weight: 700; color: var(--color-text-dark);
	margin: 0 0 20px;
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	-webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
main h2 { font-size: 22px; color: var(--color-text-dark); margin: 30px 0 12px; }
main p { margin: 0 0 16px; }
table { border-collapse: collapse; width: 100%; margin: 16px 0; }
th, td { border: 1px solid var(--color-border); padding: 8px 12px; text-align: center; }

/* ---- 页脚 ---- */
.site-footer {
	background: #1a1a2e; border-top: 1px solid var(--color-border);
	text-align: center; padding: 20px; font-size: 13px; color: var(--color-text-muted);
}
.footer-links { margin-bottom: 10px; font-size: 13px; }
.footer-links a {
	color: #9fb3c8; text-decoration: none; margin: 0 8px;
	transition: color .2s;
}
.footer-links a:hover { color: #fff; text-decoration: underline; }
html.dark .footer-links a { color: #8aa; }
html.dark .footer-links a:hover { color: #fff; }

/* ---- 法律 / 信息页 ---- */
.legal h1 { margin-bottom: 4px; }
.legal-meta { font-size: 13px; color: var(--color-text-muted); margin-bottom: 30px; }
.legal h2 { font-size: 19px; margin: 32px 0 10px; }
.legal h3 { font-size: 16px; margin: 22px 0 8px; color: var(--color-text-dark); }
.legal p, .legal li { line-height: 1.9; color: var(--color-text); }
.legal ul, .legal ol { margin: 0 0 18px; padding-left: 24px; }
.legal a { color: var(--color-primary-dark); }
.legal .highlight-box {
	background: var(--color-bg-soft); border: 1px solid var(--color-border);
	border-radius: 10px; padding: 14px 16px; margin: 14px 0 20px;
}
html.dark .legal .highlight-box { background: #12121f; }

/* ---- 站点地图页 ---- */
.sitemap-list { list-style: none; padding: 0; margin: 0 0 20px; }
.sitemap-list li { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px dashed var(--color-border); }
.sitemap-list li:last-child { border-bottom: none; }
.sitemap-list .sm-title { font-weight: 700; color: var(--color-text-dark); font-size: 16px; }
.sitemap-list .sm-title a { color: var(--color-primary-dark); text-decoration: none; }
.sitemap-list .sm-title a:hover { text-decoration: underline; }
.sitemap-list .sm-desc { font-size: 13px; color: var(--color-text-muted); margin-top: 3px; line-height: 1.7; }

/* ---- 暗黑模式 ---- */
html.dark {
	--color-primary: #3b82f6;
	--color-primary-dark: #60a5fa;
	--color-border: #374151;
	--color-text: #d1d5db;
	--color-text-dark: #f9fafb;
	--color-text-muted: #6b7280;
	--color-bg: #111827;
	--color-bg-soft: #1f2937;
}
html.dark body { background: var(--color-bg-soft); }
html.dark .site-header { background: #111827; border-color: #333; }
html.dark .site-footer { background: #111827; border-color: #333; }
html.dark .brand-name { color: #eee; font-weight: 700; }

/* ---- 返回顶部按钮 ---- */
.back-to-top {
	position: fixed; bottom: 30px; right: 30px; width: 44px; height: 44px;
	border-radius: 50%; background: #1a1a2e; color: #fff; border: none;
	cursor: pointer; font-size: 20px; display: none; align-items: center; justify-content: center;
	box-shadow: 0 2px 10px rgba(0,0,0,.2); z-index: 999; transition: all .3s;
}
.back-to-top:hover { background: #2563eb; transform: translateY(-2px); }
.back-to-top.show { display: flex; }

/* FAQ 区块 */
.faq-panel {
	background: #fff;
	border: 1px solid var(--color-border);
	border-radius: 12px;
	padding: 20px 22px 12px;
	margin-top: 30px;
}
html.dark .faq-panel { background: #1f2937; border-color: #333; }
.faq-panel > h2 { margin-top: 0; }
.faq {
	margin: 0;
	padding: 0;
	background: transparent;
	border-radius: 0;
}
/* FAQ 折叠项（原生 details，SEO 友好：内容始终在源码中） */
.faq-item {
	border: 1px solid var(--color-border, #e3e6ea);
	border-radius: 10px;
	margin: 0 0 10px;
	background: var(--card-bg, #fff);
	overflow: hidden;
}
.faq-item summary {
	margin: 0;
	padding: 13px 16px 13px 18px;
	font-size: 1.02em;
	font-weight: 600;
	color: var(--color-text-dark, #1a1a2e);
	cursor: pointer;
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	transition: background .2s;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { background: var(--color-bg-soft, #f1f5fb); }
.faq-item summary::after {
	content: '';
	flex: none;
	width: 9px; height: 9px;
	border-right: 2px solid #9aa4b2;
	border-bottom: 2px solid #9aa4b2;
	transform: rotate(45deg);
	transition: transform .25s;
	margin-top: -4px;
}
.faq-item[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.faq-item[open] summary { border-bottom: 1px solid var(--color-border, #e3e6ea); }
.faq-body {
	overflow: hidden;
	max-height: 0;
	transition: max-height .3s ease;
}
.faq-item[open] .faq-body { max-height: 600px; }
.faq-body p {
	margin: 0;
	padding: 14px 18px;
	line-height: 1.75;
	color: var(--color-text-dark, #333);
}
html.dark .faq-item { background: #1f2937; border-color: #333; }
html.dark .faq-item summary { color: #eef2f7; }
html.dark .faq-body p { color: #c8d0dc; }

/* ============================================================
   计算器组件
   ============================================================ */

.calc-wrap { margin: 8px 0 32px; }

/* ---- Tab 切换 ---- */
.calc-tabs {
	display: flex; flex-wrap: wrap; gap: 8px;
	margin-bottom: 22px;
}
.calc-tab {
	padding: 10px 16px; border-radius: 10px;
	border: 1px solid var(--color-border);
	background: #fff; cursor: pointer;
	font-size: 14px; font-weight: 600; color: var(--color-text-dark);
	transition: all .2s; user-select: none;
}
.calc-tab:hover { border-color: var(--color-primary); color: var(--color-primary-dark); }
.calc-tab.active {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	color: #fff; border-color: transparent;
}
/* 友情链接（外部工具站） */
.calc-tab.friend-link {
	background: #fff;
	border-style: dashed;
	border-color: #9fc9a0;
	color: #1a9e63;
	text-decoration: none;
}
.calc-tab.friend-link:hover {
	border-color: #1a9e63;
	background: rgba(52,199,123,.08);
	color: #157a4b;
}
html.dark .calc-tab.friend-link { background: #1f2937; }
html.dark .calc-tab { background: #1f2937; }
html.dark .calc-tab.active { color: #fff; }
.calc-panel { display: none; }
/* 两栏布局：左表单 / 右结果（参考 tuixiu.5kai.org） */
.calc-panel.active {
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	column-gap: 28px;
	align-items: start;
}
.calc-panel.active > .calc-form {
	grid-column: 1;
	align-self: start;
}
/* 左侧表单卡片框 */
.calc-form {
	background: #fff;
	border: 1px solid var(--color-border);
	border-radius: 12px;
	padding: 18px 20px;
}
html.dark .calc-form { background: #1f2937; border-color: #333; }
/* 左侧表单两列排布：城市/参保类型一行、当前/计划退休年龄一行等 */
.calc-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.calc-form .form-grid + .form-grid { margin-top: 14px; }
.field.wide { grid-column: 1 / -1; }
/* 累计缴费年限行 */
.total-years-line {
	margin: 12px 0 2px; padding: 8px 12px;
	background: var(--color-bg-soft); border: 1px dashed var(--color-border);
	border-radius: 8px; font-size: 13px; color: var(--color-text-dark);
}
html.dark .total-years-line { background: #12121f; }
/* 参保类型说明行 */
.ins-note {
	margin: 10px 0 2px; padding: 8px 12px;
	background: rgba(59,130,246,.1); border: 1px dashed rgba(37,99,235,.4);
	border-radius: 8px; font-size: 13px; color: var(--color-text-dark);
	line-height: 1.7;
}
/* 高级设置（折叠面板） */
.advanced {
	margin-top: 16px; border: 1px solid var(--color-border); border-radius: 10px;
	padding: 10px 14px; background: var(--color-bg-soft);
}
html.dark .advanced { background: #12121f; }
.advanced summary {
	cursor: pointer; font-size: 14px; font-weight: 700; color: var(--color-text-dark);
	user-select: none; list-style: none;
}
.advanced summary::before { content: '▸ '; color: var(--color-primary-dark); }
.advanced[open] summary::before { content: '▾ '; }
.advanced .form-grid { margin-top: 12px; }
/* 禁用输入框（1992年后参保时视同缴费年限） */
.field input:disabled, .field select:disabled {
	opacity: .55; background: var(--color-bg-soft); cursor: not-allowed;
}
.calc-panel.active > .result-card {
	grid-column: 2; grid-row: 1;
	position: sticky; top: 88px;
	margin-top: 0;
}
/* 结果栏空间较窄时收紧表格与卡片 */
.calc-panel.active .calc-table th,
.calc-panel.active .calc-table td { padding: 7px 6px; font-size: 12.5px; }
.calc-panel.active .summary-item .num { font-size: 18px; }
.calc-panel.active .summary-item.highlight .num { font-size: 22px; }

/* ---- 表单 ---- */
.form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
	gap: 14px;
}
.field label {
	display: block; font-size: 13px; color: var(--color-text);
	margin-bottom: 6px; font-weight: 600;
}
.field input, .field select {
	width: 100%; padding: 10px 12px;
	border: 1px solid var(--color-border); border-radius: 8px;
	font-size: 15px; background: #fff; color: var(--color-text-dark);
	transition: border-color .2s;
}
.field input:focus, .field select:focus {
	outline: none; border-color: var(--color-primary);
	box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
html.dark .field input, html.dark .field select { background: #1f2937; }
.field .hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.field-range { display: flex; align-items: center; gap: 10px; }
.field-range input[type=range] { flex: 1; padding: 0; }
.field-range input[type=range]:disabled { opacity: .4; cursor: not-allowed; }
.field-range input[type=range]:disabled + output { opacity: .4; }
.field-range output {
	min-width: 44px; text-align: center; font-weight: 700;
	color: var(--color-primary-dark); font-size: 15px;
}
.check-line {
	display: flex; align-items: center; gap: 8px;
	font-size: 14px; color: var(--color-text-dark);
	margin-top: 16px; cursor: pointer;
}
.check-line input { width: 16px; height: 16px; cursor: pointer; }

/* ---- 结果卡片 ---- */
.result-card {
	background: #fff; border: 1px solid var(--color-border);
	border-radius: 12px; padding: 20px 24px; margin-top: 22px;
}
html.dark .result-card { background: #1f2937; border-color: #333; }
.result-card h3 {
	font-size: 16px; color: var(--color-text-dark);
	margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.result-empty { color: var(--color-text-muted); font-size: 14px; }

/* 大数字结果卡（参考 tuixiu.5kai.org） */
.result-hero {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	border-radius: 12px; padding: 18px 20px 16px; color: #fff;
	text-align: center; margin-bottom: 14px;
}
.result-hero .label { font-size: 13px; opacity: .92; }
.result-hero .num { font-size: 34px; font-weight: 800; line-height: 1.25; margin: 4px 0 2px; }
.result-hero .sub { font-size: 12px; opacity: .92; }
/* 数据小方块 */
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-block {
	background: var(--color-bg-soft); border: 1px solid var(--color-border);
	border-radius: 10px; padding: 10px 6px; text-align: center;
}
html.dark .stat-block { background: #12121f; }
.stat-block .sb-label { font-size: 12px; color: var(--color-text-muted); }
.stat-block .sb-val { font-size: 18px; font-weight: 800; color: var(--color-primary-dark); margin-top: 2px; }
/* 分享按钮 */
.share-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn-share {
	flex: 1; min-width: 130px; padding: 10px 14px;
	border: none; background: var(--color-primary); border-radius: 8px;
	cursor: pointer; font-size: 14px; font-weight: 600; color: #fff;
	transition: all .2s; font-family: inherit;
}
.btn-share:hover { background: var(--color-primary-dark); }
html.dark .btn-share { background: var(--color-primary); }
/* 轻提示 */
.toast {
	position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%) translateY(8px);
	background: #1a1a2e; color: #fff; padding: 9px 18px; border-radius: 8px;
	font-size: 13px; opacity: 0; transition: all .25s; z-index: 9999;
	pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.summary-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 12px; margin-bottom: 16px;
}
.summary-item {
	background: var(--color-bg-soft);
	border: 1px solid var(--color-border); border-radius: 10px;
	padding: 14px 12px; text-align: center;
}
.summary-item .label { font-size: 12px; color: var(--color-text-muted); }
.summary-item .num {
	font-size: 20px; font-weight: 800; color: var(--color-primary-dark);
	margin-top: 4px; white-space: nowrap;
}
.summary-item .sub { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.summary-item.highlight { background: linear-gradient(135deg, rgba(59,130,246,.14), rgba(41,128,185,.14)); }
.summary-item.highlight .num { color: var(--color-primary-dark); font-size: 24px; }
html.dark .summary-item { background: #12121f; }

/* ---- 明细表 ---- */
table.calc-table {
	table-layout: fixed; border-collapse: collapse; width: 100%;
	margin: 12px 0; font-size: 14px;
}
.calc-table th, .calc-table td {
	border: 1px solid var(--color-border);
	padding: 8px 10px; text-align: right;
}
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table th {
	background: var(--color-bg-soft); color: var(--color-text-dark);
	font-weight: 700; font-size: 13px;
}
.calc-table tr.total td {
	background: rgba(59,130,246,.1); font-weight: 800; color: var(--color-text-dark);
}
.calc-table .muted { color: var(--color-text-muted); font-size: 12px; }

/* ---- 进度条 / 组成条 ---- */
.bar {
	height: 14px; border-radius: 7px; background: var(--color-bg-soft);
	border: 1px solid var(--color-border); overflow: hidden; margin: 8px 0 4px;
}
.bar > i { display: block; height: 100%; border-radius: 7px; background: linear-gradient(90deg, #3b82f6, #60a5fa); transition: width .3s; }
.bar-comp { display: flex; height: 18px; border-radius: 9px; overflow: hidden; border: 1px solid var(--color-border); margin: 8px 0 6px; }
.bar-comp > i { display: block; height: 100%; }
.bar-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 12px; color: var(--color-text); margin-bottom: 6px; }
.bar-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---- 徽标 ---- */
.badge {
	display: inline-block; padding: 3px 10px; border-radius: 999px;
	font-size: 12px; font-weight: 700;
}
.badge.ok { background: rgba(52,199,123,.16); color: #1a9e63; }
.badge.warn { background: rgba(255,149,0,.16); color: #c77700; }
.badge.info { background: rgba(59,130,246,.18); color: var(--color-primary-dark); }
html.dark .badge.ok { color: #4cd190; }
html.dark .badge.warn { color: #ffb45e; }

/* ---- 说明 / 提示 ---- */
.calc-note {
	margin-top: 16px; padding: 12px 16px;
	background: var(--color-bg-soft); border: 1px dashed var(--color-border);
	border-radius: 10px; font-size: 13px; color: var(--color-text);
	line-height: 1.9;
}
.calc-note b { color: var(--color-text-dark); }
.formula-box {
	margin-top: 20px; padding: 16px 20px;
	background: var(--color-bg-soft); border: 1px solid var(--color-border);
	border-radius: 10px; font-size: 14px; color: var(--color-text-dark);
	line-height: 2;
}
.formula-box code {
	background: rgba(59,130,246,.12); padding: 1px 6px; border-radius: 4px;
	font-family: Consolas, Monaco, "Courier New", monospace; font-size: 13px;
}

/* ---- 计算公式说明（页面级汇总框） ---- */
.formula-panel {
	background: #fff;
	border: 1px solid var(--color-border);
	border-radius: 12px;
	padding: 20px 22px;
}
html.dark .formula-panel { background: #1f2937; border-color: #333; }
.formula-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
}
.formula-item {
	display: none;
	background: var(--color-bg-soft);
	border: 1px solid var(--color-border);
	border-radius: 10px;
	padding: 14px 16px;
}
.formula-item.active {
	display: block;
	grid-column: 1 / -1;
}
html.dark .formula-item { background: #12121f; }
.formula-item h3 {
	font-size: 15px; color: var(--color-text-dark);
	margin-bottom: 6px;
}
.formula-item p {
	margin: 0; font-size: 13px; line-height: 1.85; color: var(--color-text);
}

/* 中屏以下恢复单列：先表单后结果 */
@media (max-width: 980px) {
	.calc-panel.active { display: block; }
	.calc-panel.active > .result-card { position: static; margin-top: 22px; }
}

@media (max-width: 600px) {
	.header-inner { flex-direction: column; gap: 10px; }
	.brand { flex-wrap: wrap; row-gap: 2px; justify-content: center; }
	.brand-sub { width: 100%; margin-left: 0; text-align: center; }
	.container { padding: 20px 16px; }
	main h1 { font-size: 22px; }
	.calc-form .form-grid { grid-template-columns: 1fr; }
	.calc-tab { padding: 8px 12px; font-size: 13px; }
	.result-card { padding: 14px 16px; }
	.summary-item .num { font-size: 17px; }
	.calc-table th, .calc-table td { padding: 6px 6px; font-size: 12.5px; }
	.formula-grid { grid-template-columns: 1fr; }
}

/* ---- 首页：城市入口 / 文章入口 ---- */
.home-sec { font-size: 20px; margin: 36px 0 12px; color: var(--color-text-dark); }
.city-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 8px; }
.city-grid a {
	display: inline-block; padding: 7px 14px; border: 1px solid var(--color-border);
	border-radius: 8px; color: var(--color-primary-dark); background: var(--color-bg-soft);
	text-decoration: none; font-size: 13.5px;
	transition: border-color .15s, background .15s, color .15s;
}
.city-grid a:hover { border-color: var(--color-primary); background: #fff; color: var(--color-primary); }
html.dark .city-grid a:hover { background: #1f2937; }
.article-list { list-style: none; padding: 0; margin: 14px 0 0; }
.article-list li { padding: 13px 0; border-bottom: 1px dashed var(--color-border); }
.article-list li:last-child { border-bottom: none; }
.article-list a { font-weight: 600; color: var(--color-text-dark); text-decoration: none; font-size: 15px; }
.article-list a:hover { color: var(--color-primary-dark); }
.article-list .a-desc { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; line-height: 1.7; }

/* 固定 3 列卡片组（城市页示例测算等 6 卡场景，避免 5+1 孤儿卡） */
.summary-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .summary-grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .summary-grid-3 { grid-template-columns: 1fr; } }
