:root{
  --bg:#f2f4f2; --card:#fff; --ink:#1c2420; --mute:#6b7771; --line:#e4e9e5; --fill:#e9eeea;
  --accent:#2f7d5b; --accent-soft:#dff0e7; --danger:#c0392b;
  --protein:#d9622b; --carb:#d9a32b; --fat:#7a5bd0; --water:#2b8fd9; --sleep:#5a63d6; --work:#2f7d5b;
  --deep:#35399b; --core:#3478f6; --rem:#58a9e0; --awake:#f0806e;
}
@media (prefers-color-scheme:dark){
  :root{--bg:#121714; --card:#1b221e; --ink:#e7eee9; --mute:#93a199; --line:#2a342e; --fill:#2a342e; --accent:#4fb988; --accent-soft:#1e3a2d; --danger:#ef6a5b;}
}
*{box-sizing:border-box;margin:0;padding:0}
body{font:14px/1.5 -apple-system,"PingFang SC","Helvetica Neue",sans-serif;background:var(--bg);color:var(--ink)}
button,input,select{font:inherit;color:inherit}
button{cursor:pointer}
.shell{display:flex;min-height:100vh}
.side{width:176px;flex:none;background:var(--card);border-right:1px solid var(--line);padding:18px 12px;position:sticky;top:0;height:100vh}
.side h1{font-size:16px;margin:0 8px 16px}
.side a{display:block;padding:8px 10px;border-radius:8px;color:var(--mute);text-decoration:none;margin-bottom:2px}
.side a.on{background:var(--accent-soft);color:var(--accent);font-weight:600}
.main{flex:1;min-width:0;padding:20px 24px 48px;max-width:1600px}
.head{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:14px}
.head h2{font-size:20px}
.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:12px}
.grid.two{grid-template-columns:repeat(2,1fr)}
.card{background:var(--card);border-radius:14px;padding:14px 16px;margin-bottom:12px}
.grid .card{margin-bottom:0}
.card h3{font-size:12px;font-weight:600;color:var(--mute);margin-bottom:8px;display:flex;justify-content:space-between;gap:8px}
.big{font-size:28px;font-weight:700;line-height:1.2}
.big small{font-size:13px;color:var(--mute);font-weight:500}
.mute{color:var(--mute);font-size:12px}
.bar{height:8px;border-radius:4px;background:var(--fill);overflow:hidden;margin-top:8px}
.bar i{display:block;height:100%;border-radius:4px}
.row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--line)}
.row:first-child{border-top:0}
.row .n{color:var(--mute);font-size:12px;text-align:right}
.btn{border:0;border-radius:8px;padding:7px 14px;background:var(--accent-soft);color:var(--accent);font-weight:600}
.btn.primary{background:var(--accent);color:#fff}
.btn.ghost{background:none;color:var(--mute);font-weight:400;padding:4px 8px}
.btn.danger{background:none;color:var(--danger);font-weight:400;padding:4px 8px}
.btn:disabled{opacity:.5;cursor:default}
.field{display:flex;flex-direction:column;gap:3px;margin-bottom:10px}
.field label{font-size:12px;color:var(--mute)}
input,select{border:1px solid var(--line);background:var(--bg);border-radius:8px;padding:7px 10px;min-width:0}
input:focus,select:focus{outline:2px solid var(--accent);outline-offset:-1px}
.inline{display:flex;gap:8px;align-items:flex-end;flex-wrap:wrap}
.inline .field{margin-bottom:0}
.tabs{display:inline-flex;background:var(--fill);border-radius:8px;padding:2px;margin-bottom:10px}
.tabs button{border:0;background:none;padding:5px 14px;border-radius:6px;color:var(--mute)}
.tabs button.on{background:var(--card);color:var(--ink);font-weight:600}
.pick{max-height:200px;overflow:auto;border:1px solid var(--line);border-radius:8px;margin-bottom:10px}
.pick button{display:flex;justify-content:space-between;width:100%;text-align:left;border:0;background:none;padding:7px 10px;border-top:1px solid var(--line);gap:10px}
.pick button:first-child{border-top:0}
.pick button.on{background:var(--accent-soft)}
table{width:100%;border-collapse:collapse;font-size:13px}
th{text-align:left;color:var(--mute);font-weight:600;padding:6px 6px;border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:7px 6px;border-bottom:1px solid var(--line)}
td.r,th.r{text-align:right}
.tablewrap{overflow-x:auto}
.tag{font-size:11px;padding:2px 7px;border-radius:6px;background:var(--accent-soft);color:var(--accent);font-weight:600}
.tag.grey{background:var(--fill);color:var(--mute)}
.stages{display:flex;height:14px;border-radius:7px;overflow:hidden;gap:2px;margin:8px 0}
.legend{display:flex;gap:12px;flex-wrap:wrap;font-size:12px;color:var(--mute)}
.legend span::before{content:"";display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:4px;background:var(--c)}
.chart{width:100%;height:auto;display:block}
.chart text{font-size:10px;fill:var(--mute)}
.chart .grid{stroke:var(--line)}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:9px 16px;border-radius:10px;z-index:9;max-width:90vw}
.login{max-width:340px;margin:18vh auto 0;padding:0 16px}
.login h1{font-size:22px;margin-bottom:16px}
.err{color:var(--danger);font-size:13px;margin-top:8px;min-height:18px}
.sets .field{margin-bottom:6px}
@media(max-width:820px){
  .shell{flex-direction:column}
  .side{width:auto;height:auto;position:static;border-right:0;border-bottom:1px solid var(--line);display:flex;gap:4px;flex-wrap:wrap;align-items:center;padding:10px 12px}
  .side h1{width:100%;margin:0 4px 4px}
  .side a{margin:0}
  .main{padding:14px 14px 40px}
  .grid{grid-template-columns:repeat(2,1fr)}
}
@media(max-width:520px){.grid.two{grid-template-columns:1fr}.big{font-size:24px}}

.echart{width:100%}
.insights{padding-left:18px}
.insights li{margin:5px 0}
tr.clickable{cursor:pointer}
tr.clickable:hover td,tr.sel td{background:var(--accent-soft)}
