* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  background: #f4f6f9; color: #1f2d3d; font-size: 13px; -webkit-font-smoothing: antialiased;
}
.app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------------- sidebar ---------------- */
.side {
  width: 196px; flex: 0 0 196px; background: #1b2735; color: #9fb0c3;
  display: flex; flex-direction: column; padding: 14px 10px 12px;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 6px 18px; color: #fff; font-size: 14px; font-weight: 600; }
.logo {
  width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #2b8cf5, #14b8a6);
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 4px;
  color: #9fb0c3; text-decoration: none; font-size: 13px;
}
.nav-item .ic { width: 16px; text-align: center; font-size: 12px; opacity: .85; }
.nav-item:hover { background: #22303f; color: #d6e2ef; }
.nav-item.active { background: #2b6cb0; color: #fff; }
.side-foot { margin-top: auto; font-size: 11px; color: #5d6f83; padding: 10px 8px; line-height: 1.7; }

/* ---------------- main ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; flex: 0 0 58px; background: #fff; border-bottom: 1px solid #e6ebf1;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: #2b6cb0; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.uname { font-size: 13px; color: #2c3e50; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 3px; }
.badge-super { background: #fdecec; color: #e04b4b; border: 1px solid #f7cdcd; }
.logout {
  border: 1px solid #e3e8ef; background: #fff; color: #7b8794; padding: 5px 12px;
  border-radius: 3px; cursor: pointer; font-size: 12px; margin-left: 6px;
}
.logout:hover { border-color: #c9d3e0; color: #2c3e50; }

.content { padding: 16px 20px 30px; }

/* ---------------- stats ---------------- */
.stats { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
.stat {
  background: #fff; border: 1px solid #e9eef4; border-radius: 4px; padding: 13px 14px;
  min-height: 74px; display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.stat .label { color: #8a97a6; font-size: 11.5px; }
.stat .value { font-size: 24px; font-weight: 700; color: #25313f; line-height: 1; }
.stat .value.green { color: #1fa971; }
.stat .value.red { color: #e04b4b; }
.stat .value.blue { color: #2b6cb0; }
.stat-row2 { margin-top: 12px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 26px; border-bottom: 1px solid #e6ebf1; margin: 20px 0 0; }
.tab {
  background: none; border: none; padding: 10px 2px 11px; font-size: 13.5px; color: #5f6f80;
  cursor: pointer; position: relative;
}
.tab.active { color: #2b6cb0; font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: #2b6cb0;
}

/* ---------------- panel ---------------- */
.panel { background: #fff; border: 1px solid #e9eef4; border-radius: 4px; margin-top: 14px; padding: 16px 18px 6px; }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; }
.panel-head h2 { font-size: 15px; font-weight: 600; }
.filters { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.filters input, .filters select {
  height: 30px; border: 1px solid #dfe6ee; border-radius: 3px; padding: 0 9px; font-size: 12.5px;
  color: #33475b; background: #fff; outline: none;
}
.filters input { width: 210px; }
.filters input:focus, .filters select:focus { border-color: #2b6cb0; }

.toolbar { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; }
.hint { color: #93a1b1; font-size: 12px; }

.btn {
  height: 30px; padding: 0 14px; border-radius: 3px; font-size: 12.5px; cursor: pointer;
  border: 1px solid transparent; background: #fff; color: #33475b;
}
.btn-sm { height: 27px; padding: 0 11px; }
.btn-plain { border-color: #dfe6ee; }
.btn-plain:hover:not(:disabled) { border-color: #b9c6d6; }
.btn-plain:disabled { color: #b6c1cc; cursor: not-allowed; }
.btn-primary { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }
.btn-primary:hover { background: #245c96; }
.btn-danger-ghost { border-color: #f3c9c9; color: #e04b4b; background: #fff; }
.btn-danger-ghost:hover { background: #fdf3f3; }

/* ---------------- table ---------------- */
.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left; font-size: 12px; color: #7b8a9a; font-weight: 500;
  padding: 10px 10px; background: #fafbfd; border-top: 1px solid #edf1f6; border-bottom: 1px solid #edf1f6;
}
.grid td { padding: 13px 10px; border-bottom: 1px solid #f0f4f8; font-size: 12.5px; color: #33475b; vertical-align: middle; }
.grid tbody tr:hover { background: #fafcff; }
.col-chk { width: 38px; }
.col-op { width: 150px; }
.u-cell .name { font-size: 13px; color: #1f2d3d; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.u-cell .sub { color: #93a1b1; font-size: 11.5px; margin-top: 4px; }
.tag-mine { background: #eaf2fb; color: #2b6cb0; border: 1px solid #cfe1f5; font-size: 10.5px; padding: 1px 5px; border-radius: 3px; font-weight: 400; }
.dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #1fa971; margin-right: 5px; }
.role { font-size: 11.5px; padding: 2px 7px; border-radius: 3px; border: 1px solid; }
.role-super { color: #e04b4b; background: #fdecec; border-color: #f7cdcd; }
.role-admin { color: #2b6cb0; background: #eaf2fb; border-color: #cfe1f5; }
.role-user { color: #5f6f80; background: #f2f5f9; border-color: #e2e8f0; }
.role-readonly { color: #97772c; background: #fdf6e6; border-color: #f2e3bd; }
.st { font-size: 11.5px; padding: 2px 8px; border-radius: 9px; }
.st-on { color: #1fa971; background: #e9f8f1; }
.st-off { color: #8a97a6; background: #f2f5f9; }
.exp { color: #5f6f80; }
.exp.warn { color: #d98324; }
.exp.dead { color: #e04b4b; }
.login-cell { line-height: 1.7; }
.login-cell .t { color: #33475b; }
.login-cell .ip { color: #93a1b1; font-size: 11.5px; }
.login-cell .cnt { color: #93a1b1; font-size: 11.5px; }
.link { color: #2b6cb0; cursor: pointer; margin-right: 10px; }
.link:hover { text-decoration: underline; }
.link.danger { color: #e04b4b; }
.empty { text-align: center; color: #a5b1be; padding: 26px 0; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 2px 12px; }
.pager span { color: #93a1b1; font-size: 12px; margin-right: 4px; }

/* ---------------- modal ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 26, 36, .45); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.dialog { width: 520px; background: #fff; border-radius: 5px; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); }
.dialog.small { width: 400px; }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid #eef2f7; font-size: 14.5px; font-weight: 600;
}
.dialog-head .x { background: none; border: none; font-size: 20px; color: #9aa7b4; cursor: pointer; line-height: 1; }
.dialog-body { padding: 16px 18px 6px; }
.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: 12.5px; color: #5f6f80; margin-bottom: 6px; }
.form-row label i { color: #e04b4b; font-style: normal; }
.form-row input, .form-row select {
  width: 100%; height: 32px; border: 1px solid #dfe6ee; border-radius: 3px; padding: 0 10px;
  font-size: 12.5px; color: #33475b; outline: none; background: #fff;
}
.form-row input:focus, .form-row select:focus { border-color: #2b6cb0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.inline { margin-bottom: 6px; }
.switch-label { display: flex !important; align-items: center; gap: 7px; font-size: 12.5px; color: #5f6f80; }
.switch-label input { width: auto; height: auto; }
.form-err { color: #e04b4b; font-size: 12px; min-height: 18px; padding-bottom: 4px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; }

/* ---------------- me ---------------- */
.me-box { padding: 4px 0 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 26px; }
.me-item { font-size: 12.5px; color: #5f6f80; }
.me-item b { display: block; color: #1f2d3d; font-size: 13.5px; font-weight: 600; margin-top: 5px; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 99;
  background: #25313f; color: #fff; padding: 9px 18px; border-radius: 4px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

/* ===== 可见设备选择器 ===== */
.hint-i{font-style:normal;color:#93a1b1;font-size:12px;font-weight:400}
.devpick{display:flex;flex-direction:column;gap:8px}
.devbox{border:1px solid #e2e8f0;border-radius:8px;overflow:hidden;background:#fff}
.devbox-head{display:flex;align-items:center;gap:10px;padding:8px 10px;border-bottom:1px solid #eef1f5;background:#fafbfd}
.devbox-head input{flex:1;min-width:80px;height:30px;padding:0 8px;border:1px solid #dfe4ec;border-radius:6px;font-size:13px;outline:none}
.devbox-head input:focus{border-color:#2f6bff}
.devbox-head .link{font-size:13px;cursor:pointer;color:#2f6bff;white-space:nowrap}
.devbox-list{max-height:230px;overflow:auto}
.dev-item{display:flex;align-items:flex-start;gap:9px;padding:8px 10px;cursor:pointer;border-bottom:1px solid #f4f6fa}
.dev-item:last-child{border-bottom:0}
.dev-item:hover{background:#f6f9ff}
.dev-item input{margin-top:3px;width:15px;height:15px;accent-color:#2f6bff;flex:0 0 auto}
.dev-txt{display:flex;flex-direction:column;min-width:0}
.dev-txt b{font-size:13px;color:#1f2a37;font-weight:600;word-break:break-all}
.dev-txt i{font-style:normal;font-size:12px;color:#7a8699;word-break:break-all}
.dev-empty{padding:26px 10px;text-align:center;color:#9aa5b5;font-size:13px}

/* ===== 手机适配：弹窗与可见设备选择器 ===== */
@media (max-width: 640px) {
  .mask { padding: 10px; align-items: flex-start; padding-top: 20px; }
  .dialog, .dialog.small { width: 100%; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
  .dialog-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .dialog-foot { border-top: 1px solid #eef2f7; background: #fff; }
  .form-grid { grid-template-columns: 1fr; }
  .devbox-list { max-height: 190px; }
  .devbox-head { flex-wrap: wrap; }
  .dev-txt b { font-size: 12.5px; }
}

/* ===== 窄屏：表格内部横向滚动，页面不被撑宽 ===== */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 820px) {
  .mask { padding: 10px; align-items: flex-start; padding-top: 20px; }
  .dialog, .dialog.small { width: 100%; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
  .dialog-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .form-grid { grid-template-columns: 1fr; }
  .devbox-list { max-height: 190px; }
  .devbox-head { flex-wrap: wrap; }
  .grid { min-width: 720px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 手机窄屏布局：侧栏转顶部横向导航 ===== */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .side {
    width: 100%; flex: 0 0 auto; flex-direction: row; align-items: center;
    gap: 6px; padding: 8px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .brand { padding: 0 10px 0 2px; white-space: nowrap; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 7px 10px; font-size: 12.5px; }
  .nav-item .ic { display: none; }
  .side-foot { display: none; }
  .topbar { height: 52px; flex: 0 0 52px; padding: 0 12px; }
  .topbar h1 { font-size: 15px; }
  .content { padding: 12px 12px 26px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat { min-height: 62px; padding: 10px; }
  .stat .value { font-size: 19px; }
  .panel { padding: 12px 12px 4px; }
  .filters { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .filters input { width: 100%; }
  .me-box { grid-template-columns: 1fr 1fr; }
}
