:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1b2740;
  --line: #24314d;
  --text: #e8eefc;
  --muted: #8ea0c0;
  --accent: #4f8cff;
  --accent-2: #33d6a6;
  --danger: #ff6b6b;
  --warn: #ffb84d;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin: 10px 0 0; }

/* ---------- 登录 ---------- */
.login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #16233d 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.brand-mark {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(79,140,255,.35);
}
.login-card h1 { font-size: 22px; margin: 0 0 8px; }
.login-card .muted { margin: 0 0 26px; line-height: 1.6; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }

/* ---------- 应用外壳 ---------- */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(11,18,32,.85));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 19px; font-weight: 650; }
.topbar-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 18px; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

main#screen { flex: 1; padding: 16px 16px calc(88px + var(--safe-bottom)); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card-title { font-size: 13px; color: var(--muted); margin: 0 0 12px; letter-spacing: .3px; }
.big-num { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.big-num small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row + .row { margin-top: 12px; }

.pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; background: var(--surface-2); color: var(--muted);
}
.pill.risk { color: var(--accent); background: rgba(79,140,255,.12); }
.pill.ok { color: var(--accent-2); background: rgba(51,214,166,.12); }
.pill.warn { color: var(--warn); background: rgba(255,184,77,.12); }

/* 偏离条 */
.devbar { margin: 10px 0; }
.devbar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.devbar-head .name { font-weight: 600; }
.devbar-head .val { color: var(--muted); }
.track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.track > i.over { background: var(--warn); }

/* ---------- 表格/列表 ---------- */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.li-name { font-weight: 600; }
.li-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.li-right { text-align: right; }
.li-right .amt { font-weight: 650; }
.li-right .amt.pos { color: var(--accent-2); }
.li-right .amt.neg { color: var(--danger); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn.primary {
  border: none;
  background: linear-gradient(135deg, var(--accent), #3f6fe0);
  color: #fff;
  box-shadow: 0 8px 24px rgba(79,140,255,.3);
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: .5; }

/* 风险档选择 */
.choice-grid { display: grid; gap: 10px; }
.choice {
  text-align: left; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.choice.active { border-color: var(--accent); background: rgba(79,140,255,.1); }
.choice .t { font-weight: 650; display: flex; justify-content: space-between; }
.choice .d { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* 输入 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 48px; }
.input-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 560px;
  display: flex; z-index: 30;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(19,28,46,.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; border: none; background: none; color: var(--muted);
  font-size: 11px; cursor: pointer;
}
.tab span { font-size: 19px; line-height: 1; }
.tab.active { color: var(--accent); }

/* 弹层 */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40;
  backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 560px; z-index: 50;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  max-height: 86vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 16px; }
.sheet h2 { font-size: 18px; margin: 0 0 16px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  padding: 10px 18px; border-radius: 12px; z-index: 60;
  font-size: 14px; border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 12px; opacity: .6; }

.section-gap { height: 6px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.warn-box {
  background: rgba(255,184,77,.08); border: 1px solid rgba(255,184,77,.3);
  border-radius: 12px; padding: 12px 14px; font-size: 12.5px; color: #ffd8a0; line-height: 1.6;
}
