:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #e5e9f0;
  --text: #16202f;
  --muted: #6b7789;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a { color: var(--accent); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #eef2fb, #f8fafc);
}
.login-card {
  width: 340px; padding: 32px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex: none; background: var(--panel);
  border-right: 1px solid var(--border); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; font-weight: 700; font-size: 15px; }
.brand .dot { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #3b82f6, #2563eb); }
.nav-item {
  display: block; padding: 9px 12px; margin-bottom: 2px; border-radius: 8px;
  color: var(--text); cursor: pointer; font-size: 14px;
}
.nav-item:hover { background: #f2f5fb; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .foot { position: absolute; bottom: 16px; left: 12px; right: 12px; font-size: 12px; color: var(--muted); }

.main { flex: 1; padding: 22px 26px 60px; min-width: 0; }
.page { display: none; }
.page.active { display: block; }
.page-head { margin-bottom: 18px; }
.page-head h2 { margin: 0 0 4px; font-size: 19px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel > h3 { margin: 0 0 12px; font-size: 15px; }
.panel > h3 .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- 表单 ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; min-height: 70px; }
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

button { font: inherit; cursor: pointer; }
.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text);
}
.btn:hover { background: #f6f8fc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--err); border-color: #f3c7c7; background: #fff5f5; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfd; }
tbody tr:hover { background: #fafbff; }
td .ellip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: #f1f5f9; color: var(--muted); }
.tag.on { background: #e8f7ee; color: var(--ok); }
.tag.off { background: #fdecec; color: var(--err); }
.tag.warn { background: #fff5e6; color: var(--warn); }

/* ---------- 图表 ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .bar .col { width: 100%; max-width: 40px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar .num { font-size: 11px; color: var(--muted); }
.bars .bar .day { font-size: 11px; color: var(--muted); }

.plist { display: flex; flex-direction: column; gap: 8px; }
.plist .row-item { display: flex; align-items: center; gap: 10px; }
.plist .row-item .nm { width: 80px; flex: none; font-size: 13px; }
.plist .row-item .track { flex: 1; height: 8px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.plist .row-item .track i { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.plist .row-item .ct { width: 48px; text-align: right; font-size: 12px; color: var(--muted); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40;
  display: grid; place-items: center; padding: 20px; overflow: auto;
}
.modal {
  width: 720px; max-width: 100%; background: var(--panel); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal .body { padding: 18px 20px; max-height: 66vh; overflow: auto; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfd; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90;
  padding: 10px 18px; border-radius: 8px; background: #16202f; color: #fff; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
pre.code {
  background: #0f172a; color: #d7e2f5; padding: 12px 14px; border-radius: 8px;
  font-size: 12px; overflow: auto; max-height: 260px; margin: 0;
}
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
