/* ============================================================
   设备统计与授权监管 —— 公共界面样式 (v2 精修版)
   在页面 inline <style> 之后加载，统一顶栏 / 配色 / 卡片 / 表格 / 表单
   ============================================================ */
:root {
  /* 主色 */
  --c-primary: #2563eb;
  --c-primary-2: #3b82f6;
  --c-primary-dark: #1d4ed8;
  --c-indigo: #4f46e5;
  /* 语义色 */
  --c-success: #16a34a;
  --c-success-2: #22c55e;
  --c-danger: #dc2626;
  --c-danger-2: #ef4444;
  --c-warn: #d97706;
  /* 中性色 */
  --c-ink: #0f172a;
  --c-text: #1e293b;
  --c-text-2: #64748b;
  --c-text-3: #94a3b8;
  --c-line: #e6ecf5;
  --c-line-2: #eef2f8;
  --c-bg: #f5f7fb;
  --c-card: #ffffff;
  /* 尺寸 */
  --radius: 14px;
  --radius-sm: 9px;
  --h-ctl: 32px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .18);
  --ring: 0 0 0 3px rgba(59, 130, 246, .16);
}

/* ---------------- 基础 ---------------- */
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif !important;
  background:
    radial-gradient(1200px 480px at 88% -8%, #e8f0ff 0%, rgba(232, 240, 255, 0) 60%),
    linear-gradient(180deg, #f7f9fd 0%, #f2f5fa 100%) !important;
  background-attachment: fixed !important;
  color: var(--c-text) !important;
  font-size: 13px;
  line-height: 1.6;
  padding: 0 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(59, 130, 246, .2); }

/* 全局细滚动条 */
* { scrollbar-width: thin; scrollbar-color: #cfd8e6 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cfd8e6; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b6c2d4; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

h1 {
  font-size: 20px !important;
  font-weight: 700 !important;
  letter-spacing: -.2px;
  color: var(--c-ink) !important;
  margin: 0 !important;
}

a { color: var(--c-primary); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(16, 24, 40, .07);
  box-shadow: 0 1px 0 rgba(16, 24, 40, .02);
}
.topbar-in {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 22px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
  flex: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #60a5fa 0%, #2563eb 52%, #4f46e5 100%);
  box-shadow: 0 4px 10px rgba(37, 99, 235, .34), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.brand-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--c-ink);
  letter-spacing: .2px;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  scrollbar-width: none;
  margin: 0 !important;
  font-size: 13px !important;
}
.nav::-webkit-scrollbar { display: none; }

.nav a,
a.navlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px !important;
  margin: 0 !important;
  border-radius: var(--radius-sm);
  color: #4b5563 !important;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.nav a:hover { background: #f1f5f9; color: var(--c-ink) !important; }
.nav a.cur,
.nav a.cur:hover {
  background: #eef4ff;
  color: var(--c-primary-dark) !important;
  font-weight: 700 !important;
  box-shadow: inset 0 0 0 1px #dbe7ff;
}

/* 顶栏计数徽标 */
.nav .pill {
  display: inline-block;
  min-width: 18px;
  height: 17px;
  line-height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: #fff1f0;
  color: #d92d20;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--c-text-2);
  white-space: nowrap;
  flex: none;
}
.topbar-user b { color: var(--c-ink); font-weight: 600; }
.avatar {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, #eaf1ff, #d3e2ff);
  box-shadow: inset 0 0 0 1px #dbe7ff;
  flex: none;
}
.topbar-user .logout {
  color: var(--c-danger) !important;
  text-decoration: none !important;
  padding: 4px 9px;
  border-radius: 7px;
  font-weight: 500;
  transition: background .15s;
}
.topbar-user .logout:hover { background: #fef2f2; }

/* ---------------- 内容容器 ---------------- */
.wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 22px 48px;
}

.pagehead {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 2px 0 16px;
}
.pagehead .sub,
.pagehead .muted { font-size: 12.5px; font-weight: 400; color: var(--c-text-3) !important; }

/* ---------------- 卡片面板 ---------------- */
.panel {
  background: var(--c-card) !important;
  border: 1px solid var(--c-line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  padding: 18px 20px !important;
  margin-bottom: 16px !important;
  overflow: hidden;
}
.panel h2 {
  font-size: 14.5px !important;
  font-weight: 700 !important;
  color: var(--c-ink) !important;
  border-left: none !important;
  padding-left: 0 !important;
  margin: 0 0 14px !important;
  line-height: 1.45;
  overflow: hidden;
  letter-spacing: -.1px;
}
.panel h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  margin-right: 9px;
  vertical-align: -1.5px;
}
.panel h2 > button { float: right; margin-top: 2px; }

/* ---------------- 指标卡 ---------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 18px !important;
}
.card {
  position: relative;
  background: var(--c-card) !important;
  border: 1px solid var(--c-line) !important;
  border-radius: var(--radius) !important;
  padding: 14px 16px !important;
  min-width: 0 !important;
  box-shadow: var(--shadow-xs) !important;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #93c5fd, #3b82f6);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
  border-color: #dbe7ff !important;
}
.card .num {
  font-size: 27px !important;
  font-weight: 700 !important;
  line-height: 1.25;
  color: var(--c-ink) !important;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
}
.card .lbl {
  font-size: 12px !important;
  color: var(--c-text-3) !important;
  margin-top: 2px;
  line-height: 1.5;
}
.card .lbl a { color: var(--c-primary) !important; text-decoration: none; }
.card .lbl a:hover { text-decoration: underline; }
.card.warn::before { background: linear-gradient(180deg, #fca5a5, #ef4444); }
.card.warn .num { color: #d92d20 !important; }

/* ---------------- 表格 ---------------- */
.tblwrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--c-line) !important;
  border-radius: 11px !important;
  background: #fff;
}
.tblwrap::-webkit-scrollbar { height: 10px; }
.tblwrap::-webkit-scrollbar-thumb { background: #cfd8e6; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.tblwrap::-webkit-scrollbar-track { background: #f8fafc; }

table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0;
  font-size: 12.5px !important;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc !important;
  color: #5b6779 !important;
  font-weight: 600 !important;
  font-size: 11.5px !important;
  letter-spacing: .3px;
  white-space: nowrap;
  text-align: left;
  border-bottom: 1px solid var(--c-line) !important;
  padding: 10px 11px !important;
}
tbody td {
  padding: 9px 11px !important;
  border-bottom: 1px solid var(--c-line-2) !important;
  vertical-align: middle;
  color: var(--c-text);
}
tbody tr:last-child td { border-bottom: none !important; }
tbody tr { transition: background .12s; }
tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:hover { background: #f6faff !important; }
tbody tr.bad,
tbody tr.dupe { background: #fff7f7 !important; }
tbody tr.bad:hover,
tbody tr.dupe:hover { background: #fff0f0 !important; }

/* 表格内的控件更紧凑 */
tbody td button { height: 26px; padding: 0 10px !important; font-size: 11.5px !important; }
tbody td select { height: 27px; font-size: 11.5px; }

/* ---------------- 按钮 ---------------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: var(--h-ctl);
  padding: 0 14px !important;
  border: none;
  border-radius: var(--radius-sm) !important;
  background: linear-gradient(180deg, #3b82f6, #2563eb) !important;
  color: #fff !important;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 1px 0 rgba(255, 255, 255, .16);
  transition: filter .15s, box-shadow .15s, transform .06s, background .15s;
}
button:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }

button.gray {
  background: #fff !important;
  color: #475569 !important;
  box-shadow: inset 0 0 0 1px #dde4ee, 0 1px 2px rgba(16, 24, 40, .04);
}
button.gray:hover {
  background: #f8fafc !important;
  filter: none;
  box-shadow: inset 0 0 0 1px #cbd5e1;
}
button.green {
  background: linear-gradient(180deg, #22c55e, #16a34a) !important;
}
button.green:hover { box-shadow: 0 4px 12px rgba(22, 163, 74, .28); }
button.red {
  background: linear-gradient(180deg, #f05252, #dc2626) !important;
}
button.red:hover { box-shadow: 0 4px 12px rgba(220, 38, 38, .28); }
button:disabled,
button[disabled] {
  opacity: .5;
  cursor: not-allowed;
  filter: none !important;
  box-shadow: none !important;
}

/* ---------------- 表单 ---------------- */
input[type=text],
input[type=password],
input[type=search],
input[type=date],
input[type=number],
textarea,
select {
  height: var(--h-ctl);
  padding: 0 11px !important;
  border: 1px solid #dfe5ee !important;
  border-radius: var(--radius-sm) !important;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--c-text);
  background-color: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  vertical-align: middle;
}
textarea { height: auto; padding: 8px 11px !important; line-height: 1.6; }
input[type=text]:focus,
input[type=password]:focus,
input[type=search]:focus,
input[type=date]:focus,
input[type=number]:focus,
textarea:focus,
select:focus {
  border-color: var(--c-primary-2) !important;
  box-shadow: var(--ring);
}
input::placeholder,
textarea::placeholder { color: #a9b3c4; }

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 26px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--c-primary);
  cursor: pointer;
  vertical-align: -2px;
}

/* ---------------- 状态标记 ---------------- */
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 1.7;
  background: #eef4ff;
  color: var(--c-primary-dark);
  box-shadow: inset 0 0 0 1px #dbe7ff;
  white-space: nowrap;
}
.tag .del { color: #9aa8bd; font-size: 11px; }
.tag .del:hover { color: var(--c-danger); }

span.ok,
span.no {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.75;
  white-space: nowrap;
}
span.ok { background: #e8f8ef; color: #15803d; box-shadow: inset 0 0 0 1px #d3f2e0; }
span.no { background: #fef0f0; color: #d92d20; box-shadow: inset 0 0 0 1px #fbdbdb; }

.ok { color: var(--c-success); font-weight: 600; }
.no { color: var(--c-danger); font-weight: 600; }

.online { color: #15803d !important; font-weight: 600; }
.online::before,
.offline::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.online::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }
.offline { color: var(--c-text-3) !important; font-weight: 400; }
.offline::before { background: #cbd5e1; }

.muted { color: var(--c-text-3) !important; font-size: 12px; }

/* ---------------- 工具条 ---------------- */
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px !important;
}
.userbox { float: right; font-size: 12.5px; color: var(--c-text-2); }
.userbox button { margin-left: 8px; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--c-text);
}

/* 空状态 */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--c-text-3);
  font-size: 12.5px;
}

/* ---------------- 弹窗（未登记页） ---------------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, .38);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.mask.show { display: flex; }
.dlg {
  width: 380px;
  max-width: 100%;
  background: #fff;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 22px 24px !important;
}
.dlg h3 { font-size: 15px !important; font-weight: 700; color: var(--c-ink); margin-bottom: 12px; }
.dlg .idline {
  font-size: 12px;
  color: #667085;
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
  background: #f6f8fb;
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 10px;
}
.dlg .dlg-tip {
  font-size: 12px;
  color: var(--c-text-2);
  background: #eef4ff;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 12px;
}
.dlg .dlg-lbl { display: block; font-size: 12px; font-weight: 600; color: var(--c-text-2); margin-bottom: 6px; }
.dlg input[type="date"],
.dlg input[type="text"],
.dlg select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: 9px;
  font-size: 14px;
  color: var(--c-text);
  background: #fff;
  margin-bottom: 10px;
}
.dlg input[type="date"]:focus,
.dlg input[type="text"]:focus,
.dlg select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.dlg .dlg-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.dlg .dlg-quick button { height: 28px; font-size: 12px; padding: 0 10px !important; }
.dlg textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--c-line);
  border-radius: 9px;
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--c-text);
  background: #fff;
  margin-bottom: 16px;
  word-break: break-all;
  resize: vertical;
}
.dlg textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.dlg .btns { display: flex; justify-content: flex-end; gap: 8px; }
.dlg .btns button { min-width: 84px; }

/* ---------------- 设备明细查询结果卡片 ---------------- */
.devcard {
  border: 1px solid var(--c-line);
  border-radius: 11px;
  background: #fff;
  padding: 4px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.devcard .kv {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--c-line-2);
  font-size: 12.5px;
  line-height: 20px;
}
.devcard .kv:last-child { border-bottom: none; }
.devcard .k { flex: 0 0 132px; color: #8a95a8; font-weight: 600; }
.devcard .v { flex: 1; min-width: 0; color: var(--c-text); word-break: break-all; }
@media (max-width: 768px) {
  .devcard { padding: 2px 12px; }
  .devcard .k { flex: 0 0 104px; }
}

/* ---------------- 小屏适配 ---------------- */
@media (max-width: 1100px) {
  .topbar-in { height: auto; min-height: 56px; padding: 8px 14px; flex-wrap: wrap; row-gap: 6px; gap: 10px; }
  .nav { order: 3; width: 100%; flex: none; }
  .topbar-user { margin-left: auto; }
}
@media (max-width: 768px) {
  .wrap { padding: 14px 12px 36px; }
  .panel { padding: 14px 13px !important; border-radius: 12px !important; }
  h1 { font-size: 17.5px !important; }
  table { font-size: 12px !important; }
  thead th, tbody td { padding: 8px 9px !important; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 9px; }
  .card .num { font-size: 23px !important; }
  .brand-name { display: none; }
}

/* ---------------- 宽表在小屏转卡片（避免只看到前两列） ---------------- */
@media (max-width: 768px) {
  .tblwrap.tblwrap-cards { border: none !important; background: transparent; overflow: visible; }
  table.cards-sm { display: block; font-size: 12.5px !important; }
  table.cards-sm thead { display: none; }
  table.cards-sm tbody { display: block; }
  table.cards-sm tbody tr {
    display: block;
    margin: 0 0 10px;
    padding: 3px 12px 5px;
    border: 1px solid var(--c-line);
    border-radius: 11px;
    background: #fff !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  }
  table.cards-sm tbody tr:last-child { margin-bottom: 0; }
  table.cards-sm tbody tr.bad,
  table.cards-sm tbody tr.dupe { border-color: #f3bcbc; background: #fffafa !important; }
  table.cards-sm tbody td {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px 10px;
    padding: 7px 0 !important;
    border: none !important;
    border-bottom: 1px dashed var(--c-line-2) !important;
    font-size: 12.5px;
    line-height: 20px;
    text-align: left;
    word-break: break-word;
  }
  table.cards-sm tbody tr td:last-child { border-bottom: none !important; }
  table.cards-sm tbody td::before {
    content: attr(data-label);
    flex: 0 0 66px;
    color: #8a95a8;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 20px;
  }
  table.cards-sm tbody td > * { min-width: 0; max-width: 100%; }
  table.cards-sm tbody td.noteCell {
    max-width: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  table.cards-sm tbody td button { height: 28px; margin: 0; }
  table.cards-sm tbody td select { height: 28px; }
}

/* ---------------- 注册码生成器（/regtool） ---------------- */
.regout {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f7faff, #f2f6fd);
  box-shadow: inset 0 0 0 1px #dce6f5;
}
.regout-t { font-size: 12.5px; font-weight: 700; color: #3d4a5c; margin-bottom: 8px; }
.regout textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cfdcee;
  border-radius: 8px;
  background: #fff;
  color: var(--c-ink);
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13.5px;
  line-height: 1.7;
  letter-spacing: .2px;
  word-break: break-all;
  resize: vertical;
}
.regout textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

/* 设备明细卡片底部操作行 */
.devacts {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f2;
}
