:root{
  --bg:#f5f8f8; --panel:#fff; --line:#e4ebec; --text:#16292c; --muted:#7a8d90;
  --brand:#0f766e; --brand-2:#14b8a6; --brand-soft:#e8f5f2;
  --danger:#dc2626; --warn:#d97706; --radius:14px;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
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:14px; line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;cursor:pointer;border:none;background:none;color:inherit;font-size:14px}
input,select{font-family:inherit;font-size:14px;color:inherit;outline:none}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:#cfdadb;border-radius:4px}
::-webkit-scrollbar-track{background:transparent}

.app{display:flex;height:100vh;overflow:hidden}

/* 侧栏 */
.sidebar{
  width:196px;flex-shrink:0;background:var(--panel);border-right:1px solid var(--line);
  display:flex;flex-direction:column;padding:18px 12px;
}
.logo{display:flex;align-items:center;gap:9px;padding:0 8px 20px;font-weight:600;font-size:16px;letter-spacing:.5px}
.logo .dot{width:10px;height:10px;border-radius:3px;background:linear-gradient(135deg,var(--brand),var(--brand-2))}
.nav{display:flex;flex-direction:column;gap:2px}
.nav button{
  display:flex;align-items:center;gap:9px;padding:9px 12px;border-radius:9px;
  color:var(--muted);text-align:left;transition:.15s;width:100%;
}
.nav button:hover{background:#f2f6f6;color:var(--text)}
.nav button.active{background:var(--brand-soft);color:var(--brand);font-weight:500}
.nav .ico{width:17px;text-align:center;font-size:15px}
.sidebar .foot{margin-top:auto;padding:10px 12px;font-size:11px;color:#a8b6b8;line-height:1.6}

/* 主区 */
.main{flex:1;display:flex;flex-direction:column;overflow:hidden}
.quickbar{
  background:var(--panel);border-bottom:1px solid var(--line);padding:14px 26px;
  display:flex;align-items:center;gap:12px;flex-wrap:wrap;
}
.qwrap{flex:1;min-width:320px;position:relative}
.qinput{
  width:100%;padding:11px 15px;border:1.5px solid var(--line);border-radius:11px;
  background:#fbfcfc;transition:.15s;
}
.qinput:focus{border-color:var(--brand-2);background:#fff;box-shadow:0 0 0 3px rgba(20,184,166,.1)}
.qinput::placeholder{color:#a9b8ba}
.preview{
  position:absolute;top:calc(100% + 6px);left:0;right:0;background:#fff;
  border:1px solid var(--line);border-radius:10px;padding:9px 14px;font-size:12.5px;
  color:var(--muted);display:none;z-index:50;box-shadow:0 8px 24px rgba(16,40,44,.09);
}
.preview.show{display:block}
.preview b{color:var(--brand);font-weight:600}
.preview .amt{color:var(--text);font-weight:600}
.btn{
  padding:10px 18px;border-radius:10px;background:var(--brand);color:#fff;font-weight:500;
  transition:.15s;white-space:nowrap;
}
.btn:hover{background:#0b5f59}
.btn.ghost{background:#f2f6f6;color:var(--text)}
.btn.ghost:hover{background:#e8eeee}
.btn.sm{padding:6px 12px;font-size:13px;border-radius:8px}
.btn.danger{background:#fef2f2;color:var(--danger)}
.btn.danger:hover{background:#fee2e2}

.content{flex:1;overflow-y:auto;padding:24px 26px 60px}
.page{max-width:1120px;margin:0 auto}
.page-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px;gap:16px;flex-wrap:wrap}
.page-title{font-size:19px;font-weight:600}
.sub{color:var(--muted);font-size:12.5px;margin-top:2px}

/* 卡片 */
.cards{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:16px 18px}
.card .label{font-size:12.5px;color:var(--muted);margin-bottom:6px}
.card .value{font-size:23px;font-weight:600;letter-spacing:-.3px}
.card .value small{font-size:13px;font-weight:400;color:var(--muted);margin-left:2px}
.card .hint{font-size:11.5px;color:var(--muted);margin-top:5px}
.card.accent{background:linear-gradient(135deg,#0f766e,#14b8a6);border:none;color:#fff}
.card.accent .label,.card.accent .value small,.card.accent .hint{color:rgba(255,255,255,.78)}

.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:18px 20px;margin-bottom:16px}
.panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px;gap:12px;flex-wrap:wrap}
.panel-title{font-size:14.5px;font-weight:600}

/* 表单元素 */
.field{display:flex;flex-direction:column;gap:6px}
.field label{font-size:12.5px;color:var(--muted)}
.inp,.sel{
  padding:8px 11px;border:1px solid var(--line);border-radius:9px;background:#fff;
  transition:.15s;
}
.inp:focus,.sel:focus{border-color:var(--brand-2);box-shadow:0 0 0 3px rgba(20,184,166,.1)}
.toolbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:16px}
.toolbar .sel,.toolbar .inp{min-width:110px}

/* 账单列表 */
.day-group{margin-bottom:16px}
.day-head{
  display:flex;justify-content:space-between;align-items:baseline;
  padding:0 4px 7px;font-size:12.5px;color:var(--muted);border-bottom:1px dashed var(--line);
}
.day-head b{color:var(--text);font-weight:600;font-size:13px}
.bill{cursor:pointer;
  display:flex;align-items:center;gap:12px;padding:11px 6px;border-bottom:1px solid #f2f5f5;
  transition:.12s;border-radius:8px;
}
.bill:hover{background:#fafcfc}
.bill:last-child{border-bottom:none}
.bill .emoji{
  width:34px;height:34px;border-radius:10px;background:#f3f7f7;display:flex;
  align-items:center;justify-content:center;font-size:16px;flex-shrink:0;
}
.bill .info{flex:1;min-width:0}
.bill .cat{font-size:13.5px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bill .note{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bill .money{font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
.bill .money.income{color:var(--brand)}
.bill .acts{display:flex;gap:4px;opacity:0;transition:.12s}
.bill:hover .acts{opacity:1}
.iconbtn{width:28px;height:28px;border-radius:7px;display:flex;align-items:center;justify-content:center;font-size:13px;color:var(--muted)}
.iconbtn:hover{background:#eef4f4;color:var(--text)}

/* 预算进度 */
.bar{height:8px;background:#eef3f3;border-radius:5px;overflow:hidden;margin-top:8px}
.bar > i{display:block;height:100%;border-radius:5px;background:linear-gradient(90deg,var(--brand),var(--brand-2));transition:width .3s}
.bar.warn > i{background:linear-gradient(90deg,#d97706,#f59e0b)}
.bar.over > i{background:linear-gradient(90deg,#dc2626,#ef4444)}
.budget-row{display:flex;align-items:center;gap:14px;padding:11px 0;border-bottom:1px solid #f2f5f5}
.budget-row:last-child{border-bottom:none}
.budget-row .nm{width:130px;flex-shrink:0;font-size:13.5px}
.budget-row .mid{flex:1;min-width:120px}
.budget-row .num{font-size:12.5px;color:var(--muted);font-variant-numeric:tabular-nums;text-align:right;width:150px;flex-shrink:0}
.budget-row .num.over{color:var(--danger);font-weight:600}

/* 图例 */
.legend{display:flex;flex-direction:column;gap:9px;flex:1;min-width:220px}
.legend-item{display:flex;align-items:center;gap:9px;font-size:13px}
.legend-item .sw{width:10px;height:10px;border-radius:3px;flex-shrink:0}
.legend-item .nm{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.legend-item .pc{color:var(--muted);font-variant-numeric:tabular-nums;width:52px;text-align:right}
.legend-item .vl{font-variant-numeric:tabular-nums;width:78px;text-align:right;font-weight:500}
.chart-flex{display:flex;gap:26px;align-items:center;flex-wrap:wrap}

/* 分类树 */
.cat-group{border:1px solid var(--line);border-radius:11px;margin-bottom:10px;overflow:hidden}
.cat-parent{display:flex;align-items:center;gap:10px;padding:11px 14px;background:#fbfcfc}
.cat-parent .emoji{font-size:16px}
.cat-parent .nm{font-weight:500;flex:1}
.cat-child{display:flex;align-items:center;gap:10px;padding:9px 14px 9px 46px;border-top:1px solid #f2f5f5;font-size:13.5px}
.cat-child .nm{flex:1;color:#3d5257}
.cat-child .emoji{font-size:14px;width:20px;text-align:center}
.kw{font-size:11.5px;color:#9fb0b2;max-width:280px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* 弹窗 */
.mask{position:fixed;inset:0;background:rgba(16,40,44,.35);display:none;align-items:center;justify-content:center;z-index:200;padding:20px}
.mask.show{display:flex}
.modal{background:#fff;border-radius:16px;width:100%;max-width:430px;padding:22px 24px;box-shadow:0 24px 60px rgba(16,40,44,.22);max-height:90vh;overflow-y:auto}
.modal h3{font-size:16px;margin-bottom:16px}
.modal .field{margin-bottom:13px}
.modal .row{display:flex;gap:10px}
.modal .row .field{flex:1}
.modal .actions{display:flex;gap:10px;justify-content:flex-end;margin-top:20px}
.seg{display:inline-flex;background:#f2f6f6;border-radius:9px;padding:3px;gap:2px}
.seg button{padding:6px 14px;border-radius:7px;font-size:13px;color:var(--muted)}
.seg button.on{background:#fff;color:var(--text);font-weight:500;box-shadow:0 1px 3px rgba(16,40,44,.09)}

.empty{text-align:center;padding:56px 20px;color:var(--muted);font-size:13.5px}
.empty .big{font-size:34px;margin-bottom:10px;opacity:.45}
.toast{
  position:fixed;bottom:28px;left:50%;transform:translateX(-50%) translateY(12px);
  background:#16292c;color:#fff;padding:10px 20px;border-radius:10px;font-size:13px;
  opacity:0;transition:.25s;pointer-events:none;z-index:300;
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.tip{font-size:12px;color:var(--muted);line-height:1.7}
.kbd{display:inline-block;padding:1px 6px;border:1px solid var(--line);border-bottom-width:2px;border-radius:5px;font-size:11.5px;background:#fafcfc;font-family:ui-monospace,monospace}
@media(max-width:900px){
  .sidebar{width:64px;padding:14px 8px}
  .logo span,.nav button span:not(.ico),.sidebar .foot{display:none}
  .cards{grid-template-columns:repeat(2,1fr)}
}

/* ---- 标签 / 报销 / 快捷勾选 ---- */
.tagchip{font-size:11.5px;background:#e8f1f2;color:#0f766e;border-radius:5px;padding:1px 7px;display:inline-block;line-height:1.7}
.tags{margin-top:3px}
.rebadge{font-size:11px;border-radius:5px;padding:1px 7px;margin-left:6px;display:inline-block;vertical-align:1px}
.rebadge.pending{background:#fef3c7;color:#b45309}
.rebadge.done{background:#d1fae5;color:#047857}
.rebadge.refund{background:#dbeafe;color:#1d4ed8}
.qbtn{border:1px solid #cfd8da;background:#fff;border-radius:999px;padding:2px 11px;font-size:12px;color:#465559}
.qbtn:hover{border-color:var(--brand)}
.qbtn.on{background:var(--brand);border-color:var(--brand);color:#fff}
.qbtn.off{background:#fef3c7;border-color:#f59e0b;color:#b45309}

/* ---- 快捷记账日期胶囊 ---- */
.qdate{border:1px solid #cfd8da;background:#f0faf7;color:#0f766e;border-radius:999px;padding:7px 14px;font-size:13px;white-space:nowrap}
.qdate:hover{border-color:var(--brand)}
.qdate.changed{background:#e0edff;border-color:#93c5fd;color:#1d4ed8}
.qdate-hint{color:#1d4ed8;font-size:12.5px;font-weight:600}

/* ---- 统计页收支日历 ---- */
.cal-sum{display:flex;gap:16px;font-size:13px;margin-bottom:10px;font-variant-numeric:tabular-nums}
.cal-sum .ci{color:#0f766e}.cal-sum .ce{color:#b45309}.cal-sum .cb{color:#465559}
.cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}
.calwd{text-align:center;font-size:11px;color:#9fb0b2;padding:2px 0}
.calcell{min-height:56px;border:1px solid #eef3f3;border-radius:7px;padding:4px 6px;font-size:11px;overflow:hidden}
.calcell:not(.muted){cursor:pointer}
.calcell:not(.muted):hover{border-color:#9fd0c8;background:#f4faf9}
.calcell.muted{background:#fafcfb;border-color:transparent}
.calcell .cal-d{font-size:11px;color:#7a8d90}
.calcell.hot{background:#f1efe8}
.calcell.hasinc{background:#e1f5ee}
.calcell.hasexp{background:#faece7}
.calcell.today{border-color:#0f766e}
.calcell.sel{border-color:#185fa5;border-width:1.5px;padding:3.5px 5.5px}
.cal-e{color:#b45309;margin-top:2px;white-space:nowrap;font-variant-numeric:tabular-nums}
.cal-i{color:#0f766e;white-space:nowrap;font-variant-numeric:tabular-nums}
.cal-p{color:#b45309;opacity:.85;white-space:nowrap}
.daybill{display:flex;align-items:center;gap:12px;padding:10px 6px;border-bottom:1px solid #f2f5f5;border-radius:8px}
.daybill:hover{background:#fafcfc}
.daybill:last-child{border-bottom:none}
.daybill .emoji{font-size:20px}
.daybill .info{flex:1;min-width:0}
.daybill .cat{font-size:13.5px}
.daybill .note{font-size:12px;color:#9fb0b2;margin-top:1px}
.daybill .money{font-size:14px;font-weight:600;white-space:nowrap}
.daybill .money.income{color:var(--brand)}

#backupFoot{cursor:pointer}
#backupFoot:hover{background:#f4faf9}
