:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #7a828c;
  --brand: #2b6cb0;
  --brand-dark: #22548a;
  --ok: #2f855a;
  --warn: #b7791f;
  --danger: #c53030;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

button {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--brand-dark); color: #fff; }
button.danger { color: var(--danger); border-color: #f0c6c6; }

input, select, textarea {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
textarea { width: 100%; min-height: 260px; line-height: 1.6; resize: vertical; }

/* ---------------- 登录 ---------------- */
#login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #eef2f7, #dfe7f0);
  z-index: 50;
}
/* 必须显式写：作者样式里的 display:flex 会盖掉浏览器对 [hidden] 的 display:none */
#login[hidden] { display: none; }
#login .card {
  width: 340px; padding: 28px;
  background: #fff; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 40, 70, .12);
}
#login h1 { font-size: 18px; margin: 0 0 4px; }
#login p.sub { color: var(--muted); margin: 0 0 20px; font-size: 12px; }
#login label { display: block; margin-bottom: 12px; }
#login label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
#login input { width: 100%; }
#login button { width: 100%; margin-top: 6px; padding: 8px; }

/* ---------------- 发起查看：事由弹窗 ---------------- */
#askReason { position: fixed; inset: 0; background: rgba(15, 23, 32, .72); z-index: 70; display: flex; align-items: center; justify-content: center; }
#askReason[hidden] { display: none; }
#askReason .box { background: #fff; border-radius: 8px; overflow: hidden; }
#askReason .bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfc; }
#askReason .bar .title { font-weight: 600; }
#askReason .bar .spacer { flex: 1; }

/* ---------------- 提示条 ---------------- */
.alert-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 16px;
  background: #fdeaea; border: 1px solid #f3c8c8; border-radius: var(--radius);
  color: #8a2b2b; font-size: 13px; line-height: 1.7;
}
.alert-banner button { margin-left: auto; border-color: #e0a8a8; color: #8a2b2b; }
.ok-banner {
  padding: 10px 14px; margin-bottom: 16px;
  background: #e6f4ec; border: 1px solid #c3e2d1; border-radius: var(--radius);
  color: #24603f; font-size: 13px;
}
.hint {
  margin: 0; padding: 10px 12px; background: #f6f8fa;
  border-left: 3px solid var(--brand); border-radius: 3px;
  color: #4a5568; font-size: 12.5px; line-height: 1.8;
}
.lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.lbl em { font-style: normal; color: #9aa5b1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 label { display: block; }
.grid2 input { width: 100%; }
.grid2 .span2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------------- 布局 ---------------- */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 52px;
  background: #1f2937; color: #fff;
}
header h1 { font-size: 15px; font-weight: 600; margin: 0; }
header .spacer { flex: 1; }
header .who { font-size: 12px; color: #b6c0cd; }
header button { background: transparent; border-color: #4b5563; color: #d5dae1; }
header button:hover { border-color: #9aa5b1; color: #fff; }

nav {
  display: flex; gap: 2px; padding: 0 20px;
  background: #fff; border-bottom: 1px solid var(--border);
}
nav a {
  padding: 11px 14px; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; font-size: 13px;
}
nav a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

main { padding: 18px 20px 60px; }
section[hidden] { display: none; }

/* ---------------- 组件 ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.card .n { font-size: 26px; font-weight: 600; line-height: 1.2; }
.card .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.alert .n { color: var(--danger); }
.card.warn .n { color: var(--warn); }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.panel > .head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.panel > .head h2 { font-size: 14px; margin: 0; }
.panel > .head .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #fafbfc; font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
td.path { max-width: 320px; word-break: break-all; font-family: Consolas, monospace; font-size: 12px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; white-space: nowrap; line-height: 18px;
}
.tag.info { background: #ebf2fa; color: #2b6cb0; }
.tag.notice { background: #eef2f6; color: #4a5568; }
.tag.warning { background: #fdf4e3; color: var(--warn); }
.tag.critical { background: #fdeaea; color: var(--danger); }
.tag.online { background: #e6f4ec; color: var(--ok); }
.tag.offline { background: #f0f1f3; color: var(--muted); }
.tag.ok { background: #e6f4ec; color: var(--ok); }
.tag.no { background: #fdeaea; color: var(--danger); }
.tag.live { background: #fdeaea; color: var(--danger); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .45; } }

.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--muted); font-size: 12px; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 9px 18px; border-radius: 20px;
  font-size: 13px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  z-index: 100; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
#toast.err { background: var(--danger); }

#viewer[hidden] { display: none; }
/* ---------------- 屏幕查看 ---------------- */
#viewer { position: fixed; inset: 0; background: rgba(15, 23, 32, .72); z-index: 60; display: flex; align-items: center; justify-content: center; }
#viewer .box { width: min(1180px, 94vw); height: auto; background: #fff; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; max-height: 94vh; transition: width .18s ease, height .18s ease, transform .18s ease; }
#viewer .box.maximized { width: min(96vw, 1500px); height: 92vh; }
#viewer .box.minimized { width: min(520px, 72vw); height: 150px; }
#viewer .box.minimized .notice,
#viewer .box.minimized .stage,
#viewer .box.minimized .foot { display: none; }
#viewer .bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#viewer .bar .title { font-weight: 600; }
#viewer .bar .spacer { flex: 1; }
#viewer .notice {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 14px; background: #fdf4e3; color: #7b5b12; font-size: 12px; line-height: 1.6;
}
#viewer .stage { flex: 1; overflow: auto; background: #0f1720; display: flex; align-items: center; justify-content: center; min-height: 380px; }
#viewer .stage img { max-width: 100%; display: block; }
#viewer .stage .wait { color: #93a1b0; font-size: 13px; text-align: center; padding: 40px; line-height: 2; }
#viewer .foot { padding: 8px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; display: flex; gap: 16px; }

/* 留存截图预览：和信息流里的"看屏"用同一套版式，
   但顶栏的「下载」是个 <a>，得让它看起来也是按钮 */
#snapView { position: fixed; inset: 0; background: rgba(15, 23, 32, .72); display: flex; align-items: center; justify-content: center; z-index: 40; }
#snapView[hidden] { display: none; }

/* 单机配置弹窗：跟其它覆盖层同一套版式 */
#machineSettings { position: fixed; inset: 0; background: rgba(15, 23, 32, .72); display: flex; align-items: center; justify-content: center; z-index: 45; overflow: auto; }
#machineSettings[hidden] { display: none; }
#machineSettings .box { width: min(720px, 94vw); background: #fff; border-radius: 8px; overflow: hidden; margin: 24px 0; }
#machineSettings .bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#machineSettings .bar .title { font-weight: 600; }
#machineSettings .bar .spacer { flex: 1; }
#machineSettings textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* 终端备注：跟其它覆盖层同一套版式 */
#machineAlias { position: fixed; inset: 0; background: rgba(15, 23, 32, .72); display: flex; align-items: center; justify-content: center; z-index: 45; }
#machineAlias[hidden] { display: none; }
#machineAlias .box { width: min(560px, 92vw); background: #fff; border-radius: 8px; overflow: hidden; }
#machineAlias .bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#machineAlias .bar .title { font-weight: 600; }
#machineAlias .bar .spacer { flex: 1; }

/* 列表里点设备名即可改备注 —— 用按钮但去掉按钮外观 */
button.namebtn {
  padding: 0; border: 0; background: none; font: inherit; color: var(--text);
  text-align: left; cursor: pointer; border-bottom: 1px dashed var(--border);
}
button.namebtn:hover { color: var(--brand); border-bottom-color: var(--brand); }
#snapView .box { width: min(1100px, 95vw); background: #fff; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; max-height: 94vh; }
#snapView .bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#snapView .bar .title { font-weight: 600; }
#snapView .bar .spacer { flex: 1; }
#snapView .notice {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 14px; background: #fdf4e3; color: #7b5b12; font-size: 12px; line-height: 1.6;
}
#snapView .stage { flex: 1; overflow: auto; background: #0f1720; display: flex; align-items: center; justify-content: center; min-height: 320px; }
#snapView .stage img { max-width: 100%; display: block; }
a.btn {
  font: inherit; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-block;
}
a.btn:hover { border-color: var(--brand); color: var(--brand); }
