/* 活码后台 —— 浅蓝浅紫，卡片化数据页 */
:root {
  --bg: #f4f6fb;
  --panel: #fff;
  --ink: #1f2a44;
  --muted: #8b95a8;
  --line: #e8ecf4;
  --accent: #5b7cfa;
  --accent-hover: #4a6aef;
  --accent-soft: rgba(91, 124, 250, 0.12);
  --danger: #e85d5d;
  --side-w: 232px;
  --radius: 16px;
  --c-blue: #5b7cfa;
  --c-mint: #2ec4a2;
  --c-orange: #ff8a4c;
  --c-purple: #8b6dff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; outline: none; }
input, select, textarea {
  font: inherit;
  color: #445;
  border: 1px solid #d9e0ef;
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 72px; resize: vertical; }

#app.shell { min-height: 100vh; }

#app .left {
  width: var(--side-w);
  height: 100%;
  background: #fff;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  border-right: 1px solid var(--line);
  z-index: 20;
}
#app .left .dhview {
  width: 196px;
  margin: 28px auto;
  height: calc(100% - 56px);
  position: relative;
}
#app .left .logo {
  width: 196px;
  margin-bottom: 24px;
  padding: 2px 6px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
#app .left .logo .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #6b8cff, #8b6dff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 8px 16px rgba(91, 124, 250, .25);
}
#app .left .logo .brand-name {
  font-size: 18px;
  font-weight: 750;
  color: var(--ink);
  line-height: 1.2;
}
#app .left .logo .brand-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
#app .left nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#app .left .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 196px;
  height: 42px;
  border: 0;
  background: transparent;
  color: #5a657a;
  border-radius: 12px;
  text-align: left;
  transition: .18s;
  padding: 0 12px;
}
#app .left .nav-item:hover {
  background: #f5f7ff;
  color: var(--accent);
}
#app .left .nav-item.selected {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}
#app .left .nav-item .ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}
#app .left .nav-item .ico svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#app .left .nav-item .nav-text { font-size: 15px; }
#app .left .nav-group-label {
  padding: 16px 8px 6px 14px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .08em;
}

#app .left .account {
  width: 196px;
  position: absolute;
  bottom: 8px;
  left: 0;
  background: #f7f9ff;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
  font-size: 14px;
  padding: 12px 10px;
  color: #5a657a;
}
#app .left .account .user_name {
  margin-bottom: 6px;
  word-break: break-all;
}
#app .left .account .exitLogin,
#app .left .account .back-link {
  display: inline-block;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  padding: 4px 8px;
  cursor: pointer;
}

#right {
  margin-left: 276px;
  padding: 28px 0 80px;
  min-height: 100vh;
}
#right .page {
  width: calc(100% - 52px);
  display: grid;
  gap: 18px;
}
.err,
#right .err,
.modal .err,
[data-err] {
  color: var(--danger) !important;
  margin: 8px 0;
  font-size: 13px;
  min-height: 18px;
}

.default-btn {
  border: none;
  color: #fff;
  background: var(--accent);
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 14px;
  display: inline-block;
}
.default-btn:hover { background: var(--accent-hover); }
.tint-btn {
  border: 1px solid #d9e0ef;
  color: #5a657a;
  background: #f7f9ff;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 14px;
  transition: .12s;
  display: inline-block;
}
.tint-btn:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.button-view {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.button-view .button-gongneng { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

/* —— 统计卡（图2） —— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 18px 18px 14px;
  box-shadow: 0 8px 24px rgba(31, 42, 68, .05);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .8);
}
.stat-card::before {
  content: "";
  position: absolute;
  left: -20px;
  top: -30px;
  width: 120px;
  height: 120px;
  border-radius: 40%;
  opacity: .45;
  pointer-events: none;
}
.stat-card.theme-blue::before { background: #c9d6ff; }
.stat-card.theme-mint::before { background: #c8f3e8; }
.stat-card.theme-orange::before { background: #ffe0cc; }
.stat-card.theme-purple::before { background: #e2d9ff; }

.stat-card .stat-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.stat-card .stat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.stat-card .stat-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
}
.theme-blue .stat-ico { background: var(--c-blue); box-shadow: 0 8px 16px rgba(91, 124, 250, .35); }
.theme-mint .stat-ico { background: var(--c-mint); box-shadow: 0 8px 16px rgba(46, 196, 162, .35); }
.theme-orange .stat-ico { background: var(--c-orange); box-shadow: 0 8px 16px rgba(255, 138, 76, .35); }
.theme-purple .stat-ico { background: var(--c-purple); box-shadow: 0 8px 16px rgba(139, 109, 255, .35); }

.stat-card .stat-main {
  position: relative;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  color: var(--ink);
}
.stat-card .stat-label {
  position: relative;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.stat-card .stat-subs {
  position: relative;
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card .stat-sub {
  border: 1px solid #eef1f7;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .7);
}
.stat-card .stat-sub .k {
  font-size: 11px;
  color: var(--muted);
}
.stat-card .stat-sub .v {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.stat-card .stat-foot {
  position: relative;
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.stat-card .stat-bar {
  margin-top: 8px;
  height: 4px;
  border-radius: 999px;
  background: #eef1f7;
  overflow: hidden;
}
.stat-card .stat-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
}
.theme-blue .stat-bar > i { background: var(--c-blue); }
.theme-mint .stat-bar > i { background: var(--c-mint); }
.theme-orange .stat-bar > i { background: var(--c-orange); }
.theme-purple .stat-bar > i { background: var(--c-purple); }

/* —— 面板卡（图3/图4） —— */
.panel-card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(31, 42, 68, .05);
  border: 1px solid rgba(232, 236, 244, .9);
  position: relative;
  overflow: hidden;
}
.panel-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 40%;
  background: radial-gradient(circle, rgba(139, 109, 255, .12), transparent 65%);
  pointer-events: none;
}
.panel-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  z-index: 1;
}
.panel-head .titles .t {
  font-size: 17px;
  font-weight: 750;
  color: var(--ink);
}
.panel-head .titles .s {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.panel-head .badge {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: #eef3ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f5f7ff;
  color: #5a657a;
  font-size: 12px;
  border: 1px solid #e8ecf4;
}
.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.chart-box {
  position: relative;
  z-index: 1;
  height: 240px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafbff, #fff);
  border: 1px solid #eef1f7;
  padding: 12px 8px 8px 36px;
}
.chart-box svg { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
.toolbar input {
  width: auto;
  min-width: 180px;
}
.table-wrap { width: 100%; overflow-x: auto; position: relative; z-index: 1; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data-table th,
table.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #eef1f7;
  text-align: left;
  vertical-align: middle;
}
table.data-table th {
  color: #7a8499;
  font-weight: 650;
  font-size: 12px;
  background: #f7f9ff;
}
table.data-table tbody tr:hover { background: #f8faff; }
.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 36px 10px !important;
}
.dark-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}
.light-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  background: #eef1f7;
  color: #7a8499;
  border-radius: 999px;
}
/* 操作列：表头与按钮居中对齐 */
table.data-table th:last-child,
table.data-table td:last-child {
  text-align: center;
}
.ops {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.ops .tint-btn {
  padding: 3px 10px;
  font-size: 12px;
  text-decoration: none;
  color: #5a657a;
  line-height: 1.4;
}
.ops a.tint-btn:hover { color: #fff; }

.switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 0;
  padding: 2px;
  position: relative;
  vertical-align: middle;
  transition: .2s;
}
.switch i {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: .2s;
}
.switch.on { background: var(--accent); }
.switch.on i { margin-left: 18px; }
.switch.off { background: #d5dae6; }
.switch.off i { margin-left: 0; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(24, 32, 56, .38);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .14);
}
.modal.modal-lg { width: min(680px, 100%); }
.field-row {
  display: flex;
  gap: 12px;
}
.field-row .field { flex: 1; min-width: 0; }
.pick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pick-row-sm { grid-template-columns: 1fr 1fr; }
.pick-item {
  border: 1px solid #d9e0ef;
  background: #f7f9ff;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  color: #5a657a;
  transition: .15s;
}
.pick-item strong {
  display: block;
  font-size: 14px;
  color: var(--ink);
}
.pick-item small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.pick-item:hover {
  border-color: #b8c6f5;
  background: #eef3ff;
}
.pick-item.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, .08);
}
.pick-item.on strong { color: var(--accent); }
.modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal .modal-header h4 {
  margin: 0;
  font-size: 17px;
  color: var(--ink);
}
.modal .modal-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  color: #99a;
  line-height: 1;
  padding: 0 4px;
}
.modal .modal-body { padding: 18px 20px; }
.modal .modal-footer {
  padding: 12px 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.field { margin-bottom: 14px; }
.field label,
.field .text {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #5a657a;
  font-weight: 650;
}
.item-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
  color: #5a657a;
  font-size: 13px;
  font-weight: 650;
  align-items: end;
}
.item-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.item-row .limit-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.item-row .limit-wrap input[name="limit_pv"] {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.item-row .tint-btn[data-del] {
  flex-shrink: 0;
  min-width: 42px;
  padding: 6px 8px;
}
.item-row .tint-btn[data-del].is-disabled,
.item-row .tint-btn[data-del]:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.url-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.url-list { display: block; }

/* 目标图片：虚线加号 + 小图网格 */
.img-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.img-grid .item-row.img-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  grid-template-columns: unset;
}
.img-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f5fa;
  border: 1px solid var(--line);
}
.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.img-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
}
.img-grid .img-card input[name="limit_pv"] {
  width: 100%;
  text-align: center;
  padding: 9px 12px;
  font-size: 14px;
}
.img-add {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px dashed #c5cde0;
  background: #fafbff;
  color: #9aa6bf;
  cursor: pointer;
  transition: .15s;
  margin: 0;
}
.img-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.img-add .plus {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  user-select: none;
}
@media (max-width: 640px) {
  .img-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 登录 */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 15% 10%, rgba(139, 109, 255, .28), transparent 55%),
    radial-gradient(800px 400px at 90% 85%, rgba(91, 124, 250, .35), transparent 50%),
    linear-gradient(145deg, #2a3560, #3a4a8a 45%, #243056);
}
.formBox {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  padding: 0 0 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .22);
}
.formBox .header-box {
  width: 88%;
  margin: 30px auto 0;
  text-align: center;
}
.formBox .header-box .login-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: linear-gradient(145deg, #6b8cff, #8b6dff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 8px 16px rgba(91, 124, 250, .3);
}
.formBox .header-box .login-brand {
  font-size: 24px;
  font-weight: 750;
  color: var(--ink);
}
.formBox .header-box .login-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}
.formBox .line {
  width: 100%;
  height: 1px;
  background: var(--line);
  margin-top: 20px;
}
.formBox .form-box {
  width: 80%;
  margin: 24px auto 0;
}
.formBox .form-box label {
  display: block;
  color: #5a657a;
  font-size: 13px;
  margin: 12px 0 6px;
  font-weight: 650;
}
.formBox .form-box .form-control { height: 42px; font-size: 15px; }
.formBox .form-control-login {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 11px;
  color: #fff;
  background: var(--accent);
  margin: 28px auto 0;
  display: block;
  cursor: pointer;
  font-weight: 650;
}
.formBox .form-control-login:hover { background: var(--accent-hover); }
.formBox .login-err {
  text-align: center;
  color: var(--danger);
  margin-top: 14px;
  font-size: 13px;
  min-height: 20px;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-box {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 36px 28px;
  text-align: center;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(31, 42, 68, .05);
}
.gate-box h1 {
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--ink);
}
.gate-box .hint { color: var(--muted); margin-bottom: 20px; }

@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  #app .left {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
  }
  #app .left .dhview {
    width: auto;
    margin: 12px 16px;
    height: auto;
  }
  #app .left nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  #app .left .nav-item { width: auto; }
  #app .left .nav-group-label { display: none; }
  #app .left .account {
    position: static;
    width: auto;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
  }
  #right {
    margin-left: 0;
    padding: 16px 16px 60px;
  }
  #right .page { width: 100%; }
  .stat-grid { grid-template-columns: 1fr; }
  .device-row { justify-content: center; }
}

/* —— 分享 / 设备数据 —— */
.share-box { padding: 4px 2px 8px; }
.share-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: .15s;
}
.share-link:hover { background: #e9ebf0; }
.share-link .k {
  display: block;
  font-size: 13px;
  color: #8b95a8;
  margin-bottom: 6px;
}
.share-link .v {
  display: block;
  font-size: 14px;
  color: #1a1f2c;
  word-break: break-all;
  line-height: 1.45;
}
.share-qr {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}
.share-qr img {
  width: 220px;
  height: 220px;
  border-radius: 8px;
  background: #fff;
}

.device-stats { padding: 6px 2px 10px; }
.device-stats-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #1a1f2c;
  margin: 4px 0 18px;
}
.device-block { margin-bottom: 18px; }
.device-block-label {
  text-align: center;
  font-size: 13px;
  color: #8b95a8;
  margin-bottom: 10px;
}
.device-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.device-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  border-radius: 999px;
  padding: 8px 12px 8px 10px;
  min-width: 72px;
}
.device-pill .ico {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.device-pill .lbl {
  font-size: 12px;
  color: #5a657a;
}
.device-pill .num {
  font-size: 14px;
  font-weight: 650;
  color: #1a1f2c;
  font-variant-numeric: tabular-nums;
}

.link-toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(26, 31, 44, .88);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 80;
}
.link-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
