/* =========================================================================
 * style.css — 移动端优先 UI（简洁 / 清晰 / 流畅）
 * ========================================================================= */
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #94a3b8;
  --line: #eef1f6;
  --primary: #2f6df6;
  --primary-d: #1f55d6;
  --green: #16a37b;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(31, 41, 55, .06);
  --tab-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------- 应用锁 / 设置密码 ---------- */
#lock {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, #2f6df6 0%, #1f55d6 60%, #16327a 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px; color: #fff; text-align: center;
}
#lock .lock-logo {
  width: 84px; height: 84px; border-radius: 24px; background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
  backdrop-filter: blur(4px);
}
#lock h1 { font-size: 22px; margin: 6px 0 2px; font-weight: 700; }
#lock .sub { opacity: .85; font-size: 13px; margin-bottom: 26px; }
.pin-wrap { width: 100%; max-width: 320px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 10px 0 18px; }
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6);
  transition: .15s;
}
.pin-dots span.on { background: #fff; border-color: #fff; }
.pin-hint { font-size: 13px; min-height: 18px; margin-top: 6px; opacity: .9; }
.pin-hint.err { color: #ffd2d2; }
.lock-actions { margin-top: 22px; }
.lock-actions a { color: #cfe0ff; font-size: 13px; text-decoration: underline; }

/* ---------- 应用主体 ---------- */
#app { display: none; max-width: 480px; margin: 0 auto; min-height: 100vh;
  background: var(--bg); padding-bottom: calc(var(--tab-h) + var(--safe-b) + 12px); }
#app.show { display: block; }

.app-header {
  position: sticky; top: 0; z-index: 20; background: rgba(245,247,250,.92);
  backdrop-filter: blur(10px); padding: 14px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.app-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.app-header .header-sub { font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; background: var(--card);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
  color: var(--text); font-size: 18px;
}

.view { display: none; padding: 14px 14px 0; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 / 容器 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; display: flex;
  align-items: center; justify-content: space-between; }
.card-title .more { font-size: 12px; color: var(--primary); font-weight: 500; }
.row { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 顶部汇总数字 ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; position: relative; overflow: hidden;
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: .3px; }
.stat .v.sm { font-size: 18px; }
.stat .accent { position: absolute; right: -10px; bottom: -10px; width: 56px; height: 56px;
  border-radius: 50%; opacity: .12; }
.stat.danger .v { color: var(--red); }
.stat.warn .v { color: var(--amber); }
.stat.ok .v { color: var(--green); }

/* ---------- 信用卡视觉卡 ---------- */
.cc {
  border-radius: 18px; padding: 16px; color: #fff; margin-bottom: 12px;
  box-shadow: var(--shadow); position: relative; overflow: hidden; min-height: 116px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cc::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px;
  border-radius: 50%; background: rgba(255,255,255,.12); }
.cc .bank { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cc .num { font-size: 17px; letter-spacing: 2px; font-variant-numeric: tabular-nums; opacity: .95; }
.cc .meta { display: flex; justify-content: space-between; font-size: 12px; opacity: .9; margin-top: 8px; }
.cc .tag { background: rgba(255,255,255,.22); padding: 2px 8px; border-radius: 8px; font-size: 11px; }

/* ---------- 提醒条 ---------- */
.reminder {
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; display: flex;
  align-items: center; gap: 10px; font-size: 13px;
}
.reminder.due { background: #fff1f1; color: #b91c1c; }
.reminder.soon { background: #fff7e6; color: #b45309; }
.reminder.ok { background: #ecfdf5; color: #047857; }
.reminder .badge { font-weight: 700; font-size: 12px; padding: 1px 7px; border-radius: 7px;
  background: rgba(0,0,0,.08); }

/* ---------- 列表 ---------- */
.list-item {
  background: var(--card); border-radius: 14px; padding: 13px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
}
.list-item .avatar { width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .ttl { font-weight: 600; font-size: 14px; }
.list-item .desc { font-size: 12px; color: var(--muted); }
.list-item .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.list-item .right { text-align: right; flex: none; }

/* ---------- 段控 / 筛选 ---------- */
.seg { display: flex; background: #eef1f6; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; font-size: 13px; color: var(--muted); font-weight: 600; }
.seg button.on { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.06); }

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px;
  height: calc(var(--tab-h) + var(--safe-b)); background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 30; padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative;
}
.tabbar button .ic { font-size: 20px; line-height: 1; }
.tabbar button.on { color: var(--primary); }
.tabbar button .dot { position: absolute; top: 8px; right: 50%; margin-right: -22px;
  min-width: 16px; height: 16px; padding: 0 4px; background: var(--red); color: #fff;
  border-radius: 9px; font-size: 10px; line-height: 16px; text-align: center; }

/* ---------- 浮动按钮 ---------- */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: 54px; height: 54px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 26px; box-shadow: 0 6px 18px rgba(47,109,246,.4); z-index: 25;
  display: flex; align-items: center; justify-content: center; left: 50%;
  margin-left: calc(min(480px, 100vw) / 2 - 16px - 27px);
}

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.mask.show { display: flex; animation: fade .2s; }
.sheet {
  background: #fff; width: 100%; max-width: 480px; border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + var(--safe-b)); max-height: 88vh; overflow-y: auto;
  animation: slideUp .28s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 17px; }
.sheet-head .x { font-size: 22px; color: var(--muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px;
  background: #fafbfc; outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick span { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.color-pick span.on { border-color: #1f2937; }

.btn {
  width: 100%; padding: 14px; border-radius: 13px; font-size: 15px; font-weight: 700;
  background: var(--primary); color: #fff; margin-top: 4px;
}
.btn:active { background: var(--primary-d); }
.btn.ghost { background: #eef1f6; color: var(--text); }
.btn.danger { background: #fee2e2; color: var(--red); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 0; }

/* 待确认列表中的紧凑按钮 */
.btn2 { border: none; border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn2.ok { background: var(--green, #16a37b); color: #fff; }
.btn2.no { background: #f1f5f9; color: #475569; }
.btn2:active { transform: translateY(1px); }

/* ---------- 图表容器 ---------- */
.chart-box { margin: 6px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.legend .li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .dotc { width: 10px; height: 10px; border-radius: 3px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }
.empty-mini { text-align: center; color: var(--muted); padding: 12px 0; font-size: 12px; }

/* 横向条形（charts.js） */
.barh { display: flex; flex-direction: column; gap: 10px; }
.barh-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; }
.barh-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barh-track { background: #f1f5f9; border-radius: 7px; height: 12px; overflow: hidden; }
.barh-fill { height: 100%; border-radius: 7px; transition: width .5s; }
.barh-val { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 状态徽标 */
.pill { font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 600; }
.pill.unpaid { background: #fff1f1; color: #dc2626; }
.pill.partial { background: #fff7e6; color: #b45309; }
.pill.paid { background: #ecfdf5; color: #047857; }

/* 提示 toast */
.toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 200;
  background: rgba(31,41,55,.92); color: #fff; padding: 10px 18px; border-radius: 12px;
  font-size: 13px; opacity: 0; transition: .25s; pointer-events: none; max-width: 80%;
}
.toast.show { opacity: 1; }

/* 设置项 */
.set-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px;
  border-bottom: 1px solid var(--line); }
.set-item:last-child { border-bottom: none; }
.set-item .l { display: flex; align-items: center; gap: 10px; }
.set-item .l .ic { width: 34px; height: 34px; border-radius: 10px; background: #eef1f6;
  display: flex; align-items: center; justify-content: center; font-size: 16px; }
.set-item .r { color: var(--muted); font-size: 14px; }
.set-note { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.6; }

/* 备案号（工信部要求：已备案网站须在页面底部展示并链接工信部） */
.beian { margin-top: 22px; font-size: 11px; opacity: .7; }
.beian a { color: #dbe6ff; text-decoration: none; }
.beian a:hover { text-decoration: underline; }

/* 开关 */
.switch { width: 44px; height: 26px; border-radius: 13px; background: #e2e8f0; position: relative; transition: .2s; flex: none; }
.switch.on { background: var(--primary); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on::after { left: 21px; }
