:root {
  --green: #0FA36B;
  --green-dark: #0C8B5A;
  --green-soft: #E8F6EF;
  --red: #E5484D;
  --red-soft: #FDECEC;
  --alipay: #1677FF;
  --wechat: #07C160;
  --ink: #17201D;
  --ink-2: #4A5751;
  --muted: #8A968F;
  --line: #E7ECE9;
  --bg: #F4F7F5;
  --card: #FFFFFF;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 40, 32, .04), 0 8px 24px rgba(20, 40, 32, .06);
}

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

/* hidden 属性必须压过任何 display 规则（boot/auth/panel/modal 都是 flex 布局） */
[hidden] { display: none !important; }

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

h1, h2, h3 { margin: 0; font-weight: 650; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
code { background: var(--green-soft); color: var(--green-dark); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ---------- boot ---------- */
.boot {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; background: var(--bg); z-index: 99;
}
.boot-logo { font-size: 56px; animation: pop 1.2s ease-in-out infinite; }
.boot-text { color: var(--muted); font-size: 14px; }
@keyframes pop { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--card); border-radius: 20px;
  padding: 28px 22px; box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo { font-size: 46px; }
.auth-brand h1 { font-size: 22px; margin-top: 4px; }
.auth-brand p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.auth-tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px;
  font-size: 14px; color: var(--ink-2); cursor: pointer; transition: .15s;
}
.auth-tab.active { background: var(--card); color: var(--green); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field input, .field select, textarea, .date-input, .month-select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
  background: #FCFDFC; outline: none; transition: .15s;
}
.field input:focus, .field select:focus, textarea:focus, .date-input:focus, .month-select:focus {
  border-color: var(--green); background: #fff;
}
textarea { resize: vertical; line-height: 1.6; font-size: 14px; }
.row-field { display: flex; gap: 10px; align-items: flex-end; }
.flex1 { flex: 1; }
.send-btn { white-space: nowrap; height: 43px; }

.btn {
  border: 0; border-radius: 11px; padding: 11px 16px; cursor: pointer;
  font-weight: 600; font-size: 15px; transition: .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-dark); }
.btn-ghost { background: var(--bg); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: #E9EFEC; }
.btn-block { width: 100%; }
.btn-mini { padding: 5px 11px; font-size: 13px; background: var(--bg); color: var(--ink-2); border-radius: 8px; }
.link-btn { background: none; border: 0; color: var(--green); font-size: 13px; cursor: pointer; align-self: center; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; line-height: 1.6; }

.msg { font-size: 13px; border-radius: 10px; padding: 10px 12px; background: var(--green-soft); color: var(--green-dark); }
.msg.error { background: var(--red-soft); color: var(--red); }

/* ---------- app shell ---------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 920px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 17px; }
.brand-logo { font-size: 22px; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-email { font-size: 13px; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { max-width: 920px; margin: 0 auto; display: flex; padding: 0 8px; }
.tab {
  flex: 1; border: 0; background: none; padding: 9px 4px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 12px; border-bottom: 2px solid transparent; transition: .15s;
}
.tab i { font-style: normal; font-size: 19px; }
.tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }

.main { max-width: 920px; margin: 0 auto; padding: 16px 16px 100px; display: flex; flex-direction: column; gap: 14px; }
.panel { display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-title { display: flex; align-items: center; justify-content: space-between; font-weight: 650; font-size: 15px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 400; }
.empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 18px 0; }

/* ---------- overview ---------- */
.ov-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.ov-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ov-right .muted { font-size: 12px; white-space: nowrap; }
.ov-month { font-weight: 650; font-size: 15px; }
.month-select { width: auto; padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ov-item { background: var(--bg); border-radius: 12px; padding: 11px 12px; }
.ov-label { font-size: 12px; color: var(--muted); }
.ov-value { font-size: 19px; font-weight: 700; margin-top: 2px; letter-spacing: -.2px; }
.expense, .val-expense { color: var(--red); }
.income, .val-income { color: var(--green); }

.budget-row { margin-top: 14px; }
.budget-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.progress { height: 9px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); border-radius: 99px; transition: width .4s ease, background .3s; }
.progress-bar.warn { background: #F5A524; }
.progress-bar.over { background: var(--red); }

/* ---------- record ---------- */
.kind-switch { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.kind { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--ink-2); }
.kind.active { background: var(--card); font-weight: 650; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.kind[data-kind="expense"].active { color: var(--red); }
.kind[data-kind="income"].active { color: var(--green); }

.amount-box { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--line); padding: 6px 2px 10px; margin-bottom: 16px; }
.cny { font-size: 26px; color: var(--muted); font-weight: 600; }
.amount-input { border: 0; background: none; outline: none; font-size: 34px; font-weight: 700; width: 100%; padding: 0; letter-spacing: -.5px; }
.amount-input::-webkit-outer-spin-button, .amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input { -moz-appearance: textfield; }

.block { margin-bottom: 14px; }
.block-title { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #FCFDFC; padding: 7px 13px; border-radius: 99px;
  cursor: pointer; font-size: 13.5px; color: var(--ink-2); transition: .15s;
}
.chip:hover { border-color: #CBD6D0; }
.chip.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.date-input { width: auto; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-item {
  border: 1px solid var(--line); background: #FCFDFC; border-radius: 12px; padding: 10px 4px;
  cursor: pointer; text-align: center; transition: .15s;
}
.quick-item:hover { background: var(--green-soft); border-color: var(--green); }
.quick-emoji { font-size: 20px; display: block; }
.quick-name { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* ---------- list ---------- */
.filter-row { display: flex; gap: 7px; margin-bottom: 12px; flex-wrap: wrap; }
.txn-list { display: flex; flex-direction: column; }
.txn-day { font-size: 12px; color: var(--muted); padding: 10px 0 4px; }
.txn {
  display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.txn:last-child { border-bottom: 0; }
.txn-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.txn-main { flex: 1; min-width: 0; }
.txn-title { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 1px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--bg); }
.tag.alipay { background: #E8F1FF; color: var(--alipay); }
.tag.wechat { background: #E6F7EE; color: var(--wechat); }
.txn-amt { font-weight: 650; font-size: 15.5px; white-space: nowrap; }
.txn-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 4px; }
.txn-del:hover { color: var(--red); }

/* ---------- stats ---------- */
.channel-compare { display: flex; flex-direction: column; gap: 12px; }
.cc-row { display: flex; align-items: center; gap: 10px; }
.cc-name { width: 78px; font-size: 13.5px; display: flex; align-items: center; gap: 5px; }
.cc-dot { width: 8px; height: 8px; border-radius: 50%; }
.cc-bar-wrap { flex: 1; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.cc-bar { height: 100%; border-radius: 99px; transition: width .4s; }
.cc-amt { width: 92px; text-align: right; font-weight: 600; font-size: 13.5px; }
.chart-box { position: relative; height: 240px; }

/* ---------- goals ---------- */
.goal-list { display: flex; flex-direction: column; gap: 12px; }
.goal { border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.goal-top { display: flex; align-items: center; gap: 10px; }
.goal-emoji { font-size: 26px; }
.goal-name { font-weight: 650; font-size: 15px; }
.goal-sub { font-size: 12px; color: var(--muted); }
.goal-num { margin-left: auto; text-align: right; }
.goal-num b { font-size: 17px; color: var(--green); }
.goal-num span { font-size: 12px; color: var(--muted); }
.goal-progress { margin: 10px 0; }
.goal-actions { display: flex; gap: 8px; }
.goal-actions .btn { flex: 1; padding: 8px; font-size: 13.5px; }
.goal-done { background: var(--green-soft); border-color: var(--green); }

/* ---------- 自动接收卡片 ---------- */
.steps { margin: 0 0 12px; padding-left: 19px; display: flex; flex-direction: column; gap: 6px; }
.steps li { font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.steps a { color: var(--green); font-weight: 600; text-decoration: none; word-break: break-all; }
.steps-sub { display: block; font-size: 11.5px; color: var(--muted); }
.pair-box { background: var(--green-soft); border-radius: 12px; padding: 11px 13px; margin: 12px 0; }
.pair-label { font-size: 12px; color: var(--green-dark); margin-bottom: 6px; }
.pair-row { display: flex; align-items: center; gap: 8px; }
.pair-token {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 17px;
  letter-spacing: 1.5px; font-weight: 700; color: var(--green-dark); background: transparent; padding: 0;
}
.cfg { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.cfg summary { cursor: pointer; padding: 11px 0; font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.cfg-body { padding-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.cfg-row { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; }
.cfg-k { width: 78px; flex-shrink: 0; color: var(--muted); }
.cfg-row code { flex: 1; word-break: break-all; line-height: 1.55; font-size: 12px; }
.cfg .btn { margin-bottom: 12px; }

/* ---------- smart ---------- */
.drop-zone {
  border: 1.5px dashed #C7D6CE; border-radius: 14px; background: #FBFDFC;
  padding: 20px 14px; text-align: center; cursor: pointer; transition: .15s;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--green); background: var(--green-soft); }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.dz-icon { font-size: 26px; }
.dz-text { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.dz-sub { font-size: 12px; color: var(--muted); }

.img-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 68px; height: 68px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 2px; right: 2px; width: 19px; height: 19px; border-radius: 50%;
  border: 0; background: rgba(23,32,29,.72); color: #fff; font-size: 13px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.or-line { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--muted); font-size: 12px; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.preview-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 420px; overflow-y: auto; }
.pv {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 11px; background: #FCFDFC;
}
.pv-check { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--green); }
.pv-main { flex: 1; min-width: 0; }
.pv-title { font-size: 14px; font-weight: 500; }
.pv-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pv-amt { font-weight: 650; font-size: 15px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 30, 24, .38); }
.modal-card {
  position: relative; background: var(--card); width: 100%; max-width: 460px;
  border-radius: 20px 20px 0 0; padding: 20px 18px 22px; display: flex; flex-direction: column; gap: 14px;
  max-height: 88vh; overflow-y: auto;
}
.modal-actions { display: flex; gap: 10px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.check-line input { width: 17px; height: 17px; accent-color: var(--green); }

/* ---------- 安装指引 ---------- */
.guide { display: flex; flex-direction: column; gap: 12px; }
.guide p { margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.guide-block { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.guide-title { font-size: 13px; font-weight: 650; color: var(--green-dark); margin-bottom: 3px; }
.guide-text { font-size: 13px; line-height: 1.65; color: var(--ink-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: rgba(23, 32, 29, .92); color: #fff; padding: 10px 18px; border-radius: 11px;
  font-size: 14px; z-index: 80; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}

/* ---------- 手机端：导航固定在底部 ---------- */
@media (max-width: 767px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(20, 40, 32, .05);
  }
  .tab { padding: 6px 2px 5px; border-bottom: 0; }
  .tab.active { border-bottom: 0; }
  .tab i { font-size: 21px; }
}

/* ---------- 桌面端 ---------- */
@media (min-width: 768px) {
  .main { padding-bottom: 40px; }
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; }
  .toast { bottom: 40px; }
  .quick-grid { grid-template-columns: repeat(6, 1fr); }
  .tab { font-size: 13px; flex-direction: row; gap: 6px; padding: 12px 4px; }
  .tab i { font-size: 16px; }
}
@media (min-width: 900px) {
  .panel[data-panel="stats"] { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .panel[data-panel="stats"] .card:last-child { grid-column: 1 / -1; }
}
