:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --border: #e6e3dc;
  --border-strong: #d6d2c8;
  --text: #23211d;
  --text-2: #6b665c;
  --text-3: #9a9488;
  --accent: #2f6b4f;
  --accent-soft: #e8f2ec;
  --expense: #c0392b;
  --expense-soft: #fdeeec;
  --income: #2f6b4f;
  --income-soft: #e8f2ec;
  --warn: #b7791f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(35, 33, 29, 0.04), 0 8px 24px rgba(35, 33, 29, 0.05);
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ------------------------------- 布局骨架 ------------------------------- */

.shell { max-width: 1080px; margin: 0 auto; padding: 28px 22px 80px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, #2f6b4f, #458a68);
  color: #fff;
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(47, 107, 79, 0.22);
}

.brand-text h1 { font-size: 16px; }
.brand-text span { font-size: 12px; color: var(--text-3); }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: 0;
  background: transparent;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  transition: all .16s ease;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--accent); color: #fff; }

.panel { display: none; }
.panel.active { display: block; animation: fade .22s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------- 卡片 --------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-head h3 { font-size: 14px; }
.card-head p { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 760px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .shell { padding: 20px 14px 60px; }
}

/* --------------------------------- 指标 --------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.money-expense { color: var(--expense); }
.money-income { color: var(--income); }

/* --------------------------------- 列表 --------------------------------- */

.row-list { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px dashed var(--border);
}
.row:last-child { border-bottom: 0; }

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.row-note {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.chip.team { background: #f0f0fb; border-color: #ddddf3; color: #4b4b8f; }
.chip.accent { background: var(--accent-soft); border-color: #cfe4d8; color: var(--accent); }

/* -------------------------------- 分类条 -------------------------------- */

.bar-item { margin-bottom: 11px; }
.bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 5px;
}
.bar-head b { font-weight: 500; color: var(--text-2); }
.bar-head span { font-variant-numeric: tabular-nums; color: var(--text-3); }
.bar-track {
  height: 7px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3f7d5e, #6aa98a);
  border-radius: 999px;
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}

/* -------------------------------- 趋势图 -------------------------------- */

.trend {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 132px;
  padding-top: 8px;
}
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.trend-bars { display: flex; gap: 3px; align-items: flex-end; width: 100%; justify-content: center; height: 100%; }
.trend-bar { width: 11px; border-radius: 3px 3px 0 0; min-height: 3px; transition: height .4s ease; }
.trend-bar.exp { background: #e0a49c; }
.trend-bar.inc { background: #87b8a0; }
.trend-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }

/* --------------------------------- 表单 --------------------------------- */

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }

input[type="text"], input[type="password"], input[type="time"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.1);
}
input[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea { resize: vertical; min-height: 78px; }

.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline > * { flex: 0 0 auto; }

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #285b43; border-color: #285b43; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); padding: 6px 10px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--expense); border-color: #eccdc7; }
.btn.danger:hover { background: var(--expense-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 22px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background .18s;
  flex: 0 0 auto;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch span { font-size: 13px; }

/* ------------------------------- 聊天预览 ------------------------------- */

.chat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
}

.bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.62;
}
.bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(35,33,29,.03);
  font-variant-numeric: tabular-nums;
}

.quick-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.quick-chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-2);
}
.quick-chip:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }

/* -------------------------------- 步骤说明 ------------------------------ */

.steps { counter-reset: step; padding: 0; margin: 0; list-style: none; }
.steps li {
  position: relative;
  padding-left: 34px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  display: grid; place-items: center;
}
.steps li b { color: var(--text); font-weight: 600; }
.steps code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--accent);
}

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 11px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: #2c5341;
  margin: 14px 0;
}
.callout.warn { border-color: var(--warn); background: #fdf6e7; color: #7a5410; }

.copy-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.copy-box input { font-family: var(--mono); font-size: 12px; }

/* -------------------------------- 空状态 -------------------------------- */

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 30px; margin-bottom: 10px; opacity: .55; }

/* --------------------------------- Toast -------------------------------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #23211d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s ease;
  z-index: 99;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #a83a2c; }

/* ------------------------------- 独立页面 ------------------------------- */

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.center-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.center-card h2 { font-size: 18px; margin-bottom: 6px; }
.center-card .sub { font-size: 13px; color: var(--text-3); margin-bottom: 22px; }
.center-card .btn { width: 100%; }

.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mt-16 { margin-top: 16px; }
.mt-12 { margin-top: 12px; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
