* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  font-size: 14px;
}
.app { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 0; border-bottom: 1px solid #e0e0e0; margin-bottom: 20px;
}
.topbar h1 { font-size: 20px; font-weight: 700; color: #16213e; }
.topbar-actions { display: flex; gap: 8px; }

/* 按钮 */
.btn {
  padding: 7px 16px; border: none; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .15s;
}
.btn:active { transform: translateY(1px); box-shadow: inset 0 2px 5px rgba(0,0,0,.18); }
.btn-primary { background: #16213e; color: #fff; }
.btn-primary:hover { background: #0f3460; }
.btn-primary:active { background: #0a2540; }
.btn-ghost { background: #fff; color: #555; border: 1px solid #ddd; }
.btn-ghost:hover { background: #f5f5f5; }
.btn-ghost:active { background: #e9eef5; border-color: #c9ced6; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-danger:active { background: #a93226; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-success:active { background: #1e8449; }
.btn-block { width: 100%; margin-top: 8px; padding: 10px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 空状态 */
.empty-state {
  text-align: center; padding: 80px 20px; color: #888;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: #555; }

/* 账号卡片 */
.account-card {
  background: #fff; border-radius: 10px; padding: 18px;
  margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: 1px solid #e8e8e8;
}
.account-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #f0f0f0;
}
.account-info { display: flex; align-items: center; gap: 12px; }
.account-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #16213e, #0f3460);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.account-name { font-weight: 600; font-size: 15px; }
.account-meta { font-size: 12px; color: #888; margin-top: 2px; }
.account-actions { display: flex; gap: 6px; align-items: center; }

/* 状态徽章 */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge-online { background: #e8f5e9; color: #27ae60; }
.badge-offline { background: #fde8e8; color: #e74c3c; }
.badge-running { background: #e3f2fd; color: #1976d2; }
.badge-stopped { background: #f5f5f5; color: #999; }

/* 任务区 */
.tasks-section { margin-top: 4px; }
.tasks-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.tasks-header h4 { font-size: 13px; color: #666; font-weight: 600; }
.task-card {
  background: #fafbfc; border: 1px solid #eee; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
}
.task-flow { flex: 1; min-width: 0; }
.task-flow .flow-line {
  font-size: 13px; color: #333; display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.flow-arrow { color: #aaa; font-weight: 700; }
.flow-group {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 4px;
  padding: 2px 8px; font-size: 12px;
}
.task-members { font-size: 11px; color: #888; margin-top: 4px; }
.task-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* 开关 */
.switch {
  position: relative; display: inline-block; width: 40px; height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #ccc; border-radius: 22px; transition: .2s;
}
.slider:before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: #27ae60; }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 12px; width: 420px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-wide { width: 560px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: #999; padding: 4px 8px;
}
.modal-body { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 6px;
}
.form-group input, .form-group select {
  width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: #16213e; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.hint { font-size: 11px; color: #999; margin-top: 6px; }
.login-msg {
  margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 12px;
  display: none;
}
.login-msg.error { display: block; background: #fde8e8; color: #c0392b; }
.login-msg.info { display: block; background: #e3f2fd; color: #1976d2; }
.task-modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

/* 日志 */
.log-view {
  background: #1a1a2e; color: #a8e6cf; padding: 12px;
  border-radius: 6px; font-family: Consolas, monospace; font-size: 12px;
  max-height: 400px; overflow-y: auto; white-space: pre-wrap;
  word-break: break-all;
}

/* 响应式 */
@media (max-width: 640px) {
  .task-card { flex-direction: column; align-items: flex-start; }
  .form-row { flex-direction: column; }
}

/* ========== 系统告警面板 ========== */
.alerts-panel {
  margin-top: 24px; background: #fff; border: 1px solid #e0e0e0;
  border-radius: 10px; overflow: hidden;
}
.alerts-panel.has-alerts { border-color: #e74c3c; box-shadow: 0 0 0 1px #f5c6cb; }
.alerts-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; cursor: pointer; user-select: none;
  background: #f8f9fa;
}
.alerts-panel.has-alerts .alerts-header { background: #fdf0ef; }
.alerts-title { font-weight: 600; font-size: 14px; color: #555; }
.alerts-panel.has-alerts .alerts-title { color: #c0392b; }
.alerts-count {
  display: inline-block; min-width: 20px; padding: 1px 7px; margin-left: 6px;
  background: #ccc; color: #fff; border-radius: 10px; font-size: 12px; text-align: center;
}
.alerts-panel.has-alerts .alerts-count { background: #e74c3c; }
.alerts-toggle { font-size: 13px; color: #888; }
.alerts-body { border-top: 1px solid #eee; }
.alerts-list { max-height: 360px; overflow-y: auto; padding: 10px 16px; }
.alerts-empty { color: #27ae60; font-size: 13px; padding: 6px 0; }
.alert-item {
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid #f5c6cb; background: #fdf0ef;
}
.alert-item.alert-warn { border-color: #ffe0a3; background: #fff8e8; }
.alert-item.alert-ad { border-color: #9adfe8; background: #f0fbfd; }
.alert-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.alert-badge {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  background: #e74c3c; color: #fff; font-size: 11px; font-weight: 600;
}
.alert-warn .alert-badge { background: #f0ad4e; }
.alert-ad .alert-badge { background: #17a2b8; }
.alert-time { color: #999; font-size: 12px; }
.alert-msg { font-size: 13px; color: #333; line-height: 1.5; word-break: break-all; }
.alert-source { color: #aaa; font-size: 11px; margin-top: 4px; }
.alerts-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 8px 16px; border-top: 1px solid #f0f0f0;
}

/* ========== 广告检测面板（独立区域，青色主题） ========== */
.adscan-panel {
  margin-top: 16px; background: #fff; border: 1px solid #e0e0e0;
  border-radius: 10px; overflow: hidden;
}
.adscan-panel.has-ads { border-color: #17a2b8; box-shadow: 0 0 0 1px #b8e6ee; }
.adscan-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; cursor: pointer; user-select: none;
  background: #f8f9fa;
}
.adscan-panel.has-ads .adscan-header { background: #f0fbfd; }
.adscan-title { font-weight: 600; font-size: 14px; color: #555; }
.adscan-panel.has-ads .adscan-title { color: #117a8b; }
.adscan-count {
  display: inline-block; min-width: 20px; padding: 1px 7px; margin-left: 6px;
  background: #ccc; color: #fff; border-radius: 10px; font-size: 12px; text-align: center;
}
.adscan-panel.has-ads .adscan-count { background: #17a2b8; }
.adscan-toggle { font-size: 13px; color: #888; }
.adscan-body { border-top: 1px solid #eee; }
.adscan-list { max-height: 360px; overflow-y: auto; padding: 10px 16px; }
.adscan-empty { color: #27ae60; font-size: 13px; padding: 6px 0; }
.adscan-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 8px 16px; border-top: 1px solid #f0f0f0;
}

/* ========== 任务级错误提示（如账号被移出源群） ========== */
.task-error-banner {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0 2px; padding: 8px 10px;
  background: #fff4e5; border: 1px solid #ffcc80; border-radius: 7px;
  color: #a8550f; font-size: 12px; line-height: 1.45;
}
.task-error-icon { flex-shrink: 0; font-size: 14px; }
.task-error-text { flex: 1; word-break: break-all; }
.task-error-time { flex-shrink: 0; color: #c98a2b; font-size: 11px; white-space: nowrap; }

/* ========== 表单内复选框行（如复制图片开关） ========== */
.check-line { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: normal; margin: 0; }
.check-line input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; margin: 0; flex-shrink: 0; }
.check-line span { font-size: 14px; color: #2c3e50; }
/* 目标类型切换 + Safe Chat 面板 */
.kind-switch { display:flex; gap:18px; margin:6px 0 8px; }
.radio-line { display:inline-flex; align-items:center; gap:6px; font-size:14px; cursor:pointer; margin:0; }
.radio-line input { margin:0; }
.sc-panel { margin-top:8px; padding:12px; border:1px solid #e3d5d8; border-radius:8px; background:#fcf8f9; }
.sc-panel input { width:100%; margin-bottom:8px; }
.sc-divider { font-size:12px; color:#a07a82; margin:4px 0 8px; }

/* ---- 账号设置弹窗 ---- */
.device-readonly{background:#f5f6f8;border:1px solid #e5e7eb;border-radius:8px;padding:9px 12px;font-size:13px;color:#374151;font-family:Consolas,monospace;}
.rate-row{display:flex;gap:10px;flex-wrap:wrap;}
.rate-row>div{flex:1;min-width:120px;display:flex;flex-direction:column;gap:4px;}
.rate-row span{font-size:12px;color:#6b7280;}
.rate-row input,.rate-row select{padding:7px 9px;border:1px solid #d1d5db;border-radius:7px;font-size:13px;width:100%;box-sizing:border-box;}
.proxy-line{margin-bottom:8px;}
.chk-line{display:flex;align-items:center;gap:6px;font-size:13px;color:#374151;cursor:pointer;}
.chk-line input{margin:0;}

/* ========== 账号出口节点 ========== */
.account-exit{font-size:12px;color:#276678;margin-top:3px;}

/* ========== 节点网络弹窗 ========== */
.clash-result{margin-top:12px;max-height:340px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:8px;padding:10px 12px;background:#fafbfc;}
.clash-table{width:100%;border-collapse:collapse;font-size:13px;}
.clash-table th{text-align:left;color:#6b7280;font-weight:600;padding:6px 8px;border-bottom:1px solid #e5e7eb;font-size:12px;}
.clash-table td{padding:6px 8px;border-bottom:1px solid #f0f0f0;}
.clash-table td.cl-name{color:#1f2937;word-break:break-all;}
.cl-ok{color:#1a9e5c;font-size:12px;white-space:nowrap;}
.cl-bad{color:#d23b3b;font-size:12px;white-space:nowrap;}
.assign-lines{font-size:13px;line-height:1.9;color:#1f2937;font-family:Consolas,monospace;}

/* ========== 成员活跃度建议（转发任务） ========== */
.activity-tools{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:6px;}
.activity-tools .hint{flex:1;min-width:140px;}
.activity-panel{margin-top:6px;border:1px solid #e5e7eb;border-radius:8px;padding:8px 10px;background:#fafbfc;max-height:280px;overflow-y:auto;}
.act-table{width:100%;border-collapse:collapse;font-size:13px;}
.act-table th{text-align:left;color:#6b7280;font-weight:600;padding:6px 6px;border-bottom:1px solid #e5e7eb;font-size:12px;white-space:nowrap;}
.act-table td{padding:5px 6px;border-bottom:1px solid #f0f0f0;white-space:nowrap;}
.act-table td:first-child{max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.act-level{padding:1px 8px;border-radius:10px;font-size:12px;font-weight:600;}
.act-high{background:#fde2e2;color:#c0392b;}
.act-mid{background:#fdf3d0;color:#8a6d3b;}
.act-low{background:#e3e8ef;color:#4b5563;}

/* ========== 多租户：登录页 ========== */
.login-body {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 55%, #1b2a4a 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: 100%; padding: 20px; display: flex; justify-content: center; }
.login-card {
  background: #fff; border-radius: 16px; width: 380px; max-width: 94vw;
  padding: 40px 36px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo {
  width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 16px;
  background: linear-gradient(135deg, #0f3460, #16213e);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; box-shadow: 0 6px 18px rgba(22,33,62,.35);
}
.login-title { text-align: center; font-size: 22px; font-weight: 700; color: #16213e; }
.login-sub { text-align: center; font-size: 13px; color: #888; margin: 6px 0 26px; }
.login-foot { text-align: center; font-size: 12px; color: #aaa; margin-top: 18px; }
.login-page-msg {
  min-height: 22px; margin: 6px 0 2px; font-size: 13px; color: #e74c3c;
  text-align: center;
}
.login-page-msg:empty { margin: 0; }
.login-card .form-group label { font-size: 13px; color: #555; }
.login-card input {
  width: 100%; padding: 11px 14px; margin-top: 6px;
  border: 1px solid #d9dee8; border-radius: 8px; font-size: 14px;
  transition: border .15s, box-shadow .15s;
}
.login-card input:focus {
  outline: none; border-color: #0f3460;
  box-shadow: 0 0 0 3px rgba(15,52,96,.12);
}

/* ========== 多租户：顶栏 ========== */
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.brand { font-size: 20px; font-weight: 700; color: #16213e; }
.brand-sub { font-size: 12px; color: #999; }
.topbar-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 20px;
  padding: 4px 12px; margin-right: 4px;
}
.user-nick { font-weight: 600; font-size: 13px; color: #16213e; }

/* 徽章 */
.badge-admin { background: #0f3460; color: #fff; }
.badge-user { background: #e8eaf6; color: #3f51b5; }
.badge-ok { background: #e8f5e9; color: #27ae60; }
.badge-warn { background: #fdf3d0; color: #b7791f; }
.badge-expired { background: #fde2e2; color: #c0392b; }
.badge-disabled { background: #f5f5f5; color: #999; }

/* ========== 多租户：管理后台 ========== */
#admin-panel { margin-top: 4px; }
.admin-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.admin-head h2 { font-size: 18px; color: #16213e; }
/* 管理后台按钮激活态（进入管理后台视图时高亮） */
.btn-active { background: #16213e !important; color: #fff !important; border-color: #16213e !important; }
.btn-active:hover { background: #0f3460 !important; }
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff; border-radius: 10px; padding: 18px 16px; text-align: center;
  border: 1px solid #e8e8e8; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.stat-num { font-size: 24px; font-weight: 700; color: #0f3460; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }

.admin-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
  margin-bottom: 16px;
}
.card {
  background: #fff; border-radius: 10px; padding: 16px 18px;
  border: 1px solid #e8e8e8; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h3 { font-size: 14px; color: #16213e; margin-bottom: 12px; }
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.card-head h3 { margin-bottom: 0; }

/* 监控条 */
.meter-block { margin-bottom: 14px; }
.meter-label {
  display: flex; justify-content: space-between; font-size: 12px; color: #555;
  margin-bottom: 5px;
}
.meter {
  height: 12px; background: #eef0f4; border-radius: 6px; overflow: hidden;
}
.meter-bar {
  height: 100%; border-radius: 6px; background: #27ae60;
  transition: width .6s ease;
}
.meter-bar.meter-yellow { background: #f39c12; }
.meter-bar.meter-red { background: #e74c3c; }
.srv-meta { font-size: 12px; color: #999; margin-top: 8px; }

/* 图表 */
.chart { min-height: 160px; }
.chart-empty { color: #aaa; font-size: 13px; text-align: center; padding: 50px 0; }
.hbar-list { display: flex; flex-direction: column; gap: 8px; }
.hbar-row { display: flex; align-items: center; gap: 8px; }
.hbar-name { width: 56px; font-size: 12px; color: #555; flex-shrink: 0; text-align: right; }
.hbar-track { flex: 1; height: 16px; background: #f0f2f5; border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #0f3460, #4a6fa5); }
.hbar-val { width: 30px; font-size: 13px; font-weight: 600; color: #16213e; text-align: right; }

/* 用户管理表格 */
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; color: #6b7280; font-weight: 600; padding: 9px 10px;
  border-bottom: 2px solid #eef0f4; font-size: 12px; white-space: nowrap;
}
.admin-table td { padding: 9px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.admin-table tr:hover td { background: #fafbfc; }
.td-empty { text-align: center; color: #aaa; padding: 30px 0 !important; }
.td-mono { font-family: Consolas, monospace; }
.td-sub { font-size: 11px; color: #c0392b; margin-top: 2px; }
.td-ops { white-space: nowrap; }
.td-ops .btn { margin-right: 4px; }
.btn-danger { background: #fff; color: #e74c3c; border-color: #f5c6c6; }
.btn-danger:hover { background: #fde8e8; }
.btn-danger:active { background: #fbdcdc; border-color: #eeb5b5; }

/* 响应式 */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: 12px; align-items: flex-start; }
  .topbar-user { width: 100%; }
}

