:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #74787e;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --border: #e3e5e8;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.container { max-width: 720px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1080px; }

/* 图表网格：手机单列，≥720px 两列，wide 卡片通栏 */
.charts { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 60px; }
@media (min-width: 720px) {
  .charts { grid-template-columns: 1fr 1fr; }
  .chart-card.wide { grid-column: span 2; }
}
.chart-card h2 { font-size: 15px; margin: 2px 4px 10px; font-weight: 600; }
.chart-card .chart-box { position: relative; height: 200px; }
.chart-card.wide .chart-box { height: 280px; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 14px; align-items: center; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--primary); }

/* 卡片与指标 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
@media (min-width: 560px) { .metrics { grid-template-columns: repeat(4, 1fr); } }
.metric { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.metric .value { font-size: 22px; font-weight: 700; line-height: 1.3; }
.metric .value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.metric .label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.metric.hero { grid-column: span 2; background: var(--primary); border-color: var(--primary); color: #fff; }
.metric.hero .value { font-size: 32px; }
.metric.hero .label { color: rgba(255,255,255,.85); }

/* 表单 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select {
  width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #cbd1d8; border-radius: 30px; cursor: pointer; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* 按钮 */
.btn {
  display: inline-block; padding: 12px 18px; border: 0; border-radius: 8px; font-size: 16px;
  background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; }

/* 悬浮记一笔 */
.fab {
  position: fixed; right: 20px; bottom: 24px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 30px; line-height: 56px; text-align: center;
  text-decoration: none; box-shadow: 0 4px 14px rgba(37,99,235,.4); z-index: 20;
}

/* 记录列表 */
.record-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.record-item .line1 { display: flex; justify-content: space-between; align-items: baseline; }
.record-item .date { font-weight: 600; }
.record-item .amount { font-weight: 700; font-size: 18px; }
.record-item .line2 { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.record-item .line3 { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; }
.badge.full { background: #dcfce7; color: #15803d; }
.badge.partial { background: #fef3c7; color: #b45309; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 16px 0 60px; }

/* 杂项 */
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0; }
.hint { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
h2.section { font-size: 16px; margin: 22px 0 10px; }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.login-wrap { max-width: 380px; margin: 12vh auto 0; padding: 16px; }
.login-wrap h1 { text-align: center; }
