:root {
  --bg: #0f1117;
  --surface: #171a22;
  --surface-2: #1e222c;
  --border: #262b37;
  --border-soft: #20242e;
  --text: #e9edf5;
  --muted: #8a93a6;
  --accent: #34d399;
  --accent-dim: #1f6b52;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background-image: radial-gradient(
      900px 420px at 50% -160px,
      rgba(52, 211, 153, 0.14),
      transparent 70%
    ),
    radial-gradient(700px 400px at 100% 100%, rgba(96, 165, 250, 0.07), transparent 70%);
  background-attachment: fixed;
}

.app {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 12px;
  background: linear-gradient(180deg, rgba(15, 17, 23, 0.96), rgba(15, 17, 23, 0.82));
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-mark {
  font-size: 19px;
}

.brand-text {
  font-size: 17px;
}

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

.date-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  color-scheme: dark;
  max-width: 140px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- 视图 ---------- */
.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade 0.22s ease;
}

.view.hidden,
.hidden {
  display: none !important;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 18px 20px 20px;
  background: linear-gradient(140deg, #17342a 0%, #14202b 55%, #161b28 100%);
  border: 1px solid rgba(52, 211, 153, 0.22);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.24), transparent 65%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.hero-day {
  font-variant-numeric: tabular-nums;
}

.hero-value {
  margin: 6px 0 4px;
  font-size: 40px;
  font-weight: 750;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: #ecfdf5;
}

.hero-value.neg {
  color: var(--red);
}

.hero-foot {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 统计格 ---------- */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.grid3 .stat {
  padding: 10px 11px;
  gap: 2px;
}

.grid3 .stat-label {
  font-size: 11px;
}

.grid3 .stat-value {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.phone-urls {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.75;
  word-break: break-all;
  color: var(--muted);
}

.phone-urls a {
  color: var(--accent);
  text-decoration: none;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

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

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

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

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: #cfd6e4;
  letter-spacing: 0.2px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.13);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.pill.ghost {
  background: var(--surface-2);
  color: var(--muted);
}

.hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.hint.tiny {
  font-size: 11.5px;
  opacity: 0.85;
}

.hint code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 11.5px;
}

/* ---------- 渠道 ---------- */
.chan-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chan {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 11px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.chan-ico {
  font-size: 17px;
  line-height: 1.2;
}

.chan-name {
  font-size: 11.5px;
  color: var(--muted);
}

.chan-val {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
}

/* ---------- 图表 ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 96px;
  padding-top: 6px;
}

.bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 30px;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  min-height: 4px;
  transition: height 0.3s ease;
}

.bar.zero {
  background: var(--surface-2);
}

.bar.neg {
  background: linear-gradient(180deg, var(--red), #7f1d1d);
}

.bar-day {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.bar-val {
  font-size: 9.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 列表 ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  background: var(--surface-2);
  border-radius: 14px;
}

.row-ico {
  font-size: 17px;
  width: 22px;
  text-align: center;
}

.row-main {
  flex: 1;
  min-width: 0;
}

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

.row-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-amount {
  font-size: 14.5px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-del {
  background: none;
  border: 0;
  color: #5c6577;
  font-size: 15px;
  padding: 6px;
  cursor: pointer;
  line-height: 1;
}

.empty {
  margin: 0;
  padding: 18px 4px;
  text-align: center;
  color: #5c6577;
  font-size: 13px;
}

/* ---------- 表单 ---------- */
.amount-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 6px;
}

.currency {
  font-size: 17px;
  color: var(--muted);
  font-weight: 600;
}

.amount-input {
  background: none;
  border: 0;
  color: var(--text);
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -1.5px;
  width: 210px;
  flex: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0;
  outline: none;
}

.amount-input::placeholder {
  color: #3a4152;
}

.label {
  font-size: 12px;
  color: var(--muted);
  margin: 16px 0 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: #b9c2d4;
  border-radius: 999px;
  padding: 8px 13px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}

.chip.active {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.55);
  color: #a7f3d0;
}

.text-input,
.text-area {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 12px 13px;
  margin-top: 14px;
  outline: none;
}

.text-input:focus,
.text-area:focus {
  border-color: rgba(52, 211, 153, 0.5);
}

.text-area {
  resize: vertical;
  line-height: 1.6;
  min-height: 120px;
}

.field {
  display: block;
  margin-top: 12px;
}

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

.field-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 0 13px;
}

.field-input:focus-within {
  border-color: rgba(52, 211, 153, 0.5);
}

.pfx {
  font-size: 12px;
  color: #5c6577;
  font-weight: 600;
}

.field-input input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 19px;
  font-weight: 600;
  padding: 12px 0;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

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

.dot.cash {
  background: var(--amber);
}
.dot.tng {
  background: var(--blue);
}
.dot.grab {
  background: var(--accent);
}
.dot.expected {
  background: #a78bfa;
}

/* ---------- 计算区 ---------- */
.calc {
  margin-top: 16px;
  background: linear-gradient(160deg, #12161f, #151a24);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-variant-numeric: tabular-nums;
}

.calc-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.calc-line b {
  color: #c8d1e1;
  font-weight: 600;
}

.calc-line.sub {
  font-size: 12.5px;
  opacity: 0.9;
}

.calc-eq {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
}

.calc-eq b {
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
}

.calc-eq b.muted {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.calc-eq b.neg {
  color: var(--red);
}

.calc-net {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.calc-net b {
  font-size: 22px;
  font-weight: 720;
  color: #f1f5f9;
  letter-spacing: -0.5px;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 620;
  cursor: pointer;
  transition: 0.15s;
}

.btn:active {
  transform: scale(0.985);
}

.btn.primary {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(180deg, #34d399, #22b07d);
  color: #06281e;
  box-shadow: 0 6px 18px rgba(52, 211, 153, 0.22);
}

.btn.ghost {
  background: var(--surface-2);
  color: #b9c2d4;
  border: 1px solid var(--border);
}

.btn.flex1 {
  flex: 1;
}

.btn.as-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13.5px;
  padding: 12px 10px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.row-gap {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.row-gap .btn {
  margin-top: 0;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(16, 19, 26, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: 0;
  color: #6b7488;
  font: inherit;
  font-size: 10.5px;
  padding: 6px 0;
  cursor: pointer;
  border-radius: 12px;
}

.tab-ico {
  font-size: 18px;
  line-height: 1.1;
  filter: grayscale(0.5);
  opacity: 0.75;
}

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

.tab.active .tab-ico {
  filter: none;
  opacity: 1;
}

/* ---------- 设置面板 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(540px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  z-index: 50;
  background: #151922;
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up 0.24s ease;
}

@keyframes up {
  from {
    transform: translate(-50%, 30px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-head h2 {
  margin: 0;
  font-size: 16px;
}

/* ---------- AI 结果 ---------- */
.ai-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ai-field {
  background: var(--surface-2);
  border-radius: 13px;
  padding: 10px 12px;
}

.ai-field span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.ai-field b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.ai-field.none b {
  color: #4b5468;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: #e9edf5;
  color: #0f1117;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err {
  background: #fecaca;
  color: #7f1d1d;
}

/* ---------- 流水条目 ---------- */
.entry {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 14px;
}

.kind-badge {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 14px;
  background: #232836;
}

.kind-badge.settle {
  background: rgba(52, 211, 153, 0.15);
}
.kind-badge.expense {
  background: rgba(248, 113, 113, 0.14);
}
.kind-badge.change {
  background: rgba(251, 191, 36, 0.14);
}
.kind-badge.adjust {
  background: rgba(96, 165, 250, 0.15);
}

.kind-badge.move {
  background: rgba(167, 139, 250, 0.16);
}

.entry-main {
  flex: 1;
  min-width: 0;
}

.entry-title {
  font-size: 13.5px;
  font-weight: 560;
  color: #dbe2ee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.entry-amt {
  font-size: 14.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-amt.pos {
  color: var(--accent);
}
.entry-amt.neg {
  color: #f0a1a1;
}

.entry-amt.muted {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.warn-dot {
  color: var(--amber);
  font-size: 11px;
}

.day-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.day-head {
  font-size: 11.5px;
  color: #6b7488;
  padding: 6px 2px 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ---------- 周切换 ---------- */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.week-title {
  text-align: center;
  line-height: 1.25;
}

.week-title b {
  display: block;
  font-size: 16px;
}

.week-title span {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- AI 一句话记账 ---------- */
.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.ai-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 16px;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
}

.ai-input:focus {
  border-color: rgba(52, 211, 153, 0.5);
}

.ai-send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, #34d399, #22b07d);
  color: #06281e;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
}

.ai-send:disabled {
  opacity: 0.5;
}

.ai-reply {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.65;
  color: #dbe2ee;
  white-space: pre-wrap;
}

/* ---------- 转帐 ---------- */
.transfer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.select {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 11px 12px;
  color-scheme: dark;
  outline: none;
}

.select:focus {
  border-color: rgba(52, 211, 153, 0.5);
}

.model-select {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 0;
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
}

.transfer-arrow {
  color: var(--muted);
  font-size: 16px;
  flex: none;
}

#wMovedNote {
  white-space: pre-line;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
