/* ============================================
   记账小助手 H5 版 · 清新活力风格
   参考：浅嫩绿渐变 + 圆角白卡 + 草绿主色 + 撞色点缀
   ============================================ */

:root {
  --green: #22C55E;
  --green-dark: #16A34A;
  --green-bright: #4ADE80;
  --bg-top: #C9F2D2;
  --bg-bottom: #EAFBF0;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-light: #6B7280;
  --border: #C6EBD3;
  --field-bg: #F3FBF6;
  --orange: #F97316;
  --purple: #8B5CF6;
  --blue: #3B82F6;
  --income: #10B981;
  --expense: #EF4444;
  --danger: #EF4444;
  --shadow: 0 6px 20px rgba(34, 197, 94, 0.14);
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg-bottom);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 通用 ---------- */
.hidden { display: none !important; }

.screen { min-height: 100vh; }

.login-bg {
  background: linear-gradient(180deg, #86E8A8 0%, #EAFBF0 55%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 24px;
}

.main-bg {
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 34%);
  padding: 0 14px 110px;
}

.btn-primary {
  display: block;
  width: 100%;
  border: none;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 13px;
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.2s ease;
  font-family: inherit;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; }

.btn-ghost {
  flex: 1;
  border: none;
  background: #F3F4F6;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-danger {
  flex: 1;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}

input, button { font-family: inherit; }

/* ---------- 登录页 ---------- */
.login-wrap { width: 100%; max-width: 340px; text-align: center; }

.login-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--green-bright), var(--green-dark));
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.4);
}

.login-title { font-size: 26px; font-weight: 800; letter-spacing: 1px; }
.login-title .dot { color: var(--green-dark); }

.login-sub { color: #3E6B4F; font-size: 13px; margin: 6px 0 22px; }

.login-card {
  background: #fff;
  border-radius: 22px;
  padding: 24px 18px 20px;
  box-shadow: var(--shadow);
}

/* 密码圆点 */
.pin-display {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 4px 0 14px;
}
.pin-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #E8F5EE;
  border: 2px solid var(--border);
  transition: all 0.15s ease;
}
.pin-dot.filled {
  background: var(--green-dark);
  border-color: var(--green-dark);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.4);
  transform: scale(1.05);
}
.pin-dot.error {
  background: var(--expense);
  border-color: var(--expense);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.login-error {
  color: var(--expense);
  font-size: 12px;
  margin: 4px 4px 8px;
  text-align: center;
  min-height: 16px;
}

/* 九宫格键盘 */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.num-key {
  height: 52px;
  border: none;
  border-radius: 14px;
  background: #F0F9F4;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s ease, background 0.15s ease;
  font-family: inherit;
}
.num-key:active { background: #D9F0E3; transform: scale(0.94); }
.num-key.back { font-size: 18px; color: var(--text-light); font-weight: 600; }
.num-key.empty { visibility: hidden; }
.num-key:disabled { opacity: 0.5; }

.login-hint { font-size: 10.5px; color: #8FA8C0; margin-top: 16px; }

/* ---------- 顶部 ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 2px 14px;
}
.app-title { font-size: 18px; font-weight: 800; }
.app-title .dot { color: var(--green-dark); }

.header-right { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FBBF24, #F97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* ---------- 余额卡 ---------- */
.balance-card {
  background: linear-gradient(135deg, #34D399 0%, var(--green-dark) 100%);
  border-radius: 20px;
  padding: 18px;
  color: #fff;
  box-shadow: 0 10px 24px rgba(22, 163, 74, 0.35);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}
.balance-card::after {
  content: '';
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  top: -52px;
  right: -34px;
}
.balance-card::before {
  content: '';
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  bottom: -32px;
  left: -16px;
}

.balance-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  opacity: 0.92;
  position: relative;
  z-index: 1;
}
.month-badge {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
}

.balance-amount {
  font-size: 34px;
  font-weight: 800;
  margin: 8px 0 12px;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 1;
}

.balance-detail {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  opacity: 0.95;
  position: relative;
  z-index: 1;
}
.balance-detail b { font-size: 14px; font-variant-numeric: tabular-nums; }
.balance-detail .income { color: #D1FAE5; }
.balance-detail .expense { color: #FEE2E2; }
.balance-detail .divider { width: 1px; height: 16px; background: rgba(255,255,255,0.3); }

/* ---------- 记一笔卡 ---------- */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.type-switch {
  display: flex;
  background: #EFFDF4;
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 14px;
}
.type-btn {
  flex: 1;
  text-align: center;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
}
.type-btn.active {
  background: #fff;
  color: var(--expense);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
}
.type-btn[data-type="income"].active { color: var(--income); }

.amount-row {
  display: flex;
  align-items: center;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.amount-prefix {
  font-size: 26px;
  font-weight: 800;
  color: var(--expense);
  margin-right: 8px;
}
.amount-input, #amount-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
#amount-input::placeholder { color: #D1D5DB; }

.form-row { display: flex; gap: 8px; margin-bottom: 12px; }
.field {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--field-bg);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 9px 10px;
  min-width: 0;
}
.field svg { flex-shrink: 0; margin-right: 6px; }
.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
}
#date-input { color: var(--text-light); }
#note-input::placeholder { color: #9CA3AF; }

/* ---------- 明细列表 ---------- */
.list-section { margin-bottom: 20px; }
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 800;
  margin: 2px 2px 8px;
}
.list-header .leaf { margin-left: 4px; }
.list-count { font-size: 11px; font-weight: 500; color: var(--text-light); }

.list-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 0;
}

.record-item {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid #F1F5F9;
}
.record-item:last-child { border-bottom: none; }

.record-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  margin-right: 11px;
  flex-shrink: 0;
}
.record-icon.income { background: #D1FAE5; }
.record-icon.expense { background: #FEF3C7; }

.record-main { flex: 1; min-width: 0; }
.record-note {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.record-note.empty { color: var(--text-light); font-weight: 500; }
.record-date { font-size: 10.5px; color: var(--text-light); margin-top: 2px; }

.record-amount {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}
.record-amount.income { color: var(--income); }
.record-amount.expense { color: var(--expense); }

.record-del {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: #FEE2E2;
  color: var(--expense);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-tip {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  padding: 26px 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0B1B12;
  border-radius: 24px 24px 0 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 10px 14px 14px;
  z-index: 20;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.18);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #9CA3AF;
  cursor: pointer;
  padding-top: 2px;
  user-select: none;
}
.tab.on { color: var(--green-bright); }
.tab.center .fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  margin-top: -26px;
  background: linear-gradient(135deg, var(--green-bright), var(--green-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.5);
  border: 3px solid #0B1B12;
  transition: transform 0.1s ease;
}
.tab.center:active .fab { transform: scale(0.94); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 27, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal-box {
  width: 100%;
  max-width: 300px;
  background: #fff;
  border-radius: 20px;
  padding: 22px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal-text {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 18px;
}
.modal-actions { display: flex; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 30px;
  z-index: 99;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  max-width: 86vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 桌面端 ---------- */
@media (min-width: 640px) {
  body {
    display: flex;
    justify-content: center;
  }
  #main-screen {
    width: 420px;
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(22, 163, 74, 0.15);
  }
  .tabbar { max-width: 420px; margin: 0 auto; }
}
