/* 钱迹 · 记账 - Web 复刻版
   设计规范对齐 com.mutangtech.qianji v4.5.1b3 (colors.xml)
   主色 #3792FA 支出#eb595e 收入#25b87a 转账#879099 背景#f5f6f7 */
:root {
  --primary: #3792fa;
  --primary-dark: #1f7ae0;
  --primary-light: #e8f1fd;
  --spend: #eb595e;
  --income: #25b87a;
  --transfer: #879099;
  --refund: #879099;
  --baoxiao: #3792fa;
  --liability: #9138;
  --text: #101214;
  --text-sub: #a3a3a3;
  --text-mid: #737373;
  --bg: #f5f6f7;
  --card: #ffffff;
  --line: #eaeaea;
  --radius: 12px;
}

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

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #e8eaed;
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--text-sub); font-size: 13px; }
.c-income { color: var(--income); }
.c-spend { color: var(--spend); }

/* ===== 登录页 ===== */
#login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #3792fa 0%, #1f7ae0 100%);
}
.login-card {
  background: #fff; border-radius: 20px; padding: 44px 36px;
  width: 360px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { font-size: 52px; }
.login-card h1 { margin: 10px 0 2px; font-size: 26px; letter-spacing: 2px; }
.login-sub { color: var(--text-sub); font-size: 13px; margin-bottom: 26px; }
.login-form input {
  width: 100%; padding: 13px 16px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 15px; outline: none;
}
.login-form input:focus { border-color: var(--primary); }
.login-tip { margin-top: 14px; color: var(--text-sub); font-size: 12px; }
.login-switch { margin-top: 16px; }
.login-switch a { color: var(--primary); font-size: 13px; cursor: pointer; text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }

/* ===== 手机容器 ===== */
#app { min-height: 100vh; display: flex; justify-content: center; }
#phone {
  position: relative;
  width: 100%; max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0,0,0,.08);
  overflow-x: hidden;
}

/* ===== 顶部 AppBar ===== */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 12px;
  background: var(--bg);
}
#topbar .icon-btn {
  width: 40px; height: 40px; border: none; background: none;
  font-size: 22px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center; border-radius: 10px;
}
#month-selector {
  display: flex; align-items: center; gap: 4px;
  font-size: 17px; font-weight: 700; cursor: pointer; user-select: none;
}
#month-selector .caret { font-size: 12px; color: var(--text-sub); }

/* ===== 汇总卡片 ===== */
.summary-card {
  background: linear-gradient(135deg, #4d9fff 0%, #3792fa 100%);
  color: #fff; border-radius: 16px;
  margin: 4px 16px 14px; padding: 20px;
  box-shadow: 0 6px 18px rgba(55,146,250,.35);
}
.summary-label { font-size: 13px; opacity: .9; }
.summary-amount { font-size: 34px; font-weight: 700; margin: 6px 0 14px; }
.summary-sub { display: flex; gap: 24px; font-size: 13px; opacity: .95; }
.summary-sub b { font-weight: 600; }

/* ===== 账单流水 ===== */
.bill-list { padding: 0 12px 90px; }
.bill-day {
  font-size: 12px; color: var(--text-sub);
  padding: 14px 8px 6px;
}
.bill-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  position: relative; overflow: hidden;
}
.bill-type-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.bill-type-bar.spend { background: var(--spend); }
.bill-type-bar.income { background: var(--income); }
.bill-type-bar.transfer { background: var(--transfer); }
.bill-type-bar.baoxiao { background: var(--baoxiao); }
.bill-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.bill-info { flex: 1; min-width: 0; }
.bill-title { font-size: 15px; font-weight: 500; }
.bill-desc { font-size: 12px; color: var(--text-sub); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-right { text-align: right; flex-shrink: 0; }
.bill-money { font-size: 16px; font-weight: 600; }
.bill-money.spend { color: var(--spend); }
.bill-money.income { color: var(--income); }
.bill-money.transfer { color: var(--transfer); }
.bill-asset { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

.empty-tip { text-align: center; padding: 60px 0 30px; color: var(--text-sub); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== 悬浮 FAB ===== */
#fab-add {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(calc(-50% + 120px));
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--primary); color: #fff;
  font-size: 30px; font-weight: 300; line-height: 1;
  cursor: pointer; box-shadow: 0 6px 18px rgba(55,146,250,.45);
  z-index: 30; display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
#fab-add:active { transform: translateX(calc(-50% + 120px)) scale(.92); }

/* ===== 侧滑抽屉 ===== */
#drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
#drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
  background: #fff; z-index: 60;
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
#drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; gap: 14px;
  padding: 40px 20px 20px;
  background: linear-gradient(135deg, #4d9fff, #3792fa);
  color: #fff;
}
.drawer-avatar { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; font-size: 28px; }
.drawer-name { font-size: 17px; font-weight: 700; }
.drawer-sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.drawer-menu { flex: 1; padding: 12px 0; overflow-y: auto; }
.drawer-menu a {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; font-size: 15px; color: var(--text);
  cursor: pointer; user-select: none;
}
.drawer-menu a:hover { background: var(--bg); }
.drawer-menu a span { font-size: 20px; }
.drawer-footer { padding: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.drawer-footer button {
  padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text-mid); cursor: pointer; font-size: 14px;
}
.drawer-footer #logout-btn:hover { color: var(--spend); border-color: var(--spend); }

/* ===== 记账弹层 (BottomSheet) ===== */
#sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
#add-bill-sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%);
  width: 100%; max-width: 480px;
  background: var(--bg); z-index: 45;
  border-radius: 18px 18px 0 0;
  transition: transform .28s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
#add-bill-sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 40px; height: 4px; background: #ddd; border-radius: 2px; margin: 10px auto 4px; }

.sheet-tabs { display: flex; padding: 0 16px; gap: 6px; }
.sheet-tabs button {
  flex: 1; padding: 9px 0; border: none; background: none;
  font-size: 15px; color: var(--text-mid); cursor: pointer;
  border-radius: 8px; position: relative;
}
.sheet-tabs button.active { color: var(--primary); font-weight: 700; }
.sheet-tabs button.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 20px; height: 3px; background: var(--primary); border-radius: 2px;
}

.sheet-categories {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  padding: 12px 16px; max-height: 200px; overflow-y: auto;
}
.cate-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 2px; border-radius: 12px; cursor: pointer;
}
.cate-item.selected { background: var(--primary-light); }
.cate-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: var(--bg);
}
.cate-item.selected .cate-icon { background: #fff; }
.cate-name { font-size: 12px; color: var(--text-mid); }
.cate-item.selected .cate-name { color: var(--primary); font-weight: 600; }

.sheet-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-top: 1px solid var(--line);
}
.sheet-input-row input {
  flex: 1; border: none; outline: none; font-size: 15px; padding: 8px 0; background: none;
}
.amount-display { font-size: 26px; font-weight: 700; color: var(--spend); }

.sheet-chips { display: flex; gap: 8px; padding: 8px 16px; background: #fff; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--bg); font-size: 13px; color: var(--text-mid); cursor: pointer;
}
.chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.calculator { display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); }
.calculator button {
  padding: 14px 0; border: none; background: none;
  font-size: 22px; cursor: pointer; color: var(--text); border-radius: 10px;
}
.calculator button:active { background: var(--bg); }
.calculator .calc-save {
  grid-column: 3 / 5; background: var(--primary); color: #fff;
  font-size: 17px; font-weight: 600; margin: 6px;
}
.calculator .calc-save:active { background: var(--primary-dark); }

/* ===== 通用页面 ===== */
.page { padding: 0 16px 90px; }
.page-title { font-size: 20px; font-weight: 700; padding: 8px 0 16px; }

/* ===== 资产 ===== */
.asset-total {
  background: linear-gradient(135deg, #4d9fff, #3792fa); color: #fff;
  border-radius: 16px; padding: 24px; margin-bottom: 16px;
}
.asset-total .label { font-size: 13px; opacity: .9; }
.asset-total .value { font-size: 34px; font-weight: 700; margin-top: 6px; }
.asset-item {
  background: #fff; border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.asset-item .asset-icon { width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.asset-item .asset-info { flex: 1; }
.asset-item .asset-name { font-size: 15px; font-weight: 500; }
.asset-item .asset-type { font-size: 12px; color: var(--text-sub); }
.asset-item .asset-money { font-weight: 700; font-size: 16px; }

/* ===== 统计 ===== */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 16px; }
.month-nav button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 18px; color: var(--text-mid); }
.month-nav span { font-size: 16px; font-weight: 700; }
.stat-cards { display: flex; gap: 10px; margin-bottom: 16px; }
.stat-card { flex: 1; background: #fff; border-radius: 12px; padding: 16px; text-align: center; }
.stat-card .label { font-size: 12px; color: var(--text-sub); }
.stat-card .value { font-size: 19px; font-weight: 700; margin-top: 6px; }
.stat-card .value.income { color: var(--income); }
.stat-card .value.spend { color: var(--spend); }
.card { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.card canvas { max-width: 100%; }
#category-stat-list { margin-top: 12px; }
.cat-stat-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cat-stat-row:last-child { border-bottom: none; }
.cat-stat-bar { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.cat-stat-bar .fill { height: 100%; background: var(--primary); border-radius: 4px; }
.cat-stat-row .pct { font-size: 12px; color: var(--text-sub); width: 40px; text-align: right; }

/* ===== 分段 tab ===== */
.seg-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg-tabs button { flex: 1; padding: 9px; border: none; background: none; border-radius: 8px;
  font-size: 14px; color: var(--text-mid); cursor: pointer; }
.seg-tabs button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ===== 分类管理 / 列表 ===== */
.cate-manage-row { background: #fff; border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.cate-manage-row.sub { margin-left: 22px; }
.cate-manage-row .cate-icon { font-size: 22px; }
.cate-manage-row .cate-name { flex: 1; font-size: 15px; }
.cate-manage-row .cate-actions { display: flex; gap: 6px; }
.cate-manage-row .cate-actions button { border: none; background: none; cursor: pointer;
  font-size: 15px; color: var(--text-sub); padding: 2px 8px; }
.cate-manage-row .cate-actions button:hover { color: var(--spend); }

.simple-row { background: #fff; border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.simple-row .name { flex: 1; font-size: 15px; }
.simple-row .del { cursor: pointer; color: var(--text-sub); }
.simple-row .del:hover { color: var(--spend); }

/* ===== 预算 ===== */
.budget-item { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.budget-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.budget-name { font-size: 15px; font-weight: 600; }
.budget-amount { font-size: 13px; color: var(--text-sub); }
.budget-bar { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.budget-bar .fill { height: 100%; border-radius: 5px; transition: width .3s; }

/* ===== 日志 ===== */
.log-item { background: #fff; border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; font-size: 13px; }
.log-value { color: var(--text-sub); word-break: break-all; margin-top: 4px; }
.log-status { font-weight: 600; }
.log-status.ok { color: var(--income); }
.log-status.fail { color: var(--spend); }

/* ===== 按钮 ===== */
.btn-primary { background: var(--primary); color: #fff; border: none; border-radius: 12px;
  padding: 13px 22px; font-size: 15px; cursor: pointer; }
.btn-primary:active { background: var(--primary-dark); }
.btn-block { width: 100%; margin-top: 14px; padding: 15px; font-size: 16px; }

/* ===== 弹窗 ===== */
#modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 320px;
  max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.form-group input, .form-group select { width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.form-group input:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; padding: 11px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn-cancel { background: #fff; border: 1px solid var(--line); color: var(--text-mid); }
.btn-confirm { background: var(--primary); border: none; color: #fff; }

/* ===== Toast ===== */
#toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 10px 20px; border-radius: 22px;
  font-size: 14px; z-index: 200; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%,-10px); } to { opacity: 1; transform: translate(-50%,0); } }

.code-block { background: #f7f7f7; border-radius: 8px; padding: 14px; font-size: 12px;
  line-height: 1.6; overflow-x: auto; margin-top: 8px; color: #555; }
.code-block code { font-family: "SF Mono", Consolas, monospace; }

/* ===== 桌面端居中 ===== */
@media (min-width: 720px) {
  #phone { min-height: calc(100vh - 40px); margin: 20px 0; border-radius: 20px; }
  #add-bill-sheet { border-radius: 18px 18px 20px 20px; }
}
