/* ============================================================
   我的记账本 · Neumorphism（软 3D / Soft UI）设计系统
   参考规范：neumorphism.md（design-system-is-all-you-need）

   规范输入：
     --theme-color      #A67B5B（焦糖，沿用你现有的暖调）
     --shadow-intensity medium（推荐档）

   核心规则：
     1. 整块画布同色（matte），靠阴影表达凸起/凹陷，而不是边框或色块
     2. 凸起 = 左上白色高光 + 右下暖色暗影；凹陷/输入框 = 内阴影
     3. 主题色只用于激活态、开关、关键 CTA，不做大面积填充
     4. 圆角统一（基础 12px，卡片 24px），间距 8px 网格
     5. 每次交互都换阴影形态（凸→凹），并配合颜色/文字变化
     6. 字体沿用系统字体（按你的要求，不引入其他字体）
   ============================================================ */

:root {
  /* 规范输入 */
  --theme-color: #a67b5b;
  --shadow-intensity: medium;

  /* 由主题色推导：去饱和到 ~7%、亮度 ~90% 的暖象牙底 */
  --bg-base: #e9e3d9;
  --bg-base-soft: #ece7de;

  /* 文字（暖中性，保证 4.5:1 以上对比） */
  --text-primary: #3a322a;
  --text-secondary: #6f6455;
  --text-light: #948877;

  /* 主题色派生 */
  --theme-soft: rgba(166, 123, 91, 0.14);
  --theme-mid: rgba(166, 123, 91, 0.3);
  --theme-text: #8a6244;
  --theme-text: #8a6244;

  /* 语义色（暖调，低饱和，只用于文字/填充，不做阴影） */
  --positive: #4f7a5e;
  --positive-soft: rgba(79, 122, 94, 0.16);
  --negative: #a8554b;
  --negative-soft: rgba(168, 85, 75, 0.16);
  --warning: #a8802c;
  --warning-soft: rgba(168, 128, 44, 0.18);
  --terracotta: #b5623c;
  --terracotta-soft: rgba(181, 98, 60, 0.16);

  /* 双向阴影（光源：左上）—— medium 档：偏移 6-10px、模糊 12-20px、不透明度 55-70% */
  --shadow-out: -6px -6px 14px rgba(255, 255, 255, 0.85), 7px 7px 16px rgba(150, 130, 106, 0.46);
  --shadow-out-hover: -8px -8px 18px rgba(255, 255, 255, 0.9), 9px 9px 20px rgba(150, 130, 106, 0.52);
  --shadow-in: inset -4px -4px 10px rgba(255, 255, 255, 0.72), inset 5px 5px 10px rgba(150, 130, 106, 0.42);
  --shadow-in-deep: inset -5px -5px 12px rgba(255, 255, 255, 0.62), inset 7px 7px 14px rgba(150, 130, 106, 0.52);
  --shadow-modal: -10px -10px 24px rgba(255, 255, 255, 0.9), 14px 14px 32px rgba(150, 130, 106, 0.55);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --space: 8px;
  --dur: 240ms;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
    'Noto Sans SC', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* 规范：整块画布使用同一个平面的哑光底色 */
  background: var(--bg-base);
}

body.modal-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

a {
  color: var(--theme-text);
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-primary);
}

p {
  margin: 0;
}

.stat-value,
.money,
.table td,
.table th,
.hint-meta strong,
.flow-value,
.br-numbers,
.di-cell strong,
.entry-amount,
.topbar-stat strong,
.calc-display {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ 页面骨架 */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 104px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 168px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  color: var(--theme-text);
  font-size: 16px;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-light);
}

.topbar-stats {
  display: flex;
  gap: 24px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar-stats::-webkit-scrollbar {
  display: none;
}

.topbar-stat {
  min-width: 92px;
}

.topbar-stat span {
  display: block;
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}

.topbar-stat strong {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pos {
  color: var(--positive) !important;
}

.neg {
  color: var(--negative) !important;
}

/* ------------------------------------------------------------ 标签导航（凹陷槽 + 凸起激活块） */

.tabbar {
  display: flex;
  gap: 6px;
  margin: 24px 0 28px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 0 auto;
  min-width: 84px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--theme-text);
  font-weight: 600;
}

.tab .tab-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

/* ------------------------------------------------------------ 页面标题 */

.view {
  display: block;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h2 {
  font-size: 23px;
  font-weight: 600;
}

.page-head p {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.page-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.grid {
  display: grid;
  gap: 24px;
  align-items: start;
}

.grid.dense,
.grid-2.dense,
.grid-3.dense,
.grid-4.dense {
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
}

.grid > .card {
  align-self: start;
  height: auto;
}

.stack {
  display: grid;
  gap: 24px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

/* ------------------------------------------------------------ 卡片（凸起） */

.card {
  background: var(--bg-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-out);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 0;
}

.card-head h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-head p {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card-body {
  padding: 18px 24px 24px;
}

.card-body.flush {
  padding: 0;
}

/* ------------------------------------------------------------ 数据块（小凸起） */

.stat {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-light);
}

.stat-value {
  margin-top: 4px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
}

.stat-sub {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}

.stat-pos .stat-label::before {
  background: var(--positive);
}

.stat-pos .stat-value {
  color: var(--positive);
}

.stat-neg .stat-label::before {
  background: var(--negative);
}

.stat-neg .stat-value {
  color: var(--negative);
}

.stat-warn .stat-label::before {
  background: var(--warning);
}

.stat-warn .stat-value {
  color: var(--warning);
}

.stat-primary .stat-label::before {
  background: var(--theme-color);
}

.stat-primary .stat-value {
  color: var(--theme-text);
}

.muted {
  color: var(--text-light);
}

.small {
  font-size: 12px;
}

.delta {
  font-size: 12px;
  white-space: nowrap;
}

.money {
  white-space: nowrap;
}

/* ------------------------------------------------------------ 按钮（凸起 → 按下凹陷） */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 10px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), color var(--dur) var(--ease), transform 120ms ease-in;
}

.btn:hover {
  box-shadow: var(--shadow-out-hover);
}

.btn:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(145deg, rgba(166, 123, 91, 0.22), rgba(166, 123, 91, 0.12));
  color: var(--theme-text);
  font-weight: 600;
}

.btn.ghost {
  box-shadow: none;
  color: var(--text-secondary);
  padding-left: 10px;
  padding-right: 10px;
}

.btn.ghost:hover {
  color: var(--text-primary);
  box-shadow: var(--shadow-out);
}

.btn.danger {
  color: var(--negative);
  font-weight: 600;
}

.btn.green {
  color: var(--positive);
  font-weight: 600;
}

.btn.small {
  min-height: 32px;
  padding: 6px 14px;
  font-size: 12px;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  box-shadow: none;
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover {
  color: var(--text-primary);
  box-shadow: var(--shadow-out-hover);
}

.icon-btn:active {
  box-shadow: var(--shadow-in);
}

.link-btn {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}

.link-btn:hover {
  color: var(--theme-text);
}

.link-btn.danger {
  color: var(--negative);
}

.link-btn.danger:hover {
  color: #8e3f37;
}

/* ------------------------------------------------------------ 分段控件（凹陷槽 + 凸起选中） */

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  flex-wrap: nowrap;
}

.segmented.wrap {
  flex-wrap: wrap;
}

.seg-btn {
  padding: 7px 13px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--theme-text);
  font-weight: 600;
}

.segmented.dense .seg-btn {
  padding: 6px 11px;
  font-size: 12px;
}

/* ------------------------------------------------------------ 标签 */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--text-secondary);
  font-size: 11.5px;
  white-space: nowrap;
}

.badge-blue {
  color: var(--theme-text);
}

.badge-green {
  color: var(--positive);
}

.badge-amber {
  color: var(--warning);
}

.badge-orange {
  color: var(--terracotta);
}

.badge-red {
  color: var(--negative);
}

/* ------------------------------------------------------------ 今日可用（带色相提示的凸起面板） */

.hint-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 24px 26px;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  flex-wrap: wrap;
}

/* 用极淡的色相叠加表示状态（同时配合文字与数字颜色，不只靠阴影） */
.tone-none {
  --tone: var(--text-light);
  background: var(--bg-base);
}

.tone-calm {
  --tone: var(--positive);
  background: linear-gradient(145deg, rgba(79, 122, 94, 0.12), rgba(79, 122, 94, 0.04)), var(--bg-base);
}

.tone-warn {
  --tone: var(--warning);
  background: linear-gradient(145deg, rgba(168, 128, 44, 0.14), rgba(168, 128, 44, 0.05)), var(--bg-base);
}

.tone-alert {
  --tone: var(--terracotta);
  background: linear-gradient(145deg, rgba(181, 98, 60, 0.14), rgba(181, 98, 60, 0.05)), var(--bg-base);
}

.tone-critical {
  --tone: var(--negative);
  background: linear-gradient(145deg, rgba(168, 85, 75, 0.15), rgba(168, 85, 75, 0.05)), var(--bg-base);
}

.hint-main {
  min-width: 214px;
}

.hint-main .label {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.hint-main .value {
  margin: 4px 0 2px;
  font-size: 31px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tone, var(--text-primary));
}

.hint-meta {
  display: flex;
  gap: 26px;
  flex: 1;
  flex-wrap: wrap;
}

.hint-meta div span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.hint-meta div strong {
  font-size: 15px;
  font-weight: 600;
}

.hint-card.compact {
  padding: 22px 24px;
  gap: 22px;
}

.hint-card.compact .hint-main .value {
  font-size: 27px;
}

/* ------------------------------------------------------------ 进度与三级预算（凹陷槽） */

/* 今日可用：紧凑横条（web 端只占一行） */

.hint-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  flex-wrap: wrap;
}

.hint-bar.tone-calm {
  background: linear-gradient(145deg, rgba(79, 122, 94, 0.12), rgba(79, 122, 94, 0.04)), var(--bg-base);
}

.hint-bar.tone-warn {
  background: linear-gradient(145deg, rgba(168, 128, 44, 0.14), rgba(168, 128, 44, 0.05)), var(--bg-base);
}

.hint-bar.tone-alert {
  background: linear-gradient(145deg, rgba(181, 98, 60, 0.14), rgba(181, 98, 60, 0.05)), var(--bg-base);
}

.hint-bar.tone-critical {
  background: linear-gradient(145deg, rgba(168, 85, 75, 0.15), rgba(168, 85, 75, 0.05)), var(--bg-base);
}

.hint-bar .hb-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.hint-bar .hb-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.hint-bar .hb-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--tone, var(--text-primary));
  font-variant-numeric: tabular-nums;
}

.hint-bar .hb-facts {
  display: flex;
  gap: 18px;
  flex: 1;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
}

.hint-bar .hb-facts b {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.hint-bar .hb-state {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* 月度日历 */

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.cal-cell {
  display: grid;
  align-content: start;
  gap: 3px;
  min-height: 68px;
  padding: 8px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform 120ms ease-in;
}

.cal-cell.has-data {
  box-shadow: var(--shadow-out);
}

.cal-cell.has-data:hover {
  box-shadow: var(--shadow-out-hover);
}

.cal-cell.has-data:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.cal-cell.blank {
  background: transparent;
  cursor: default;
}

.cal-cell.today {
  box-shadow: var(--shadow-out), 0 0 0 2px rgba(166, 123, 91, 0.4);
}

.cal-cell .cal-day {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.cal-cell.today .cal-day {
  color: var(--theme-text);
  font-weight: 700;
}

.cal-cell .cal-out,
.cal-cell .cal-in {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cal-cell .cal-out {
  color: var(--negative);
}

.cal-cell .cal-in {
  color: var(--positive);
}

.cal-foot {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(150, 130, 106, 0.18);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.cal-foot b {
  font-weight: 600;
}

/* 单日明细（弹窗内） */

.day-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(150, 130, 106, 0.14);
}

.day-entry:last-child {
  border-bottom: 0;
}

.day-entry .entry-ops {
  opacity: 1;
}

/* 比例环图（复盘用） */

.donut-wrap {
  display: grid;
  grid-template-columns: minmax(150px, 200px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.donut-canvas svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(150, 130, 106, 0.25));
}

.donut-canvas .donut-cap {
  font-size: 11px;
  fill: var(--text-light);
}

.donut-canvas .donut-total {
  font-size: 17px;
  font-weight: 700;
  fill: var(--text-primary);
}

.donut-legend {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.donut-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.donut-legend .donut-name {
  color: var(--text-secondary);
}

.donut-legend strong {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.donut-legend em {
  width: 48px;
  font-style: normal;
  text-align: right;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
}

.tierbar {
  position: relative;
  display: flex;
  gap: 2px;
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  overflow: hidden;
}

.tierbar.empty {
  display: grid;
  place-items: center;
  height: 12px;
  font-size: 9.5px;
  color: var(--text-light);
}

.tierbar-seg {
  position: relative;
  flex-basis: 0;
  min-width: 4px;
  border-radius: 999px;
  overflow: hidden;
}

.tierbar-seg-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  transition: width 300ms var(--ease);
}

.tier-1 {
  background: var(--positive);
}

.tier-2 {
  background: var(--warning);
}

.tier-3 {
  background: var(--terracotta);
}

.tierbar-seg-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 8px;
  color: var(--text-light);
}

.tierbar-over {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: repeating-linear-gradient(45deg, rgba(168, 85, 75, 0.45) 0 5px, rgba(168, 85, 75, 0.18) 5px 10px);
}

.progress {
  height: 8px;
  padding: 1px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--theme-color);
  transition: width 300ms var(--ease);
}

.progress-green {
  background: var(--positive);
}

.progress-amber {
  background: var(--warning);
}

.progress-red {
  background: var(--negative);
}

/* ------------------------------------------------------------ 预算页 */

.budget-rows {
  display: grid;
  gap: 16px;
}

.budget-row {
  display: grid;
  gap: 12px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
}

.budget-row .br-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.budget-row .br-head strong {
  font-size: 15px;
  font-weight: 600;
}

.budget-row .br-numbers {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.budget-row .br-numbers .spent {
  font-size: 22px;
  font-weight: 700;
}

.budget-row .br-numbers .total {
  font-size: 12px;
  color: var(--text-light);
}

.budget-row.over {
  background: linear-gradient(145deg, rgba(168, 85, 75, 0.14), rgba(168, 85, 75, 0.05)), var(--bg-base);
}

.budget-row.inactive {
  color: var(--text-secondary);
}

.budget-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.budget-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

/* ------------------------------------------------------------ 本月收支条状图 */

.flow-bars {
  display: grid;
  gap: 10px;
}

.flow-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 96px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}

.flow-label {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-track {
  height: 14px;
  padding: 2px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  overflow: hidden;
}

.flow-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 300ms var(--ease);
}

.flow-row.in .flow-bar {
  background: var(--positive);
}

.flow-row.out .flow-bar {
  background: var(--negative);
}

.flow-value {
  text-align: right;
  font-weight: 600;
}

.flow-row.in .flow-value {
  color: var(--positive);
}

.flow-row.out .flow-value {
  color: var(--negative);
}

.flow-axis {
  height: 1px;
  margin: 2px 0;
  background: rgba(150, 130, 106, 0.35);
}

.flow-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-light);
}

.flow-surplus {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.flow-surplus strong {
  font-size: 16px;
  font-weight: 700;
}

/* ------------------------------------------------------------ 明细列表（内容保持平面） */

.entry-list {
  display: grid;
}

.entry-day {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 2px 8px;
  font-size: 11.5px;
  color: var(--text-light);
}

.entry-day:first-child {
  padding-top: 4px;
}

.entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 104px auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  transition: box-shadow var(--dur) var(--ease);
}

.entry-row:hover {
  box-shadow: var(--shadow-out);
}

.entry-cat {
  font-size: 13.5px;
}

.entry-cat .tag {
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-light);
}

.entry-note {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.entry-wallet {
  white-space: nowrap;
}

.entry-amount {
  text-align: right;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}

.entry-ops {
  display: flex;
  gap: 10px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.entry-row:hover .entry-ops {
  opacity: 1;
}

/* ------------------------------------------------------------ 表格（内容平面） */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  padding: 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.22);
}

.table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(150, 130, 106, 0.14);
  white-space: nowrap;
}

.table tbody tr {
  transition: box-shadow var(--dur) var(--ease);
}

.table tbody tr:hover {
  box-shadow: var(--shadow-out);
}

.table tr.paid td {
  color: var(--text-light);
}

.table tr.overdue td {
  color: var(--negative);
}

.table tr.total-row td {
  font-weight: 600;
  border-top: 1px solid rgba(150, 130, 106, 0.28);
  border-bottom: 0;
}

.table tr.row-link {
  cursor: pointer;
}

.align-right {
  text-align: right;
}

.align-center {
  text-align: center;
}

/* ------------------------------------------------------------ 债务列表（每条凸起可点） */

.debt-list {
  display: grid;
  gap: 16px;
}

.debt-item {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) repeat(4, minmax(78px, 1fr)) auto;
  gap: 10px 14px;
  align-items: center;
  width: 100%;
  padding: 18px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform 120ms ease-in;
}

.debt-item:hover {
  box-shadow: var(--shadow-out-hover);
}

.debt-item:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.debt-item .di-main strong {
  font-size: 14.5px;
  font-weight: 600;
}

.debt-item .di-cell {
  display: grid;
  gap: 3px;
}

.debt-item .di-cell span {
  font-size: 11px;
  color: var(--text-secondary);
}

.debt-item .di-cell strong {
  font-size: 13.5px;
  font-weight: 600;
}

.debt-item .di-badge {
  text-align: right;
}

.debt-item .di-progress {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  max-width: 420px;
}

.debt-item .di-percent {
  font-size: 11px;
  color: var(--text-light);
  text-align: right;
}

/* ------------------------------------------------------------ 图表 */

.chart-wrap {
  width: 100%;
}

.chart-canvas {
  position: relative;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}

.chart .grid {
  stroke: rgba(150, 130, 106, 0.18);
  stroke-width: 1;
}

.chart .zero {
  stroke: rgba(150, 130, 106, 0.4);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart .axis {
  fill: var(--text-light);
  font-size: 10.5px;
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-guide {
  position: absolute;
  top: 6px;
  bottom: 20px;
  width: 0;
  border-left: 1px dashed rgba(150, 130, 106, 0.5);
  pointer-events: none;
}

.chart-tip {
  position: absolute;
  top: 4px;
  z-index: 5;
  min-width: 140px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out-hover);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.chart-tip .tip-title {
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--text-light);
}

.chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-tip .tip-row i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.chart-tip .tip-row strong {
  margin-left: auto;
  font-weight: 600;
}

.hbars {
  display: grid;
  gap: 12px;
}

.hbars-row {
  display: grid;
  grid-template-columns: 100px 1fr 96px;
  gap: 12px;
  align-items: center;
  font-size: 12.5px;
}

.hbars-label {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbars-track {
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
}

.hbars-fill {
  height: 100%;
  border-radius: 999px;
}

.hbars-value {
  text-align: right;
}

.spark {
  width: 100%;
  height: 32px;
}

/* ------------------------------------------------------------ 空状态（凹陷槽） */

.empty {
  padding: 32px 20px;
  margin: 8px 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.empty p {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-light);
}

.empty.small {
  padding: 14px;
}

/* ------------------------------------------------------------ 表单 */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.field {
  display: grid;
  gap: 7px;
  align-content: start;
}

.field-full {
  grid-column: 1 / -1;
}

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

.field-label .req {
  margin-left: 3px;
  font-style: normal;
  color: var(--negative);
}

.field-hint {
  font-size: 11px;
  color: var(--text-secondary);
}

/* 输入框：凹陷的“井”（neomorphism 的经典做法） */
.input {
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: box-shadow var(--dur) var(--ease);
}

.input::placeholder {
  color: var(--text-light);
}

.input:focus {
  outline: none;
  box-shadow: var(--shadow-in-deep), 0 0 0 2px rgba(166, 123, 91, 0.32);
}

select.input {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.form-hint {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  font-size: 12px;
  color: var(--text-secondary);
}

.form-error {
  margin-top: 12px;
  min-height: 18px;
  font-size: 12.5px;
  color: var(--negative);
}

.field-switch {
  grid-column: 1 / -1;
}

/* 开关：凹陷轨道 + 凸起圆钮 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch span {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  transition: background var(--dur) var(--ease);
}

.switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-base-soft);
  box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.9), 3px 3px 6px rgba(150, 130, 106, 0.5);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.switch input:checked + span {
  background: linear-gradient(145deg, rgba(166, 123, 91, 0.32), rgba(166, 123, 91, 0.2));
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--theme-color);
}

.switch em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------ 计算器（按键凸起，按下凹陷） */

.calc-card .card-body {
  display: grid;
  gap: 16px;
}

/* 计算器在桌面端不再占满整行，保持原来的手感宽度 */
.calc-card {
  max-width: 560px;
}

.calc-picks {
  display: grid;
  gap: 16px;
}

.calc-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.calc-display {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
}

.calc-display .cur {
  font-size: 16px;
  color: var(--text-light);
}

.calc-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  outline: none;
}

.calc-key {
  padding: 15px 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
  user-select: none;
}

.calc-key:hover {
  box-shadow: var(--shadow-out-hover);
}

.calc-key:active {
  box-shadow: var(--shadow-in);
}

.calc-key.key-back,
.calc-key.key-clear {
  color: var(--text-secondary);
  font-size: 15px;
}

.calc-key.key-save {
  grid-column: span 2;
  background: linear-gradient(145deg, rgba(166, 123, 91, 0.22), rgba(166, 123, 91, 0.12));
  color: var(--theme-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
}

/* ------------------------------------------------------------ 弹窗（大凸起面板） */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 4vh;
  overflow-y: auto;
  /* 规范：遮罩用底色 60% 不透明度 */
  background: rgba(233, 227, 217, 0.72);
  backdrop-filter: blur(3px);
  animation: fade 260ms var(--ease);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow: var(--shadow-modal);
  animation: fade 260ms var(--ease);
}

.modal-wide {
  max-width: 800px;
}

.modal-lg {
  max-width: 1020px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 26px 28px 0;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-body {
  padding: 22px 28px 10px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 28px 26px;
  flex-wrap: wrap;
}

.confirm-text {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-line;
}

/* ------------------------------------------------------------ 提示条（凸起小面板） */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 120;
  display: grid;
  gap: 12px;
  justify-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: 88vw;
  padding: 14px 22px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out-hover);
  color: var(--text-primary);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.in {
  opacity: 1;
  transform: none;
}

.toast-success {
  color: var(--positive);
}

.toast-error {
  color: var(--negative);
}

.toast-warn {
  color: var(--warning);
}

/* ------------------------------------------------------------ 登录页 */

.auth-layer {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  display: grid;
  gap: 20px;
  width: 100%;
  max-width: 420px;
  padding: 44px 40px 40px;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow: var(--shadow-modal);
}

.auth-card h1 {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
}

.auth-card p {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--theme-text);
  font-size: 22px;
  font-weight: 700;
}

/* ------------------------------------------------------------ 提示块（凹陷井） */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.notice.warn {
  background: linear-gradient(145deg, rgba(168, 128, 44, 0.14), rgba(168, 128, 44, 0.05)), var(--bg-base);
  color: #7d5f1c;
}

.notice.danger {
  background: linear-gradient(145deg, rgba(168, 85, 75, 0.14), rgba(168, 85, 75, 0.05)), var(--bg-base);
  color: #8e3f37;
}

.notice.ok {
  background: linear-gradient(145deg, rgba(79, 122, 94, 0.14), rgba(79, 122, 94, 0.05)), var(--bg-base);
  color: #3d6249;
}

/* ------------------------------------------------------------ 焦点可见（规范：主题色 40% 柔光） */

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-out), 0 0 0 2px rgba(166, 123, 91, 0.4);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
  background-color: rgba(150, 130, 106, 0.35);
}

/* ------------------------------------------------------------ 移动端 */

@media (max-width: 860px) {
  .app {
    padding: 16px 16px 116px;
  }

  .topbar {
    position: static;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius-lg);
  }

  .topbar-stats {
    order: 3;
    width: 100%;
    gap: 20px;
  }

  /* 底部导航：凸起的悬浮条 */
  .tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 40;
    margin: 0;
    padding: 8px;
    gap: 4px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-out-hover);
    background: var(--bg-base);
  }

  .tab {
    min-width: 0;
    flex: 1 1 0;
    min-height: 48px;
    padding: 8px 2px;
    font-size: 11.5px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'main amount'
      'wallet ops';
    gap: 8px;
    padding: 14px;
  }

  /* 只在明细行上使用网格区域，避免影响弹窗里的单日条目 */
  .entry-row .entry-main {
    grid-area: main;
  }

  .entry-row .entry-wallet {
    grid-area: wallet;
  }

  .entry-row .entry-amount {
    grid-area: amount;
  }

  .entry-row .entry-ops {
    grid-area: ops;
    justify-content: flex-end;
    opacity: 1;
  }

  /* 单日条目在手机上：分类与金额一行，操作另起一行 */
  .day-entry {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .debt-item {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
  }

  .debt-item .di-main,
  .debt-item .di-badge {
    grid-column: 1 / -1;
  }

  .debt-item .di-badge {
    text-align: left;
  }

  .hbars-row {
    grid-template-columns: 78px 1fr 84px;
  }

  .modal-overlay {
    padding: 3vh 12px 12px;
  }

  /* 触控目标 ≥44px */
  .btn {
    min-height: 44px;
  }

  .btn.small {
    min-height: 42px;
  }

  .seg-btn {
    min-height: 42px;
  }

  .link-btn {
    padding: 8px 2px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-head h2 {
    font-size: 20px;
  }

  .card-body {
    padding: 16px 18px 20px;
  }

  .card-head {
    padding: 20px 18px 0;
  }

  /* 手机：日历格子更紧凑 */
  .cal-grid,
  .cal-weekdays {
    gap: 5px;
  }

  .cal-cell {
    min-height: 58px;
    padding: 6px;
  }

  .cal-cell .cal-day,
  .cal-cell .cal-out,
  .cal-cell .cal-in {
    font-size: 11px;
  }

  .hint-bar {
    border-radius: var(--radius);
    padding: 12px 16px;
    gap: 12px;
  }

  .hint-bar .hb-value {
    font-size: 20px;
  }

  .hint-bar .hb-facts {
    gap: 12px;
    font-size: 11.5px;
  }

  .donut-wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    justify-items: center;
  }

  .donut-legend {
    width: 100%;
  }
}
