/* =========================================================
   pages.css — 新结构的样式
   在 style.css 之后加载，负责：
     1. 页面容器与底部标签栏
     2. 首页的收支概览卡
     3. 各页面的标题栏与空状态
   （账单查询页、账表分析页、设置页的具体样式，在对应阶段追加）
   ========================================================= */

/* ---------- 1. 页面容器 ---------- */

/* 四个页面同时存在于 DOM 里，靠 class 控制显示哪一个。
   好处：切页不重新加载，状态不丢，速度快。 */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* 给底部标签栏留出空间，否则最后一张卡片会被挡住 */
body {
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

/* ---------- 2. 底部标签栏 ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;               /* 和 body 同宽，电脑上也是居中一条 */
  display: flex;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 15;
}

/* 毛玻璃效果：支持才生效，不支持就是纯色底 */
@supports (backdrop-filter: blur(12px)) {
  .tabbar {
    background: color-mix(in srgb, var(--card) 88%, transparent);
    backdrop-filter: blur(12px);
  }
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.tab-icon {
  font-size: 19px;
  line-height: 1;
  transition: transform 0.18s;
}

.tab-item.active {
  color: var(--accent);
}

.tab-item.active .tab-icon {
  transform: translateY(-1px) scale(1.08);
}

.tab-item:active {
  background: var(--card-2);
}

/* ---------- 3. 非首页的标题栏 ---------- */

.page-head {
  padding: 22px 20px 10px;
  max-width: 480px;
  margin-inline: auto;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* 首页顶部：原来是一大块渐变，现在只需要一行标题 */
.hero {
  padding: 22px 20px 4px;
  background: none;
  border-bottom: none;
  border-radius: 0;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.hero .theme-btn {
  margin-left: auto;
}

/* ---------- 4. 收支概览卡 ---------- */

.overview-card {
  gap: 16px;
}

.ov-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ov-period {
  font-size: 13px;
  color: var(--text-dim);
}

/* 结余的数字最大，是这一屏的主角 */
.ov-balance {
  margin-top: 6px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.ov-sub {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.ov-sub .income  { color: var(--income); }
.ov-sub .expense { color: var(--expense); }

/* 今日 / 本月两块之间的间距 */
.budget-day,
.budget-main {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.budget-day .budget-track,
.budget-main .budget-track {
  margin-top: 12px;
}

.budget-day .budget-foot,
.budget-main .budget-foot {
  margin-top: 7px;
}

/* 今日超支时抖一下（只播一次），和本月的抖动各自独立 */
.budget-day.just-over {
  animation: shake 0.45s ease-in-out;
}

/* ---------- 5. 通用空状态（非列表区域用） ---------- */

.empty-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
}

.empty-inline .empty-icon {
  font-size: 38px;
}

.empty-inline p {
  margin: 0;
}

/* ---------- 6. 通用小结构 ---------- */

/* 一行两列：左边说明，右边数值 */
.row-between {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.muted {
  color: var(--text-dim);
  font-size: 13px;
}

.tiny {
  font-size: 12px;
  color: var(--text-dim);
}

.amount-income  { color: var(--income); }
.amount-expense { color: var(--expense); }
/* =========================================================
   账单查询页
   ========================================================= */

/* ---------- 控制条：视图切换 + 金额/占比 ---------- */

.query-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compact-switch {
  flex: 1;
  padding: 3px;
}

.compact-switch .type-btn {
  padding: 7px 0;
  font-size: 13px;
}

/* ¥/% 这一组窄一些，和参考图一致 */
.compact-switch.narrow {
  flex: 0 0 84px;
}

/* ---------- 日期导航 ---------- */

.range-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.range-arrow {
  flex: 0 0 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--card-2);
  color: var(--text-dim);
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.range-arrow:active {
  background: var(--accent);
  color: #fff;
}

.range-label {
  flex: 1;
  height: 42px;
  background: var(--card-2);
  color: var(--text);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

/* ---------- 这一段的收支小结 ---------- */

.range-summary {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.rs-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--card-2);
  border-radius: 12px;
}

.rs-label {
  font-size: 12px;
  color: var(--text-dim);
}

.rs-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- 日历 ---------- */

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 4px;
}

.cal-head {
  padding: 6px 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 1 / 1;
  padding: 2px;
  background: var(--card-2);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
  overflow: hidden;
}

.cal-cell:active { transform: scale(0.94); }

.cal-day {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.cal-value {
  font-size: 9px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.muted-value { color: var(--text-dim); opacity: 0.55; }

/* 补白格（上/下月）压暗 */
.cal-cell.outside { opacity: 0.32; }

/* 有支出的日子：淡红底 + 红字，一眼看出花得多的那几天 */
.cal-cell.has-expense {
  background: rgba(255, 107, 107, 0.14);
  color: var(--expense);
}

/* 只有收入的日子：淡绿底 */
.cal-cell.has-income {
  background: rgba(61, 220, 151, 0.14);
  color: var(--income);
}

/* 今天：实心强调 */
.cal-cell.is-today {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(91, 140, 255, 0.4);
}

.cal-cell.is-today .cal-value { color: rgba(255, 255, 255, 0.85); }

/* 选中态：点过的那一天要有明确反馈。
   用"描边+放大"而不是填充，这样即使那天正好是今天
   （已经是实心蓝），也还能看出选中效果。 */
.cal-cell.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  transform: scale(1.06);
  z-index: 1;
}

.cal-cell.is-selected .cal-day { font-weight: 700; }

/* 今天且被选中：加一圈光晕，让两种状态同时可见 */
.cal-cell.is-today.is-selected {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent);
}

/* 补白格被选中时不要放大，避免视觉上跳出去 */
.cal-cell.outside.is-selected {
  transform: none;
  outline-style: dashed;
}

/* ---------- 周 / 月 / 年 卡片网格 ---------- */

.range-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.range-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 8px;
  min-height: 84px;
  background: var(--card-2);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
}

.range-card:active { transform: scale(0.96); }

.rc-title {
  font-size: 15px;
  font-weight: 600;
}

.rc-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rc-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.range-card.has-expense {
  background: rgba(255, 107, 107, 0.14);
  color: var(--expense);
}

.range-card.has-income {
  background: rgba(61, 220, 151, 0.14);
  color: var(--income);
}

.range-card.is-empty { color: var(--text-dim); }

/* 当前所在的周/月/年：实心强调 */
.range-card.is-current {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(91, 140, 255, 0.35);
}

.range-card.is-current .rc-sub { color: rgba(255, 255, 255, 0.85); }

/* 三个月份一行，避免 12 个月排太长 */
@media (min-width: 400px) {
  .range-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 明细列表 ---------- */

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-2);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.entry:active { border-color: var(--accent); }

.entry-icon {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--card);
  border-radius: 9px;
}

.entry-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.entry-amount {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-empty {
  padding: 22px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* =========================================================
   账表分析页
   ========================================================= */

.chart-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-controls .compact-switch.narrow {
  flex: 0 0 auto;
}

/* ---------- 走势图 ---------- */

.chart-box {
  margin-top: 4px;
  padding: 8px 4px 0;
  background: var(--card-2);
  border-radius: 14px;
  overflow: hidden;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 200px;
}

.chart-svg text {
  font-family: inherit;
}

/* 折线图上的圆点在悬停时放大，方便看具体数值 */
.chart-svg circle { transition: r 0.15s; cursor: pointer; }
.chart-svg circle:hover { r: 4; }

.chart-stats {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.cs-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  background: var(--card-2);
  border-radius: 11px;
  min-width: 0;
}

.cs-label {
  font-size: 11px;
  color: var(--text-dim);
}

.cs-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 饼图 ---------- */

.pie-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.pie-visual {
  position: relative;
  flex: 0 0 140px;
  width: 140px;
  height: 140px;
}

.donut-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 圆环每一段：用 stroke 画，悬停加粗 */
.donut-seg {
  fill: none;
  stroke-width: 22;
  transition: stroke-width 0.2s;
  cursor: pointer;
}

.donut-seg:hover { stroke-width: 26; }

.pie-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}

.pie-center-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.pie-center-label {
  font-size: 10px;
  color: var(--text-dim);
}

/* ---------- 图例 ---------- */

.legend {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  max-height: 148px;
  overflow-y: auto;
}

.legend-item {
  display: grid;
  grid-template-columns: 10px 16px 1fr auto auto;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.legend-icon { font-size: 12px; }

.legend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.legend-pct {
  width: 34px;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.legend-empty {
  padding: 20px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* 窄屏时饼图和图例改为上下排列 */
@media (max-width: 360px) {
  .pie-wrap { flex-direction: column; }
  .pie-visual { flex: 0 0 auto; }
  .legend { width: 100%; max-height: none; }
}

/* =========================================================
   设置页
   ========================================================= */

/* ---------- 皮肤选择 ---------- */

.theme-choices {
  display: flex;
  gap: 8px;
}

.theme-choice {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 6px;
  background: var(--card-2);
  border: 1.5px solid transparent;
  border-radius: 13px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.theme-choice .tc-icon { font-size: 20px; }

.theme-choice.active {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.12);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- 通用设置行 ---------- */

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
}

.setting-row.clickable { cursor: pointer; }

.sr-label {
  font-size: 14px;
}

/* 货币 / 小数位：一排小方块 */
.currency-choices {
  display: flex;
  gap: 6px;
}

.cur-choice {
  min-width: 38px;
  padding: 7px 10px;
  background: var(--card-2);
  border: 1.5px solid transparent;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s;
}

.cur-choice.active {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.14);
  color: var(--accent);
  font-weight: 600;
}

/* 开关 */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 46px;
  height: 27px;
  background: var(--card-2);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
  flex: 0 0 auto;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(19px); }

.select,
.time-input {
  padding: 8px 12px;
  background: var(--card-2);
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}

/* ---------- 分类管理 ---------- */

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--card-2);
  border-radius: 11px;
}

.ci-icon {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
}

.ci-name {
  flex: 1;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ci-usage {
  font-size: 11px;
  color: var(--text-dim);
  flex: 0 0 auto;
}

.ci-del {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 17px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.ci-del:active {
  background: rgba(255, 107, 107, 0.15);
  color: var(--expense);
}

.ci-del:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---------- 关于 ---------- */

.kv-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.kv-row:last-child { border-bottom: none; }

.kv-key {
  font-size: 13px;
  color: var(--text-dim);
  flex: 0 0 auto;
}

.kv-value {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-all;
}

/* ---------- 危险操作 ---------- */

.danger-card {
  border-color: rgba(255, 107, 107, 0.3);
}

.danger-btn.full {
  width: 100%;
  flex: none;
  padding: 13px;
  font-size: 15px;
}
