:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #2f6fed;
  --primary-2: #1f56c7;
  --text: #1f2733;
  --muted: #6b7686;
  --border: #e3e8f0;
  --ok: #1f9d55;
  --warn: #e0962b;
  --danger: #d8453b;
  --shadow: 0 2px 12px rgba(31, 39, 51, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #2f6fed 0%, #6a4ef0 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  padding: 28px 24px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.role-tabs { display: flex; gap: 6px; background: #eef1f7; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.role-tabs button {
  flex: 1; border: none; background: transparent; padding: 8px 4px; border-radius: 8px;
  color: var(--muted); font-size: 13px; transition: .15s;
}
.role-tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none;
  transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,237,0.12); }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.btn {
  width: 100%; padding: 11px; border: none; border-radius: 10px; background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 600; transition: .15s;
}
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .6; }
.btn.ghost { background: #eef1f7; color: var(--text); }
.btn.ghost:hover { background: #e2e7f1; }
.btn.sm { width: auto; padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-box { margin-top: 16px; font-size: 12px; color: var(--muted); background: #f0f4ff; border: 1px dashed #c5d4f7; border-radius: 8px; padding: 10px; }

/* ---------- 应用布局 ---------- */
.topbar {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px; position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; color: var(--primary); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.topbar .who { display: flex; align-items: center; gap: 10px; }
.tag-role { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eaf0ff; color: var(--primary-2); font-weight: 600; }
.menu-btn { display: none; background: none; border: none; font-size: 22px; color: var(--text); }

.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 210px; background: var(--card); border-right: 1px solid var(--border); padding: 14px 10px; flex-shrink: 0;
}
.sidebar .nav-item {
  display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 10px 12px;
  border-radius: 9px; color: var(--text); font-size: 14px; margin-bottom: 4px; transition: .12s;
}
.sidebar .nav-item:hover { background: #f0f4ff; }
.sidebar .nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.main { flex: 1; padding: 18px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { margin: 0; font-size: 18px; }
.page-head .desc { color: var(--muted); font-size: 13px; }

/* ---------- 卡片/表格 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat .l { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; min-width: 120px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f7f9fc; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #fafbff; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: #eef1f7; color: var(--muted); }
.badge.s-new { background: #e8f0ff; color: #2f6fed; }
.badge.s-follow { background: #fff3e0; color: #c8761a; }
.badge.s-win { background: #e6f7ee; color: #1f9d55; }
.badge.s-loss { background: #fdecea; color: #d8453b; }
.status-pending { color: var(--warn); font-weight: 600; }
.status-active { color: var(--ok); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- 模态 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; box-shadow: 0 16px 50px rgba(0,0,0,0.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { background: none; border: none; font-size: 22px; color: var(--muted); }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.code-box { background: #f0f4ff; border: 1px dashed #c5d4f7; border-radius: 10px; padding: 14px; text-align: center; margin: 8px 0; }
.code-box .code { font-size: 28px; letter-spacing: 4px; font-weight: 800; color: var(--primary-2); font-family: monospace; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv .k { color: var(--muted); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2733; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: fade .2s; max-width: 90vw; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes fade { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 56px; bottom: 0; width: 220px; z-index: 30;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 14px; }
  .topbar .who .name { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
