:root {
  --bg: #0f1420;
  --bg2: #161d2e;
  --card: #1b2336;
  --card2: #222c44;
  --line: #2c3650;
  --text: #e7ecf5;
  --muted: #8b97b3;
  --brand: #2d6cdf;
  --brand2: #3f7ef0;
  --green: #2ec27e;
  --red: #e5604d;
  --amber: #e0a23b;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(0,0,0,.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- 登录 ---------- */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 50% -10%, #1c2740, var(--bg)); }
.login-card { width: 320px; max-width: 90vw; background: var(--card); padding: 30px 24px; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card input { width: 100%; margin: 10px 0; padding: 12px 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 15px; }
.btn-primary { width: 100%; margin-top: 8px; padding: 12px; border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn-primary:active { transform: translateY(1px); }

/* ---------- 布局 ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { height: 52px; display: flex; align-items: center; padding: 0 16px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.spacer { flex: 1; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }

.side-nav { display: none; }
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 16px; }
.bottom-nav { display: flex; height: 60px; background: var(--bg2); border-top: 1px solid var(--line); }
.bottom-nav button { flex: 1; background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; cursor: pointer; }
.bottom-nav button .ico { font-size: 20px; }
.bottom-nav button.active { color: var(--brand2); }

/* 桌面端：侧栏 + 隐藏底部 Tab；用 grid 保证顶栏横跨顶部、内容区顶格对齐 */
@media (min-width: 820px) {
  .app { display: grid; grid-template-columns: 190px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
  .topbar { grid-column: 1 / -1; grid-row: 1; }
  .side-nav { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; padding: 14px 10px; background: var(--bg2); border-right: 1px solid var(--line); }
  .side-nav button { text-align: left; background: none; border: 0; color: var(--muted); padding: 12px 14px; border-radius: 10px; font-size: 15px; cursor: pointer; margin-bottom: 4px; }
  .side-nav button.active { background: var(--card); color: var(--text); }
  .view { grid-column: 2; grid-row: 2; }
  .bottom-nav { display: none; }
}

/* ---------- 通用组件 ---------- */
.page-title { font-size: 19px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid.cols2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .grid.cols3 { grid-template-columns: repeat(2, 1fr); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.click { cursor: pointer; transition: border-color .15s, transform .05s; }
.card.click:active { transform: scale(.985); }
.card.click:hover { border-color: var(--brand); }
.stat { background: linear-gradient(135deg, var(--card), var(--card2)); }
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: rgba(46,194,126,.16); color: var(--green); }
.badge.red { background: rgba(229,96,77,.16); color: var(--red); }
.badge.amber { background: rgba(224,162,59,.16); color: var(--amber); }
.badge.gray { background: rgba(139,151,179,.16); color: var(--muted); }

.field { margin: 8px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-size: 15px; }
.btn { padding: 10px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--card2); color: var(--text); cursor: pointer; font-size: 14px; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); border: 0; color: #fff; font-weight: 600; }
.btn.danger { background: rgba(229,96,77,.16); border-color: rgba(229,96,77,.4); color: var(--red); }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 8px; line-height: 1; }
.icon-btn:hover { color: var(--red); background: rgba(229,96,77,.12); }
.btn.block { width: 100%; justify-content: center; }

/* ---------- 抽屉 / 模态 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: var(--bg2); border-radius: 18px 18px 0 0; padding: 18px 16px 26px; z-index: 50; box-shadow: var(--shadow); }
.sheet .sheet-head { display: flex; align-items: center; margin-bottom: 10px; }
.sheet .sheet-head .x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 22px; }
.modal { background: var(--card); border-radius: 16px; padding: 18px; max-width: 440px; margin: 8vh auto; border: 1px solid var(--line); box-shadow: var(--shadow); }
.center-box { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 20px; overflow-y: auto; }

.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--brand); color: #fff; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #11192b; border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 10px; z-index: 80; box-shadow: var(--shadow); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; background: var(--bg2); font-size: 13px; position: relative; }
.cal-cell.has { background: rgba(45,108,223,.2); }
.cal-cell.today { outline: 1px solid var(--brand2); }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); margin-top: 2px; }
.cal-wk { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
