:root{
  --bg:#eaf4ff; --bg2:#dfeefb; --card:#ffffff; --card2:#f3f9ff;
  --line:#c8ddf2; --txt:#1e293b; --sub:#5c6b7e; --sub2:#8fa0b3;
  --blue:#3b82f6; --purple:#8b5cf6; --green:#10b981; --red:#ef4444; --orange:#f59e0b;
  --shadow:0 8px 24px rgba(59,130,246,.12);
}
*{box-sizing:border-box;}
[hidden]{display:none !important;}
html,body{margin:0;padding:0;}
button{font-family:inherit; -webkit-tap-highlight-color:transparent; touch-action:manipulation;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
  background:var(--bg); color:var(--txt); font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
.app{display:flex; min-height:100vh;}
/* sidebar */
.sidebar{width:210px; flex:0 0 210px; background:var(--bg2); border-right:1px solid var(--line); padding:18px 14px; display:flex; flex-direction:column;}
.brand{display:flex; align-items:center; gap:10px; margin-bottom:22px;}
.logo{font-size:26px;}
.brand-name{font-weight:700; font-size:16px;}
.brand-sub{font-size:11px; color:var(--sub); letter-spacing:1px;}
.tabs{display:flex; flex-direction:column; gap:8px;}
.tab{text-align:left; background:transparent; border:1px solid transparent; color:var(--sub); padding:11px 14px; border-radius:10px; cursor:pointer; font-size:14px; transition:.15s;}
.tab:hover{background:var(--card); color:var(--txt);}
.tab.active{background:linear-gradient(135deg,var(--blue),var(--purple)); color:#fff; border-color:transparent; box-shadow:0 4px 14px rgba(59,130,246,.35);}
.side-foot{margin-top:auto; display:flex; flex-direction:column; gap:8px;}
.side-title{font-size:11px; color:var(--sub2); margin:6px 2px 2px; letter-spacing:1px;}
.ghost-btn{background:var(--card); border:1px solid var(--line); color:var(--sub); padding:9px 12px; border-radius:9px; cursor:pointer; font-size:13px; transition:.15s; text-align:left;}
.ghost-btn:hover{color:var(--txt); border-color:var(--blue);}
.ghost-btn.danger:hover{color:var(--red); border-color:var(--red);}
/* content */
.content{flex:1; padding:22px 26px; overflow:auto;}
.panel{display:none;}
.panel.active{display:block; animation:fade .2s ease;}
@keyframes fade{from{opacity:0; transform:translateY(6px);}to{opacity:1; transform:none;}}
.panel-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:18px;}
.panel-head h2{margin:0; font-size:20px;}
.primary-btn{background:linear-gradient(135deg,var(--blue),var(--purple)); color:#fff; border:none; padding:9px 16px; border-radius:9px; cursor:pointer; font-size:13px; font-weight:600; box-shadow:0 4px 14px rgba(59,130,246,.3);}
.primary-btn:hover{filter:brightness(1.08);}
.secondary-btn{background:var(--card); border:1px solid var(--line); color:var(--txt); padding:9px 14px; border-radius:9px; cursor:pointer; font-size:13px;}
.secondary-btn:hover{border-color:var(--blue);}
.finance-actions{display:flex; gap:8px;}
/* schedule */
.schedule-grid{display:grid; grid-template-columns:1.4fr 1fr; gap:18px;}
.calendar-card,.day-card{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow);}
.cal-nav{display:flex; align-items:center; gap:8px; margin-bottom:12px;}
.cal-nav button{background:var(--card2); border:1px solid var(--line); color:var(--txt); width:32px; height:32px; border-radius:8px; cursor:pointer; font-size:16px;}
.cal-nav button:hover{border-color:var(--blue);}
.today-btn{width:auto !important; padding:0 12px; font-size:13px;}
.cal-title{font-weight:700; font-size:16px; flex:1; text-align:center;}
.cal-weekdays{display:grid; grid-template-columns:repeat(7,1fr); gap:4px; margin-bottom:6px;}
.cal-weekdays span{text-align:center; font-size:12px; color:var(--sub);}
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:4px;}
.cal-cell{position:relative; min-height:54px; background:var(--bg2); border:1px solid var(--line); border-radius:8px; padding:6px; cursor:pointer; transition:.12s; display:flex; flex-direction:column;}
.cal-cell:hover{border-color:var(--blue);}
.cal-cell.muted{opacity:.4;}
.cal-cell.today{border-color:var(--orange);}
.cal-cell.selected{background:var(--card2); border-color:var(--blue); box-shadow:inset 0 0 0 1px var(--blue);}
.cal-num{font-size:13px; font-weight:600;}
.cal-dots{margin-top:auto; display:flex; align-items:center; gap:4px;}
.cal-dots .dot{width:6px; height:6px; border-radius:50%; background:var(--blue);}
.cal-dots .cnt{font-size:11px; color:var(--sub);}
.day-title{font-weight:700; margin-bottom:12px; font-size:15px;}
.day-events{display:flex; flex-direction:column; gap:10px; max-height:440px; overflow:auto;}
.event-row{display:flex; gap:10px; align-items:flex-start; background:var(--bg2); border:1px solid var(--line); border-left:3px solid var(--blue); border-radius:10px; padding:10px 12px;}
.event-row.cat-work{border-left-color:var(--blue);}
.event-row.cat-life{border-left-color:var(--purple);}
.event-row.cat-health{border-left-color:var(--green);}
.event-row.cat-important{border-left-color:var(--red);}
.event-row.cat-other{border-left-color:var(--sub2);}
.event-row.done{opacity:.55;}
.event-row.done .ev-title{text-decoration:line-through;}
.ev-check{margin-top:2px;}
.ev-main{flex:1; min-width:0;}
.ev-title{font-weight:600; font-size:14px;}
.ev-meta{font-size:12px; color:var(--sub); margin-top:3px; display:flex; flex-wrap:wrap; gap:6px; align-items:center;}
.tag{display:inline-block; padding:1px 8px; border-radius:20px; font-size:11px; background:var(--card2);}
.tag.cat-work{color:var(--blue);} .tag.cat-life{color:var(--purple);} .tag.cat-health{color:var(--green);} .tag.cat-important{color:var(--red);} .tag.cat-other{color:var(--sub);}
.repeat-badge{font-size:10px; color:var(--orange); border:1px solid var(--orange); border-radius:10px; padding:0 6px;}
.ev-actions{display:flex; flex-direction:column; gap:5px;}
.mini{background:var(--card2); border:1px solid var(--line); color:var(--sub); padding:3px 9px; border-radius:6px; cursor:pointer; font-size:12px;}
.mini:hover{color:var(--txt); border-color:var(--blue);}
.mini.danger:hover{color:var(--red); border-color:var(--red);}
.empty{color:var(--sub); font-size:13px; text-align:center; padding:24px 0;}
.stats-card{margin-top:18px; background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow); display:flex; flex-wrap:wrap; gap:14px; align-items:center;}
.stat{display:flex; flex-direction:column;}
.stat-num{font-size:24px; font-weight:800;}
.stat-lbl{font-size:12px; color:var(--sub);}
.stat.cat{display:flex; flex-direction:row; align-items:center; gap:6px; font-size:13px; color:var(--sub);}
.swatch{width:10px; height:10px; border-radius:3px;}
/* finance */
.fin-overview{display:grid; grid-template-columns:repeat(6,1fr); gap:12px; margin-bottom:18px;}
.ov-card{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:14px; box-shadow:var(--shadow);}
.ov-card.net{background:linear-gradient(135deg,var(--card2),#dbeafe); border-color:var(--blue);}
.ov-lbl{font-size:12px; color:var(--sub);}
.ov-num{font-size:20px; font-weight:800; margin-top:4px;}
.ov-num.pos{color:var(--green);} .ov-num.neg{color:var(--red);}
.fin-body{display:grid; grid-template-columns:1fr 1.1fr; gap:18px;}
.sub-title{font-size:13px; color:var(--sub); margin:4px 2px 10px; font-weight:600;}
.account-list,.tx-list{display:flex; flex-direction:column; gap:10px; margin-bottom:18px;}
.acc-card{background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px; display:flex; flex-direction:column; gap:6px;}
.acc-card.debt{border-left:3px solid var(--red);}
.acc-top{display:flex; justify-content:space-between; align-items:center;}
.acc-name{font-weight:600;}
.acc-type{font-size:11px; color:var(--sub); background:var(--card2); padding:2px 8px; border-radius:10px;}
.acc-bal{font-size:18px; font-weight:700;}
.acc-card.debt .acc-bal{color:var(--red);}
.tx-row{display:flex; align-items:center; gap:10px; background:var(--card); border:1px solid var(--line); border-radius:10px; padding:9px 12px;}
.tx-info{flex:1; min-width:0;}
.tx-cat{font-weight:600;}
.tx-sub{font-size:12px; color:var(--sub);}
.tx-amt{font-weight:700; font-size:15px;}
.tx-amt.income{color:var(--green);} .tx-amt.expense{color:var(--red);}
.chart-card{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow); margin-bottom:18px;}
.chart-title{font-size:13px; color:var(--sub); margin-bottom:12px; font-weight:600;}
.pie-chart,.trend-chart{display:flex; flex-direction:column; align-items:center; gap:10px;}
.legend{display:flex; flex-wrap:wrap; gap:8px 16px; justify-content:center; font-size:12px; color:var(--sub);}
.legend-item{display:flex; align-items:center; gap:5px;}
.legend-dot{width:10px; height:10px; border-radius:3px; display:inline-block;}
.budget-row{display:flex; justify-content:space-between; font-size:13px; margin-bottom:8px;}
.budget-row .neg{color:var(--red);} .budget-row .pos{color:var(--green);}
.progress{height:10px; background:var(--bg2); border-radius:6px; overflow:hidden; border:1px solid var(--line);}
.progress-bar{height:100%; background:linear-gradient(90deg,var(--green),var(--blue)); transition:.3s;}
.progress-bar.over{background:linear-gradient(90deg,var(--orange),var(--red));}
.warn{color:var(--red); font-size:12px; margin-top:8px;}
/* checkin */
.checkin-date{font-size:13px; color:var(--sub); font-weight:600;}
.checkin-progress{display:flex; align-items:center; gap:18px; background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px 18px; box-shadow:var(--shadow); margin-bottom:18px;}
.cp-info{display:flex; align-items:baseline; gap:8px;}
.cp-num{font-size:30px; font-weight:800; color:var(--blue);}
.cp-num span{font-size:16px; color:var(--sub);}
.cp-lbl{font-size:13px; color:var(--sub);}
.cp-bar{flex:1; height:12px; background:var(--bg2); border-radius:8px; overflow:hidden; border:1px solid var(--line);}
.cp-fill{height:100%; width:0; background:linear-gradient(90deg,var(--blue),var(--purple)); transition:.35s;}
.checkin-list{display:grid; grid-template-columns:repeat(2,1fr); gap:12px; margin-bottom:20px;}
.habit-row{display:flex; align-items:center; gap:12px; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:14px 16px; cursor:pointer; transition:.15s; box-shadow:var(--shadow);}
.habit-row:hover{border-color:var(--blue);}
.habit-row.done{border-color:var(--green); background:linear-gradient(135deg,var(--card),#eafaf2);}
.habit-icon{font-size:24px; width:42px; height:42px; display:flex; align-items:center; justify-content:center; background:var(--bg2); border-radius:10px;}
.habit-row.done .habit-icon{background:#e3f7ee;}
.habit-name{flex:1; font-weight:600; font-size:15px;}
.habit-row.done .habit-name{color:var(--green);}
.habit-check{width:24px; height:24px; border-radius:50%; border:2px solid var(--line); display:flex; align-items:center; justify-content:center; color:#fff; font-size:14px; font-weight:700;}
.habit-row.done .habit-check{background:var(--green); border-color:var(--green);}
.checkin-week{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow);}
.week-grid{display:flex; align-items:flex-end; justify-content:space-between; gap:10px; height:120px; margin-top:6px;}
.week-cell{flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100%; justify-content:flex-end;}
.week-bar-wrap{flex:1; width:100%; display:flex; align-items:flex-end; justify-content:center;}
.week-bar{width:60%; max-width:22px; min-height:3px; background:linear-gradient(180deg,var(--blue),var(--purple)); border-radius:6px 6px 0 0; transition:.3s;}
.week-day{font-size:11px; color:var(--sub);}
.week-cell.today .week-day{color:var(--blue); font-weight:700;}
.weight-trend{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow); margin-top:18px;}
.weight-chart{display:flex; flex-direction:column; align-items:center; gap:10px;}
.weight-chart svg{width:100%; height:auto;}
.habit-meta{font-size:11px; color:var(--sub); margin-top:2px; font-weight:400;}
@media (max-width: 860px){
  .checkin-list{grid-template-columns:1fr;}
}
.modal-overlay{position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,.6); display:flex; align-items:center; justify-content:center; z-index:50; padding:16px;}
.modal{background:var(--card); border:1px solid var(--line); border-radius:16px; width:100%; max-width:420px; box-shadow:var(--shadow); position:relative; z-index:51; pointer-events:auto;}
.modal-head{display:flex; justify-content:space-between; align-items:center; padding:16px 18px; border-bottom:1px solid var(--line);}
.modal-head h3{margin:0; font-size:16px;}
.modal-close{background:none; border:none; color:var(--sub); font-size:22px; cursor:pointer; line-height:1;}
.modal-body{padding:18px; display:flex; flex-direction:column; gap:12px; max-height:62vh; overflow:auto;}
.modal-body label{display:flex; flex-direction:column; gap:5px; font-size:13px; color:var(--sub);}
.modal-body input,.modal-body select,.modal-body textarea{
  background:var(--bg2); border:1px solid var(--line); color:var(--txt);
  padding:10px 12px; border-radius:8px; font-size:14px; font-family:inherit;
  -webkit-appearance:none; appearance:none;
}
.modal-body select option{background:var(--card); color:var(--txt);}
.modal-body textarea{resize:vertical; min-height:70px;}
.modal-body input:focus,.modal-body select:focus,.modal-body textarea:focus{outline:none; border-color:var(--blue); box-shadow:0 0 0 2px rgba(59,130,246,.25);}
.modal-body .row{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
.modal-foot{padding:14px 18px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px;}
/* toast */
.toast{position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--card2); border:1px solid var(--line); color:var(--txt); padding:10px 18px; border-radius:10px; font-size:13px; box-shadow:var(--shadow); z-index:60;}
/* responsive H5 */
@media (max-width: 860px){
  .app{flex-direction:column;}
  .sidebar{width:100%; flex:none; flex-direction:row; align-items:center; padding:10px 12px; gap:10px; overflow-x:auto;}
  .brand{margin-bottom:0;}
  .tabs{flex-direction:row; margin:0;}
  .tab{padding:8px 12px;}
  .side-foot{margin-top:0; flex-direction:row; margin-left:auto;}
  .side-title{display:none;}
  .content{padding:14px;}
  .schedule-grid,.fin-body{grid-template-columns:1fr;}
  .fin-overview{grid-template-columns:repeat(2,1fr);}
}
/* auth */
.auth{position:fixed; inset:0; z-index:100; display:flex; align-items:center; justify-content:center; padding:18px; background:linear-gradient(135deg,#eaf4ff,#dbeafe 60%,#eef2ff);}
.auth-card{width:100%; max-width:380px; background:var(--card); border:1px solid var(--line); border-radius:18px; padding:26px 24px; box-shadow:0 18px 50px rgba(59,130,246,.18);}
.auth-brand{display:flex; align-items:center; gap:10px; justify-content:center; margin-bottom:18px;}
.auth-brand .logo{font-size:30px;}
.auth-brand .brand-name{font-weight:800; font-size:20px;}
.auth-view{animation:fade .2s ease;}
.auth-form{display:flex; flex-direction:column; gap:13px;}
.auth-switch{margin-top:16px; text-align:center; font-size:13px; color:var(--sub);}
.link-btn{background:none; border:none; color:var(--blue); font-size:13px; font-weight:600; cursor:pointer; padding:0; text-decoration:underline;}
.auth-form label{display:flex; flex-direction:column; gap:6px; font-size:13px; color:var(--sub);}
.auth-form input{background:var(--bg2); border:1px solid var(--line); color:var(--txt); padding:11px 13px; border-radius:9px; font-size:14px; font-family:inherit; -webkit-appearance:none; appearance:none;}
.auth-form input:focus{outline:none; border-color:var(--blue); box-shadow:0 0 0 2px rgba(59,130,246,.22);}
.code-row{flex-direction:row; align-items:flex-end; gap:8px;}
.code-row input{flex:1;}
.code-btn{background:var(--card2); border:1px solid var(--line); color:var(--blue); padding:11px 12px; border-radius:9px; cursor:pointer; font-size:13px; white-space:nowrap; font-weight:600;}
.code-btn:disabled{color:var(--sub2); cursor:not-allowed;}
.auth-submit{margin-top:6px; background:linear-gradient(135deg,var(--blue),var(--purple)); color:#fff; border:none; padding:12px; border-radius:10px; cursor:pointer; font-size:15px; font-weight:700; box-shadow:0 6px 18px rgba(59,130,246,.3);}
.auth-submit:hover{filter:brightness(1.06);}
.auth-submit:disabled{opacity:.7; cursor:not-allowed; filter:grayscale(.2);}
.auth-hint{margin-top:14px; font-size:12px; color:var(--sub); text-align:center; min-height:18px; line-height:1.5;}
.auth-hint.ok{color:var(--green);}
.auth-hint.err{color:var(--red);}
