/* 小管家 V1.0 — 设计令牌取自 dataviz 参考调色板（浅色模式） */
:root {
  color-scheme: light;
  --page: #f9f9f7;            /* 页面底 */
  --surface: #fcfcfb;         /* 卡片/图表面 */
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --baseline: #c3c2b7;
  --accent: #2a78d6;          /* series-1 蓝，贯穿图表与主操作 */
  --accent-deep: #1c5cab;     /* 同色高亮步（周末列） */
  --accent-track: #cde2fb;    /* meter 未填充轨道（同 ramp 浅步） */
  --danger: #d03b3b;          /* 状态-危险 / 支出文字 */
  --income: #006300;          /* 收入文字（success text） */
  --warning: #fab219;         /* 状态-警告（预算 80%+） */
  --wash: rgba(11, 11, 11, 0.05);
  --ring: rgba(11, 11, 11, 0.10);
  --radius: 14px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button[disabled] { opacity: .35; cursor: not-allowed; }
input, select { font: inherit; color: var(--ink); }
h2, h3 { font-weight: 600; }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
.view { padding: 0 14px calc(var(--tabbar-h) + 84px); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  padding: 12px 2px 10px;
  background: linear-gradient(var(--page) 82%, rgba(249, 249, 247, 0));
}
.topbar-title { flex: 1; text-align: center; font-size: 17px; }
.topbar-title.plain { padding-left: 64px; } /* 无切换按钮时保持标题居左视觉平衡 */
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; color: var(--ink-2);
}
.icon-btn:active { background: var(--wash); }
.filter-btn {
  position: relative; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--surface);
  font-size: 13px; color: var(--ink-2);
}
.filter-btn.active { color: var(--accent); border-color: var(--accent); }

.dot {
  position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}
.tab .dot { top: 6px; right: 14%; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h3 { font-size: 15px; }
.card-sub { font-size: 12px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 44px 0; }
.list-more { text-align: center; padding: 10px 0 0; }
.btn.ghost {
  padding: 8px 22px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--ink-2); background: var(--surface); font-size: 13px;
}

/* ---------- 明细：汇总卡 ---------- */
.summary-card {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px;
  background: linear-gradient(135deg, #256abf, #1c5cab);
  color: #fff; border-radius: var(--radius);
  padding: 16px 14px; margin-top: 4px;
}
.summary-card .lbl { font-size: 12px; opacity: .8; }
.summary-card .val { font-size: 19px; font-weight: 600; margin-top: 2px; }
.summary-card .val.small { font-size: 16px; }
.summary-card .val .sign { font-weight: 400; opacity: .75; font-size: 13px; margin-right: 2px; }

/* ---------- 明细：账单列表 ---------- */
.bill-list { margin-top: 6px; }
.day-group { margin-bottom: 16px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 4px 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 4px;
}
.day-head span { font-size: 13px; color: var(--ink-2); }
.day-head .sub { font-size: 12px; color: var(--muted); }
.day-head .sub .out { color: var(--danger); }
.day-head .sub .in { color: var(--income); }
.bill-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 10px; border-radius: 8px; background: var(--surface); margin-top: 6px;
  text-align: left; border: 1px solid transparent;
}
.bill-item:active { background: var(--wash); }
.bill-item .ico { font-size: 20px; margin-right: 10px; }
.bill-item .mid { flex: 1; }
.bill-item .mid .cat { font-size: 15px; font-weight: 600; }
.bill-item .mid .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bill-item .photo-flag {
  font-size: 16px; margin-left: 8px; color: var(--muted); cursor: pointer;
}
.bill-item .amt { font-size: 16px; font-weight: 600; }
.bill-item .amt.out { color: var(--danger); }
.bill-item .amt.in { color: var(--income); }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(11, 11, 11, 0.4); z-index: 100;
  animation: fadeIn 0.2s;
}
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 0 14px 80px; z-index: 101;
  animation: slideUp 0.3s;
  transform: translateY(100%);
  transition: transform 0.3s;
}
.sheet.open { transform: translateY(0); }
.sheet.grab {
  position: absolute; top: 0; left: 0; right: 0; height: 30px;
  display: flex; justify-content: center; align-items: center;
}
.sheet.grab::after {
  content: ''; width: 40px; height: 4px; background: var(--ink-2);
  border-radius: 2px; opacity: 0.3;
}
.sheet-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; text-align: center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--ink-2); }
.sheet-actions {
  display: flex; gap: 8px; margin-top: 20px; padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.btn {
  flex: 1; padding: 12px; border-radius: 999px;
  font-size: 15px; font-weight: 600; border: 0;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--wash); color: var(--ink-2); }
.btn.ghost.plain { flex: 0; padding: 8px 16px; }
.btn.danger-btn { background: var(--danger); color: #fff; }
.btn.wide { flex: 1; }

/* ---------- 锁屏 ---------- */
.lock {
  position: fixed; inset: 0; background: var(--page); z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px;
}
.lock h2 { font-size: 24px; margin-bottom: 32px; }
.lock .lock-form { width: 100%; max-width: 300px; }
.lock-form .field { margin-bottom: 16px; }
.lock-form .field input {
  width: 100%; padding: 14px; border: 1px solid var(--hairline);
  border-radius: 999px; font-size: 15px;
}
.lock-form .field input:focus {
  outline: none; border-color: var(--accent);
}
.lock-form button.btn {
  width: 100%; padding: 14px; font-size: 16px;
}

/* ---------- 统计 ---------- */
.kpi-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px;
}
.kpi-row > div {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); padding: 12px 10px;
}
.kpi-row .lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.kpi-row .val { font-size: 18px; font-weight: 600; }
.kpi-row .val.out { color: var(--danger); }
.kpi-row .val.in { color: var(--income); }
.cat-bars { margin-top: 12px; }
.cat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--hairline);
}
.cat-row:last-child { border-bottom: none; }
.cat-name { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.track { flex: 1; max-width: 160px; height: 14px; background: var(--accent-track); border-radius: 7px; overflow: hidden; position: relative; }
.rail { width: 100%; height: 100%; border-radius: 7px; }
.fill { height: 100%; border-radius: 7px; background: var(--accent); transition: width 0.3s; }
.v { display: flex; gap: 6px; font-size: 13px; }
.v .pct { color: var(--muted); }

/* ---------- 图表 ---------- */
.chart-host { min-height: 200px; position: relative; }
.chart-note { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }
.chart-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.chart-table th, .chart-table td {
  padding: 8px; text-align: left; border-bottom: 1px solid var(--hairline);
}
.chart-table th { font-weight: 600; color: var(--ink-2); }
.chart-table tr:last-child td { border-bottom: none; }

/* ---------- 预算 ---------- */
.alert-banner {
  background: linear-gradient(135deg, #fab219, #e8a506);
  color: #fff; padding: 12px 14px; border-radius: var(--radius);
  margin-bottom: 12px; font-size: 14px;
}
.budget-item {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px;
}
.budget-item-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.budget-item-header .month { font-size: 15px; font-weight: 600; }
.budget-item-header .actions { font-size: 12px; color: var(--muted); }
.budget-meter { height: 12px; background: var(--accent-track); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.budget-meter-fill {
  height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.3s;
}
.budget-meter-fill.warning { background: var(--warning); }
.budget-meter-fill.danger { background: var(--danger); }
.budget-item-footer {
  display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2);
}
.budget-btn {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--surface);
}

/* ---------- 我的 ---------- */
.mine-section {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
}
.mine-header {
  padding: 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--hairline);
}
.mine-header .avatar {
  width: 48px; height: 48px; background: var(--accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff;
}
.mine-header .info { flex: 1; }
.mine-header .info .name { font-size: 16px; font-weight: 600; }
.mine-header .info .detail { font-size: 13px; color: var(--muted); }
.mine-menu-item {
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: background 0.2s;
}
.mine-menu-item:active { background: var(--wash); }
.mine-menu-item .label { font-size: 15px; }
.mine-menu-item .icon { font-size: 20px; color: var(--muted); }
.mine-menu-item .arrow { font-size: 16px; color: var(--muted); }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar-h);
  background: var(--surface); border-top: 1px solid var(--hairline);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 50;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; font-size: 11px; color: var(--muted);
}
.tab[aria-selected="true"] { color: var(--accent); }
.t-ico { font-size: 22px; }

/* ---------- Fab ---------- */
.fab {
  position: fixed; bottom: calc(var(--tabbar-h) + 14px); right: 14px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 28px;
  box-shadow: 0 4px 12px rgba(42, 120, 214, 0.4);
  z-index: 90;
}

/* ---------- Tooltip ---------- */
.chart-tip {
  position: fixed; z-index: 200; pointer-events: none;
  background: rgba(11, 11, 11, 0.95); color: #fff;
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 80px; text-align: center;
}
.chart-tip .t-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.chart-tip .t-val { font-weight: 600; font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 400px) {
  .app { max-width: 100%; }
  .summary-card { grid-template-columns: 1fr; gap: 8px; }
  .summary-card .val { font-size: 16px; }
}
