:root {
  --bg: #05080f;
  --bg2: #0a0f1c;
  --surface: rgba(18, 26, 44, 0.72);
  --surface-solid: #121a2c;
  --surface2: #1a2540;
  --border: rgba(0, 224, 255, 0.14);
  --border-strong: rgba(0, 224, 255, 0.35);
  --text: #e8edf7;
  --muted: #7c89a8;
  --primary: #00e0ff;
  --primary2: #3b82f6;
  --accent: #a78bfa;
  --success: #2dd4a7;
  --warning: #fbbf24;
  --danger: #fb5a6a;
  --radius: 14px;
  --glow: 0 0 24px rgba(0, 224, 255, 0.18);
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text); font-size: 15px; line-height: 1.65;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59, 130, 246, 0.16), transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 0%, rgba(167, 139, 250, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
}
/* 网格背景层 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 224, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 224, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 30%, #000 40%, transparent 90%);
}
body > * { position: relative; z-index: 1; }
a { color: var(--primary); text-decoration: none; transition: .18s; }
a:hover { text-decoration: underline; text-shadow: 0 0 8px rgba(0, 224, 255, 0.5); }

/* ---- 顶部导航 ---- */
.topnav {
  display: flex; align-items: center; gap: 2px;
  background: linear-gradient(180deg, rgba(10, 16, 30, 0.92), rgba(10, 16, 30, 0.78));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 0 22px; height: 56px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  overflow-x: auto; white-space: nowrap;
}
.topnav .brand {
  font-weight: 800; font-size: 18px; margin-right: 18px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: .6px; text-shadow: 0 0 18px rgba(0, 224, 255, 0.25);
}
.topnav a {
  color: var(--muted); padding: 7px 14px; border-radius: 8px;
  font-size: 14px; transition: .18s; text-decoration: none;
}
.topnav a:hover { background: var(--surface2); color: var(--text); text-shadow: none; }
.topnav .nav-right { margin-left: auto; }

/* ---- 布局 ---- */
.container { max-width: 1760px; margin: 30px auto; padding: 0 22px; }

/* ---- 统计卡片 ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px;
  position: relative; overflow: hidden; transition: .25s;
}
.stat-card::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: .6;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--glow); }
.stat-card .num { font-size: 30px; font-weight: 800; background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card .num.text-sm { font-size: 15px; }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 6px; letter-spacing: .3px; }

/* ---- 卡片 ---- */
.card {
  background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; margin-bottom: 24px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.card h2 { font-size: 18px; margin-bottom: 16px; }
.card h3 { font-size: 16px; margin-bottom: 12px; }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
tr:hover td { background: rgba(0, 224, 255, 0.04); }
td a { font-size: 13px; }

/* ---- 表单 ---- */
label { display: block; margin: 14px 0 5px; font-weight: 600; font-size: 14px; color: #cdd6ea; }
input, select, textarea {
  width: 100%; padding: 10px 13px; background: rgba(5, 9, 18, 0.6);
  border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-size: 14px; font-family: inherit;
  transition: .18s;
}
input::placeholder, textarea::placeholder { color: #4a5878; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 224, 255, 0.12), 0 0 16px rgba(0, 224, 255, 0.15);
  background: rgba(5, 9, 18, 0.85);
}
textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- 验证码 ---- */
.captcha-row { display: flex; gap: 12px; align-items: stretch; }
.captcha-row input { flex: 1; }
.captcha-img {
  height: 46px; border-radius: 9px; border: 1px solid var(--border);
  cursor: pointer; flex-shrink: 0; transition: .18s; background: #070b16;
}
.captcha-img:hover { border-color: var(--border-strong); box-shadow: 0 0 14px rgba(0, 224, 255, 0.25); }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 22px; border: 0; border-radius: 9px;
  cursor: pointer; font-size: 14px; font-weight: 700;
  transition: .2s; text-decoration: none; letter-spacing: .3px;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #04121f; box-shadow: 0 4px 18px rgba(0, 224, 255, 0.3); }
.btn-primary:hover { box-shadow: 0 6px 26px rgba(0, 224, 255, 0.5); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #e11d48); color: #fff; }
.btn-danger:hover { box-shadow: 0 6px 22px rgba(251, 90, 106, 0.4); }
.btn-sm { padding: 5px 13px; font-size: 12px; border-radius: 7px; }
.btn-line { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-strong); color: var(--text); }
.btn-line:hover { background: rgba(0, 224, 255, 0.08); border-color: var(--primary); }

/* ---- Flash ---- */
.flash { padding: 13px 17px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; border: 1px solid; }
.flash-info { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.5); color: #93c5fd; }
.flash-success { background: rgba(45, 212, 167, 0.1); border-color: rgba(45, 212, 167, 0.5); color: #6ee7b7; }
.flash-error { background: rgba(251, 90, 106, 0.1); border-color: rgba(251, 90, 106, 0.5); color: #fca5a5; }

/* ---- 徽章 ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.badge-ok { background: rgba(45, 212, 167, 0.15); color: var(--success); box-shadow: inset 0 0 0 1px rgba(45, 212, 167, 0.3); }
.badge-off { background: rgba(251, 90, 106, 0.15); color: var(--danger); box-shadow: inset 0 0 0 1px rgba(251, 90, 106, 0.3); }
.badge-muted { background: var(--surface2); color: var(--muted); }

/* ---- 登录页 ---- */
.login-wrap { max-width: 400px; margin: 9vh auto 40px; padding: 0 20px; }
.login-card {
  background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong); border-radius: 18px; padding: 36px 34px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 40px rgba(0, 224, 255, 0.08);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
}
.login-card h1 {
  font-size: 24px; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-card .btn { width: 100%; margin-top: 22px; }
.login-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ---- 代码块 ---- */
.code-block {
  background: rgba(5, 9, 18, 0.7); border: 1px solid var(--border);
  border-radius: 9px; padding: 15px 16px; font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  font-size: 13px; word-break: break-all; white-space: pre-wrap; color: #c8d3e8;
}
.mono { font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace; }

/* ---- 工具 ---- */
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.text-muted { color: var(--muted); } .text-sm { font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

/* ---- 动画 ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.card, .stat-card, .login-card { animation: fadeUp .4s ease both; }
.flash { animation: fadeUp .3s ease both; }

/* ---- 可排序表头 ---- */
th a.sort-th { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; transition: .15s; }
th a.sort-th:hover { color: var(--primary); text-shadow: none; }
th a.sort-th.sort-active { color: var(--primary); text-shadow: 0 0 6px rgba(0,224,255,.4); }
.sort-arrow { font-size: 10px; opacity: .85; }

/* ---- 表格容器 (自动适应内容宽度, 无需左右拖动) ---- */
.table-scroll { border-radius: var(--radius); border: 1px solid var(--border); background: rgba(5,9,18,0.35); overflow-x: auto; }
.table-scroll table { width: 100%; }
.table-scroll th { white-space: nowrap; }
.table-scroll td { white-space: normal; word-break: break-word; }

/* ---- 客户信息单元格 (独立列, 完整显示) ---- */
.cell-cust { min-width: 88px; }
.cell-addr { min-width: 140px; word-break: break-word; line-height: 1.5; }
.cell-actions { white-space: nowrap; }

/* ---- 文本工具 ---- */
.text-danger { color: var(--danger); }

/* ---- 列表工具栏: 搜索+排序 ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .tb-search { flex: 1; min-width: 220px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar select { min-width: 128px; }
.toolbar .btn { flex-shrink: 0; }

/* ---- 小屏优化 ---- */
@media (max-width: 768px) {
  .container { padding: 0 12px; margin: 16px auto; }
  .card { padding: 16px 14px; }
  .topnav { padding: 0 10px; }
  th, td { padding: 9px 10px; font-size: 13px; }
  .toolbar { gap: 8px; }
  .toolbar .tb-search { min-width: 100%; flex-basis: 100%; }
}

/* ---- 分页 ---- */
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.page-info { color: var(--muted); font-size: 13px; }
.page-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.page-btns .btn { min-width: 32px; text-align: center; padding: 4px 10px; }

/* ---- 小屏优化 ---- */
@media (max-width: 768px) {
  .pagination { flex-direction: column; align-items: flex-start; }
}

/* ---- 在线状态指示器 ---- */
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.online-dot.online { background: #2dd4a7; box-shadow: 0 0 6px rgba(45, 212, 167, 0.6); }
.online-dot.offline { background: #6b7280; box-shadow: 0 0 4px rgba(107, 114, 128, 0.3); }

/* 设备列表: 自适应宽度, 内容全部直接显示, 不需要左右拖动 */
.table-scroll.table-auto { overflow-x: visible; }
.table-scroll.table-auto table { width: 100%; table-layout: auto; }
.table-scroll.table-auto th,
.table-scroll.table-auto td { white-space: normal; word-break: break-word; overflow-wrap: anywhere; padding: 8px 8px; }
.table-scroll.table-auto th { white-space: nowrap; }
.table-scroll.table-auto td.mono { font-size: 12px; letter-spacing: -.2px; }
.table-scroll.table-auto td.cell-actions { white-space: nowrap; }
@media (max-width: 900px) {
  .table-scroll.table-auto { overflow-x: auto; }
}