/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --dingtalk: #1677ff;
  --wechat: #07c160;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.12);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select { font-family: inherit; }

/* ===== 通用组件 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: var(--primary); color: #fff; transition: all .15s; border: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }
.btn-dingtalk { background: var(--dingtalk); }
.btn-dingtalk:hover { background: #0958d9; }
.btn-wechat { background: var(--wechat); }
.btn-wechat:hover { background: #06ad56; }

.input, .select {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 14px; background: #fff; transition: border .15s, box-shadow .15s; outline: none;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-light); margin-bottom: 6px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.tag {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.tag-green { background: #dcfce7; color: #15803d; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-gray { background: #f3f4f6; color: #6b7280; }
.tag-blue { background: #dbeafe; color: #1d4ed8; }
.tag-indigo { background: var(--primary-soft); color: var(--primary-dark); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-light); font-weight: 600; background: #fafbfc; }
tbody tr:hover { background: #fafbff; }

.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 22px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 14px;
  z-index: 9999; box-shadow: var(--shadow-lg); animation: toastIn .25s;
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }
.toast-info { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty { text-align: center; padding: 48px 16px; color: var(--text-light); }
.empty-ico { font-size: 40px; margin-bottom: 8px; }

/* ===== 登录页 ===== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
  padding: 24px;
}
.auth-wrap::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.12), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,.10), transparent 40%);
}
.auth-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 40px 36px; position: relative; z-index: 1;
}
.auth-logo {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 28px; font-weight: 800;
}
.auth-title { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 22px; background: #f3f4f6; padding: 4px; border-radius: 10px; }
.auth-tab {
  flex: 1; padding: 9px; text-align: center; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--text-light); cursor: pointer; transition: all .15s;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-light); font-size: 12px; margin: 18px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-foot { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-light); }

/* QR 区 */
.qr-box {
  background: #f9fafb; border: 1px dashed var(--border); border-radius: 14px;
  padding: 24px; text-align: center; margin-bottom: 16px;
}
.qr-img {
  width: 180px; height: 180px; margin: 0 auto 14px; background: #fff; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; position: relative;
  border: 1px solid var(--border);
}
.qr-tip { font-size: 12px; color: var(--text-light); }
.qr-preview { font-size: 13px; color: var(--text); margin-top: 8px; font-weight: 600; }

/* ===== 后台布局 ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px 22px; font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .dot { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); display:flex;align-items:center;justify-content:center;color:#fff;font-size:15px; }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 700; color: #9ca3af; padding: 14px 12px 6px; text-transform: uppercase; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  color: var(--text-light); font-size: 14px; font-weight: 500; cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 15px; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.content { padding: 24px; flex: 1; overflow-y: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stat-label { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-ico { float: right; font-size: 26px; opacity: .35; }

.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { font-size: 15px; font-weight: 700; }
.panel-body { padding: 20px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }

/* 来源选择卡 */
.source-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.source-card {
  border: 2px solid var(--border); border-radius: 14px; padding: 22px; cursor: pointer; transition: all .15s; background: #fff;
}
.source-card:hover { border-color: var(--primary); }
.source-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.source-ico { font-size: 34px; margin-bottom: 10px; }
.source-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.source-desc { font-size: 12px; color: var(--text-light); }

/* 部门树 */
.tree-node { padding: 8px 0 8px 0; }
.tree-child { padding-left: 22px; border-left: 2px solid var(--border); margin-left: 8px; }
.tree-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; }
.tree-row:hover { background: #f9fafb; }
.tree-name { font-weight: 600; }
.tree-meta { color: var(--text-light); font-size: 12px; }

/* 绑定卡 */
.bind-card { display: flex; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
.bind-ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; }
.bind-info { flex: 1; }
.bind-info h3 { font-size: 15px; margin-bottom: 2px; }
.bind-info p { font-size: 12px; color: var(--text-light); }

.muted { color: var(--text-light); }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
.kbd { background:#f3f4f6; border:1px solid var(--border); border-radius:6px; padding:1px 7px; font-family:monospace; font-size:12px; }

/* 弹窗 */
.modal { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; z-index:1000; }
.modal-bg { position:absolute; inset:0; background:rgba(0,0,0,.4); }
.modal-card { position:relative; background:var(--card); border-radius:16px; padding:28px 32px; max-width:420px; width:100%; box-shadow:0 20px 60px rgba(0,0,0,.15); z-index:1; }
.modal-card h2 { font-size:18px; margin-bottom:20px; }

/* ===== 响应式：平板 (≤768px) ===== */
@media (max-width: 768px) {
  .auth-card { max-width: 100%; padding: 32px 24px; border-radius: 14px; }
  .auth-title { font-size: 20px; }
  .auth-tabs { gap: 4px; }
  .auth-tab { padding: 8px 6px; font-size: 12px; }

  .sidebar { width: 200px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 24px; }

  .topbar { padding: 0 16px; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 16px; }

  .source-cards { gap: 12px; }
  .source-card { padding: 16px; }
  .source-name { font-size: 15px; }
}

/* ===== 响应式：手机 (≤480px) ===== */
@media (max-width: 480px) {
  body { font-size: 14px; }

  /* 登录页全屏 */
  .auth-wrap { padding: 16px; align-items: flex-start; padding-top: 40px; }
  .auth-card { max-width: 100%; padding: 28px 18px; border-radius: 12px; }
  .auth-logo { width: 48px; height: 48px; font-size: 24px; border-radius: 12px; }
  .auth-title { font-size: 18px; }
  .auth-sub { font-size: 12px; margin-bottom: 20px; }
  .auth-tabs { gap: 3px; margin-bottom: 16px; padding: 3px; border-radius: 8px; }
  .auth-tab { padding: 7px 4px; font-size: 11px; border-radius: 6px; }
  .auth-foot { font-size: 12px; margin-top: 14px; }

  .qr-img { width: 140px; height: 140px; }
  .qr-box { padding: 16px; }

  .btn { padding: 10px 16px; font-size: 14px; }
  .input, .select { padding: 10px 12px; font-size: 14px; }
  .field { margin-bottom: 12px; }

  /* 后台：侧栏变汉堡菜单 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 500;
    width: 260px; transform: translateX(-100%); transition: transform .25s;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 499;
  }
  .sidebar-overlay.show { display: block; }

  .main { width: 100%; }
  .topbar { height: 52px; padding: 0 14px; }
  .topbar h1 { font-size: 15px; }
  .topbar-right { gap: 8px; font-size: 12px; }
  .content { padding: 12px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-label { font-size: 12px; }
  .stat-value { font-size: 22px; }
  .stat-ico { font-size: 22px; }

  .source-cards { grid-template-columns: 1fr; gap: 10px; }
  .source-card { padding: 14px; }
  .source-ico { font-size: 28px; }

  .panel-head { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .panel-body { padding: 14px; }

  table { font-size: 12px; }
  th, td { padding: 8px 6px; font-size: 12px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .modal-card { max-width: calc(100vw - 32px); padding: 22px 18px; border-radius: 12px; }
  .modal-card h2 { font-size: 16px; margin-bottom: 14px; }

  .bind-card { flex-wrap: wrap; padding: 14px; gap: 10px; }
  .bind-ico { width: 38px; height: 38px; font-size: 18px; }

  .nav-item { padding: 8px 10px; font-size: 13px; }
  .sidebar-brand { padding: 16px 18px; font-size: 15px; }

  /* Toast 适配小屏 */
  .toast { max-width: 90vw; font-size: 13px; padding: 10px 16px; top: 16px; }
}

/* 汉堡菜单按钮（移动端专用，桌面端隐藏） */
.hamburger {
  display: none; width: 36px; height: 36px; background: none;
  align-items: center; justify-content: center; border-radius: 8px;
  margin-right: 10px; cursor: pointer;
}
.hamburger:hover { background: #f3f4f6; }
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text); position: relative; }
.hamburger span::before, .hamburger span::after {
  content: ""; display: block; width: 18px; height: 2px; background: var(--text);
  position: absolute; left: 0; transition: transform .2s;
}
.hamburger span::before { top: -6px; }
.hamburger span::after { top: 6px; }

@media (max-width: 480px) {
  .hamburger { display: flex; }
}
