:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #202433;
  --muted: #7a8095;
  --line: #e6e8f2;
  --accent: #6c5ce7;
  --accent-2: #8e7bff;
  --ok: #0f9d58;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}
.container { max-width: 880px; margin: 0 auto; padding: 0 16px; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; height: 56px; }
.brand { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; gap: 14px; align-items: center; }
.topbar-link { color: var(--muted); text-decoration: none; font-size: 14px; cursor: pointer; }
.topbar-link:hover { color: var(--accent); }

main.container { padding: 24px 16px 60px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: 0 6px 24px rgba(32, 36, 51, .05);
}
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 22px 0 8px; }

/* 登录 */
#loginView { max-width: 420px; margin: 60px auto 0; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; margin-bottom: 6px; }
input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fbfbff; color: var(--text); outline: none; font-family: inherit;
}
input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; border: none; border-radius: 10px; padding: 12px; font-size: 16px; font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); cursor: pointer;
}
.btn-primary:disabled { opacity: .6; }
.btn-secondary {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { border-color: var(--err); color: var(--err); }
.err { color: var(--err); font-size: 14px; min-height: 20px; margin-bottom: 6px; }

/* 概要 */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: #fbfbff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 13px; }

/* 设备表 */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; white-space: nowrap; }
table.grid th { color: var(--muted); font-weight: 500; font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: #c6cad8; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #ecfdf3; }

.add-bar { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.add-bar input { flex: 1; min-width: 200px; }

/* 二维码弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(24, 27, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 14px; padding: 20px; max-width: 460px; width: 100%;
  max-height: 92vh; overflow: auto; text-align: center;
}
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal .qr-holder { display: inline-block; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; }
.modal .qr-holder svg { width: 230px; height: 230px; display: block; }
.modal textarea {
  width: 100%; height: 150px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  background: #fbfbff; color: var(--text); resize: vertical;
}
.modal-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }

.foot-note { color: var(--muted); font-size: 13px; text-align: center; margin-top: 14px; }

/* 教程页 */
.toc { padding-left: 18px; color: var(--muted); font-size: 14px; }
.toc li { margin: 4px 0; }
.kv { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.kv td { padding: 6px 0; border-bottom: 1px dashed var(--line); word-break: break-all; }
.kv td:first-child { color: var(--muted); width: 120px; white-space: nowrap; }
a { color: var(--accent); }

@media (max-width: 640px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  table.grid { font-size: 13px; }
  .hide-sm { display: none; }
}

/* HTML hidden must win over component display rules. */
[hidden]{display:none!important}
