:root {
  --primary: #10B981;
  --primary-dark: #059669;
  --primary-light: #34D399;
  --primary-container: #D1FAE5;
  --on-primary-container: #052E21;
  --bg: #F5F7F9;
  --surface: #FFFFFF;
  --text: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --danger: #EF4444;
  --green: #16A34A;
  --blue: #2563EB;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 76px; /* bottom nav 高度 */
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 12px 16px 8px;
}
.topbar-title {
  font-size: 22px;
  font-weight: 700;
}

.content { padding: 4px 16px 24px; }

/* ---- 汇总卡 ---- */
.summary-card {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.summary-row { display: flex; gap: 12px; }
.summary-col { flex: 1; }
.summary-label { font-size: 12px; opacity: .8; }
.summary-value { font-size: 22px; font-weight: 700; }
.summary-counts { display: flex; gap: 8px; margin-top: 12px; font-size: 12px; }

/* ---- 筛选 chips ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---- 物品卡片 ---- */
.item-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.thumb {
  width: 52px; height: 52px;
  border-radius: 12px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  color: #fff;
}
.item-main { flex: 1; min-width: 0; }
.item-title-row { display: flex; align-items: center; gap: 8px; }
.item-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; border-radius: 6px; padding: 2px 6px; flex: none; }
.item-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.item-bottom { display: flex; align-items: baseline; margin-top: 6px; }
.item-price { font-size: 13px; color: var(--text-muted); }
.item-right { text-align: right; font-weight: 700; }
.item-daily { color: var(--primary-dark); font-size: 16px; }
.item-daily small { font-size: 11px; font-weight: 400; }
.profit-plus { color: var(--green); }
.profit-minus { color: var(--danger); }

/* ---- 空状态 ---- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty .emoji { font-size: 48px; }
.empty .t { font-size: 16px; font-weight: 600; color: var(--text); margin-top: 8px; }
.empty .s { font-size: 13px; margin-top: 4px; }

/* ---- FAB ---- */
.fab {
  position: fixed;
  right: max(20px, calc(50% - 260px + 20px));
  bottom: 92px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(16,185,129,.4);
  cursor: pointer;
  z-index: 20;
}
.fab.hidden { display: none; }

/* ---- 底部导航 ---- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 520px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}
.nav-item.active { color: var(--primary); }
.nav-emoji { font-size: 20px; }

/* ---- 表单 ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); }

/* 表单里的 chips */
.field .chips { flex-wrap: wrap; }

/* emoji 选择器 */
.emoji-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.emoji-btn.active { background: var(--primary-container); border-color: var(--primary); }
.color-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.color-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-btn.active { border-color: var(--text); }

/* 状态选择 */
.status-chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  cursor: pointer;
}
.status-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 按钮 */
.btn {
  display: block; width: 100%;
  padding: 13px;
  border: none; border-radius: 12px;
  background: var(--primary); color: #fff;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger { background: var(--danger); }

/* ---- 弹窗 ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) { .modal-backdrop { align-items: center; } }
.modal-sheet {
  background: var(--bg);
  width: 100%; max-width: 520px;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  animation: slideUp .22s ease;
}
@media (min-width: 600px) { .modal-sheet { border-radius: 20px; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
}
.modal-header .title { font-size: 17px; font-weight: 600; }
.modal-header .close { border: none; background: transparent; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 16px; }

.hidden { display: none !important; }

/* ---- 详情 ---- */
.detail-hero {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 14px;
}
.detail-hero .big { font-size: 34px; font-weight: 800; }
.detail-hero .sub { font-size: 13px; opacity: .85; margin-top: 4px; }
.info-row { display: flex; padding: 7px 0; font-size: 14px; }
.info-row .k { width: 88px; color: var(--text-muted); flex: none; }
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h4 { margin: 0 0 8px; font-size: 15px; }
.action-row { display: flex; gap: 10px; margin-top: 16px; }
.action-row .btn { flex: 1; padding: 12px; font-size: 15px; }

/* ---- 趋势 ---- */
.stat-row { display: flex; gap: 12px; margin-bottom: 12px; }
.stat-block { flex: 1; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat-block .l { font-size: 12px; color: var(--text-muted); }
.stat-block .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.chart { width: 100%; height: auto; display: block; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut {
  width: 140px; height: 140px; border-radius: 50%; flex: none;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.donut::after {
  content: ""; position: absolute; inset: 26px;
  background: var(--surface); border-radius: 50%;
}
.donut .center { position: relative; z-index: 1; font-weight: 700; }
.legend { font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.legend .li { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---- 设置 ---- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .l { font-size: 15px; }
.setting-row .s { font-size: 12px; color: var(--text-muted); }
.setting-row.danger .l { color: var(--danger); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 110px;
  transform: translateX(-50%);
  background: rgba(17,24,39,.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  max-width: 85%;
  text-align: center;
}
