:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a5;
  --accent: #4f9cf9;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --bad: #f0616d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-weight: 600; margin: 0 0 12px; }
h1 { font-size: 18px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--muted); }

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.msg { min-height: 18px; color: var(--bad); margin: 0; font-size: 13px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 600; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.topbar nav a.active { background: var(--panel-2); color: var(--text); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

/* ---------- 通用控件 ---------- */
button, .btn {
  background: var(--accent);
  color: #08121f;
  border: 0;
  border-radius: 6px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.ghost, .btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #2a0509; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
  width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
label { font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input[type=checkbox] { width: auto; }

/* ---------- 面板与卡片 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 22px; font-weight: 600; margin-top: 4px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--ok); border-color: #1f4d38; }
.tag.bad { color: var(--bad); border-color: #4d1f26; }
.tag.warn { color: var(--warn); border-color: #4d3d1f; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: var(--warn); border-color: #4d3d1f; }

.muted { color: var(--muted); }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.error { color: var(--bad); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 18px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

.chart { width: 100%; height: 220px; display: block; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.events { max-height: 320px; overflow: auto; }
.events li { list-style: none; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.events ul { margin: 0; padding: 0; }

/* 设备详情里"矿机原始数据"的折叠块 */
details.panel summary { cursor: pointer; color: var(--muted); }
details.panel[open] summary { margin-bottom: 12px; }
pre.raw {
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}
