/* book 记账系统 — 手机端样式 */
:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --danger: #dc2626;
  --income: #16a34a;
  --expense: #dc2626;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* 居中容器，手机宽度 */
.wrap { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* 顶部栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  font-size: 16px; font-weight: 600;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .spacer { flex: 1; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* 结余大字 */
.balance-hero {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff; text-align: center; padding: 24px 16px;
}
.balance-hero .label { font-size: 13px; opacity: 0.9; }
.balance-hero .amount { font-size: 34px; font-weight: 700; margin: 4px 0; }

/* 账户/分类条目 */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .icon { font-size: 24px; width: 36px; text-align: center; }
.row .main { flex: 1; }
.row .main .name { font-size: 15px; font-weight: 600; }
.row .main .sub { font-size: 12px; color: var(--muted); }
.row .value { font-size: 15px; font-weight: 600; }

/* 收支配色 */
.income { color: var(--income); }
.expense { color: var(--expense); }

/* 按钮 */
.btn {
  display: inline-block; width: 100%;
  background: var(--primary); color: #fff;
  border: none; border-radius: 10px;
  padding: 14px; font-size: 16px; font-weight: 600;
  text-align: center; cursor: pointer; text-decoration: none;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn.sm { width: auto; padding: 6px 14px; font-size: 13px; display: inline-block; }

/* 底部固定操作条 */
.fabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  gap: 12px;
}
.fabbar .btn { flex: 1; }
body.has-fab { padding-bottom: 80px; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }

/* 分段切换（收入/支出） */
.seg { display: flex; background: #eef2ef; border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.seg button {
  flex: 1; padding: 10px; border: none; border-radius: 8px;
  font-size: 16px; font-weight: 600; background: transparent; color: var(--muted); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.seg button.on.income-on { color: var(--income); }
.seg button.on.expense-on { color: var(--expense); }

/* 金额输入 */
.amount-input { font-size: 30px; font-weight: 700; text-align: center; padding: 16px; }

/* 分类网格 */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; background: #f9fafb;
}
.cat-item .icon { font-size: 26px; }
.cat-item .name { font-size: 12px; color: var(--text); }
.cat-item.on { border-color: var(--primary); background: #f0fdf4; }

/* 错误提示 */
.error { background: #fef2f2; color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }

/* 登录/注册 */
.auth-box { padding-top: 40px; }
.auth-box .logo { text-align: center; font-size: 40px; margin-bottom: 8px; }
.auth-box h1 { text-align: center; font-size: 22px; margin-bottom: 24px; }
.auth-box .link { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.auth-box .link a { color: var(--primary); text-decoration: none; }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; }

/* 月份切换 */
.month-nav { display: flex; align-items: center; gap: 8px; justify-content: center; margin-bottom: 8px; }
.month-nav input { width: 130px; text-align: center; }
