/* 口袋记账 · 样式（深色主题，移动优先） */
:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card2: #263449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #4ade80;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.ok { color: var(--ok); }
.bad { color: var(--danger); }
.muted { color: var(--muted); }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, #0f172a 0%, rgba(15,23,42,.95) 70%, rgba(15,23,42,0));
}
.topbar h1 { font-size: 17px; letter-spacing: .5px; }
.period-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 560px; margin: 0 auto; padding: 4px 12px 90px; }
.page { display: none; }
.page.active { display: block; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.overview-row, .mini-row { display: flex; gap: 8px; }
.ov-cell, .mini { flex: 1; background: var(--card2); border-radius: 10px; padding: 10px 8px; text-align: center; }
.ov-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.ov-value { font-size: 15px; font-weight: 700; word-break: break-all; }
.ov-value.warn { color: var(--warn); }
.ov-value.accent { color: var(--accent); }
.ov-value.neg { color: var(--danger); }

.progress { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress.small { height: 6px; margin-top: 8px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.progress-bar.high { background: var(--warn); }
.progress-bar.over { background: var(--danger); }

.allowance-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.allowance-row label { font-size: 12px; color: var(--muted); white-space: nowrap; }

.range-label { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.period-meta { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* 吃饭每日卡片 */
.daily-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.daily-line b { color: var(--text); }
.daily-status { margin-top: 10px; font-size: 19px; font-weight: 700; line-height: 1.4; }
.daily-status.ok { color: var(--ok); }
.daily-status.bad { color: var(--danger); }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%;
  background: var(--card2);
  border: 1px solid #334155;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="color"] { padding: 4px; height: 42px; width: 48px; cursor: pointer; }
input[type="date"], input[type="month"] { color-scheme: dark; }

.btn-row { display: flex; gap: 8px; }
.btn-row.wrap { flex-wrap: wrap; }
.btn {
  flex: 1;
  border: none; border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  color: #0b1220;
  background: var(--accent);
}
.btn.primary { background: var(--accent); color: #0b1220; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid #334155; }
.btn.danger { background: rgba(248,113,113,.15); color: var(--danger); border: 1px solid rgba(248,113,113,.35); }
.btn.small { flex: 0 0 auto; padding: 8px 14px; font-size: 13px; }
.btn:active { transform: scale(.97); }

.entry-hint { font-size: 13px; min-height: 18px; margin: 2px 0 10px; }
.entry-hint.ok { color: var(--ok); }
.entry-hint.bad { color: var(--danger); }

/* 流水列表 */
.record-list { list-style: none; }
.record-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #263449; }
.record-list li:last-child { border-bottom: none; }
.record-list li.empty { justify-content: center; color: var(--muted); font-size: 13px; padding: 18px 0; border: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.rec-main { flex: 1; min-width: 0; }
.rec-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.rec-amount { font-size: 14px; font-weight: 700; color: var(--warn); white-space: nowrap; }
.rec-del {
  flex: 0 0 auto;
  background: none; border: none;
  color: var(--muted); font-size: 14px;
  padding: 6px 4px; cursor: pointer;
}
.rec-del:hover { color: var(--danger); }

.filter-row { display: flex; gap: 8px; margin-bottom: 4px; }
.filter-row select { flex: 1; }
.filter-row input { flex: 1; }

/* 分模块预算（首页） */
.budget-list { list-style: none; }
.budget-list li.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 14px 0; }
.budget-row { padding: 10px 0; border-bottom: 1px solid #263449; }
.budget-row:last-child { border-bottom: none; }
.budget-head { display: flex; align-items: center; gap: 8px; }
.budget-head .b-name { flex: 1; font-size: 14px; }
.b-remain { font-size: 15px; font-weight: 700; }
.b-remain.ok { color: var(--ok); }
.b-remain.bad { color: var(--danger); }
.b-remain.muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.budget-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 6px; }

/* 省钱 */
.saving-list { list-style: none; }
.saving-list li.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 14px 0; }
.saving-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #263449; }
.saving-row:last-child { border-bottom: none; }
.saving-main { flex: 1; min-width: 0; }
.saving-title { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.saving-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.saving-amount { font-size: 15px; font-weight: 700; white-space: nowrap; }
.saving-amount.ok { color: var(--ok); }
.saving-amount.bad { color: var(--danger); }
.badge-current, .badge-ended { font-size: 10px; padding: 2px 7px; border-radius: 99px; font-weight: 400; }
.badge-current { background: rgba(56,189,248,.16); color: var(--accent); }
.badge-ended { background: #263449; color: var(--muted); }

/* 模块管理 & 预算编辑 */
.module-list, .budget-edit-list { list-style: none; margin-bottom: 12px; }
.module-row, .budget-edit-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #263449; }
.budget-edit-row { flex-wrap: wrap; }
.module-row:last-child, .budget-edit-row:last-child { border-bottom: none; }
.module-row .mod-name { flex: 1; padding: 7px 10px; font-size: 14px; }
.budget-edit-row .b-name { flex: 1; font-size: 14px; min-width: 56px; }
.budget-edit-row .b-field { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.budget-edit-row .b-field input { width: 72px; padding: 6px 8px; font-size: 13px; }
.add-module-row { display: flex; gap: 8px; }
.add-module-row input[type="text"] { flex: 1; }

/* 页签 */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  background: var(--card);
  color: var(--muted);
  border: none; border-radius: 10px;
  padding: 9px 0;
  font-size: 14px;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: #0b1220; font-weight: 600; }

/* 图表 */
.chart-box { min-height: 120px; }
.chart-box .empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 170px; height: 170px; flex: 0 0 auto; }
.donut-total { fill: var(--text); font-size: 15px; font-weight: 700; }
.legend { list-style: none; flex: 1; min-width: 140px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.legend b { margin-left: auto; font-weight: 600; }
.trend { width: 100%; height: auto; }
.trend rect { fill: var(--accent); }
.trend .axis { fill: var(--muted); font-size: 11px; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  background: rgba(15,23,42,.97);
  border-top: 1px solid #1e293b;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab-btn {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0;
  cursor: pointer;
}
.tab-btn .tb-icon { font-size: 19px; line-height: 1; }
.tab-btn.active { color: var(--accent); }

/* 进账双输入 */
.income-edit { display: flex; gap: 10px; flex-wrap: wrap; }
.income-field { flex: 1; min-width: 130px; }
.income-field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.income-total { margin-top: 12px; font-size: 13px; color: var(--muted); }
.income-total b { font-size: 18px; color: var(--accent); margin-left: 6px; }

/* 吃饭每日结转 */
.daily-sub { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.daily-sub.ok { color: var(--ok); }
.daily-sub.bad { color: var(--danger); }
.daily-history-title { margin-top: 14px; font-size: 12px; color: var(--muted); }
.daily-history { list-style: none; margin-top: 6px; }
.daily-history-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 5px 0; border-bottom: 1px solid #263449; }
.daily-history-row:last-child { border-bottom: none; }
.daily-history-row .dh-date { width: 42px; color: var(--muted); }
.daily-history-row .dh-budget { flex: 1; }
.daily-history-row .dh-spent { flex: 1; }
.daily-history-row .dh-diff { font-weight: 600; }
.daily-history-row .dh-diff.ok { color: var(--ok); }
.daily-history-row .dh-diff.bad { color: var(--danger); }

/* 左右滑动的「每日可花」卡片 */
.daily-card { padding: 14px 14px 10px; overflow: hidden; }
.daily-slider { overflow: hidden; }
.daily-track { display: flex; transition: transform .28s ease; will-change: transform; }
.daily-slide { min-width: 100%; box-sizing: border-box; }
.daily-slide h2 { font-size: 15px; margin-bottom: 10px; }
.daily-nav-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }
.daily-nav {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%; border: 1px solid #334155;
  background: var(--card2); color: var(--text);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.daily-nav:active { transform: scale(.94); }
.daily-dots { display: flex; align-items: center; gap: 6px; }
.daily-dot {
  width: 7px; height: 7px; padding: 0; border: none; cursor: pointer;
  border-radius: 99px; background: #3b4a61;
  transition: width .2s ease, background .2s ease;
}
.daily-dot.active { width: 18px; background: var(--accent); }
.daily-hint { margin-top: 8px; text-align: center; font-size: 11px; color: var(--muted); }

/* 每日可花说明 */
.daily-note { margin-top: 8px; font-size: 12px; color: var(--accent); line-height: 1.5; }
.auto-hint { margin-left: 6px; font-size: 11px; color: var(--accent); }

/* 存钱罐 */
.jar-line { margin-top: 10px; font-size: 13px; color: var(--muted); }
.jar-line b { font-size: 16px; color: var(--ok); margin: 0 2px; }
.jar-today { margin-left: 6px; font-size: 12px; }
.jar-today.ok { color: var(--ok); }
.jar-today.bad { color: var(--warn); }
.daily-history-row .dh-jar { color: var(--muted); white-space: nowrap; }

/* 每个模块下面的记账入口 */
.mod-entry { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mod-entry .mod-amount { flex: 1 1 110px; padding: 9px 12px; font-size: 14px; }
.mod-entry .mod-date { flex: 0 1 150px; padding: 9px 10px; font-size: 13px; }
.mod-hint { font-size: 12px; min-height: 16px; margin-top: 6px; }
.mod-hint.ok { color: var(--ok); }
.mod-hint.bad { color: var(--danger); }

/* 宽屏微调 */
@media (min-width: 620px) {
  .overview-row, .mini-row { gap: 12px; }
  .ov-value { font-size: 17px; }
}
