/* ============================================================
   记账本 · 设计系统 v2
   深色 hero + 亮色正文，大圆角、柔和多层阴影
   ============================================================ */

:root {
  /* 中性色 */
  --bg:        #f4f6fb;
  --bg-soft:   #eceff7;
  --panel:     #ffffff;
  --panel-2:   #f8fafd;

  --text:      #0c1425;
  --text-2:    #3a4761;
  --muted:     #78869f;
  --faint:     #9aa7bd;

  --line:      #e7ebf3;
  --line-soft: #f0f3f9;

  /* 品牌色 */
  --primary:      #4f46e5;
  --primary-600:  #4338ca;
  --primary-700:  #3730a3;
  --primary-soft: #eef0ff;
  --primary-ring: rgba(79, 70, 229, .15);
  --violet:       #7c3aed;

  /* 语义色 */
  --pos:      #0f9d6e;
  --pos-soft: #e7f7f1;
  --neg:      #e5484d;
  --neg-soft: #fdeeee;
  --warn:     #d97706;

  /* 圆角 */
  --r-xl: 22px;
  --r-lg: 18px;
  --r:    14px;
  --r-sm: 10px;
  --r-xs: 8px;

  /* 阴影 */
  --sh-xs:   0 1px 2px rgba(12, 20, 37, .04);
  --sh-sm:   0 1px 2px rgba(12, 20, 37, .04), 0 6px 16px -12px rgba(12, 20, 37, .18);
  --sh:      0 2px 6px rgba(12, 20, 37, .05), 0 20px 44px -28px rgba(12, 20, 37, .32);
  --sh-hero: 0 16px 40px -18px rgba(67, 56, 202, .55);
  --sh-pop:  0 28px 70px -24px rgba(12, 20, 37, .45);

  /* 图表（供 JS 读取） */
  --chart-grid:   #eef1f8;
  --chart-axis:   #93a1b8;
  --chart-line:   #4f46e5;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

.num, .card-value, .data-table .num, .mono, .month-label {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, border-color .16s, color .16s,
              box-shadow .16s, transform .08s;
}
.btn:hover { background: var(--panel-2); border-color: #dbe1ee; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn.primary {
  background: linear-gradient(180deg, #5b52ea 0%, var(--primary) 100%);
  border-color: var(--primary-600);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .7);
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
  border-color: var(--primary-700);
  color: #fff;
}

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text-2); border-color: transparent; }

.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: var(--r-xs); }
.btn.block { width: 100%; padding: 13px; font-size: 15px; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .16s, border-color .16s, color .16s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); border-color: #dbe1ee; }

/* ============================================================
   登录 / 注册页
   ============================================================ */
.auth-view {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 32px 18px 48px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  background: #f4f6fb;
}
/* 空间足够时垂直居中；内容过高时自动可滚动（不会像 justify-content:center 那样截顶） */
.auth-card { margin-top: auto; }
.auth-foot { margin-bottom: auto; }

.auth-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 420px at 50% -6%, rgba(99, 91, 255, .22), transparent 66%),
    radial-gradient(560px 320px at 88% 8%, rgba(124, 58, 237, .14), transparent 68%),
    radial-gradient(520px 340px at 6% 96%, rgba(79, 70, 229, .10), transparent 70%);
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 404px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--r-xl);
  box-shadow: 0 2px 8px rgba(12, 20, 37, .04), 0 32px 64px -32px rgba(12, 20, 37, .3);
  padding: 34px 28px 24px;
  text-align: center;
  animation: authIn .42s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes authIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.auth-mark {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 17px;
  background: linear-gradient(145deg, #6366f1 0%, var(--primary) 45%, var(--violet) 100%);
  color: #fff;
  font-size: 27px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 26px -12px rgba(79, 70, 229, .8);
}

.auth-title {
  margin: 0 0 7px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.auth-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}

/* ---- 登录 / 注册 切换 ---- */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--bg-soft);
  border-radius: 12px;
}
.auth-ink {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--panel);
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(12, 20, 37, .1), 0 4px 12px -6px rgba(12, 20, 37, .18);
  transition: transform .26s cubic-bezier(.3, 1.2, .5, 1);
}
.auth-tab {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 9px 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 9px;
  transition: color .18s;
}
.auth-tab.active { color: var(--primary); }
.auth-tab:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 2px; }

/* ---- 表单 ---- */
.field { display: block; text-align: left; margin-bottom: 13px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.field > span .opt { color: var(--faint); font-weight: 400; }

.input-wrap { position: relative; }
.input-wrap input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--text);
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.input-wrap input::placeholder { color: var(--faint); }
.input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.input-wrap:has(.pw-toggle) input { padding-right: 44px; }

.pw-toggle {
  position: absolute;
  top: 50%; right: 6px;
  transform: translateY(-50%);
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .16s, background .16s;
}
.pw-toggle:hover { color: var(--text-2); background: var(--bg-soft); }
.pw-toggle.on { color: var(--primary); }

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  font-style: normal;
  color: var(--neg);
}

/* ---- 图形验证码 ---- */
.cap-row {
  display: flex;
  align-items: stretch;
  gap: 9px;
}
.cap-img {
  flex: 0 0 auto;
  appearance: none;
  padding: 0;
  width: 132px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #f4f6fb;
  line-height: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .16s, box-shadow .16s;
}
.cap-img svg { display: block; width: 132px; height: 44px; }
.cap-img:hover { border-color: var(--primary); }
.cap-img:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 2px; }
.cap-img.cap-fail {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
  padding: 0 8px;
  text-align: center;
}
.cap-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--text);
  letter-spacing: .05em;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.cap-row input::placeholder { color: var(--faint); letter-spacing: normal; }
.cap-row input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ---- 蜜罐字段：挪出可视区，真人看不见，机器人会照填 ---- */
.hp-trap {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- 注册关闭时的提示 ---- */
.auth-tabs.single { grid-template-columns: 1fr; }
.auth-tabs.single .auth-ink { width: calc(100% - 8px); }
.auth-note {
  margin: 16px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 14px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.check input {
  appearance: none;
  width: 16px; height: 16px;
  margin: 0;
  border: 1.5px solid #cbd4e4;
  border-radius: 5px;
  background: var(--panel-2);
  cursor: pointer;
  position: relative;
  transition: background .16s, border-color .16s;
}
.check input:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.check input:checked::after {
  content: '';
  position: absolute;
  left: 4.6px; top: 1.4px;
  width: 4px; height: 8.5px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.auth-tip { font-size: 12px; color: var(--faint); }

.auth-error {
  background: var(--neg-soft);
  border: 1px solid #f8cfd0;
  color: #b4232a;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 13px;
  text-align: left;
  animation: shake .3s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* 提交按钮 loading 态 */
#btnSubmit { position: relative; }
.btn-spin {
  display: none;
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
#btnSubmit.loading .btn-spin { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 演示账号 ---- */
.auth-demo {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--muted);
}
.link-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0 0 0 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.auth-foot {
  position: relative;
  margin: 0;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* ============================================================
   顶栏用户胶囊
   ============================================================ */
.user-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 180px;
  padding: 4px 11px 4px 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .16s, border-color .16s, box-shadow .16s;
}
.user-chip:hover {
  background: var(--panel-2);
  border-color: #dbe1ee;
  box-shadow: var(--sh-xs);
}
.user-avatar {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #6366f1, var(--primary));
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   账号设置弹窗
   ============================================================ */
.pf-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 18px;
}
.pf-avatar {
  width: 54px; height: 54px;
  flex-shrink: 0;
  border-radius: 17px;
  background: linear-gradient(145deg, #6366f1 0%, var(--primary) 50%, var(--violet) 100%);
  color: #fff;
  font-size: 23px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px -12px rgba(79, 70, 229, .85);
}
.pf-id { min-width: 0; }
.pf-nick {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-user { font-size: 13px; color: var(--muted); margin-top: 2px; }

.pf-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 13px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.pf-stat { text-align: center; }
.pf-stat b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.pf-stat span { font-size: 12px; color: var(--muted); }

.pf-block { padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.pf-block:last-child { border-bottom: 0; padding-bottom: 4px; }
.pf-block h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pf-desc { margin: 0 0 11px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.pf-inline { display: flex; gap: 8px; }
.pf-inline input { flex: 1; min-width: 0; }

.pf-block input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14.5px;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--text);
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.pf-block input::placeholder { color: var(--faint); }
.pf-block input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.pf-inline input { margin-bottom: 0; }

.pf-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 1px dashed var(--line-soft);
}
.pf-line b { color: var(--text-2); font-weight: 600; }
.pf-logout { margin-top: 14px; color: var(--neg); }
.pf-logout:hover { background: var(--neg-soft); border-color: #f8cfd0; color: #b4232a; }

/* ============================================================
   顶栏
   ============================================================ */
.app-view {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 11px 22px;
  padding-top: max(11px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  justify-self: start;
  white-space: nowrap;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: linear-gradient(145deg, #6366f1 0%, var(--primary) 48%, var(--violet) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px -7px rgba(79, 70, 229, .85);
}
.brand-text { font-size: 15.5px; font-weight: 700; letter-spacing: -.2px; }

.month-nav {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-self: center;
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.month-label {
  appearance: none;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0 12px;
  height: 26px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 106px;
  justify-content: center;
  transition: background .16s;
}
.month-label:hover { background: var(--bg-soft); }
.cal-icon { color: var(--muted); flex-shrink: 0; }

.month-picker {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  width: 1px; height: 1px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
}
.user-name {
  font-size: 13.5px;
  color: inherit;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   布局
   ============================================================ */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 22px 22px 0;
}

/* ============================================================
   汇总卡片
   ============================================================ */
.cards {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  box-shadow: var(--sh-sm);
  min-height: 116px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: auto;
}

.mini-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-asset    { background: var(--pos); }
.dot-liability{ background: var(--neg); }
.dot-progress { background: var(--primary); }

.card-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.6px;
  color: var(--text);
  margin-top: 12px;
  word-break: break-all;
  line-height: 1.15;
}

.card-sub, .card-delta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- hero --- */
.card-hero {
  background: linear-gradient(140deg, #312e81 0%, #4338ca 46%, #6d28d9 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--sh-hero);
}
.card-hero::before {
  content: '';
  position: absolute;
  width: 280px; height: 280px;
  right: -84px; top: -128px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .24), transparent 66%);
  pointer-events: none;
}
.card-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(440px 170px at 10% 122%, rgba(139, 92, 246, .55), transparent 72%);
  pointer-events: none;
}
.card-hero > * { position: relative; z-index: 1; }

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: auto;
}
.card-hero .card-label { color: rgba(255, 255, 255, .8); margin-bottom: 0; }

.hero-badge {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 999px;
  padding: 2px 9px;
  backdrop-filter: blur(4px);
}

.card-hero .card-value {
  color: #fff;
  font-size: 31px;
  letter-spacing: -1px;
  margin-top: 14px;
}
.card-hero .card-delta {
  color: rgba(255, 255, 255, .94);
  font-weight: 600;
  margin-top: 8px;
}

.delta-up   { color: var(--pos); }
.delta-down { color: var(--neg); }
.card-hero .delta-up   { color: #6ee7b7; }
.card-hero .delta-down { color: #fda4af; }

/* ============================================================
   Tab（胶囊分段）
   ============================================================ */
.tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: 999px;
  margin-bottom: 20px;
}
.tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 8px 20px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  transition: color .18s, background .18s, box-shadow .18s;
}
.tab:hover { color: var(--text-2); }
.tab.active {
  background: var(--panel);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--sh-xs);
}

/* ============================================================
   面板
   ============================================================ */
.panel-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px 18px 14px;
  margin-bottom: 16px;
  box-shadow: var(--sh-sm);
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -.1px;
}
.panel-head .hint { font-size: 12.5px; color: var(--faint); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ============================================================
   渠道录入行
   ============================================================ */
.acc-list { display: flex; flex-direction: column; }

.acc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 186px) 178px;
  align-items: center;
  gap: 12px;
  padding: 7px 11px;
  border-radius: var(--r);
  transition: background .16s;
}
.acc-row:hover { background: var(--panel-2); }

.acc-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.acc-bullet {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--line);
  box-shadow: 0 0 0 3px transparent;
  transition: background .2s, box-shadow .2s;
}
.acc-row.filled .acc-bullet {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.acc-text { min-width: 0; display: flex; align-items: center; gap: 8px; }
.acc-name {
  font-size: 14.5px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acc-tag {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 500;
}

/* 备注：弱化，聚焦才显形 */
.acc-note {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--text-2);
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.acc-note::placeholder { color: var(--faint); }
.acc-note:hover { background: var(--bg-soft); }
.acc-note:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* 金额框 */
.acc-field { position: relative; }
.acc-cur {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 600;
  color: var(--faint);
  pointer-events: none;
  transition: color .16s;
}
.acc-input {
  width: 100%;
  padding: 9px 12px 9px 27px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: -.2px;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.acc-input::placeholder { color: var(--faint); font-weight: 400; letter-spacing: 0; }
.acc-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.acc-field:focus-within .acc-cur { color: var(--primary); }
.acc-input.filled {
  background: #fff;
  border-color: #d9def0;
  color: var(--text);
}
.acc-input::-webkit-outer-spin-button,
.acc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.acc-input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.acc-empty {
  padding: 26px 4px;
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
}

/* ============================================================
   底部操作条
   ============================================================ */
.sticky-actions {
  position: sticky;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px;
  margin-top: 6px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 8px rgba(12, 20, 37, .05), 0 18px 40px -24px rgba(12, 20, 37, .35);
}
.sticky-actions .btn.primary { min-width: 168px; }

/* ============================================================
   图表
   ============================================================ */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; }

.empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  min-width: 560px;
}
.data-table th, .data-table td {
  padding: 11px 13px;
  text-align: left;
  white-space: nowrap;
}
.data-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  letter-spacing: .2px;
}
.data-table th:first-child { border-radius: var(--r-xs) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--r-xs) 0 0; }

.data-table td { border-bottom: 1px solid var(--line-soft); color: var(--text-2); }
.data-table tbody tr:nth-child(even) td { background: #fbfcfe; }
.data-table tbody tr:hover td { background: var(--primary-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table td.num, .data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table tbody tr.cur td {
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 600;
}
.data-table tbody tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

.td-pos { color: var(--pos); font-weight: 650; }
.td-neg { color: var(--neg); font-weight: 650; }
.td-dash { color: var(--faint); }

/* ============================================================
   弹窗
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 37, .46);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-body {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-pop);
  overflow: hidden;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.modal-content { padding: 16px 20px 22px; overflow-y: auto; }

.acc-add {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding-bottom: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.acc-add input, .acc-add select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--text);
  width: 100%;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.acc-add input:focus, .acc-add select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.acc-add input#newAccName { grid-column: 1 / -1; }
.acc-add button { grid-column: 1 / -1; }

.modal-list { display: flex; flex-direction: column; }

.manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.manage-row:last-child { border-bottom: none; }
.manage-row .m-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; }
.manage-row .m-name em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
  margin-left: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 1px 8px;
}
.manage-row.archived .m-name { color: var(--faint); text-decoration: line-through; }
.manage-row .m-actions { display: flex; gap: 6px; flex-shrink: 0; }

.kind-pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
  font-weight: 600;
}
.kind-asset     { background: var(--pos-soft); color: var(--pos); }
.kind-liability { background: var(--neg-soft); color: var(--neg); }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: rgba(12, 20, 37, .94);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 16px 40px -14px rgba(12, 20, 37, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 90;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #c2262c; }

/* ============================================================
   响应式 · 触摸设备
   ============================================================ */

/* 触摸屏没有 hover 概念，禁用一切 hover 残留（否则点完会「粘住」高亮） */
@media (hover: none) {
  .btn:hover { background: var(--panel); border-color: var(--line); color: var(--text-2); }
  .btn.primary:hover { background: linear-gradient(180deg, #5b52ea 0%, var(--primary) 100%); border-color: var(--primary-600); }
  .btn.ghost:hover { background: transparent; color: var(--muted); }
  .icon-btn:hover { background: var(--panel); color: var(--text-2); border-color: var(--line); }
  .acc-row:hover { background: transparent; }
  .acc-note:hover { background: transparent; }
  .month-label:hover { background: transparent; }
  .data-table tbody tr:hover td { background: inherit; }
  .data-table tbody tr:nth-child(even):hover td { background: #fbfcfe; }
}

/* 触摸设备通用规则（含手机横屏、平板 —— 这些设备宽度可能 >720px，但依然是手指操作）。
   按设备能力判定而不是按宽度，否则横屏时输入框字号回落会重新触发 iOS 聚焦缩放 */
@media (pointer: coarse), (hover: none) {
  input, select, textarea { font-size: 16px !important; }
  .icon-btn { width: 36px; height: 36px; }
  .btn.sm { min-height: 32px; }
  .sticky-actions .btn { min-height: 44px; }
}

/* ============================================================
   响应式 · 中等屏（平板 / 窄桌面）
   ============================================================ */
@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-hero { grid-column: 1 / -1; }
  .card-mini:last-child { grid-column: 1 / -1; }
}

/* ============================================================
   响应式 · 手机
   ============================================================ */
@media (max-width: 720px) {
  /* iOS 上字号 < 16px 的输入框聚焦时会自动放大整个页面，这里统一兜底 */
  input, select, textarea { font-size: 16px !important; }

  /* --- 顶栏：两行，收窄内边距，加大触摸目标 --- */
  .topbar {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand month"
      "user  user";
    row-gap: 8px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .brand { grid-area: brand; }
  .month-nav { grid-area: month; justify-self: end; }
  .user-area { grid-area: user; justify-self: stretch; justify-content: flex-end; gap: 2px; }
  .user-name { display: none; }
  .icon-btn { width: 34px; height: 34px; font-size: 17px; }
  .month-label { height: 28px; }

  .container { padding: 16px 14px 0; }

  .cards { gap: 11px; margin-bottom: 18px; }

  /* --- Tab：撑满一行，点击区更大 --- */
  .tabs { display: flex; width: 100%; margin-bottom: 16px; }
  .tab { flex: 1; padding: 10px 8px; }

  /* --- 录入行：名称 + 金额同行，备注另起一行 --- */
  .acc-row {
    grid-template-columns: minmax(0, 1fr) 124px;
    grid-template-areas:
      "info field"
      "note note";
    align-items: center;
    gap: 6px 10px;
    padding: 11px 2px;
    border-radius: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .acc-row:last-child { border-bottom: none; }
  .acc-row:hover { background: transparent; }
  .acc-info { grid-area: info; }
  .acc-field { grid-area: field; }
  .acc-note {
    grid-area: note;
    padding: 7px 9px;
    background: var(--panel-2);
    border-color: var(--line-soft);
  }
  .acc-input { padding: 10px 11px 10px 25px; }
  .acc-cur { left: 11px; font-size: 12.5px; }

  /* --- 底部操作条：主按钮独占一行，留出安全区 --- */
  .sticky-actions {
    bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 10px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .sticky-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .sticky-actions .btn.primary { flex: 1 1 100%; min-width: 0; }

  /* --- 表格 → 卡片：彻底告别横向滚动 --- */
  .table-wrap { overflow: visible; }
  .data-table { min-width: 0; display: block; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; }

  .data-table tbody tr {
    display: block;
    padding: 12px 14px;
    margin-bottom: 9px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r);
  }
  .data-table tbody tr:nth-child(even) td { background: none; }
  .data-table tbody tr:last-child { margin-bottom: 0; }
  .data-table tbody tr.cur {
    background: var(--primary-soft);
    border-color: #d7dbfa;
  }
  .data-table tbody tr.cur td:first-child { box-shadow: none; }

  .data-table tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: none;
    background: none !important;
    font-size: 13.5px;
    white-space: normal;
    text-align: left;
  }
  .data-table tbody td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
  }
  /* 首行「月份」当卡片标题 */
  .data-table tbody td:first-child {
    display: block;
    padding: 0 0 9px;
    margin-bottom: 7px;
    border-bottom: 1px dashed var(--line);
    font-size: 14.5px;
    font-weight: 650;
    color: var(--text);
  }
  .data-table tbody td:first-child::before { content: none; }
  .data-table tbody tr.cur td:first-child { color: var(--primary-700); }

  /* --- 弹窗 → 底部抽屉 --- */
  .modal { padding: 0; align-items: flex-end; }
  .modal-body {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: sheet-up .26s cubic-bezier(.2, .9, .3, 1);
  }
  .modal-head {
    position: relative;
    padding: 18px 16px 14px;
  }
  .modal-head::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 38px; height: 4px;
    border-radius: 999px;
    background: var(--line);
  }
  .modal-content { padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); }

  .acc-add { grid-template-columns: 1fr; gap: 8px; }
  .acc-add input#newAccName { grid-column: auto; }

  /* 渠道管理行：名称一行，操作按钮一行 */
  .manage-row { flex-wrap: wrap; row-gap: 10px; padding: 13px 2px; }
  .manage-row .m-name { flex: 1 1 auto; }
  .manage-row .m-actions { flex: 1 1 100%; justify-content: flex-end; gap: 8px; }
  .manage-row .m-actions .btn { min-height: 36px; padding: 7px 14px; }

  .chart-wrap { overflow: visible; }
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   响应式 · 手机横屏（视口很矮，必须把纵向空间省出来）
   ============================================================ */
@media (orientation: landscape) and (max-height: 520px) {
  /* 汇总卡片：4 张并排一行，不再纵向堆成三行 */
  .cards {
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }
  .card-hero, .card-mini:last-child { grid-column: auto; }
  .card { min-height: 84px; padding: 11px 14px; }
  .card-label { font-size: 11.5px; }
  .card-value { font-size: 17px; margin-top: 7px; letter-spacing: -.4px; }
  .card-hero .card-value { font-size: 23px; margin-top: 8px; }
  .card-sub, .card-delta { font-size: 11.5px; margin-top: 5px; }

  .container { padding-top: 12px; }
  .tabs { margin-bottom: 12px; }
  .panel-block { padding: 14px 16px 12px; margin-bottom: 12px; }
}

/* ============================================================
   响应式 · 小屏
   ============================================================ */
@media (max-width: 560px) {
  .card { min-height: 0; padding: 14px; border-radius: var(--r); }
  .card-value { font-size: 19px; margin-top: 9px; letter-spacing: -.4px; }
  .card-hero .card-value { font-size: 27px; margin-top: 12px; }
  .card-sub, .card-delta { font-size: 12px; margin-top: 6px; }

  .panel-block { padding: 15px 13px 12px; }
  .panel-head h2 { font-size: 14.5px; }
  .panel-head .hint { font-size: 12px; }
}

@media (max-width: 400px) {
  .card-hero .card-value { font-size: 25px; }
  .month-label { min-width: 88px; font-size: 13.5px; }
  .acc-row { grid-template-columns: minmax(0, 1fr) 112px; }
}

/* ============================================================
   响应式 · 登录页与账号弹窗
   ============================================================ */
@media (max-width: 560px) {
  .auth-view { padding: 22px 14px 32px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); gap: 14px; }
  .auth-card { padding: 26px 19px 18px; border-radius: var(--r-lg); }
  .auth-mark { width: 50px; height: 50px; font-size: 24px; border-radius: 15px; margin-bottom: 12px; }
  .auth-title { font-size: 21px; }
  .auth-sub { font-size: 13px; margin-bottom: 18px; }
  .auth-tab { padding: 10px 0; }
  .cap-img, .cap-img svg { width: 120px; height: 42px; }
  .cap-row input { padding: 10px 11px; }

  .pf-avatar { width: 48px; height: 48px; font-size: 20px; border-radius: 15px; }
  .pf-nick { font-size: 16px; }
  .pf-stat b { font-size: 17px; }
  .pf-block { padding: 15px 0; }
}

@media (max-width: 360px) {
  .auth-view { padding-left: 10px; padding-right: 10px; }
  .auth-card { padding: 22px 15px 16px; }
  .cap-row { gap: 7px; }
  .cap-img, .cap-img svg { width: 104px; height: 40px; }
  .user-chip { padding-right: 8px; }
  .pf-stats { gap: 4px; }
}
