:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-2: #6b7280;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
}
.login-card {
  width: 340px;
  background: var(--card);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: #111827;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  padding: 8px 20px 20px;
  border-bottom: 1px solid #1f2937;
  margin-bottom: 12px;
}
#nav { flex: 1; }
.nav-item {
  display: block;
  padding: 10px 20px;
  color: #d1d5db;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.active { background: #1f2937; color: #fff; border-left-color: var(--primary); }
.logout-btn { margin: 12px 16px 8px; }

.content { flex: 1; padding: 24px 28px; max-width: 1200px; }

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

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.card .label { color: var(--text-2); font-size: 12px; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; }
.card .sub { color: var(--text-2); font-size: 12px; margin-top: 4px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}
.panel h3 { font-size: 15px; margin-bottom: 14px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-2); font-weight: 500; font-size: 12px; white-space: nowrap; }
tr:hover td { background: #f9fafb; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef3c7; color: #b45309; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-block { width: 100%; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn + .btn { margin-left: 6px; }

input[type="text"], input[type="number"], input[type="password"], select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
label input, label select { width: 100%; margin-top: 5px; color: var(--text); }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
.checkbox input { width: auto; margin: 0; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; }

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--text-2);
  font-size: 13px;
}
.pagination .spacer { flex: 1; }

.empty { text-align: center; color: var(--text-2); padding: 40px 0; }

/* ---------- 趋势图 ---------- */
.trend { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.trend-bar {
  width: 100%;
  max-width: 36px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  opacity: .85;
}
.trend-date { font-size: 11px; color: var(--text-2); transform: rotate(-30deg); white-space: nowrap; }

/* ---------- 维护 ---------- */
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.check-row .name { width: 110px; font-weight: 500; }
.check-row .msg { color: var(--text-2); flex: 1; word-break: break-all; }
.ok-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ok-dot.ok { background: var(--ok); }
.ok-dot.fail { background: var(--danger); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 12px; width: 640px; max-width: 94vw;
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-sm { width: 420px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 16px; }
.detail-grid .k { color: var(--text-2); font-size: 12px; }
.detail-grid .v { font-size: 13px; word-break: break-all; }

.sec-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 14px 0 8px; }

.mono-list { max-height: 260px; overflow-y: auto; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.mono-list li { padding: 6px 0; border-bottom: 1px solid var(--border); list-style: none; }
