/* 白话报税 · 移动优先样式 */
:root {
  --bg: #F7F6F2; --card: #FFFFFF; --ink: #17201F; --ink-2: #4A5553; --ink-3: #8A9492;
  --line: #E7E4DC; --brand: #0F766E; --brand-soft: #E6F4F1;
  --warn: #B45309; --warn-soft: #FEF3E2; --danger: #B91C1C; --danger-soft: #FEE9E7;
  --ok: #15803D; --ok-soft: #E8F5EC;
  --radius: 16px; --shadow: 0 1px 2px rgba(23,32,31,.04), 0 8px 24px rgba(23,32,31,.06);
  --tabbar-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, textarea, select, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); box-shadow: 0 0 0 1px rgba(0,0,0,.03), 0 0 40px rgba(0,0,0,.04); }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(247,246,242,.92); backdrop-filter: blur(12px) saturate(1.2); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(145deg, #12867C, #0B5D57); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; box-shadow: 0 2px 8px rgba(15,118,110,.25); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.ghost-btn, .icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 11px; font-size: 13px; color: var(--ink-2); transition: transform .12s ease, background .12s; }
.ghost-btn:active, .icon-btn:active { transform: scale(.97); background: var(--brand-soft); }
.icon-btn { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; }
#main { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.view { display: none; }
.view.active { display: block; animation: fadeup .22s ease; }
@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stream { padding: 16px 14px calc(220px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 88%; padding: 11px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.55; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(15,118,110,.18); }
.bubble.sys { align-self: center; background: transparent; color: var(--ink-3); font-size: 12px; padding: 2px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.answer-card { padding: 0; overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.answer-head { padding: 16px 16px 13px; background: linear-gradient(180deg, #F4FAF8 0%, #FFFFFF 100%); border-bottom: 1px solid var(--line); }
.answer-kicker { font-size: 11px; letter-spacing: .12em; color: var(--ink-3); margin-bottom: 8px; }
.answer-line { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 5px 0; align-items: start; }
.answer-line .n { width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--brand-soft); color: var(--brand); margin-top: 1px; }
.answer-line .txt { font-size: 14.5px; line-height: 1.55; }
.answer-line.verdict .txt { font-size: 16px; font-weight: 600; }
.answer-line.ref .txt { color: var(--ink-2); font-size: 13px; }
.answer-line.ref .txt .date { color: var(--brand); font-weight: 600; }
.answer-line.counter .txt { color: var(--ink-2); font-size: 13.5px; }
.answer-line.counter .txt .diff { color: var(--warn); font-weight: 700; }
.amt { font-variant-numeric: tabular-nums; font-weight: 700; }
.amt.big { font-size: 19px; letter-spacing: -.2px; }
.amt.zero { color: var(--ok); }
.amt.pay { color: var(--danger); }
.breakdown { padding: 4px 16px 14px; }
.breakdown-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 6px; }
.breakdown-title { font-size: 12px; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; }
.link-btn { border: 0; background: none; color: var(--brand); font-size: 12px; padding: 2px 0; }
.tax-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); }
.tax-row:first-of-type { border-top: 0; }
.tax-row .k { color: var(--ink-2); font-size: 13px; }
.tax-row .v { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.tax-row .v.zero { color: var(--ok); }
.tax-row .v.pay { color: var(--danger); }
.tax-row .sub { display: block; color: var(--ink-3); font-size: 11px; font-weight: 400; margin-top: 2px; text-align: right; }
.tax-row.total { border-top: 1.5px solid var(--ink); margin-top: 2px; padding-top: 11px; }
.tax-row.total .k { color: var(--ink); font-weight: 600; }
.tax-row.total .v { font-size: 16px; }
.cliff-banner { margin: 2px 16px 14px; padding: 11px 12px; border-radius: 12px; background: var(--warn-soft); border: 1px solid #F2D6A9; color: #7C3E00; font-size: 12.5px; line-height: 1.55; display: flex; gap: 8px; }
.cliff-banner .ico { flex: none; }
.cliff-banner b { font-weight: 700; }
.assumptions { padding: 0 16px 16px; }
.assump { font-size: 12px; color: var(--ink-3); line-height: 1.6; padding: 2px 0; }
.ask-card { background: linear-gradient(180deg, #FFFFFF, #FBFDFC); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.ask-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.ask-desc { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; margin-bottom: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--card); padding: 9px 13px; border-radius: 999px; font-size: 13px; color: var(--ink-2); transition: transform .1s; }
.chip:active { transform: scale(.96); }
.chip.primary { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 13px; font-size: 14px; outline: none; }
.inline-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.inline-form button { border: 0; background: var(--brand); color: #fff; border-radius: 12px; padding: 0 16px; font-size: 14px; font-weight: 600; }
.notice { border-radius: 12px; padding: 11px 13px; font-size: 12.5px; line-height: 1.6; }
.notice.warn { background: var(--warn-soft); color: #7C3E00; border: 1px solid #F2D6A9; }
.notice.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #F4C6C0; }
.notice.info { background: var(--brand-soft); color: #0B5D57; border: 1px solid #CBE9E3; }
.cliff-chart { margin: 4px 16px 14px; }
.cliff-chart svg { display: block; width: 100%; height: auto; }
.chart-caption { font-size: 11px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
details.policy-fold { border-top: 1px solid var(--line); }
details.policy-fold summary { list-style: none; cursor: pointer; padding: 11px 0; font-size: 12.5px; color: var(--brand); display: flex; justify-content: space-between; align-items: center; }
details.policy-fold summary::-webkit-details-marker { display: none; }
details.policy-fold summary::after { content: "▾"; font-size: 10px; opacity: .6; }
details.policy-fold[open] summary::after { content: "▴"; }
.source { padding: 10px 0 12px; border-top: 1px dashed var(--line); }
.source .src-name { font-size: 13px; font-weight: 600; line-height: 1.5; }
.source .src-meta { font-size: 11px; color: var(--ink-3); margin-top: 3px; line-height: 1.6; }
.source .src-quote { font-size: 11.5px; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-top: 7px; line-height: 1.65; border-left: 2px solid var(--brand); }
.sweep-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sweep-table th, .sweep-table td { padding: 7px 4px; text-align: right; border-top: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.sweep-table th { color: var(--ink-3); font-weight: 500; border-top: 0; }
.sweep-table td:first-child, .sweep-table th:first-child { text-align: left; }
.sweep-table tr.cliff td { background: #FFF7E8; }
.sweep-table td.cliff-mark { color: var(--warn); font-weight: 700; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; max-width: 640px; margin: 0 auto; padding: 10px 12px calc(10px + var(--safe-b)); background: linear-gradient(180deg, rgba(247,246,242,0) 0%, rgba(247,246,242,.94) 18%, var(--bg) 42%); }
.composer-inner { display: flex; gap: 8px; align-items: flex-end; }
.input-shell { flex: 1; display: flex; align-items: flex-end; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 7px 7px 7px 13px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 20px rgba(0,0,0,.05); transition: border-color .15s, box-shadow .15s; }
.input-shell:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12), 0 8px 20px rgba(0,0,0,.05); }
#input { flex: 1; border: 0; outline: none; resize: none; background: transparent; font-size: 15px; line-height: 1.45; padding: 4px 0; max-height: 120px; }
#input::placeholder { color: #A7AFAD; }
.mic-btn { border: 0; background: none; font-size: 17px; padding: 6px; border-radius: 10px; opacity: .8; }
.mic-btn.recording { background: var(--danger-soft); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.send-btn { flex: none; border: 0; background: var(--brand); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(15,118,110,.22); transition: transform .12s, opacity .15s; }
.send-btn:active { transform: scale(.97); }
.send-btn:disabled { opacity: .45; box-shadow: none; }
.examples { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding: 8px 2px 2px; scrollbar-width: none; }
.examples::-webkit-scrollbar { display: none; }
.examples-label { flex: none; font-size: 11px; color: var(--ink-3); }
.example-chip { flex: none; border: 1px solid var(--line); background: rgba(255,255,255,.7); border-radius: 999px; padding: 4px 10px; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.example-chip:active { background: var(--brand-soft); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 26; max-width: 640px; margin: 0 auto; display: flex; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tab { flex: 1; border: 0; background: none; padding: 8px 0 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink-3); font-size: 10.5px; }
.tab-icon { font-size: 17px; filter: grayscale(1) opacity(.55); transition: filter .15s; }
.tab.active { color: var(--brand); font-weight: 600; }
.tab.active .tab-icon { filter: none; }
#view-chat .stream { padding-bottom: calc(232px + var(--safe-b) + var(--tabbar-h)); }
.page-head { padding: 16px 16px 10px; }
.back-btn { border: 0; background: none; color: var(--brand); font-size: 13px; padding: 0 0 8px; }
.page-head h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.2px; }
.page-sub { margin: 0; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.library-list { padding: 0 14px 40px; display: flex; flex-direction: column; gap: 10px; }
.rule-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.rule-card.retired { opacity: .72; background: #FBF9F4; }
.rule-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rule-title { font-size: 14px; font-weight: 650; line-height: 1.45; }
.badge { flex: none; font-size: 10.5px; padding: 3px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: #EFEDE6; color: var(--ink-3); }
.rule-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.6; }
.rule-body { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.rule-body b { color: var(--ink); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(23,32,31,.28); z-index: 40; animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(360px, 88vw); background: var(--card); z-index: 41; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.18); animation: slidein .2s ease; }
@keyframes slidein { from { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field select { border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: var(--card); font-size: 13.5px; outline: none; }
.drawer-note { border-top: 1px solid var(--line); padding-top: 14px; }
.drawer-note p { margin: 0 0 10px; font-size: 12px; line-height: 1.7; color: var(--ink-3); }
.drawer-links { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.drawer-links a { font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: rgba(23,32,31,.92); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 12px; z-index: 60; max-width: 80%; text-align: center; animation: fadeup .18s; }
.welcome { padding: 4px 2px; }
.welcome-eyebrow { font-size: 11px; letter-spacing: .14em; color: var(--ink-3); }
.welcome-title { margin: 8px 0 6px; font-size: 23px; line-height: 1.35; letter-spacing: -.4px; }
.welcome-title em { font-style: normal; color: var(--brand); }
.welcome-sub { font-size: 13px; color: var(--ink-2); line-height: 1.75; margin: 0 0 16px; }
.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.welcome-cell { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 10px; }
.welcome-cell .k { font-size: 10.5px; color: var(--ink-3); margin-bottom: 4px; }
.welcome-cell .v { font-size: 13px; font-weight: 650; line-height: 1.4; }
.muted { color: var(--ink-3); }
@media (min-width: 700px) {
  .stream { padding: 20px 18px calc(230px + var(--safe-b)); }
  #view-chat .stream { padding-bottom: calc(240px + var(--safe-b)); }
}
.cliff-banner.info { background: var(--brand-soft); border-color: #CBE9E3; color: #0B5D57; }
.answer-line.verdict .txt .amt.big { display: inline; }

/* 关键修复：给 [hidden] 显式 display:none，避免被 .drawer{display:flex} 覆盖 */
[hidden] { display: none !important; }

/* 小屏（<=400px）压缩字号，避免三行结论换行过多 */
@media (max-width: 400px) {
  .welcome-title { font-size: 20px; }
  .answer-line .txt, .answer-line.verdict .txt { font-size: 14px; }
  .welcome-grid { grid-template-columns: 1fr 1fr; }
  .welcome-cell:last-child { display: none; }
}

/* 近期记录 */
.recent-card { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.recent-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px 6px; font-size: 11.5px; color: var(--ink-3); }
.recent-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; border: 0; background: transparent; padding: 10px 13px; border-top: 1px dashed var(--line); text-align: left; }
.recent-row:active { background: var(--brand-soft); }
.recent-main { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-side { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.recent-side b { display: block; font-size: 13px; color: var(--ink); }
.recent-side span { font-size: 10.5px; color: var(--ink-3); }
.field-hint { font-size: 11px; color: var(--ink-3); line-height: 1.5; }
.drawer-section { border-top: 1px solid var(--line); padding-top: 14px; }
.drawer-recent { margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.drawer-recent .recent-row { padding: 9px 11px; }

/* AI 兜底设置 */
#llmConfig input { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 12.5px; margin-top: 6px; outline: none; background: var(--card); }
#llmConfig input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.field-hint.ok { color: var(--ok); }
.field-hint.err { color: var(--danger); }
.llm-flag { display: inline-block; font-size: 10px; padding: 2px 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); margin-left: 4px; }
.notice.llm { background: #F1F0FF; color: #4C3FB5; border: 1px solid #DAD6FF; }

/* ---------- 年度汇总 ---------- */
.year-body { padding: 0 14px 60px; display: flex; flex-direction: column; gap: 12px; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .k { font-size: 11px; color: var(--ink-3); margin-bottom: 5px; }
.kpi .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.kpi .v.pay { color: var(--danger); }
.kpi .v.ok { color: var(--ok); }
.kpi .sub { font-size: 11px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
.year-chart { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px 6px; }
.year-chart svg { display: block; width: 100%; height: auto; }
.year-legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 6px 4px 2px; font-size: 11px; color: var(--ink-3); }
.year-legend span { display: inline-flex; align-items: center; gap: 4px; }
.year-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.year-table { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.year-table th, .year-table td { padding: 8px 6px; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px dashed var(--line); }
.year-table th { color: var(--ink-3); font-weight: 500; border-top: 0; background: #FBFCFB; }
.year-table td:first-child, .year-table th:first-child { text-align: left; }
.year-table tr.over td { background: #FFF7E8; }
.year-table tr.over td:first-child::after { content: " ⚠️"; }
.year-table tr.total td { border-top: 1.5px solid var(--ink); font-weight: 700; background: #FBFDFC; }
.year-empty { background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 22px 16px; text-align: center; }
.year-empty p { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; margin: 0 0 12px; }
.year-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.year-note { font-size: 11px; color: var(--ink-3); line-height: 1.7; padding: 2px 4px; }
