* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  display: flex;
  height: 100vh;
  background: #f0f2f5;
  color: #333;
  overflow: hidden;
  font-size: 14px;
}

/* ===== 侧边栏 ===== */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: #1a1a2e;
  color: #ccc;
  display: flex;
  flex-direction: column;
  user-select: none;
}
.sidebar-header {
  padding: 22px 18px 14px;
  border-bottom: 1px solid #2a2a4a;
}
.sidebar-header h2 {
  font-size: 18px;
  color: #fff;
  font-weight: 600;
  margin-bottom: 4px;
}
.sidebar-header span {
  color: #8a92a8;
  font-size: 11px;
}
#nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-item {
  display: block;
  padding: 11px 22px;
  color: #b9c1d4;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: #2d2d50; color: #fff; border-left: 3px solid #6c8cff; padding-left: 19px; }
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid #2a2a4a;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
}
#status-dot.status-online { background: #4ade80; box-shadow: 0 0 4px #4ade80; }
#status-dot.status-offline { background: #f87171; }
.sidebar-footer button { margin-left: auto; }

/* ===== 主内容 ===== */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px 80px;
}
.panel { max-width: 1200px; margin: 0 auto; }
.panel.hidden { display: none; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-header h1 { font-size: 22px; font-weight: 600; color: #1a1a2e; }
.panel-actions { display: flex; gap: 8px; align-items: center; }

/* ===== 登录页 ===== */
#panel-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  max-width: none;
}
#panel-login.hidden { display: none; }
#panel-login.active { display: flex; }
.login-card {
  background: #fff;
  padding: 36px 40px;
  border-radius: 10px;
  box-shadow: 0 6px 30px rgba(0,0,0,.08);
  width: 360px;
}
.login-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
  color: #1a1a2e;
}
.login-card form {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== 表单元素 ===== */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #555;
  font-weight: 500;
}
input, select, textarea {
  padding: 8px 12px;
  border: 1px solid #d6dae3;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #333;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #6c8cff;
  box-shadow: 0 0 0 3px rgba(108,140,255,.15);
}
textarea { resize: vertical; min-height: 60px; font-family: ui-monospace, Menlo, Consolas, monospace; }
input[type="checkbox"] { width: 16px; height: 16px; }

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px;
  border: 1px solid #d6dae3;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f4f6fa; border-color: #b9c1d4; }
.btn-primary { background: #4c6ef5; border-color: #4c6ef5; color: #fff; }
.btn-primary:hover { background: #3b5bdb; border-color: #3b5bdb; }
.btn-ghost { background: transparent; border-color: transparent; color: #b9c1d4; }
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,.1); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.form-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h3 {
  font-size: 15px;
  margin-bottom: 8px;
  color: #1a1a2e;
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px 18px;
  border-left: 4px solid #ccc;
}
.stat-card .stat-label { font-size: 11px; color: #888; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 26px; font-weight: 600; color: #1a1a2e; }
.stat-blue { border-left-color: #4c6ef5; }
.stat-cyan { border-left-color: #15aabf; }
.stat-violet { border-left-color: #7950f2; }
.stat-green { border-left-color: #40c057; }

/* ===== 表格 ===== */
.table-wrapper {
  overflow-x: auto;
  margin-top: 10px;
  font-size: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 7px 10px;
  border-bottom: 1px solid #eef0f4;
  text-align: left;
  vertical-align: top;
}
th {
  background: #f8f9fc;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  user-select: none;
}
th:hover { background: #eef0f6; }
tr:hover td { background: #fafbfe; }

/* ===== 日志区 ===== */
.log-area {
  background: #1e1e2e;
  color: #a9b1d6;
  border-radius: 6px;
  padding: 12px;
  height: 360px;
  overflow-y: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}
.log-area .log-line { margin-bottom: 2px; }
.log-area .log-time { color: #6b7394; margin-right: 8px; }
.log-area .log-info { color: #a9b1d6; }
.log-area .log-ok { color: #40c057; }
.log-area .log-warn { color: #fab005; }
.log-area .log-error { color: #fa5252; }

/* ===== 工具类 ===== */
.muted { color: #888; font-size: 12px; }
.hidden { display: none !important; }
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 12px;
  font-size: 13px;
}
.alert-error { background: #fff5f5; color: #c92a2a; border: 1px solid #ffd5d5; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}
.grid-form label { width: 100%; }
.switch-line {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.switch-line input { width: 16px; height: 16px; }
.code-block {
  background: #1e1e2e;
  color: #c7d0e6;
  padding: 14px;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  max-height: 400px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0;
  border-bottom: 1px solid #eef0f4;
}
.tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: #888;
  font-size: 13px;
}
.tab.active { color: #4c6ef5; border-bottom-color: #4c6ef5; }
code {
  background: #f4f6fa;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #c44569;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #1a1a2e;
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 9999;
  font-size: 13px;
  max-width: 360px;
}
.toast.toast-error { background: #c92a2a; }
.toast.toast-ok { background: #2f9e44; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c5cde0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a9b4cc; }
.log-area::-webkit-scrollbar-thumb { background: #3a3a5a; }

@media (max-width: 768px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; }
  #nav { display: none; }
}
