:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #1f2a28;
  --ink-soft: #5c6b67;
  --line: #e3e8e6;
  --brand: #2f6f5e;
  --brand-soft: #e7f1ed;
  --income: #1f9d6b;
  --expense: #d8643c;
  --warn: #c8932a;
  --danger: #c0392b;
  --shadow: 0 2px 10px rgba(31,42,40,.06);
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 64px;
}
#app { max-width: 860px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

.app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--brand); color: #fff;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; }
.brand-text small { font-size: 11px; opacity: .85; }
.sync-state {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
}
.sync-state.ok { background: rgba(255,255,255,.28); }
.sync-state.err { background: var(--danger); }

.view { padding: 14px 14px 24px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 14px; border: 1px solid var(--line);
}
.card h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card .hint { color: var(--ink-soft); font-size: 12px; }
.card .sub { color: var(--ink-soft); font-size: 12px; margin-top: 4px; }

/* 概览数字 */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.stat .label { font-size: 12px; color: var(--ink-soft); }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .value.income { color: var(--income); }
.stat .value.expense { color: var(--expense); }
.stat .delta { font-size: 11px; margin-top: 2px; color: var(--ink-soft); }

/* 提醒横幅 */
.alert-banner {
  background: #fff6e6; border: 1px solid #f0d9a8; color: #8a5a00;
  border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
  display: flex; gap: 8px; align-items: flex-start;
}
.alert-banner .dot { color: var(--warn); }

/* 录入区 */
.enter-box { position: relative; }
.enter-box textarea {
  width: 100%; min-height: 96px; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 15px; resize: vertical; font-family: inherit; color: var(--ink);
}
.enter-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  border: none; border-radius: 10px; padding: 10px 14px; font-size: 14px; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 600;
}
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.line { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warn); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.mic-btn {
  width: 46px; height: 46px; border-radius: 50%; background: var(--brand);
  color: #fff; border: none; font-size: 20px; cursor: pointer; flex: 0 0 auto;
}
.mic-btn.recording { background: var(--danger); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(192,57,43,.5);} 70%{box-shadow:0 0 0 12px rgba(192,57,43,0);} 100%{box-shadow:0 0 0 0 rgba(192,57,43,0);} }

/* 解析预览 */
.preview-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px;
  background: #fbfdfc;
}
.preview-item .row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.tag.in { background: #e3f6ee; color: var(--income); }
.tag.out { background: #fbe9e1; color: var(--expense); }
.preview-item input, .preview-item select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 14px; font-family: inherit;
}
.preview-item input.amt { width: 110px; }
.preview-item input.note { flex: 1; min-width: 120px; }
.preview-item select { min-width: 120px; }

/* 列表 */
.list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: none; }
.row-item .main { flex: 1; min-width: 0; }
.row-item .cat { font-size: 14px; }
.row-item .meta { font-size: 12px; color: var(--ink-soft); }
.row-item .amt { font-weight: 700; }
.row-item .amt.in { color: var(--income); }
.row-item .amt.out { color: var(--expense); }
.row-item .del { color: var(--danger); background: none; border: none; font-size: 16px; cursor: pointer; padding: 4px; }

/* 表单控件 */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 5px; }
input.text, select.text, textarea.text {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 14px; font-family: inherit;
}
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 14px; cursor: pointer;
}
.seg button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl th { color: var(--ink-soft); font-weight: 600; }
table.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

/* 税务/分析块 */
.block { border-left: 3px solid var(--brand); padding: 6px 12px; margin: 10px 0; background: #fbfdfc; border-radius: 0 10px 10px 0; }
.block.warn { border-left-color: var(--warn); }
.block.bad { border-left-color: var(--danger); }
.block h4 { margin: 0 0 4px; font-size: 14px; }
.block p { margin: 2px 0; font-size: 13px; color: var(--ink-soft); }

/* 日历 */
.cal-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.cal-item .name { font-size: 14px; }
.cal-item .when { font-size: 12px; color: var(--ink-soft); text-align: right; }
.cal-item .when b { color: var(--brand); }
.cal-item.urgent .when b { color: var(--danger); }

/* 底部 tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  max-width: 860px; margin: 0 auto; box-shadow: 0 -2px 10px rgba(0,0,0,.04);
}
.tab {
  flex: 1; border: none; background: none; padding: 8px 0 10px; cursor: pointer;
  color: var(--ink-soft); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab .ic { font-size: 18px; line-height: 1; }
.tab.active { color: var(--brand); font-weight: 700; }

/* toast */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(31,42,40,.92); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 通用 */
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.spacer { height: 10px; }
.flex { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.disclaimer { font-size: 11px; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink-soft); }
.goal-track { height: 12px; overflow: hidden; border-radius: 999px; background: #e3ebe7; margin: 14px 0 8px; }
.goal-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #56a88e); transition: width .25s ease; }
.section-title { font-size: 13px; color: var(--ink-soft); margin: 4px 2px 8px; }

@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 图表图例 */
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 8px; }
.legend .lg { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-soft); }
.legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 模态框 */
.modal-ov {
  position: fixed; inset: 0; z-index: 60; background: rgba(20,28,26,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) { .modal-ov { align-items: center; } }
.modal {
  background: #fff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 18px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15); max-height: 86vh; overflow: auto;
}
@media (min-width: 600px) { .modal { border-radius: 16px; } }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal .modal-actions .btn { flex: 1; }

/* 切换行 */
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }

/* 空态 */
.empty { text-align: center; color: var(--ink-soft); padding: 30px 10px; font-size: 14px; }

/* 报表切换 tab */
.subtabs { display: flex; gap: 6px; margin-bottom: 12px; }
.subtabs button { flex: 1; padding: 9px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 13px; cursor: pointer; }
.subtabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
