/* ========================================
   算账先生 - 金融计算工具站
   统一样式表 v2.0
   ======================================== */

/* CSS 变量 - 统一设计令牌 */
:root {
  /* 主色 */
  --primary: #1a56c4;
  --primary-dark: #1547a0;
  --primary-light: #e8f0fe;
  --success: #0ea568;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;

  /* 中性色 */
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* 布局 */
  --header-h: 60px;
  --container: 1200px;

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, 'Courier New', monospace;
}

/* 基础重置 */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

/* 容器 */
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }

/* ===== 导航栏 ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--container); margin: 0 auto; padding: 0 24px; height: 100%;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  text-decoration: none;
}
.logo:hover { color: var(--primary); }
.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; flex-shrink: 0;
}
.logo span { color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links a {
  color: var(--text-muted); text-decoration: none;
  padding: 8px 14px; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500; transition: all .2s;
}
.nav-links a:hover { color: var(--primary); background: var(--primary-light); }
.nav-links a.active { color: var(--primary); background: var(--primary-light); }
.mobile-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: 8px; width: 38px; height: 38px;
  font-size: 1.2rem; color: var(--text); cursor: pointer;
  align-items: center; justify-content: center;
}

/* ===== 面包屑 ===== */
.breadcrumb { margin: 20px 0; font-size: 0.85rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span.sep { margin: 0 8px; color: var(--text-light); }

/* ===== 页面布局 ===== */
.page { padding-top: calc(var(--header-h) + 24px); padding-bottom: 60px; }
.page-narrow { max-width: 800px; margin: 0 auto; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.875rem; font-weight: 600; color: var(--text);
}
.form-label .hint { font-weight: 400; font-size: 0.8rem; color: var(--text-muted); }
.form-input, .form-select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 1rem; font-family: var(--font-sans);
  background: var(--card); color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,196,0.1);
}
.form-input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.form-input-suffix {
  position: relative;
}
.form-input-suffix::after {
  content: attr(data-suffix);
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.85rem;
  pointer-events: none;
}
.form-input-suffix .form-input { padding-right: 40px; }

/* 单选按钮组 */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border-strong);
  border-radius: 8px; cursor: pointer;
  font-size: 0.875rem; transition: all .2s;
  background: var(--card);
}
.radio-item:hover { border-color: var(--primary); }
.radio-item input[type="radio"] { accent-color: var(--primary); }
.radio-item:has(input:checked) {
  border-color: var(--primary); background: var(--primary-light);
  color: var(--primary); font-weight: 600;
}

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 28px; border: none; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600;
  font-family: var(--font-sans); cursor: pointer;
  transition: all .2s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,196,0.25); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg { padding: 14px 36px; font-size: 1.05rem; }

/* ===== 结果展示 ===== */
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 24px 0; }
.result-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; text-align: center;
}
.result-card.highlight { background: var(--success-light); border-color: var(--success); }
.result-card.highlight-red { background: var(--danger-light); border-color: var(--danger); }
.result-card.highlight-blue { background: var(--primary-light); border-color: var(--primary); }
.result-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.result-value {
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}
.result-card.highlight .result-value { color: var(--success); }
.result-card.highlight-red .result-value { color: var(--danger); }
.result-card.highlight-blue .result-value { color: var(--primary); }
.result-unit { font-size: 0.8rem; color: var(--text-muted); margin-left: 4px; }

/* ===== 表格 ===== */
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.85rem; margin: 16px 0;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.data-table th {
  background: var(--primary); color: #fff;
  padding: 10px 12px; text-align: left;
  font-weight: 600; white-space: nowrap;
}
.data-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.data-table tbody tr:nth-child(even) { background: var(--bg); }
.data-table tbody tr:hover { background: var(--primary-light); }
.data-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.table-wrap { overflow-x: auto; }

/* ===== 提示框 ===== */
.tip-box, .warn-box, .info-box {
  border-radius: 10px; padding: 14px 18px; margin: 16px 0;
  font-size: 0.875rem; line-height: 1.7;
}
.tip-box { background: var(--primary-light); border-left: 4px solid var(--primary); }
.warn-box { background: var(--warning-light); border-left: 4px solid var(--warning); }
.info-box { background: var(--bg); border-left: 4px solid var(--text-muted); }
.tip-box strong, .warn-box strong, .info-box strong { color: var(--text); }

/* ===== SEO 内容 ===== */
.seo-content { line-height: 1.85; color: var(--text); }
.seo-content h2 {
  font-size: 1.3rem; font-weight: 700; margin: 28px 0 12px;
  color: var(--text); border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}
.seo-content h3 { font-size: 1.1rem; font-weight: 600; margin: 20px 0 8px; color: var(--text); }
.seo-content p { margin-bottom: 12px; color: var(--text); }
.seo-content ul, .seo-content ol { margin: 8px 0 12px 20px; }
.seo-content li { margin-bottom: 6px; line-height: 1.8; }
.seo-content strong { color: var(--primary); }

/* ===== FAQ 折叠 ===== */
.faq-list { margin: 24px 0; }
.faq-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 12px; overflow: hidden;
}
.faq-item summary {
  padding: 14px 20px; cursor: pointer; font-weight: 600;
  font-size: 0.95rem; list-style: none; display: flex;
  justify-content: space-between; align-items: center;
  color: var(--text); transition: background .2s;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+\FE0E'; font-size: 1.3rem; color: var(--primary); transition: transform .2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover { background: var(--bg); }
.faq-item .faq-answer { padding: 0 20px 16px; color: var(--text-muted); font-size: 0.9rem; line-height: 1.8; }

/* ===== 工具卡片网格 ===== */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; margin: 32px 0; }
.tool-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px;
  transition: all .25s; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 12px;
}
.tool-card:hover {
  border-color: var(--primary); box-shadow: 0 8px 24px rgba(26,86,196,0.12);
  transform: translateY(-2px);
}
.tool-card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tool-card-icon.blue { background: linear-gradient(135deg, var(--primary), #6366f1); }
.tool-card-icon.green { background: linear-gradient(135deg, var(--success), #14b8a6); }
.tool-card-icon.orange { background: linear-gradient(135deg, var(--warning), #f97316); }
.tool-card-icon.red { background: linear-gradient(135deg, #ef4444, #ec4899); }
.tool-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.tool-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.7; flex: 1; }
.tool-card .tool-link { color: var(--primary); font-size: 0.85rem; font-weight: 600; }

/* ===== Hero ===== */
.hero { padding: 40px 0 24px; }
.hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: 12px; line-height: 1.3; }
.hero h1 .highlight { color: var(--primary); }
.hero-sub { font-size: 1.05rem; color: var(--text-muted); max-width: 600px; margin-bottom: 24px; }

/* ===== 对比表 ===== */
.compare-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.875rem; }
.compare-table th { background: var(--bg); padding: 10px; text-align: left; border-bottom: 2px solid var(--border-strong); }
.compare-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.compare-table td:first-child { font-weight: 600; }

/* ===== 页脚 ===== */
.site-footer {
  background: #1e293b; color: #94a3b8;
  padding: 40px 0 24px; margin-top: 40px;
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr;
  gap: 32px; margin-bottom: 24px;
}
.footer-brand h4 { color: #fff; font-size: 1.1rem; margin-bottom: 8px; }
.footer-brand p { font-size: 0.85rem; line-height: 1.7; }
.footer-col h5 { color: #fff; font-size: 0.9rem; margin-bottom: 12px; }
.footer-col a { display: block; color: #94a3b8; font-size: 0.85rem; margin-bottom: 6px; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #334155; padding-top: 20px;
  text-align: center; font-size: 0.8rem; color: #64748b;
}
.footer-disclaimer {
  background: var(--warning-light); color: #92400e;
  padding: 8px 16px; border-radius: 8px;
  font-size: 0.8rem; margin-top: 12px; text-align: center;
}

/* ===== 工具函数 ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.font-mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .nav-links {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--card); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 8px; gap: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 16px; border-radius: 8px; }
  .mobile-toggle { display: flex; }
  .footer-grid { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.5rem; }
  .card { padding: 20px; }
}

@media (max-width: 480px) {
  .result-grid { grid-template-columns: 1fr; }
  .radio-group { flex-direction: column; }
}

/* 无障碍 */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== 表单分组 ===== */
.form-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  background: var(--bg);
}
.form-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-section-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ===== 输入框带单位（真实元素版本） ===== */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap .form-input {
  width: 100%;
  padding-right: 70px;
}
.input-unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
  white-space: nowrap;
}

/* ===== 资产分配页专用样式 ===== */
.allocation-plan {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 20px 0;
}
.alloc-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  transition: all .2s;
}
.alloc-item:hover { border-color: var(--primary); }
.alloc-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700;
  color: #fff; flex-shrink: 0;
}
.alloc-icon.debt { background: linear-gradient(135deg, #ef4444, #ec4899); }
.alloc-icon.save { background: linear-gradient(135deg, #f59e0b, #f97316); }
.alloc-icon.invest { background: linear-gradient(135deg, #0ea568, #14b8a6); }
.alloc-info { flex: 1; }
.alloc-info .alloc-name { font-weight: 600; font-size: 0.95rem; }
.alloc-info .alloc-desc { font-size: 0.8rem; color: var(--text-muted); }
.alloc-amount {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.alloc-amount.debt { color: var(--danger); }
.alloc-amount.save { color: var(--warning); }
.alloc-amount.invest { color: var(--success); }

/* 进度条 */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .5s ease;
}
.progress-fill.debt { background: linear-gradient(90deg, #ef4444, #ec4899); }
.progress-fill.save { background: linear-gradient(90deg, #f59e0b, #f97316); }
.progress-fill.invest { background: linear-gradient(90deg, #0ea568, #14b8a6); }

/* 债务列表 */
.debt-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.debt-row:last-child { border-bottom: none; }
.debt-row .form-group { margin-bottom: 0; }
.debt-row .form-label { font-size: 0.75rem; }
.debt-remove {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px; height: 38px;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.debt-remove:hover { background: var(--danger-light); border-color: var(--danger); }
.btn-add-debt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  margin-top: 8px;
}
.btn-add-debt:hover { border-style: solid; background: var(--primary-light); }

/* 时间线 */
.timeline {
  list-style: none;
  margin: 16px 0;
  padding: 0;
}
.timeline-item {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-dot.debt { background: var(--danger); }
.timeline-dot.save { background: var(--warning); }
.timeline-dot.invest { background: var(--success); }
.timeline-content { flex: 1; }
.timeline-content .tl-title { font-weight: 600; font-size: 0.9rem; }
.timeline-content .tl-desc { font-size: 0.85rem; color: var(--text-muted); }

@media (max-width: 768px) {
  .debt-row { grid-template-columns: 1fr 1fr; gap: 12px; }
}
