* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f4f6f9; color: #333; }

/* ===== 侧边栏布局 ===== */
body.layout { display: flex; min-height: 100vh; }
.sidebar { width: 200px; flex-shrink: 0; background: #1f2937; color: #e5e7eb; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 20px; font-size: 16px; font-weight: 600; color: #fff; border-bottom: 1px solid #374151; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; display: inline-block; }
.side-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.side-nav a { color: #cbd5e1; text-decoration: none; font-size: 14px; padding: 10px 14px; border-radius: 6px; transition: background .15s; }
.side-nav a:hover { background: #374151; color: #fff; }
.side-nav a.active { background: #2563eb; color: #fff; font-weight: 500; }
.side-footer { padding: 14px 20px; border-top: 1px solid #374151; }
.side-footer .link-btn { color: #9ca3af; font-size: 13px; }
.side-footer .link-btn:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.footer { text-align: center; color: #9ca3af; font-size: 12px; padding: 24px 16px; }

@media (max-width: 768px) {
  body.layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; }
  .brand { border-bottom: none; border-right: 1px solid #374151; padding: 14px 16px; }
  .side-nav { flex-direction: row; padding: 8px 10px; }
  .side-nav a { padding: 8px 10px; }
  .side-footer { border-top: none; border-left: 1px solid #374151; margin-left: auto; padding: 8px 14px; }
}

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { font-size: 20px; }

.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h3 { font-size: 15px; margin-bottom: 12px; color: #1f2937; }

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef0f3; font-size: 14px; }
.table th { background: #f9fafb; font-weight: 600; color: #4b5563; }
.table.kv td { border-bottom: 1px solid #f0f1f3; }
.table.kv td:nth-child(odd) { color: #6b7280; width: 110px; }
.table .empty { text-align: center; color: #9ca3af; padding: 32px; }
.table code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-run { background: #dbeafe; color: #1d4ed8; }
.badge-wait { background: #f3f4f6; color: #6b7280; }
.badge-err { background: #fee2e2; color: #b91c1c; }

.btn { display: inline-block; padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #374151; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f9fafb; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #fff; border-color: #ef4444; color: #dc2626; }
.btn-danger:hover { background: #fef2f2; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.ops a { margin-right: 10px; font-size: 13px; color: #2563eb; text-decoration: none; }
.ops a.danger { color: #dc2626; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: #4b5563; font-weight: 500; }
.form-group input, .form-group select { width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #2563eb; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 12px 0; }

.hint { font-size: 12px; color: #9ca3af; margin-top: 8px; line-height: 1.6; }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-warn { background: #fef3c7; color: #b45309; }

.sub-card .sub-row { display: flex; gap: 8px; }
.sub-input { flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; font-family: monospace; background: #f9fafb; }

.log-box { background: #0f172a; color: #d1fae5; font-size: 12px; line-height: 1.7; padding: 14px; border-radius: 6px; height: 480px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }

.result-card h3 { margin-bottom: 10px; }

.monitor-box { font-size: 14px; color: #6b7280; }
.mon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.mon-item { background: #f9fafb; border-radius: 6px; padding: 10px 14px; font-size: 13px; }
.mon-item b { color: #374151; margin-right: 6px; }

.login-bg { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1f2937, #374151); }
.login-card { background: #fff; border-radius: 10px; padding: 36px; width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-card h2 { text-align: center; margin-bottom: 22px; font-size: 18px; }

.inline { display: inline; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 10px; padding: 24px; width: 400px; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal h3 { margin-bottom: 8px; }
.modal-name { font-size: 13px; color: #6b7280; margin-bottom: 14px; }
.modal select { width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 16px 0; }
.pager-info { font-size: 13px; color: #6b7280; }

.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.server-card .server-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* 流量图表 */
.chart-legend { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; font-size: 13px; color: #4b5563; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw, .chart-tip .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.chart-summary { margin-left: auto; color: #6b7280; font-size: 12px; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: 220px; display: block; cursor: crosshair; }
.chart-tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 10px; font-size: 12px; line-height: 1.7; color: #374151; box-shadow: 0 4px 12px rgba(0,0,0,.10); white-space: nowrap; }

/* ===== Dashboard ===== */
.dash-date { font-size: 13px; color: #6b7280; }
.stat-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.stat-grid.g4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { position: relative; background: #fff; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card .sc-label { font-size: 12px; color: #6b7280; }
.stat-card .sc-value { font-size: 26px; font-weight: 700; color: #111827; margin: 6px 0 2px; line-height: 1.2; }
.stat-card .sc-sub { font-size: 12px; color: #9ca3af; }
.sc-icon { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.sc-icon svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dash-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-card h3 { display: flex; align-items: center; gap: 8px; }
.chart-range { margin-left: auto; font-size: 12px; font-weight: 400; color: #6b7280; }
.bw-chip { margin-left: auto; background: #fef3c7; color: #b45309; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; }
@media (max-width: 900px) {
  .stat-grid.g4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid.g3 { grid-template-columns: repeat(2, 1fr); }
  .dash-charts { grid-template-columns: 1fr; }
}
