:root {
  --bg: #f5f6f8; --card: #fff; --sidebar: #fff;
  --primary: #2563eb; --primary-hover: #1d4ed8;
  --text: #1f2937; --text-sub: #6b7280;
  --border: #e5e7eb; --danger: #dc2626; --success: #16a34a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system,"PingFang SC","Microsoft YaHei",sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.mono { font-family: "SF Mono",Consolas,monospace; font-size: 12px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border-radius: 12px; padding: 40px 36px; width: 340px; box-shadow: 0 4px 24px rgba(0,0,0,.06); text-align: center; }
.login-logo { font-size: 40px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin-bottom: 24px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--primary); }
.login-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* 布局 */
.main { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; }
.sidebar-logo { padding: 20px 20px 16px; font-size: 17px; font-weight: 600; border-bottom: 1px solid var(--border); }
.nav { flex: 1; padding: 12px 0; }
.nav-item { display: block; padding: 11px 20px; color: var(--text-sub); text-decoration: none; cursor: pointer; border-left: 3px solid transparent; font-size: 14px; }
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.active { color: var(--primary); background: #eff6ff; border-left-color: var(--primary); font-weight: 500; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--border); }
.content { flex: 1; margin-left: 200px; padding: 28px 32px; max-width: 960px; }
.content h2 { font-size: 20px; margin-bottom: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-head h2 { margin-bottom: 0; }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; margin-bottom: 20px; }

/* 网关列表 */
.gw-list { display: flex; flex-direction: column; gap: 16px; }
.gw-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; }
.gw-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gw-name { font-size: 16px; font-weight: 600; }
.gw-svc { font-size: 12px; color: var(--text-sub); font-family: "SF Mono",Consolas,monospace; }
.gw-rows { display: flex; flex-direction: column; gap: 0; }
.gw-row { display: flex; align-items: center; padding: 7px 0; border-bottom: 1px solid #f3f4f6; }
.gw-row:last-child { border-bottom: none; }
.gw-label { width: 90px; color: var(--text-sub); font-size: 13px; flex-shrink: 0; }
.gw-val { font-size: 13px; word-break: break-all; }
.gw-switch { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.gw-switch .select { max-width: 360px; }
.gw-msg { margin-top: 8px; font-size: 13px; min-height: 18px; }
.gw-msg.ok { color: var(--success); }
.gw-msg.err { color: var(--danger); }

/* 状态徽章 */
.badge { padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.active { background: #dcfce7; color: var(--success); }
.badge.inactive, .badge.failed { background: #fee2e2; color: var(--danger); }
.badge.unknown { background: #f3f4f6; color: var(--text-sub); }

/* 按钮 */
.btn { padding: 9px 18px; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; transition: background .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.op-btn { margin-right: 8px; padding: 5px 12px; font-size: 13px; }

/* 选择框 */
.select { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; outline: none; max-width: 480px; }
.select:focus { border-color: var(--primary); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; color: var(--text-sub); font-weight: 500; font-size: 13px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; word-break: break-all; }
.table tr:last-child td { border-bottom: none; }
.empty { color: var(--text-sub); text-align: center; padding: 30px 0; font-size: 13px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 24px 28px; width: 440px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 18px; }
.form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-sub); }
.form .input { display: block; width: 100%; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; color: var(--text); }
.form .input:focus { border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.apply-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.apply-msg.ok { color: var(--success); }
.apply-msg.err { color: var(--danger); }
.hint { color: var(--text-sub); font-size: 12px; margin-top: 6px; }

/* 手机适配 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 50;
  }
  .sidebar-logo, .sidebar-foot { display: none; }
  .nav { display: flex; padding: 0; flex: 1; }
  .nav-item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    border-left: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
  }
  .nav-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--primary);
  }
  .content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: 70px;
  }
  .gw-card { padding: 16px; }
  .gw-header { flex-wrap: wrap; gap: 6px; }
  .gw-svc { font-size: 11px; }
  .gw-switch { flex-direction: column; }
  .gw-switch .select { max-width: 100%; width: 100%; }
  .gw-switch .btn { width: 100%; }
  .modal { width: calc(100% - 32px); margin: 16px; }
  .login-card { width: calc(100% - 48px); padding: 28px 24px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 6px; }
}

/* 网关操作区 */
.gw-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.gw-switch { display: flex; gap: 10px; align-items: center; flex: 1; }
.gw-switch .select { max-width: 360px; }
.gw-svc-actions { flex-shrink: 0; }
.gw-svc-actions .btn { padding: 8px 16px; font-size: 13px; }

@media (max-width: 768px) {
  .gw-actions { flex-direction: column; align-items: stretch; }
  .gw-switch { flex-direction: column; }
  .gw-switch .select { max-width: 100%; width: 100%; }
  .gw-switch .btn { width: 100%; }
  .gw-svc-actions { display: flex; }
  .gw-svc-actions .btn { flex: 1; }
}
