/* ========================================
   IoT 控制台专用样式
   海南微控信息科技有限公司
   ======================================== */

/* ========== 登录页 ========== */
.iot-login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height) - 80px);
  padding: 40px 24px;
  background: linear-gradient(160deg, var(--primary-bg) 0%, #fff 50%, var(--bg-secondary) 100%);
}

.iot-login-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* 卡片顶部装饰线 */
.iot-login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.iot-login-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  margin: 0 auto 20px;
}

.iot-login-card h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.iot-login-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ---------- 二维码区域 ---------- */
.qrcode-area {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.qrcode-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 280px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  transition: all var(--transition);
  position: relative;
  padding: 12px;
  box-sizing: border-box;
}

/* OAuth 模式：微信官方扫码页，需要更大空间展示完整内容 */
.qrcode-placeholder.oauth-mode {
  width: 290px;
  padding: 0;
  padding-top: 36px;
  overflow: hidden;
  justify-content: flex-start;
}

.qrcode-placeholder.oauth-mode iframe {
  width: 100% !important;
  height: 400px !important;
  border: none;
  display: block;
}

.qrcode-placeholder:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 20px rgba(10,102,194,0.1);
}

/* CSS 模拟二维码网格 */
.qrcode-grid {
  width: 180px;
  height: 180px;
  display: grid;
  grid-template-columns: repeat(21, 1fr);
  grid-template-rows: repeat(21, 1fr);
  gap: 1px;
  margin-bottom: 12px;
  opacity: 0.9;
}

.qrcode-grid-inner {
  display: contents;
}

/* 二维码定位符样式（三个角上的方框） */
.qr-finder {
  background: var(--text-primary) !important;
}

.qr-finder-white {
  background: #fff !important;
}

.qr-finder-center {
  background: var(--text-primary) !important;
}

.qr-data-dark {
  background: var(--text-primary);
}

.qr-data-light {
  background: #fff;
}

.qrcode-label {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* 二维码过期状态 */
.qrcode-placeholder.expired {
  border-color: var(--warning);
  cursor: pointer;
}

.qrcode-placeholder.expired:hover {
  border-color: var(--primary);
}

.qrcode-placeholder.expired .qrcode-grid {
  display: none;
}

.qrcode-placeholder.expired .qrcode-label {
  color: var(--warning);
}

/* 已扫码状态 */
.qrcode-placeholder.scanned {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(0, 201, 167, 0.05);
}

/* ---------- 扫码状态提示 ---------- */
.scan-status {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
  min-height: 20px;
  transition: color var(--transition);
}

.scan-status.pending {
  color: var(--text-tertiary);
}

.scan-status.scanned {
  color: var(--accent);
  font-weight: 500;
}

.scan-status.confirmed {
  color: var(--primary);
  font-weight: 600;
}

.scan-status.expired {
  color: var(--warning);
}

.scan-status.error {
  color: var(--danger);
}

/* ---------- 底部提示 ---------- */
.iot-login-tip {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* ========== IoT 控制台主页 ========== */
.iot-console {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  background: var(--bg-secondary);
}

/* ---------- 左侧面板列表 ---------- */
.iot-panel-list {
  width: 260px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.iot-panel-list-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.iot-panel-list-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.iot-panel-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  max-width: 40px;
}

.iot-panel-count.iot-panel-count-full {
  color: var(--error, #e53935);
  font-weight: 500;
}

.iot-user-name {
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iot-panel-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ---------- 高级用户侧边栏专区 ---------- */
.iot-senior-section {
  border-top: 1px solid var(--border-light);
  padding: 0;
}

/* ---- 临时用户设置头部（可折叠） ---- */
.iot-senior-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: background 0.15s;
  user-select: none;
}
.iot-senior-header:hover {
  background: var(--border-light);
}
.iot-senior-header-icon {
  font-size: 14px;
}
.iot-senior-toggle {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}

.iot-senior-body {
  padding: 0;
  overflow-y: auto;
  max-height: 320px;
}

/* ---- 子区块 ---- */
.iot-senior-sub-block {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}
.iot-senior-sub-block:last-child {
  border-bottom: none;
}
.iot-senior-sub-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.iot-senior-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: #f59e0b;
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
}
.iot-senior-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 10px;
}

.iot-invite-link-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  word-break: break-all;
}
.iot-invite-text {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.iot-invite-text.iot-invite-loading {
  color: var(--text-tertiary);
  font-style: italic;
}
.iot-invite-text.iot-invite-error {
  color: var(--error, #e53935);
}

.iot-invite-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.iot-senior-btn {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 5px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.iot-senior-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--primary, #6366f1);
}
.iot-senior-btn-primary {
  background: var(--primary, #6366f1);
  color: #fff;
  border-color: var(--primary, #6366f1);
}
.iot-senior-btn-primary:hover {
  opacity: 0.9;
}
.iot-senior-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-tertiary);
}

.iot-senior-btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

.iot-senior-btn-danger {
  color: #e53935;
  border-color: #e53935;
}
.iot-senior-btn-danger:hover {
  background: #e53935;
  color: #fff;
}

.iot-senior-hint {
  font-size: 10px;
  color: var(--text-tertiary);
}

/* ---- 临时用户列表 / 管理 ---- */
.iot-temp-user-list {
  max-height: 200px;
  overflow-y: auto;
}
.iot-temp-empty {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 12px 0;
}

/* 待审批申请项 */
.iot-temp-pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-secondary);
  gap: 6px;
}
.iot-temp-pending-item:last-child {
  border-bottom: none;
}
.iot-temp-pending-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.iot-temp-remark {
  font-size: 10px;
  color: var(--primary, #6366f1);
  margin-top: 2px;
}

/* 已授权临时用户管理项 */
.iot-temp-manage-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-secondary);
}
.iot-temp-manage-item:last-child {
  border-bottom: none;
}
.iot-temp-manage-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

/* 天数选择器 */
.iot-temp-days-select {
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
}
.iot-temp-days-sm {
  padding: 2px 4px;
}
.iot-temp-user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.iot-temp-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iot-temp-wx-account {
  font-size: 10px;
  color: var(--text-tertiary);
}
.iot-temp-expire {
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  margin-left: 6px;
}
.iot-temp-expire.iot-temp-expired {
  color: var(--error, #e53935);
}

/* ---------- 面板项 ---------- */
.iot-panel-item {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.iot-panel-item:hover {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
}

.iot-panel-item.active {
  background: var(--primary-bg);
  border-color: var(--primary);
}

.iot-panel-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iot-panel-item-device {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---------- 面板空状态 ---------- */
.iot-panel-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  text-align: center;
}

.iot-panel-empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

.iot-panel-empty-state p {
  font-size: 13px;
}

/* ---------- 右侧面板渲染区 ---------- */
.iot-panel-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  position: relative;
}

.iot-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-tertiary);
}

.iot-panel-empty p {
  font-size: 14px;
}

/* ---------- 手机框架（面板渲染区） ---------- */
.iot-phone-frame {
  width: 375px;
  height: 667px;
  border-radius: 28px;
  background: #1a1a2e;
  padding: 12px;
  box-shadow: var(--shadow-xl), 0 0 0 2px rgba(255,255,255,0.1);
  position: relative;
}

.iot-phone-screen {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  background: #f5f5f5;
}

/* 手机顶部状态栏 */
.iot-phone-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: rgba(0,0,0,0.06);
  z-index: 10;
}

/* 手机底部导航条 */
.iot-phone-screen::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0,0,0,0.15);
  z-index: 10;
}

/* ---------- 面板背景 ---------- */
.iot-panel-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
}

/* ---------- 组件渲染 ---------- */
.iot-widget {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  cursor: default;
  user-select: none;
}

.iot-widget:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.iot-widget.interactive {
  cursor: pointer;
}

.iot-widget-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.iot-widget-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- Switch 组件 ---------- */
.iot-widget-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 6px;
}

.iot-switch-toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #ccc;
  position: relative;
  transition: background var(--transition);
  cursor: pointer;
}

.iot-switch-toggle.on {
  background: var(--accent);
}

.iot-switch-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--transition);
}

.iot-switch-toggle.on::after {
  transform: translateX(20px);
}

.iot-switch-state {
  font-size: 10px;
  margin-top: 3px;
  color: var(--text-tertiary);
}

/* ---------- Slider 组件 ---------- */
.iot-widget-slider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 8px 10px;
}

.iot-slider-track {
  width: 100%;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  position: relative;
  margin: 8px 0;
}

.iot-slider-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.1s;
}

.iot-slider-thumb {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 1px 4px rgba(10,102,194,0.3);
  transform: translate(-50%, -50%);
  cursor: grab;
  transition: box-shadow var(--transition);
}

.iot-slider-thumb:active {
  cursor: grabbing;
  box-shadow: 0 2px 8px rgba(10,102,194,0.4);
}

.iot-slider-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

/* ---------- Gauge 组件 ---------- */
.iot-widget-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.iot-gauge-value {
  font-weight: 700;
  line-height: 1.2;
}

.iot-gauge-unit {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ---------- Label 组件 ---------- */
.iot-widget-label-text {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 8px;
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  word-break: break-all;
}

.iot-label-input {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  text-align: center;
  padding: 0;
  margin: 0;
}
.iot-label-input::placeholder {
  color: var(--text-tertiary);
  opacity: 0.6;
}
.iot-label-input:focus {
  border-bottom: 1px solid var(--primary);
}

/* ---------- 退出按钮 ---------- */
.iot-logout-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  z-index: 100;
  border: 1px solid var(--border-light);
}

.iot-logout-btn:hover {
  color: var(--danger);
  box-shadow: var(--shadow-lg);
  border-color: var(--danger);
}

/* ---------- 命令发送反馈 ---------- */
.iot-cmd-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.iot-cmd-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========================================
   访客页面（无权限状态）
   ======================================== */

/* 左侧面板列表置灰禁用 */
.iot-guest-disabled {
  pointer-events: none;
  opacity: 0.35;
  filter: grayscale(1);
  user-select: none;
}

/* 右侧访客提示区 */
.iot-guest-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 320px;
  padding: 48px 32px;
  text-align: center;
  gap: 20px;
}

.iot-guest-icon {
  opacity: 0.4;
}

.iot-guest-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
  max-width: 380px;
}

/* 申请权限按钮 */
.iot-apply-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 36px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.iot-apply-btn:hover {
  background: var(--primary-dark, #0855a8);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(10,102,194,0.28);
}

.iot-apply-btn:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 申请结果提示文字 */
.iot-guest-hint {
  font-size: 13px;
  line-height: 1.6;
  max-width: 360px;
  color: var(--text-tertiary);
  min-height: 20px;
}

.iot-guest-hint.iot-apply-success {
  color: var(--accent, #00c9a7);
}

.iot-guest-hint.iot-apply-error {
  color: var(--danger, #e53e3e);
}

/* ========================================
   管理员账号登录表单
   ======================================== */
.iot-admin-login-form {
  margin-top: 8px;
  animation: iot-fade-in 0.25s ease;
}

@keyframes iot-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.iot-admin-divider {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.iot-admin-divider::before,
.iot-admin-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.iot-admin-divider span {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: 500;
}

.iot-admin-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.iot-admin-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}

.iot-admin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}

.iot-admin-input::placeholder {
  color: var(--text-tertiary);
}

.iot-admin-btn {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.iot-admin-btn:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 4px 14px rgba(10, 102, 194, 0.3);
}

.iot-admin-btn:active {
  transform: scale(0.98);
}

.iot-admin-btn:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.iot-admin-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
  margin: 0;
}

/* ========================================
   管理员面板操作
   ======================================== */

/* 侧栏头部操作区 */
.iot-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 图标按钮 */
.iot-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.iot-icon-btn:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

/* 管理员标识 */
.iot-admin-badge {
  color: var(--primary) !important;
  font-weight: 600;
}

/* 面板项布局（含操作按钮） */
.iot-panel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.iot-panel-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.iot-panel-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 面板状态标签 */
.iot-panel-status {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  line-height: 1.5;
}

.iot-panel-draft,
.iot-panel-testing {
  background: rgba(245, 166, 35, 0.12);
  color: var(--warning);
}

.iot-panel-published {
  background: rgba(0, 201, 167, 0.12);
  color: var(--accent);
}

/* 面板操作按钮组 */
.iot-panel-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.iot-panel-item:hover .iot-panel-actions {
  opacity: 1;
}

.iot-panel-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.iot-panel-edit-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.iot-panel-delete-btn:hover {
  background: rgba(229, 62, 62, 0.1);
  color: var(--danger);
}

.iot-panel-publish-btn:hover {
  background: rgba(0, 201, 167, 0.1);
  color: var(--accent);
}

.iot-panel-unpublish-btn:hover {
  background: rgba(245, 166, 35, 0.1);
  color: var(--warning);
}

.iot-cmd-toast.success {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,201,167,0.3);
}

.iot-cmd-toast.error {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(231,76,60,0.3);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .iot-login-card {
    padding: 32px 24px;
  }

  .iot-console {
    flex-direction: column;
  }

  .iot-panel-list {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }

  .iot-panel-items {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding: 12px;
  }

  .iot-panel-item {
    flex-shrink: 0;
    margin-bottom: 0;
  }

  .iot-phone-frame {
    transform: scale(0.75);
    transform-origin: center top;
  }

  .iot-logout-btn {
    bottom: 16px;
    right: 16px;
  }
}

@media (max-width: 480px) {
  .iot-phone-frame {
    transform: scale(0.55);
    transform-origin: center top;
  }

  .iot-login-card {
    padding: 24px 20px;
  }

  .qrcode-placeholder {
    width: 260px;
    padding: 10px;
  }
  .qrcode-placeholder.oauth-mode {
    width: 270px;
    padding: 0;
    padding-top: 28px;
  }
  .qrcode-placeholder.oauth-mode iframe {
    height: 380px !important;
  }

  .qrcode-grid {
    width: min(180px, 60vw);
    height: min(180px, 60vw);
  }
}

/* ========================================
   Panel Editor — 面板拖拽编辑器
   从 admin.html 迁移，使用 pe- 前缀命名空间隔离
   ======================================== */

/* ===== Panel Editor ===== */
.pe-editor {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.pe-toolbar {
  height: 48px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
}
.pe-toolbar-title {
  font-weight: 600;
  font-size: 15px;
  margin: 0 12px;
  color: var(--text-primary);
}
.pe-toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
.pe-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  transition: all 0.15s;
}
.pe-btn:hover { background: var(--bg-secondary); }
.pe-btn.active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.pe-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.pe-btn-primary:hover { background: var(--primary-dark); }
.pe-btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
  background: transparent; color: var(--text-secondary);
}
.pe-btn-icon:hover { background: var(--bg-secondary); }
.pe-btn-icon.active { background: var(--primary-bg); color: var(--primary); }
.pe-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.pe-palette {
  width: 200px;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px;
}
.pe-palette-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.pe-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: grab;
  background: #fff;
  transition: all 0.15s;
  user-select: none;
}
.pe-palette-item:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.pe-palette-item:active { cursor: grabbing; }
.pe-palette-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--bg-secondary);
  font-size: 14px;
  flex-shrink: 0;
}
.pe-palette-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.pe-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #e8eaed;
  padding: 24px;
}
.pe-canvas {
  width: 375px;
  height: 667px;
  background: #f5f5f5;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 20px rgba(0,0,0,0.12);
  border-radius: 4px;
  flex-shrink: 0;
}
.pe-canvas.pe-grid {
  background-image:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 10px 10px;
  background-color: #f5f5f5;
}
.pe-widget {
  position: absolute;
  cursor: move;
  user-select: none;
  overflow: hidden;
}
.pe-widget:hover {
  outline: 1px solid rgba(10,102,194,0.3);
}
.pe-widget-preview {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.pe-selection {
  position: absolute;
  border: 2px dashed #0A66C2;
  pointer-events: none;
  z-index: 9999;
}
.pe-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 2px solid #0A66C2;
  border-radius: 1px;
  pointer-events: all;
  z-index: 10000;
}
.pe-handle-nw { top: -5px; left: -5px; cursor: nw-resize; }
.pe-handle-n  { top: -5px; left: 50%; margin-left: -4px; cursor: n-resize; }
.pe-handle-ne { top: -5px; right: -5px; cursor: ne-resize; }
.pe-handle-e  { top: 50%; margin-top: -4px; right: -5px; cursor: e-resize; }
.pe-handle-se { bottom: -5px; right: -5px; cursor: se-resize; }
.pe-handle-s  { bottom: -5px; left: 50%; margin-left: -4px; cursor: s-resize; }
.pe-handle-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.pe-handle-w  { top: 50%; margin-top: -4px; left: -5px; cursor: w-resize; }
.pe-props {
  width: 280px;
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
.pe-props-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.pe-props-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.pe-field {
  margin-bottom: 8px;
}
.pe-field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  font-weight: 500;
}
.pe-field input[type="text"],
.pe-field input[type="number"],
.pe-field select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
  background: #fff;
}
.pe-field input:focus,
.pe-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10,102,194,0.1);
}
.pe-field input[type="color"] {
  width: 32px; height: 28px; padding: 1px 2px; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer;
}
.pe-field-row {
  display: flex; gap: 6px;
}
.pe-field-row .pe-field { flex: 1; }
.pe-field-checkbox {
  display: flex; align-items: center; gap: 6px;
}
.pe-field-checkbox input { margin: 0; }
.pe-statusbar {
  height: 28px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  gap: 16px;
  flex-shrink: 0;
}
/* Preview mode */
.pe-preview .pe-selection { display: none !important; }
.pe-preview .pe-palette { display: none; }
.pe-preview .pe-widget { cursor: default; }
.pe-preview .pe-widget:hover { outline: none; }
.pe-preview .pe-props { display: none; }
.pe-preview .pe-canvas-wrap { background: #333; }
/* Switch preview */
.pe-sw-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; width: 100%; height: 100%;
}
.pe-sw-track {
  width: 48px; height: 26px; border-radius: 13px; position: relative;
}
.pe-sw-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  position: absolute; top: 2px; left: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
/* Gauge preview */
.pe-gauge-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.pe-gauge-value {
  font-size: 28px; font-weight: 700; color: var(--primary);
}
.pe-gauge-unit {
  font-size: 12px; color: var(--text-tertiary);
}
/* Slider preview */
.pe-slider-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 8px;
}
.pe-slider-track {
  width: 80%; height: 6px; background: #e0e0e0; border-radius: 3px;
  position: relative;
}
.pe-slider-fill {
  height: 100%; background: var(--primary); border-radius: 3px;
}
.pe-slider-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--primary);
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  position: absolute; top: -5px;
}

/* ========== MQTT 参数设置侧边栏 ========== */
.iot-mqtt-settings-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 10;
}
.iot-mqtt-settings-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.mqtt-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: mqtt-sidebar-slide 0.25s ease;
}
@keyframes mqtt-sidebar-slide {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.mqtt-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.mqtt-sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.mqtt-sidebar-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.mqtt-sidebar-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.mqtt-sidebar-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.mqtt-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: 8px;
}
.mqtt-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.mqtt-status-dot.connected {
  background: #00C9A7;
  box-shadow: 0 0 6px rgba(0,201,167,0.4);
}
.mqtt-status-dot.error {
  background: #E74C3C;
}
.mqtt-status-dot.disconnected {
  background: #999;
}

.mqtt-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mqtt-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.mqtt-field input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-primary);
  outline: none;
  transition: border-color var(--transition);
}
.mqtt-field input:focus {
  border-color: var(--primary);
}
.mqtt-field input:disabled {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.mqtt-connect-btn {
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
  background: var(--primary);
  color: #fff;
}
.mqtt-connect-btn:hover {
  opacity: 0.9;
}
.mqtt-connect-btn[data-action="disconnect"] {
  background: #E74C3C;
}
