/* ===========================================================================
   房贷精灵 · 全局样式（现代、清爽、响应式）
   设计：蓝色信任基调 + 卡片化布局 + 移动端优先
   =========================================================================== */
:root {
  --brand: #1e6fd9;
  --brand-dark: #155bb5;
  --brand-light: #e8f1ff;
  --accent: #f59e0b;
  --ink: #1f2937;
  --ink-soft: #5b6675;
  --line: #e5e9f0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(30, 111, 217, 0.08);
  --shadow-hover: 0 8px 30px rgba(30, 111, 217, 0.16);
  --maxw: 1100px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
img { max-width: 100%; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.text-center { text-align: center; }

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar {
  display: flex; align-items: center; gap: 18px;
  height: 60px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; color: var(--brand); white-space: nowrap; }
.logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--ink-soft); font-size: 15px; padding: 8px 12px; border-radius: 8px; font-weight: 500;
}
.nav a:hover, .nav a.active { color: var(--brand); background: var(--brand-light); }
.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 60%, #06b6d4 100%);
  color: #fff; padding: 40px 0 48px;
}
.hero h1 { margin: 0 0 8px; font-size: 30px; }
.hero p { margin: 0; opacity: 0.92; font-size: 16px; }
.hero .tags { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .tags span { background: rgba(255,255,255,0.18); padding: 4px 12px; border-radius: 999px; font-size: 13px; }

/* ---------- 区块 ---------- */
.section { padding: 36px 0; }
.section h2 { font-size: 22px; margin: 0 0 4px; }
.section .sub { color: var(--ink-soft); margin: 0 0 20px; font-size: 14px; }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card h3 { margin: 0; font-size: 17px; }
.card p { margin: 0; color: var(--ink-soft); font-size: 13px; flex: 1; }
.card .go { color: var(--brand); font-weight: 600; font-size: 14px; }

/* ---------- 计算器外壳 ---------- */
.calc-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.calc-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.calc-card h1 { margin: 0 0 4px; font-size: 22px; }
.calc-card .summary { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .input-row { display: flex; align-items: center; gap: 8px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.field .unit { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.is-hidden { display: none !important; }
.btn {
  display: inline-block; background: var(--brand); color: #fff; border: none; cursor: pointer;
  padding: 12px 22px; border-radius: 10px; font-size: 16px; font-weight: 600; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-row { display: flex; gap: 10px; margin-top: 6px; }

/* 结果区 */
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); position: sticky; top: 80px; }
.result-card h2 { margin: 0 0 14px; font-size: 18px; }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.result-row .k { color: var(--ink-soft); }
.result-row .v { font-weight: 600; text-align: right; }
.result-row.emphasis .v { color: var(--brand); font-size: 18px; }
.result-note { margin-top: 14px; font-size: 13px; color: var(--ink-soft); background: var(--brand-light); padding: 10px 12px; border-radius: 8px; }
.result-empty { color: var(--ink-soft); font-size: 14px; }

/* 结果操作栏：打印 / 导出 / 复制 */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.result-head h2 { margin: 0; font-size: 18px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-mini {
  font-size: 12px; padding: 6px 12px; border: 1px solid var(--brand);
  background: #fff; color: var(--brand); border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap;
}
.btn-mini:hover { background: var(--brand); color: #fff; }

/* 打印专用抬头（屏幕隐藏，打印显示） */
.print-only { display: none; }
.print-head { font-size: 15px; color: var(--ink); margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--brand); }
.print-head .ph-date::before { content: '（'; }
.print-head .ph-date::after { content: '）'; }

/* 轻提示 toast */
.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%);
  background: rgba(15, 23, 42, .92); color: #fff; padding: 10px 18px;
  border-radius: 10px; font-size: 14px; z-index: 9999; opacity: 0;
  transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* 计算完成引导提示（告知结果在右侧 / 移动端下方） */
.result-hint {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 16px; padding: 10px 14px;
  background: linear-gradient(135deg, #e8f1ff, #eef6ff);
  border: 1px solid #bcd5fb; border-left: 4px solid var(--brand);
  color: var(--brand-dark); font-size: 14px; font-weight: 600;
  border-radius: 10px; animation: hintIn .3s ease;
}
.result-hint.is-hide { opacity: 0; transition: opacity .5s ease; pointer-events: none; }
@keyframes hintIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.result-card.flash { animation: cardFlash 1.2s ease; }
@keyframes cardFlash {
  0% { box-shadow: 0 0 0 0 rgba(30, 111, 217, .45); border-color: var(--brand); }
  100% { box-shadow: var(--shadow); border-color: var(--line); }
}

/* 明细表 */
.schedule { margin-top: 16px; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.schedule table { width: 100%; border-collapse: collapse; font-size: 13px; }
.schedule th, .schedule td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.schedule th { background: var(--brand-light); position: sticky; top: 0; color: var(--brand-dark); }
.schedule td:first-child, .schedule th:first-child { text-align: center; }

/* ---------- 广告位占位 ---------- */
.adslot { margin: 24px 0; padding: 24px; border: 1px dashed #c9d4e3; border-radius: var(--radius); background: #fafcff; color: var(--ink-soft); text-align: center; font-size: 13px; }
.adslot .label { font-weight: 600; color: var(--brand); }

/* ---------- 面包屑 / 文章 ---------- */
.breadcrumb { font-size: 13px; color: var(--ink-soft); margin: 14px 0; }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--brand); }
.article { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.article h1 { margin: 0 0 6px; font-size: 26px; }
.article .meta { color: var(--ink-soft); font-size: 13px; margin-bottom: 18px; }
.article p { margin: 0 0 16px; }
.tag { display: inline-block; background: var(--brand-light); color: var(--brand-dark); padding: 2px 10px; border-radius: 999px; font-size: 12px; margin-right: 6px; }

/* ---------- 页脚 ---------- */
.site-footer { background: #0f172a; color: #cbd5e1; margin-top: 48px; padding: 32px 0; font-size: 14px; }
.site-footer a { color: #93c5fd; }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; }
.site-footer h4 { color: #fff; font-size: 15px; margin: 0 0 10px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer .copy { border-top: 1px solid #1e293b; margin-top: 24px; padding-top: 16px; font-size: 13px; color: #94a3b8; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .calc-wrap { grid-template-columns: 1fr; }
  .result-card { position: static; }
  .nav { display: none; }
  .nav.open { display: flex; flex-direction: column; width: 100%; margin-left: 0; }
  .nav-toggle { display: inline-flex; margin-left: auto; background: var(--brand-light); border: none; color: var(--brand); font-size: 22px; width: 42px; height: 42px; border-radius: 10px; cursor: pointer; }
  .site-header .bar { flex-wrap: wrap; height: auto; padding: 10px 0; }
  .hero h1 { font-size: 24px; }
}

/* ---------- 评论区 ---------- */
.comment-section { margin-top: 28px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.comment-title { margin: 0 0 14px; font-size: 18px; }
.comment-count { color: var(--ink-soft); font-size: 13px; font-weight: 400; }
.comment-empty { color: var(--ink-soft); font-size: 14px; }
.comment-item { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.comment-item:last-child { border-bottom: none; }
.comment-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.comment-nick { font-weight: 600; color: var(--brand-dark); font-size: 14px; }
.comment-date { color: var(--ink-soft); font-size: 12px; }
.comment-body { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.comment-form { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.comment-nick-input, .comment-content-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none;
}
.comment-nick-input { max-width: 260px; }
.comment-content-input { min-height: 90px; resize: vertical; }
.comment-nick-input:focus, .comment-content-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
/* 蜜罐：隐藏但真实存在，机器人会填，人不会 */
.comment-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.comment-submit-row { display: flex; align-items: center; gap: 12px; }
.comment-submit { padding: 10px 22px; font-size: 14px; }
.comment-msg { font-size: 13px; color: var(--danger); min-height: 0; opacity: 0; transition: opacity .25s; }
.comment-msg.show { opacity: 1; }
/* 管理员删除按钮 */
.comment-right { display: inline-flex; align-items: center; gap: 8px; }
.comment-del { background: none; border: 1px solid var(--line); color: var(--danger); font-size: 12px; padding: 1px 9px; border-radius: 6px; cursor: pointer; line-height: 1.7; }
.comment-del:hover { background: #fef2f2; border-color: var(--danger); }
.comment-del:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 词表管理页 ---------- */
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.admin-row { display: flex; gap: 10px; }
.admin-row input, .admin-add input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; outline: none; }
.admin-row input:focus, .admin-add input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.admin-add { display: flex; gap: 10px; margin-top: 16px; }
.admin-msg { font-size: 13px; color: var(--danger); margin-top: 10px; min-height: 18px; }
.admin-msg.ok { color: var(--success); }
.chip-group { margin: 8px 0 6px; }
.chip-group-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-light); color: var(--brand-dark); border-radius: 999px; padding: 4px 12px; font-size: 13px; margin: 0 6px 8px 0; }
.chip.custom { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.chip-del { background: none; border: none; color: #9a3412; font-size: 14px; cursor: pointer; padding: 0 2px; line-height: 1; }
.chip-del:hover { color: var(--danger); }
.chip-none { color: var(--ink-soft); font-size: 13px; }

/* ---------- 管理页标签切换 & 评论管理 ---------- */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.admin-tab { background: none; border: none; padding: 10px 14px; font-size: 14px; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; }
.admin-tab:hover { color: var(--brand); }
.admin-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.admin-tab-pane { padding-top: 4px; }
.admin-subhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.admin-comment { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.admin-comment:last-child { border-bottom: none; }
.admin-comment-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.admin-comment-meta { font-size: 12px; color: var(--ink-soft); word-break: break-all; }
.admin-comment-del { background: none; border: 1px solid var(--line); color: var(--danger); font-size: 12px; padding: 2px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.admin-comment-del:hover { background: #fef2f2; border-color: var(--danger); }
.admin-comment-del:disabled { opacity: .5; cursor: not-allowed; }
.admin-comment-body { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

/* ---------- 打印：仅输出结果卡片 ---------- */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .calc-card, .result-actions, .result-hint,
  .nav, .nav-toggle, .toast, .hero, .section .sub, .breadcrumb, .adslot, .comment-section { display: none !important; }
  .container { max-width: 100%; }
  .calc-wrap { display: block; }
  .result-card { position: static; box-shadow: none; border: none; padding: 0; }
  .result-card h2 { display: none; }
  .print-only { display: block; }
  .result-row, .schedule { page-break-inside: avoid; }
}
