* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #1f2329;
  padding: 16px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto 16px;
}
header h1 { font-size: 20px; }

.svc { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #bbb; display: inline-block;
}
.dot.on { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.dot.off { background: #ef4444; }

main { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px #00000018;
}
.card h2 { font-size: 15px; margin-bottom: 10px; }
.card h2 small { font-weight: normal; color: #888; }

select {
  width: 100%;
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
}
#room-select { margin-bottom: 8px; }

.info-grid { display: grid; grid-template-columns: auto minmax(max-content, 1fr) minmax(max-content, 1fr) auto; gap: 10px; }
/* 移动端窄屏：4 列放不下会把「在线」框挤出容器 → 改 2×2 网格 */
@media (max-width: 640px) {
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.state-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.info-grid > div, .state-item { background: #f7f8fa; border-radius: 8px; padding: 10px; }
.info-grid > div { min-width: 0; }
.info-grid > div:nth-child(2), .info-grid > div:nth-child(3) { overflow-wrap: anywhere; }
.k { display: block; font-size: 12px; color: #888; margin-bottom: 4px; }

.state-value { font-size: 18px; font-weight: 600; }
.pill { padding: 2px 12px; border-radius: 999px; display: inline-block; font-size: 15px; }
.pill.on { background: #dcfce7; color: #16a34a; }
.pill.off { background: #fee2e2; color: #dc2626; }
.pill.danger { background: #fee2e2; color: #dc2626; }
.pill.warn { background: #fef3c7; color: #d97706; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 13px; }
.badge.on { background: #dcfce7; color: #16a34a; }
.badge.off { background: #f3f4f6; color: #9ca3af; }

/* 状态横向条（switch 等非 light 设备：灰色、不可拖动） */
.hbar {
  width: 100%; height: 8px; border-radius: 999px;
  background: #e5e7eb; margin-top: 8px; overflow: hidden;
}
.hbar .hbar-fill { height: 100%; border-radius: 999px; }
.hbar.off .hbar-fill { width: 0; background: #d1d5db; }

.ctrl-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ctrl-label { width: 130px; font-size: 14px; color: #444; }
.ctrl-row input[type=range] { flex: 1; }

/* 底部：凭证有效期倒计时 */
.token-bar {
  max-width: 720px;
  margin: 12px auto 0;
  padding: 8px 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px #00000018;
  font-size: 13px;
  color: #888;
  text-align: center;
}
.token-bar.warn { color: #d97706; background: #fffbeb; }

/* 登录卡 */
#login-card { max-width: 360px; margin: 0 auto; }
#login-card input[type=password] {
  width: 100%;
  padding: 8px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.login-tip { font-size: 13px; color: #888; margin-bottom: 10px; }
.login-msg { font-size: 13px; color: #dc2626; margin-top: 8px; min-height: 16px; }

.btn {
  padding: 7px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
}
.btn.ok { background: #16a34a; }
.btn.ok:hover { background: #15803d; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: #e5e7eb; color: #374151; }
.btn.ghost:hover { background: #d1d5db; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* IP 访问记录（底部） */
#access-log { list-style: none; max-height: 220px; overflow-y: auto; font-size: 13px; }
#access-log li { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; display: flex; gap: 8px; }
#access-log li .t { color: #999; flex-shrink: 0; }
#access-log li .m { color: #1f2329; }
#access-log li.empty { color: #999; }

/* 操作反馈浮动 toast（右上角） */
#toast {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 340px;
  pointer-events: none;
}
.toast-item {
  background: #1f2937;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 2px 8px #00000033;
  opacity: 1;
  transition: opacity .4s;
}
.toast-item.ok { background: #16a34a; }
.toast-item.fail { background: #dc2626; }
.toast-item.warn { background: #d97706; }
.toast-item.hide { opacity: 0; }

/* 设备资源面板 */
#res-list { display: flex; flex-direction: column; gap: 6px; }
.res-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; background: #f7f8fa; border-radius: 8px; font-size: 14px; }
.res-label { color: #444; }
.res-val { font-weight: 600; }
.res-val.on { color: #16a34a; }
.res-val.off { color: #dc2626; }
.res-val.danger { color: #dc2626; }
.res-val.warn { color: #d97706; }
.res-empty { color: #999; font-size: 13px; padding: 6px 2px; }
