/* =========================================================================
 * 个体户合规经营助手 v0.1 —— 移动优先，无依赖
 * 浅/深主题用 CSS 变量切换；≥768px 底部 Tab 变侧边导航
 * ========================================================================= */

:root {
  --bg: #fdf8f3;
  --card: #ffffff;
  --ink: #322925;
  --ink-2: #85756b;
  --line: #f0e2d6;
  --brand: #cc3d2a;
  --brand-ink: #a93121;
  --brand-weak: #fdebe3;
  --ok: #2e8b34;
  --ok-bg: #e9f7ea;
  --warn: #b26f05;
  --warn-bg: #fff4e1;
  --danger: #c62828;
  --danger-bg: #fdecea;
  --hl-bg: #fff3d6;
  --shadow: 0 1px 3px rgba(50, 41, 37, .06);
  --m0: #6cc784; --m1: #aad98f; --m2: #dce9a2; --m3: #ffee92; --m4: #f9b877; --m5: #f97476;
  --radius: 12px;
  --nav-h: 62px;
}
[data-theme="dark"] {
  --bg: #17110f;
  --card: #231a17;
  --ink: #f3e9e4;
  --ink-2: #b5a49b;
  --line: #372a24;
  --brand: #f08770;
  --brand-ink: #f4a48f;
  --brand-weak: #3c241d;
  --ok: #81c784;
  --ok-bg: #17331c;
  --warn: #ffb74d;
  --warn-bg: #362a12;
  --danger: #ef9a9a;
  --danger-bg: #3a1d1c;
  --hl-bg: #33260f;
  --shadow: none;
  --m0: #2f6e46; --m1: #3f7a4e; --m2: #5d7444; --m3: #7a7038; --m4: #7d5230; --m5: #7e3a3c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.65 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(var(--nav-h) + 16px);
}
b { color: var(--ink); }
small { color: var(--ink-2); }
a { color: var(--brand); }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
[data-theme="dark"] .top { background: rgba(35, 26, 23, .92); }
.brand { font-weight: 700; font-size: 16px; }

main { max-width: 720px; margin: 0 auto; padding: 14px 14px 8px; }

/* ---------- 底部导航 ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0));
}
[data-theme="dark"] .nav { background: rgba(35, 26, 23, .94); }
.nav-item {
  flex: 1 0 14.28%; min-width: 56px; text-align: center; text-decoration: none;
  color: var(--ink-2); padding: 4px 2px; border-radius: 8px; font-size: 11px;
}
.nav-item span { display: block; font-size: 20px; line-height: 1.3; }
.nav-item.active { color: var(--brand-ink); background: var(--brand-weak); }

/* ---------- 卡片与通用 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 14px; margin: 0 0 12px;
}
.card-title { font-weight: 700; margin-bottom: 8px; font-size: 16px; }
.card-title.small { font-size: 14px; margin-top: 6px; }
.sub { color: var(--ink-2); font-size: 13px; margin: 6px 0; }
.sec-head { margin: 18px 2px 10px; }
.sec-head h2 { margin: 0; font-size: 19px; }
.link { display: inline-block; margin-top: 8px; font-size: 14px; text-decoration: none; }
.notes { margin: 6px 0; padding-left: 18px; }
.notes li { margin: 6px 0; }

.hero { background: linear-gradient(150deg, #fde9dc, var(--card) 68%); }
[data-theme="dark"] .hero { background: linear-gradient(150deg, #2e201a, var(--card) 68%); }
.hero-hi { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  background: var(--brand-weak); color: var(--brand-ink); border-radius: 999px;
  padding: 2px 10px; font-size: 12px;
}

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.quick { text-decoration: none; color: var(--ink); display: block; padding: 12px; }
.quick b { display: block; font-size: 14px; }
.quick small { font-size: 12px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  border-radius: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; text-decoration: none;
  margin: 4px 6px 4px 0;
}
[data-theme="dark"] .btn { color: #10201d; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand-ink); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 4px 12px; font-size: 13px; margin: 0; }
.btn.icon { padding: 6px 10px; margin: 0; }
.btn.file { position: relative; overflow: hidden; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.tbl thead th { background: var(--brand-weak); color: var(--brand-ink); white-space: nowrap; }
.tbl .rowhead { font-weight: 600; white-space: nowrap; background: var(--brand-weak); }

/* 速算矩阵热力 */
.matrix td.num { text-align: right; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; }
.matrix td.m0 { background: var(--m0); } .matrix td.m1 { background: var(--m1); }
.matrix td.m2 { background: var(--m2); } .matrix td.m3 { background: var(--m3); }
.matrix td.m4 { background: var(--m4); } .matrix td.m5 { background: var(--m5); }
[data-theme="dark"] .matrix td[class*=" m"] { color: #10201d; }
[data-theme="dark"] .matrix td.m0, [data-theme="dark"] .matrix td.m1 { color: #e4efec; }

/* ---------- 清单 ---------- */
.check-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 4px;
  border-bottom: 1px dashed var(--line); cursor: pointer;
}
.check-item:last-of-type { border-bottom: none; }
.check-item input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.check-body b { display: block; font-size: 14.5px; }
.check-body small { display: block; font-size: 12.5px; }
.check-item input:checked + .check-body b { color: var(--ink-2); text-decoration: line-through; }
.pill {
  margin-left: auto; flex: none; border-radius: 999px; font-size: 11.5px; padding: 2px 9px;
  background: var(--brand-weak); color: var(--brand-ink); white-space: nowrap;
}
.pill.doing { background: var(--ok-bg); color: var(--ok); }
.pill.danger, .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.passed { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 2px; }
.progress-bar { height: 100%; background: var(--brand); transition: width .3s; }

.timeline { padding-left: 8px; }
.tl-item { display: flex; gap: 12px; padding: 8px 0; }
.tl-dot {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand);
  color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
[data-theme="dark"] .tl-dot { color: #10201d; }
.tl-item ul { margin: 4px 0; padding-left: 18px; }

/* ---------- 计算器 ---------- */
.seg { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.seg-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 6px 14px; font-size: 13.5px; cursor: pointer;
}
.seg-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .seg-btn.on { color: #10201d; }
.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 13.5px; margin-bottom: 4px; }
.field small { display: block; font-size: 12px; }
.field input, .field select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.field.third span { font-size: 12px; }
.field.third input { font-size: 14px; padding: 7px 8px; }

.out { margin-top: 12px; }
.out-row {
  display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px;
  border-bottom: 1px dashed var(--line); font-size: 14px;
}
.out-row b { font-variant-numeric: tabular-nums; }
.out-row.hl { background: var(--hl-bg); border-radius: 8px; border-bottom: none; margin-top: 4px; padding: 9px 10px; }
.note {
  border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13px;
  background: var(--brand-weak); color: var(--brand-ink);
}
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.rates summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); margin: 8px 0; }

.go-tool { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }

/* ---------- 政策卡 ---------- */
.policy-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
.policy { border-left: 4px solid var(--ok); }
.policy.warn { border-left-color: var(--warn); }
.policy.expired { border-left-color: var(--danger); }
.policy-name { font-weight: 600; font-size: 14px; }
.policy-doc, .policy-until { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.policy.expired .policy-until .pill { background: var(--danger-bg); color: var(--danger); }
.policy.warn .policy-until .pill { background: var(--warn-bg); color: var(--warn); }
.policy.ok .policy-until .pill { background: var(--ok-bg); color: var(--ok); }

/* ---------- 日历 ---------- */
.month-row { padding: 8px 4px; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; align-items: baseline; }
.month-row b { flex: none; width: 52px; }
.month-row.cur b { color: var(--brand-ink); }
.month-row ul { margin: 0; padding-left: 16px; font-size: 13.5px; }

/* ---------- 合规 / FAQ ---------- */
.compliance-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
.cc-head { margin-bottom: 6px; font-size: 15px; }
.acc { border-bottom: 1px dashed var(--line); }
.acc:last-child { border-bottom: none; }
.acc summary { cursor: pointer; padding: 10px 2px; font-weight: 600; font-size: 14.5px; list-style-position: outside; }
.acc-body { padding: 0 2px 12px; font-size: 14px; }
.two-col { display: grid; gap: 14px; grid-template-columns: 1fr; }
.two-col ol { margin: 6px 0; padding-left: 20px; }

/* ---------- 向导 / 弹层 ---------- */
#wizard, #modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
#wizard.show, #modal.show { display: flex; }
.wiz-box, .modal-box {
  background: var(--card); border-radius: 14px; padding: 18px; width: min(480px, 100%);
  max-height: 86vh; overflow-y: auto;
}
.wiz-box h3, .modal-box h3 { margin: 4px 0 12px; }
.wiz-prog { font-size: 12.5px; color: var(--ink-2); }
.wiz-opts { display: grid; gap: 8px; }
.wiz-opt {
  text-align: left; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card);
  color: var(--ink); padding: 10px 12px; cursor: pointer; font-size: 14px;
}
.wiz-opt small { display: block; margin-top: 2px; }
.wiz-opt.on { border-color: var(--brand); background: var(--brand-weak); }
.wiz-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }

/* ---------- 我的 ---------- */
.off-link { display: block; text-decoration: none; color: var(--ink); padding: 7px 0; border-bottom: 1px dashed var(--line); }
.off-link:last-child { border-bottom: none; }
.off-link small { display: block; }

/* ---------- 页脚 / 术语 ---------- */
.foot { max-width: 720px; margin: 20px auto 10px; padding: 0 16px; font-size: 12px; color: var(--ink-2); }
.term {
  border-bottom: 2px dotted var(--brand); cursor: help; font-weight: 600;
}

/* ---------- 桌面端：侧边导航 ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 24px; }
  .nav {
    top: 0; bottom: 0; left: 0; right: auto; width: 200px; flex-direction: column;
    border-top: none; border-right: 1px solid var(--line); padding: 12px 10px; overflow-y: auto;
  }
  .nav-item { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 14px; }
  .nav-item span { font-size: 18px; }
  header.top { left: 200px; }
  main, .foot { margin-left: 200px; max-width: 820px; padding-left: 24px; }
  .compliance-grid, .two-col { grid-template-columns: 1fr 1fr; }
  .policy-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- 打印 ---------- */
@media print {
  .nav, .top, .no-print, #wizard, #modal { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  main, .foot { margin: 0; max-width: 100%; }
}
