* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "Microsoft YaHei", sans-serif; background: #f0f2f5; color: #333; }
a { text-decoration: none; color: #1890ff; }

/* 登录页 */
.login-wrap { display: flex; justify-content: center; align-items: center; height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.login-box h2 { text-align: center; margin-bottom: 30px; color: #333; }
.login-box .role-switch { display: flex; gap: 10px; margin-bottom: 20px; }
.login-box .role-switch label { flex: 1; text-align: center; padding: 8px; border: 1px solid #d9d9d9;
  border-radius: 6px; cursor: pointer; font-size: 14px; }
.login-box .role-switch input { display: none; }
.login-box .role-switch input:checked + span { color: #1890ff; }
.login-box .role-switch label:has(input:checked) { border-color: #1890ff; background: #e6f7ff; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; color: #666; }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid #d9d9d9;
  border-radius: 6px; font-size: 14px; }
.form-group input:focus { border-color: #1890ff; outline: none; }
.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: 6px;
  cursor: pointer; font-size: 14px; transition: all 0.2s; }
.btn-primary { background: #1890ff; color: #fff; width: 100%; }
.btn-primary:hover { background: #40a9ff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; }
.btn-default { background: #fff; border: 1px solid #d9d9d9; color: #333; }
.btn-default:hover { border-color: #1890ff; color: #1890ff; }
.btn-success { background: #52c41a; color: #fff; }
.btn-success:hover { background: #73d13d; }

/* 设备监控-控制条按钮优化（仅作用于该条，不影响全局 .btn-primary 的满宽用法） */
.mon-ctrl-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mon-ctrl-bar .btn { width: auto; flex: 0 0 auto; padding: 9px 18px; font-size: 14px;
  font-weight: 500; line-height: 1.3; white-space: nowrap; text-align: center;
  border-radius: 6px; user-select: none; }
.mon-ctrl-bar #monBtnRun, .mon-ctrl-bar #monBtnStop { min-width: 104px; }
.mon-btn-back { background: #e6f7ff; border: 1px solid #1890ff; color: #1890ff; }
.mon-btn-back:hover { background: #bae7ff; border-color: #40a9ff; }
.mon-btn-run { background: #52c41a; border: 1px solid #52c41a; color: #fff; }
.mon-btn-run:hover { background: #73d13d; border-color: #73d13d; }
.mon-btn-stop { background: #fff; border: 1px solid #ff4d4f; color: #ff4d4f; }
.mon-btn-stop:hover { background: #fff1f0; border-color: #ff7875; }
.mon-ctrl-bar #monRunStatus { margin-left: auto; display: inline-flex; align-items: center;
  white-space: nowrap; font-size: 14px; font-weight: 600; padding: 5px 14px;
  border-radius: 999px; background: #f5f5f5; }
.mon-ctrl-bar #btnRun, .mon-ctrl-bar #btnStop { min-width: 104px; }
.mon-ctrl-bar #runStatus { margin-left: auto; display: inline-flex; align-items: center;
  white-space: nowrap; font-size: 14px; font-weight: 600; padding: 5px 14px;
  border-radius: 999px; background: #f5f5f5; }

/* 主布局 */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.sidebar { width: 100%; background: #001529; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; gap: 6px; height: 56px; padding: 0 20px;
  position: sticky; top: 0; z-index: 30; box-shadow: 0 2px 8px rgba(0,0,0,0.18); flex-wrap: nowrap; }
.sidebar .logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  font-size: 18px; font-weight: bold; line-height: 1; margin: 0; padding: 0; border: none; white-space: nowrap; }
.sidebar .nav-menu { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sidebar .nav-user { display: flex; align-items: center; gap: 10px; margin-left: 18px; padding-left: 16px;
  border-left: 1px solid #1f3a5f; color: rgba(255,255,255,0.85); font-size: 14px; white-space: nowrap; }
.sidebar .nav-logout { background: transparent; border: 1px solid #3a5577; color: #fff;
  padding: 4px 12px; border-radius: 6px; cursor: pointer; line-height: 1.4; }
.sidebar .nav-logout:hover { background: #1890ff; border-color: #1890ff; }
.sidebar .nav-account { color: rgba(255,255,255,0.85); font-size: 14px; white-space: nowrap; }
.sidebar .menu-item { padding: 8px 18px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.75); transition: all 0.2s; border-radius: 6px; white-space: nowrap; line-height: 1.4; }
.sidebar .menu-item:hover { background: #1890ff22; color: #fff; }
.sidebar .menu-item.active { background: #1890ff; color: #fff; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 48px; background: #fff; padding: 0 24px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid #f0f0f0; position: sticky; top: 56px; z-index: 20; }
.topbar #pageTitle { font-size: 15px; font-weight: 600; color: #333; }
.topbar .user-info { display: flex; align-items: center; gap: 12px; }
.content { padding: 20px 24px; flex: 1; min-width: 0; }

/* 卡片 */
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h3 { margin-bottom: 16px; font-size: 16px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
th { background: #fafafa; font-weight: 600; color: #666; }
tr:hover { background: #fafafa; }

/* 状态标签 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-online { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.tag-offline { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }

/* 设备网格 */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.device-card { background: #fff; border-radius: 8px; padding: 20px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); transition: all 0.2s; border: 2px solid transparent; }
.device-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.device-card.active { border-color: #1890ff; }
.device-card.offline { background: #fff1f0; border-color: #ffa39e; }
.device-card.offline .dev-name { color: #ff4d4f; }
.device-card.card-alarm { border-color: #ff4d4f; background: #fff7f6; }
.device-card .dev-name { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.device-card .dev-sn { font-size: 12px; color: #999; margin-bottom: 12px; }
.device-card .dev-status { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: #52c41a; }
.status-dot.offline { background: #ff4d4f; }

/* 数据项 */
.data-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.data-item { background: #f6f8fa; padding: 10px 12px; border-radius: 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.data-item .label { font-size: 13px; color: #999; margin-bottom: 0; white-space: nowrap;
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.data-item .value { font-size: 20px; font-weight: 600; color: #333; text-align: right;
  margin-left: auto; white-space: nowrap; flex: 0 0 auto; }
.data-item .unit { font-size: 14px; color: #999; font-weight: normal; }
.data-item > .btn { flex: 0 0 auto; margin: 0; padding: 4px 10px; }
/* 实时数据卡片：已移除更新时间，标签与数值同一行 */

/* 弹窗 */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 8px; padding: 24px; width: 500px; max-height: 80vh;
  overflow-y: auto; }
.modal h3 { margin-bottom: 20px; }
.modal .form-group input, .modal .form-group select { width: 100%; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* 图表容器 */
.chart-container { height: 400px; }

/* 提示 */
.toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 6px;
  color: #fff; z-index: 2000; display: none; }
.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }

/* 配置表单 */
.config-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.config-row label { font-size: 13px; color: #666; margin-bottom: 4px; display: block; }
.config-row input, .config-row select { width: 100%; padding: 8px; border: 1px solid #d9d9d9;
  border-radius: 4px; font-size: 14px; }

.empty { text-align: center; padding: 40px; color: #999; }
