:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --bg: #f5f6f7;
  --card: #ffffff;
  --border: #e5e6e8;
  --text: #1f2329;
  --text-2: #646a73;
  --danger: #e64340;
  --warn: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ===== 登录页 ===== */
.page-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #e9f9f0 0%, #f5f6f7 100%); }
.login-card { width: 360px; background: var(--card); border-radius: 16px; padding: 36px 32px 24px; box-shadow: 0 8px 30px rgba(0,0,0,0.08); }
.login-brand { text-align: center; margin-bottom: 24px; }
.brand-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 28px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.brand-logo.small { width: 28px; height: 28px; font-size: 15px; border-radius: 7px; }
.login-brand h1 { font-size: 20px; margin-top: 12px; }
.login-brand p { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border .2s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.login-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.login-tip { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border); color: var(--text-2); font-size: 12px; line-height: 1.8; }
.login-tip > div:first-child { font-weight: 600; margin-bottom: 4px; }

/* ===== 布局 ===== */
.page-app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1f2937; color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; font-size: 15px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.role-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; background: rgba(7,193,96,0.25); color: #7df0b4; margin-bottom: 6px; }
.role-badge.agent { background: rgba(245,158,11,0.25); color: #fcd34d; }
.role-badge.leader { background: rgba(59,130,246,0.25); color: #93c5fd; }
.role-badge.platform_admin { background: rgba(255,255,255,0.15); color: #fff; }
.user-name { font-size: 14px; font-weight: 600; }
.user-tenant { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.sidebar-menu { flex: 1; padding: 10px 0; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: #cbd5e1; cursor: pointer; font-size: 14px; border-left: 3px solid transparent; transition: background .15s; }
.menu-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.menu-item.active { background: rgba(7,193,96,0.15); color: #fff; border-left-color: var(--primary); }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--card); border-bottom: 1px solid var(--border); }
.topbar h2 { font-size: 18px; }
.view-container { padding: 20px 24px; }

/* ===== 卡片 / 统计 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .stat-label { color: var(--text-2); font-size: 13px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 8px; }
.stat-card .stat-sub { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 8px 18px 18px; overflow-x: auto; }

/* ===== 表格 ===== */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; background: #fafafa; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.empty { text-align: center; color: var(--text-2); padding: 40px 0; }

/* ===== 徽章 ===== */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-green { background: #e7f9ef; color: #0a9b4e; }
.tag-gray { background: #f0f0f0; color: #646a73; }
.tag-red { background: #fdecea; color: #d93a34; }
.tag-orange { background: #fef3e2; color: #d97706; }
.tag-blue { background: #e8f1fd; color: #2563eb; }

/* ===== 按钮 ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 13px; transition: background .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { background: rgba(255,255,255,0.08); color: #cbd5e1; border-color: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,0.16); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* ===== 弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-2); line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field-full { grid-column: 1 / -1; }
.form-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ===== 工具条 ===== */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.toolbar .spacer { flex: 1; }

/* ===== Toast ===== */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.toast.success { background: var(--primary); }
.toast.error { background: var(--danger); }

/* ===== 开关 ===== */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 24px; transition: .2s; }
.switch .slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ===== 详情行 ===== */
.detail-list { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; font-size: 13px; }
.detail-list .k { color: var(--text-2); }
