/* 轻记账 · 全端响应式样式 */
:root{
  --bg:#f5f7fb; --surface:#ffffff; --surface-2:#f0f3f9; --surface-3:#e9eef7;
  --text:#1b2434; --text-2:#5c677d; --text-3:#98a2b6;
  --line:#e6ebf3; --primary:#4f7cff; --primary-soft:#eaf0ff; --primary-dark:#3b63db;
  --red:#f0554d; --red-soft:#ffeeec; --green:#12a67a; --green-soft:#e6f8f2;
  --orange:#f5a623; --purple:#8b5cf6; --blue:#3897f0;
  --shadow:0 2px 10px rgba(31,52,94,.05),0 12px 32px rgba(31,52,94,.045);
  --shadow-lg:0 20px 60px rgba(20,35,70,.18);
  --radius:16px; --radius-sm:10px;
  --sidebar:216px; --topbar:64px;
}
[data-theme="dark"]{
  --bg:#0f131c; --surface:#181e2a; --surface-2:#202838; --surface-3:#283246;
  --text:#e9eef8; --text-2:#a3afc6; --text-3:#6f7c95;
  --line:#283246; --primary:#6b92ff; --primary-soft:#243357; --primary-dark:#4f7cff;
  --red:#ff6b63; --red-soft:#3a2226; --green:#31c99b; --green-soft:#16342c;
  --shadow:0 2px 10px rgba(0,0,0,.18),0 12px 32px rgba(0,0,0,.16);
  --shadow-lg:0 20px 60px rgba(0,0,0,.5);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;min-height:100%}
body{
  background:var(--bg);color:var(--text);font-size:14px;line-height:1.55;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",system-ui,sans-serif;
  -webkit-font-smoothing:antialiased;
}
input,select,textarea,button{font-family:inherit;font-size:inherit;color:inherit}
input,select,textarea{outline:none}
button{cursor:pointer;border:none;background:none}
a{color:var(--primary);text-decoration:none}
svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex:none}
.hidden{display:none !important}
.muted{color:var(--text-3)}
.sm{font-size:12px}
.link{color:var(--primary);font-size:13px;font-weight:600}
.link:hover{text-decoration:underline}
kbd{background:var(--surface-3);border-radius:4px;padding:1px 5px;font-size:11px;border:1px solid var(--line)}

/* ---------- 按钮 ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:9px 16px;border-radius:10px;font-weight:600;
  background:var(--surface-2);color:var(--text);transition:.18s;white-space:nowrap;border:1px solid transparent}
.btn:hover{transform:translateY(-1px);filter:brightness(.98)}
.btn:active{transform:translateY(0)}
.btn.primary{background:var(--primary);color:#fff;box-shadow:0 4px 12px rgba(79,124,255,.24)}
.btn.primary:hover{background:var(--primary-dark)}
.btn.ghost{background:var(--surface-2);border-color:var(--line)}
.btn.danger{background:var(--red-soft);color:var(--red)}
.btn.sm{padding:6px 11px;font-size:12px;border-radius:8px}
.btn.block{width:100%;padding:12px;font-size:15px}
.btn svg{width:16px;height:16px}
.icon-btn{width:34px;height:34px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;color:var(--text-2);background:var(--surface-2)}
.icon-btn:hover{color:var(--primary);background:var(--primary-soft)}
.badge{font-size:11px;padding:2px 8px;border-radius:20px;background:var(--primary-soft);color:var(--primary);font-weight:600}
.badge.warn{background:var(--red-soft);color:var(--red)}
.badge.ok{background:var(--green-soft);color:var(--green)}

/* ---------- 登录 ---------- */
.auth-view{min-height:100vh;display:flex;align-items:center;justify-content:center;gap:72px;padding:40px 24px;flex-wrap:wrap;
  background:radial-gradient(1000px 600px at 15% 10%,rgba(79,124,255,.13),transparent 60%),
             radial-gradient(800px 600px at 90% 90%,rgba(18,166,122,.10),transparent 60%),var(--bg)}
.auth-brand{max-width:430px}
.auth-logo{width:60px;height:60px;border-radius:18px;background:linear-gradient(135deg,#4f7cff,#7a5cff);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:30px;font-weight:800;box-shadow:0 12px 28px rgba(79,124,255,.35)}
.auth-brand h1{font-size:40px;margin:18px 0 4px;letter-spacing:1px}
.auth-brand>p{color:var(--text-2);font-size:16px;margin:0 0 26px}
.auth-points{list-style:none;padding:0;margin:0;display:grid;gap:12px}
.auth-points li{color:var(--text-2);display:flex;gap:10px;align-items:flex-start;font-size:14px}
.auth-points span{color:var(--primary);font-weight:700}
.auth-card{width:100%;max-width:380px;background:var(--surface);border:1px solid var(--line);border-radius:22px;
  padding:28px;box-shadow:var(--shadow-lg)}
.auth-tabs{display:flex;gap:8px;margin-bottom:22px;border-bottom:1px solid var(--line)}
.auth-tab{padding:10px 4px;margin-right:20px;font-weight:700;color:var(--text-3);border-bottom:2px solid transparent;margin-bottom:-1px}
.auth-tab.active{color:var(--primary);border-color:var(--primary)}
.auth-form{display:grid;gap:16px}
.auth-form label{display:grid;gap:7px;font-size:13px;font-weight:600;color:var(--text-2)}
.auth-form input,.form-control,.mini-select,.book-select,.search-box input{
  width:100%;background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;color:var(--text)}
.auth-form input:focus,.form-control:focus,.mini-select:focus,.search-box input:focus{border-color:var(--primary);background:var(--surface)}
.demo-hint{margin-top:20px;padding:12px;border-radius:10px;background:var(--primary-soft);color:var(--text-2);
  font-size:12px;display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}
.demo-hint b{color:var(--primary)}
.auth-foot{color:var(--text-3);font-size:11px;text-align:center;margin:16px 0 0}

/* ---------- 主框架 ---------- */
.app{min-height:100vh}
.sidebar{position:fixed;left:0;top:0;bottom:0;width:var(--sidebar);background:var(--surface);border-right:1px solid var(--line);
  display:flex;flex-direction:column;padding:18px 12px;z-index:20}
.side-logo{display:flex;align-items:center;gap:10px;font-size:19px;font-weight:800;padding:4px 8px 22px}
.side-logo-mark{width:34px;height:34px;border-radius:11px;background:linear-gradient(135deg,#4f7cff,#7a5cff);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:18px}
.side-nav{display:grid;gap:4px}
.side-nav button{display:flex;align-items:center;gap:12px;padding:11px 13px;border-radius:11px;color:var(--text-2);font-weight:600;text-align:left}
.side-nav button:hover{background:var(--surface-2);color:var(--text)}
.side-nav button.active{background:var(--primary-soft);color:var(--primary)}
.side-nav svg{width:19px;height:19px}
.side-bottom{margin-top:auto;display:grid;gap:12px}
.side-tip{font-size:11px;color:var(--text-3);background:var(--surface-2);padding:9px;border-radius:9px;text-align:center}
.side-user{display:flex;align-items:center;gap:9px;padding:9px;border-top:1px solid var(--line);font-size:13px;font-weight:600}
.side-user .avatar{width:32px;height:32px;border-radius:50%;background:var(--primary-soft);display:flex;align-items:center;justify-content:center;font-size:17px}
.main{margin-left:var(--sidebar);min-height:100vh}
.topbar{height:var(--topbar);position:sticky;top:0;z-index:15;background:color-mix(in srgb,var(--bg) 88%,transparent);
  backdrop-filter:blur(12px);border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;
  padding:0 22px;gap:12px}
.topbar-left,.topbar-right{display:flex;align-items:center;gap:10px}
.book-select{width:auto;min-width:150px;font-weight:700;background:transparent;border-color:transparent;padding:7px 10px}
.book-select:hover{background:var(--surface-2)}
.month-picker{display:flex;align-items:center;gap:2px;background:var(--surface-2);border-radius:10px;padding:3px}
.month-label{min-width:96px;font-weight:700;font-size:13px;padding:5px 4px;text-align:center}
.page-wrap{padding:22px;max-width:1500px;margin:0 auto}
.page{display:block}
.grid{display:grid;gap:16px;margin-bottom:16px}
.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow);margin-bottom:16px}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:14px;flex-wrap:wrap}
.card-head h3{margin:0;font-size:15px;font-weight:700}
.tabbar{display:none}
.fab{display:none}

/* ---------- 概览卡片 ---------- */
.stat-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow);position:relative;overflow:hidden}
.stat-card::after{content:"";position:absolute;right:-20px;top:-24px;width:90px;height:90px;border-radius:50%;background:var(--primary-soft);opacity:.6}
.stat-card .t{color:var(--text-2);font-size:13px;font-weight:600;display:flex;align-items:center;gap:6px}
.stat-card .v{font-size:29px;font-weight:800;margin:8px 0 4px;letter-spacing:-.5px;position:relative;z-index:1}
.stat-card .s{font-size:12px;color:var(--text-3);position:relative;z-index:1}
.stat-card.expense .v{color:var(--red)} .stat-card.expense::after{background:var(--red-soft)}
.stat-card.income .v{color:var(--green)} .stat-card.income::after{background:var(--green-soft)}
.stat-card.balance .v{color:var(--primary)}
.up{color:var(--red)} .down{color:var(--green)}
.progress{height:9px;border-radius:10px;background:var(--surface-3);overflow:hidden}
.progress>i{display:block;height:100%;border-radius:10px;background:linear-gradient(90deg,var(--primary),#7a5cff);transition:width .5s}
.progress>i.over{background:linear-gradient(90deg,#f5a623,var(--red))}
.quick-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.quick-btn{display:flex;flex-direction:column;align-items:center;gap:6px;padding:12px 6px;border-radius:12px;background:var(--surface-2);font-size:12px;font-weight:600;transition:.18s}
.quick-btn:hover{background:var(--primary-soft);color:var(--primary);transform:translateY(-2px)}
.quick-btn .q-icon{width:36px;height:36px;border-radius:11px;background:var(--surface);display:flex;align-items:center;justify-content:center;font-size:19px}
.quick-btn svg{width:19px;height:19px}
.tips-list{display:grid;gap:8px;margin-top:12px}
.tip{display:flex;align-items:center;gap:9px;padding:9px 11px;border-radius:9px;background:var(--surface-2);font-size:12px;color:var(--text-2)}
.tip b{color:var(--text)}

/* ---------- 账单列表 ---------- */
.filter-card{padding:14px 16px}
.filter-row{display:flex;gap:9px;flex-wrap:wrap;align-items:center}
.search-box{position:relative;flex:1;min-width:180px}
.search-box svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);width:16px;height:16px;color:var(--text-3)}
.search-box input{padding-left:34px}
.mini-select{width:auto;min-width:110px;padding:9px 10px;font-size:13px}
.filter-sum{display:flex;gap:18px;margin-top:12px;font-size:12px;color:var(--text-2);flex-wrap:wrap}
.filter-sum b{font-size:15px;color:var(--text)}
.date-group{font-size:12px;font-weight:700;color:var(--text-3);padding:14px 4px 7px;display:flex;justify-content:space-between}
.tx-item{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--line);border-radius:12px;
  padding:12px 14px;margin-bottom:8px;cursor:pointer;transition:.16s}
.tx-item:hover{border-color:var(--primary);box-shadow:var(--shadow);transform:translateX(2px)}
.tx-icon{width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:20px;background:var(--surface-2);flex:none}
.tx-main{flex:1;min-width:0}
.tx-title{font-weight:700;display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.tx-sub{font-size:11px;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
.tx-right{text-align:right;flex:none}
.tx-amount{font-weight:800;font-size:15px}
.tx-amount.expense{color:var(--red)} .tx-amount.income{color:var(--green)} .tx-amount.transfer{color:var(--blue)}
.tx-tag{font-size:10px;padding:1px 6px;border-radius:5px;background:var(--surface-2);color:var(--text-3);font-weight:600}
.tx-tag.warn{background:var(--red-soft);color:var(--red)}
.tx-tag.ok{background:var(--green-soft);color:var(--green)}
.pager{display:flex;justify-content:center;align-items:center;gap:12px;padding:16px;color:var(--text-2)}
.empty{text-align:center;padding:50px 20px;color:var(--text-3)}
.empty .e-icon{font-size:42px;margin-bottom:10px}
.cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.cal-cell{aspect-ratio:1;border-radius:10px;background:var(--surface-2);padding:6px;font-size:11px;display:flex;flex-direction:column;justify-content:space-between;cursor:pointer}
.cal-cell:hover{outline:2px solid var(--primary)}
.cal-cell .d{color:var(--text-3);font-weight:700}
.cal-cell .m{font-size:10px;font-weight:700}
.cal-head{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;text-align:center;font-size:11px;color:var(--text-3);margin-bottom:6px}

/* ---------- 统计 ---------- */
.stat-tabs{display:flex;gap:6px;overflow-x:auto;padding:4px 0 14px;scrollbar-width:none}
.stat-tabs::-webkit-scrollbar{display:none}
.stat-tabs button{padding:8px 14px;border-radius:20px;background:var(--surface);border:1px solid var(--line);white-space:nowrap;font-weight:600;color:var(--text-2)}
.stat-tabs button.active{background:var(--primary);color:#fff;border-color:var(--primary)}
.chart-box{width:100%;overflow:hidden}
.chart-box svg{width:100%;height:auto;display:block;stroke:none}
.legend{display:grid;gap:9px}
.legend-row{display:flex;align-items:center;gap:9px;font-size:13px}
.legend-dot{width:10px;height:10px;border-radius:3px;flex:none}
.legend-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.legend-val{font-weight:700}
.rank-row{display:flex;align-items:center;gap:10px;padding:9px 0;border-bottom:1px dashed var(--line)}
.rank-row:last-child{border-bottom:none}
.rank-no{width:22px;height:22px;border-radius:7px;background:var(--surface-2);display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;color:var(--text-3)}
.rank-row:first-child .rank-no{background:#fff2d9;color:#d98c00}
.rank-row:nth-child(2) .rank-no{background:#e9eef7;color:#6b7a96}
.rank-row:nth-child(3) .rank-no{background:#fbe6dc;color:#c4754a}
.rank-bar{height:6px;border-radius:6px;background:var(--primary);min-width:3px}
.report-words{display:grid;gap:10px}
.report-words p{margin:0;padding:13px 15px;background:var(--surface-2);border-radius:10px;line-height:1.8}
.kv-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
.kv{background:var(--surface-2);border-radius:11px;padding:13px}
.kv .k{font-size:12px;color:var(--text-3)} .kv .v{font-size:20px;font-weight:800;margin-top:3px}

/* ---------- 预算 / 账本 / 更多 ---------- */
.budget-row{padding:13px 0;border-bottom:1px dashed var(--line)}
.budget-row:last-child{border-bottom:none}
.budget-top{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:8px}
.budget-name{font-weight:700;display:flex;align-items:center;gap:8px}
.budget-num{font-size:12px;color:var(--text-2)}
.book-item{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;border:1px solid var(--line);margin-bottom:9px;cursor:pointer}
.book-item.active{border-color:var(--primary);background:var(--primary-soft)}
.book-icon{width:42px;height:42px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:22px;background:var(--surface-2)}
.member-row{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px dashed var(--line)}
.member-row:last-child{border-bottom:none}
.join-box{display:flex;gap:8px;margin-top:14px}
.join-box input{flex:1;background:var(--surface-2);border:1px solid var(--line);border-radius:9px;padding:9px 11px}
.code-chip{display:inline-flex;align-items:center;gap:6px;background:var(--primary-soft);color:var(--primary);padding:5px 10px;border-radius:8px;font-weight:700;font-size:12px;margin:4px 6px 0 0}
.more-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:16px}
.more-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow)}
.more-card h3{margin:0 0 12px;font-size:15px;display:flex;align-items:center;gap:8px}
.more-actions{display:grid;gap:8px}
.more-action{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;background:var(--surface-2);font-weight:600;font-size:13px;text-align:left;width:100%}
.more-action:hover{background:var(--primary-soft);color:var(--primary)}
.more-action .a-icon{width:30px;height:30px;border-radius:9px;background:var(--surface);display:flex;align-items:center;justify-content:center;font-size:15px}
.acct-row{display:flex;align-items:center;gap:10px;padding:9px 0;border-bottom:1px dashed var(--line);font-size:13px}
.acct-row:last-child{border-bottom:none}
.acct-row .bal{margin-left:auto;font-weight:700}
.toggle{display:flex;align-items:center;justify-content:space-between;padding:11px 0;border-bottom:1px dashed var(--line);font-size:13px}
.toggle:last-child{border-bottom:none}
.switch{width:42px;height:24px;border-radius:20px;background:var(--surface-3);position:relative;transition:.2s;flex:none}
.switch.on{background:var(--primary)}
.switch::after{content:"";position:absolute;left:3px;top:3px;width:18px;height:18px;border-radius:50%;background:#fff;transition:.2s}
.switch.on::after{left:21px}

/* ---------- 记账抽屉 ---------- */
.sheet-mask{position:fixed;inset:0;background:rgba(12,20,38,.45);z-index:40;backdrop-filter:blur(2px)}
.record-sheet{position:fixed;z-index:41;background:var(--surface);display:flex;flex-direction:column;
  right:0;top:0;bottom:0;width:430px;max-width:100%;box-shadow:var(--shadow-lg);overflow-y:auto}
.sheet-handle{display:none}
.sheet-head{display:flex;align-items:center;justify-content:space-between;padding:16px 18px 10px;position:sticky;top:0;background:var(--surface);z-index:2}
.type-switch{display:flex;background:var(--surface-2);border-radius:10px;padding:3px;gap:2px}
.type-switch button{padding:7px 16px;border-radius:8px;font-weight:700;color:var(--text-2)}
.type-switch button.active{background:var(--surface);color:var(--primary);box-shadow:var(--shadow)}
.smart-row{display:flex;align-items:center;gap:7px;margin:0 18px 12px;padding:7px 8px 7px 11px;border-radius:11px;background:var(--primary-soft)}
.smart-icon{color:var(--primary);display:flex}
.smart-row input{flex:1;min-width:0;background:transparent;border:none;font-size:12px;color:var(--text)}
.smart-row input::placeholder{color:var(--text-3)}
.mic-btn{background:var(--surface);width:30px;height:30px}
.mic-btn.listening{background:var(--red);color:#fff;animation:pulse 1s infinite}
@keyframes pulse{50%{opacity:.55}}
.template-chips{display:flex;gap:7px;overflow-x:auto;padding:0 18px 12px;scrollbar-width:none}
.template-chips::-webkit-scrollbar{display:none}
.tpl-chip{flex:none;padding:6px 11px;border-radius:20px;background:var(--surface-2);font-size:12px;font-weight:600;white-space:nowrap}
.tpl-chip:hover{background:var(--primary-soft);color:var(--primary)}
.amount-row{display:flex;align-items:baseline;gap:8px;padding:6px 18px 16px;border-bottom:1px solid var(--line)}
.currency{font-size:22px;font-weight:700;color:var(--text-3)}
.amount-input{flex:1;min-width:0;background:transparent;border:none;font-size:40px;font-weight:800;letter-spacing:-1px;padding:0}
.amount-input::placeholder{color:var(--text-3);opacity:.45}
.amount-source{font-size:11px;color:var(--text-3);white-space:nowrap}
.rec-section{padding:14px 18px;border-bottom:1px solid var(--line)}
.rec-label{font-size:12px;font-weight:700;color:var(--text-2);margin-bottom:10px}
.cat-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:7px}
.cat-item{display:flex;flex-direction:column;align-items:center;gap:4px;padding:8px 2px;border-radius:10px;font-size:11px;transition:.15s;white-space:nowrap;overflow:hidden}
.cat-item:hover{background:var(--surface-2)}
.cat-item.selected{background:var(--primary-soft);color:var(--primary);font-weight:700}
.cat-item .ci{width:36px;height:36px;border-radius:12px;background:var(--surface-2);display:flex;align-items:center;justify-content:center;font-size:19px}
.cat-item.selected .ci{background:var(--surface)}
.sub-cats{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.sub-chip{padding:5px 10px;border-radius:16px;background:var(--surface-2);font-size:11px}
.sub-chip.selected{background:var(--primary);color:#fff}
.form-row{display:flex;gap:10px;margin-bottom:10px}
.form-row:last-child{margin-bottom:0}
.form-row.two>*{flex:1;min-width:0}
.field{display:grid;gap:5px;flex:1}
.field>span{font-size:11px;font-weight:600;color:var(--text-3)}
.form-control{padding:9px 10px;font-size:13px}
.toggles{flex-wrap:wrap;align-items:center;gap:14px}
.chk{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}
.chk input{accent-color:var(--primary);width:15px;height:15px}
.aa-members{display:grid;gap:7px}
.aa-member{display:flex;align-items:center;gap:8px;font-size:12px}
.aa-member input{width:90px;background:var(--surface-2);border:1px solid var(--line);border-radius:8px;padding:6px 8px}
.photo-preview{max-width:150px;max-height:150px;border-radius:10px;border:1px solid var(--line)}
.sheet-foot{padding:14px 18px 22px;position:sticky;bottom:0;background:var(--surface);border-top:1px solid var(--line)}
.keypad{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-bottom:12px}
.keypad button{padding:9px;border-radius:9px;background:var(--surface-2);font-weight:700;font-size:15px}
.keypad button:active{background:var(--primary-soft)}
.keypad .key-ok{background:var(--primary-soft);color:var(--primary)}
#recDelete{margin-bottom:10px;width:100%}

/* ---------- 弹窗 / 提示 ---------- */
.modal{position:fixed;inset:0;z-index:60;background:rgba(12,20,38,.5);display:flex;align-items:center;justify-content:center;padding:18px;backdrop-filter:blur(2px)}
.modal-card{background:var(--surface);border-radius:18px;width:100%;max-width:520px;max-height:88vh;display:flex;flex-direction:column;box-shadow:var(--shadow-lg)}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line)}
.modal-head h3{margin:0;font-size:16px}
.modal-body{padding:18px 20px 22px;overflow-y:auto}
.modal-body label{display:grid;gap:6px;font-size:12px;font-weight:600;color:var(--text-2);margin-bottom:12px}
.modal-body input,.modal-body select,.modal-body textarea{background:var(--surface-2);border:1px solid var(--line);border-radius:9px;padding:9px 11px;width:100%}
.modal-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap}
.toast{position:fixed;left:50%;bottom:34px;transform:translate(-50%,20px);background:#1d2739;color:#fff;padding:11px 20px;border-radius:11px;
  font-size:13px;font-weight:600;z-index:100;opacity:0;pointer-events:none;transition:.25s;box-shadow:var(--shadow-lg);max-width:88vw;text-align:center}
.toast.show{opacity:1;transform:translate(-50%,0)}
.toast.err{background:var(--red)}
.loading{position:fixed;inset:0;z-index:90;background:color-mix(in srgb,var(--bg) 65%,transparent);display:none;align-items:center;justify-content:center}
.loading.show{display:flex}
.spinner{width:34px;height:34px;border:3px solid var(--surface-3);border-top-color:var(--primary);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- 响应式 ---------- */
@media (max-width:1180px){
  .grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
  .stat-card .v{font-size:24px}
}
@media (max-width:1023px){
  :root{--sidebar:66px}
  .side-logo span:last-child,.side-nav button span,.side-tip,.side-user span:last-child{display:none}
  .side-logo,.side-nav button,.side-user{justify-content:center}
  .side-nav button{padding:12px}
  .sidebar{padding:16px 8px}
  .grid-2{grid-template-columns:1fr}
  .grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media (max-width:767px){
  :root{--topbar:56px}
  .auth-view{gap:26px;padding:24px 16px;flex-direction:column}
  .auth-brand{max-width:100%}
  .auth-logo{width:48px;height:48px;font-size:24px;border-radius:14px}
  .auth-brand h1{font-size:30px;margin-top:12px}
  .auth-brand>p{font-size:14px;margin-bottom:14px}
  .auth-points{gap:7px}
  .auth-points li{font-size:12px}
  .auth-card{padding:22px;border-radius:18px}
  .sidebar{display:none}
  .main{margin-left:0}
  .topbar{padding:0 12px}
  .book-select{min-width:110px;font-size:13px;padding:6px 4px}
  .month-label{min-width:78px;font-size:12px}
  .top-add span{display:none}
  .top-add{padding:8px;width:34px;height:34px}
  .page-wrap{padding:14px 12px calc(84px + env(safe-area-inset-bottom))}
  .grid{gap:12px;margin-bottom:12px}
  .grid-2,.grid-3{grid-template-columns:1fr}
  .grid-3{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .stat-card{padding:12px 10px;border-radius:13px}
  .stat-card .t{font-size:11px;gap:2px}
  .stat-card .v{font-size:18px;margin:5px 0 2px}
  .stat-card .s{font-size:10px;line-height:1.4}
  .stat-card::after{width:56px;height:56px}
  .card{padding:14px;border-radius:14px;margin-bottom:12px}
  .quick-grid{grid-template-columns:repeat(3,1fr);gap:7px}
  .quick-btn{font-size:11px;padding:9px 3px}
  .quick-btn .q-icon{width:32px;height:32px;font-size:17px}
  .tabbar{display:flex;position:fixed;left:0;right:0;bottom:0;height:calc(62px + env(safe-area-inset-bottom));
    padding-bottom:env(safe-area-inset-bottom);background:var(--surface);border-top:1px solid var(--line);z-index:25;align-items:stretch}
  .tabbar>button{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:var(--text-3);font-size:10px;font-weight:600}
  .tabbar>button.active{color:var(--primary)}
  .tabbar>button svg{width:20px;height:20px}
  .tabbar .tab-add{flex:none;width:56px;position:relative}
  .tabbar .tab-add svg{width:24px;height:24px;color:#fff}
  .tabbar .tab-add::before{content:"";position:absolute;top:-16px;width:48px;height:48px;border-radius:50%;background:var(--primary);
    box-shadow:0 6px 18px rgba(79,124,255,.42);z-index:-1}
  .tabbar .tab-add{z-index:1}
  .tabbar .tab-add::before{z-index:-1}
  .filter-row{gap:7px}
  .search-box{min-width:100%}
  .mini-select{flex:1;min-width:calc(50% - 6px)}
  #billExport{flex:1}
  .more-grid{grid-template-columns:1fr}
  .record-sheet{left:0;right:0;top:auto;bottom:0;width:100%;height:92vh;border-radius:20px 20px 0 0;box-shadow:var(--shadow-lg)}
  .sheet-handle{display:block;width:38px;height:4px;border-radius:4px;background:var(--surface-3);margin:8px auto 0}
  .sheet-head{padding:8px 14px}
  .smart-row,.template-chips,.amount-row,.rec-section,.sheet-foot{padding-left:14px;padding-right:14px}
  .smart-row,.template-chips{margin-left:14px;margin-right:14px}
  .cat-grid{grid-template-columns:repeat(5,1fr);gap:4px}
  .cat-item .ci{width:33px;height:33px;font-size:17px}
  .cat-item{font-size:10px}
  .amount-input{font-size:34px}
  .form-row.two{flex-direction:column;gap:9px}
  .keypad{display:grid}
  .sheet-foot{padding-bottom:calc(16px + env(safe-area-inset-bottom))}
  .modal{align-items:flex-end;padding:0}
  .modal-card{max-width:100%;border-radius:18px 18px 0 0;max-height:90vh}
  .toast{bottom:calc(76px + env(safe-area-inset-bottom))}
}
@media (min-width:768px){
  .keypad{display:none}
}
@media print{
  .sidebar,.tabbar,.topbar,.fab{display:none !important}
  .main{margin:0}
  .card{box-shadow:none;break-inside:avoid}
}
