* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #1f2329;
}
#app { height: 100vh; }

/* ---------- 登录 ---------- */
.login-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2C5FBC, #4b7bec);
}
.login-card {
  width: 320px;
  background: #fff;
  padding: 32px 28px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
}
.login-card h2 { margin: 0 0 20px; font-size: 18px; text-align: center; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: #555; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 9px 10px;
  border: 1px solid #d9dde3; border-radius: 6px; font-size: 14px;
}
.error { color: #e54545; font-size: 12px; min-height: 16px; margin-bottom: 8px; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 200px; background: #1f2d3d; color: #cfd8e3;
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar .logo { font-size: 16px; font-weight: 700; color: #fff; padding: 8px 10px 18px; }
.sidebar button {
  text-align: left; background: transparent; border: 0; color: #cfd8e3;
  padding: 11px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; margin-bottom: 4px;
}
.sidebar button:hover { background: #2b3b4f; }
.sidebar button.active { background: #2C5FBC; color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .user { font-size: 13px; padding: 10px 14px; color: #9fb0c3; }
.sidebar .user small { color: #6f8298; }
.sidebar .logout { color: #ff9b9b; }
.sidebar .logout:hover { background: #3a2730; }

.content { flex: 1; padding: 24px 28px; overflow: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 18px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid #d9dde3; background: #fff; color: #1f2329;
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: #2C5FBC; color: #2C5FBC; }
.btn.primary { background: #2C5FBC; border-color: #2C5FBC; color: #fff; }
.btn.primary:hover { background: #234e9c; color: #fff; }
.btn.danger { color: #e54545; border-color: #f3c2c2; }
.btn.danger:hover { background: #fdeaea; color: #c93030; }
.btn.block { width: 100%; margin-top: 6px; padding: 10px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { width: 100%; min-width: 1180px; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.grid th, .grid td { padding: 11px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid #eef0f3; }
.grid th { background: #fafbfc; color: #6b7480; font-weight: 600; }
.grid tbody tr:hover { background: #f6f9ff; }
.grid td.click { cursor: pointer; color: #2C5FBC; }
.grid td.click:hover { text-decoration: underline; }
.grid .empty { text-align: center; color: #9aa3ad; padding: 28px; }
.grid .dash { color: #b6bcc4; }

/* ---------- 表单 ---------- */
.form { background: #fff; padding: 22px; border-radius: 8px; max-width: 560px; }
.form label { display: block; margin-bottom: 14px; font-size: 13px; color: #555; }
.form input, .form select, .form textarea {
  width: 100%; margin-top: 6px; padding: 8px 10px;
  border: 1px solid #d9dde3; border-radius: 6px; font-size: 14px;
}
.form .actions { margin-top: 8px; }

/* ---------- 设备表单（字段布局与小程序 device-edit 对齐） ---------- */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  color: #555;
  line-height: 1;
}
.field-label .req { color: #e54545; font-style: normal; margin-left: 2px; }
.field-input { width: 100%; }
.field-textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
/* 编辑态下设备ID不可修改 */
.field-input.is-readonly {
  background: #f5f6f7;
  color: #8a9099;
  cursor: not-allowed;
}
.field-hint {
  margin: 5px 0 0;
  font-size: 12px;
  color: #9aa3ad;
  line-height: 1.5;
}

/* ---------- 用户选择行 ---------- */
.user-picker-row { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.picker-display { flex: 1; background: #f8f9fa; cursor: pointer; }

/* ---------- 用户详情 - 设备列表区块 ---------- */
.section-head { margin-top: 24px; margin-bottom: 10px; }
.section-head h3 { margin: 0; font-size: 15px; color: #444; }

/* ---------- 用户选择弹窗 ---------- */
.popup-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.popup-box {
  background: #fff;
  border-radius: 10px;
  width: 420px;
  max-height: 70vh;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  overflow: hidden;
}
.popup-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #eee;
}
.popup-head h3 { margin: 0; font-size: 16px; }
.popup-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: #999; line-height: 1; padding: 0 4px;
}
.popup-close:hover { color: #333; }
.popup-search {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
}
.popup-search input {
  width: 100%; padding: 8px 10px;
  border: 1px solid #d9dde3; border-radius: 6px; font-size: 14px;
  box-sizing: border-box;
}
.popup-list {
  overflow-y: auto;
  flex: 1;
  max-height: 380px;
}
.popup-item {
  padding: 11px 16px;
  border-bottom: 1px solid #f6f6f6;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.popup-item:hover { background: #f0f5ff; }
.popup-item-name { font-size: 14px; color: #1f2329; font-weight: 500; }
.popup-item small { font-size: 12px; color: #999; }


/* ---- 快速操作（设备详情页） ---- */
.ops-section {
  background: #fff; border-radius: 8px; padding: 20px; margin-top: 16px;
  border: 1px solid #e8e8e8;
}
.ops-section h3 { margin: 0 0 12px; font-size: 15px; color: #333; }
.op-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.op-btns .btn { border-radius: 6px; font-size: 13px; padding: 8px 14px; }
.op-msg { margin-top: 10px; font-size: 13px; min-height: 18px; }

/* ---- 电磁阀按钮颜色 ---- */
.btn.primary { background: #1677ff; color: #fff; border-color: #1677ff; }
.btn.danger  { background: #fff; color: #f44336; border-color: #f44336; }
.btn.danger:hover { background: #f44336; color: #fff; }

