/* 默认明亮模式；data-theme="dark" 时切换深色。
   组件里不再写死颜色，一律走变量。 */

:root,
:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --surface-2: #f7f9fc;
  --field: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
  --hero: linear-gradient(160deg, #ffffff, #f8fafc 70%);
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #151a21;
  --card: #1a2029;
  --surface-2: #12171f;
  --field: #11161d;
  --line: #262e3a;
  --line-strong: #35435a;
  --text: #e8edf4;
  --muted: #8b97a8;
  --accent: #3d8bfd;
  --accent-soft: #16233a;
  --ok: #35c47d;
  --ok-soft: #12291f;
  --warn: #f2a33c;
  --warn-soft: #2a2113;
  --bad: #ef5b5b;
  --bad-soft: #2a1517;
  --shadow: none;
  --hero: linear-gradient(160deg, #1b2432, #151a21 60%);
}

* { box-sizing: border-box; }

/* .modal 设了 display:grid，会覆盖浏览器对 [hidden] 的默认 display:none，
   结果隐藏的遮罩层仍然拦截点击。这里强制一次。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100vh; }

.boot {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; color: var(--muted);
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1000px 500px at 50% -10%, var(--accent-soft) 0%, var(--bg) 62%);
}

.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
  object-fit: cover;
  flex: none;
}
.brand-mark.sm { width: 26px; height: 26px; border-radius: 7px; }
.topbar .brand { margin-bottom: 0; }
.brand-title { font-size: 16px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.row { display: flex; gap: 8px; }
.row > input { flex: 1; }

button {
  cursor: pointer; font-family: inherit; font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--text);
  padding: 10px 14px;
  transition: .15s;
}
button:hover:not(:disabled) { border-color: var(--line-strong); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600; width: 100%; padding: 12px;
}
.btn-primary:hover:not(:disabled) { filter: brightness(.94); }

.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); border-color: var(--bad-soft); background: var(--bad-soft); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.dev-code {
  margin-top: 10px; padding: 8px 10px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg-soft) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav a:hover { color: var(--text); }

/* ---------- 内容 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 18px; margin: 0; font-weight: 600; }
.page-head .count { color: var(--muted); font-size: 13px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-size: 13px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { font-size: 11px; margin-left: 2px; opacity: .75; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.dev-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: .16s;
  box-shadow: var(--shadow);
}
.dev-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }

/* 型号配图：铺满裁切。用绝对定位，避免百分比高度在 flex/grid 里解析异常 */
.dev-media {
  position: relative;
  aspect-ratio: 2 / 1;
  height: auto;
  background: var(--surface-2);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.dev-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.dev-media .placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; letter-spacing: .08em; gap: 6px;
}
.dev-media .placeholder .ph-icon { font-size: 26px; opacity: .45; }

.dev-body { padding: 14px 16px 16px; }

.dev-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dev-name { font-size: 15px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-meta {
  font-size: 12px; color: var(--muted); margin-bottom: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: #94a3b8; }

.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface-2);
  flex: none;
}
.badge.running { color: var(--ok); border-color: var(--ok-soft); background: var(--ok-soft); }
.badge.fault { color: var(--bad); border-color: var(--bad-soft); background: var(--bad-soft); }
.badge.standby { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); }
.badge.offline { color: var(--muted); }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.metric .k { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.metric .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .v .u { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.metric .v.null { color: var(--muted); opacity: .6; }

/* ---------- 详情 ---------- */
.back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 12px;
}
.back:hover { color: var(--text); }

.hero {
  background: var(--hero);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  align-items: start;
}
.hero.no-image { grid-template-columns: 1fr; }
.hero h2 { margin: 0 0 4px; font-size: 20px; }
.hero .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.hero .metrics { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.hero .metric { background: var(--card); border: 1px solid var(--line); }
.hero .metric .v { font-size: 22px; }
.hero-img {
  width: 100%; aspect-ratio: 2 / 1;
  object-fit: cover; object-position: center;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
}

.section { margin-bottom: 22px; }
.section h3 {
  font-size: 13px; color: var(--muted); font-weight: 500;
  margin: 0 0 10px; letter-spacing: .04em;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.group-row td { color: var(--muted); font-size: 12px; background: var(--surface-2); }
.miss { color: var(--muted); opacity: .55; }

.card-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}

.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: 16px; background: var(--card);
}
.empty h3 { color: var(--text); margin: 0 0 8px; font-size: 16px; }
.empty p { margin: 0; font-size: 13px; }

/* ---------- toast / modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--text); color: var(--bg-soft);
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  z-index: 100; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.err { background: var(--bad); color: #fff; }

.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; width: 100%; max-width: 360px;
  text-align: center; box-shadow: 0 20px 50px rgba(15,23,42,.22);
}
.code-big {
  font-size: 30px; letter-spacing: 6px; font-weight: 700;
  font-family: ui-monospace, Menlo, monospace;
  margin: 14px 0 6px; color: var(--accent);
}
.code-note { font-size: 12px; color: var(--muted); margin-bottom: 18px; }

.icon-btn {
  width: 34px; height: 34px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: 9px; background: transparent; font-size: 15px;
}

/* ---------- 设备档案 / 编辑 ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
}
.info-grid .k { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.info-grid .v { font-size: 13px; }

.modal-card.wide { max-width: 520px; text-align: left; }
.editor .divider {
  margin: 18px 0 12px; padding-top: 12px;
  font-size: 12px; color: var(--muted);
  border-top: 1px dashed var(--line);
}

.media-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.media-thumb {
  width: 76px; height: 58px; padding: 4px;
  border-radius: 9px; overflow: hidden;
  border: 2px solid var(--line);
  background: var(--surface-2);
  display: grid; place-items: center;
}
.media-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-thumb.sel { border-color: var(--accent); }
.media-thumb.add {
  font-size: 20px; color: var(--muted);
  border-style: dashed; border-color: var(--line-strong);
}
.thumb-wrap { position: relative; display: inline-block; }
.thumb-del {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px; padding: 0;
  border-radius: 50%;
  background: var(--bad); border: 2px solid var(--card); color: #fff;
  font-size: 12px; line-height: 1;
  display: grid; place-items: center;
  opacity: 0; transition: opacity .12s;
}
.thumb-wrap:hover .thumb-del { opacity: 1; }

/* ---------- 历史曲线 ---------- */
.chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; }
.chart-controls { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips.sm { margin-bottom: 0; }
.chips.sm .chip { padding: 4px 11px; font-size: 12px; }
select.sm-select { width: auto; padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.chart-box { padding: 12px 14px 6px; }
.chart-empty { padding: 54px 0; text-align: center; color: var(--muted); font-size: 13px; }
.chart-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chart-meta b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-meta .dim { margin-left: auto; opacity: .8; }
.chart-meta .legend { display: inline-flex; align-items: center; gap: 5px; }
.chart-meta .legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-keys { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chart-keys .chip { font-size: 12px; padding: 4px 11px; }
.dim-hint { font-size: 12px; color: var(--muted); }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--accent-soft); }

/* 故障记录 */
.fault-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.fault-label { font-size: 12px; color: var(--muted); }
.fault-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-soft);
}
.fault-chip.muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.fault-ok { font-size: 13px; color: var(--ok); }
.fault-table td { border-bottom: 1px solid var(--line); }
.fault-table tr.fault-ongoing td { background: color-mix(in srgb, var(--bad) 5%, transparent); }

.fault-toolbar { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.fault-toolbar input { flex: 1; max-width: 320px; padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 10px 16px; border-top: 1px solid var(--line);
}
.pager-info { font-size: 12px; color: var(--muted); }
.fault-table tr:last-child td { border-bottom: none; }

/* 悬浮提示 */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 10px;
  min-width: 132px;
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .12);
  z-index: 5;
}
.tip-time { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* 型号管理 */
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.chk input { width: auto; accent-color: var(--accent); }
.modal-card.wide { max-height: 88vh; overflow-y: auto; }
.modal-card.xwide { max-width: 920px; max-height: 90vh; overflow-y: auto; text-align: left; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid line { stroke: var(--line); stroke-width: 1; }
.chart-axis text,
.chart-grid text { fill: var(--muted); font-size: 11px; }

/* 响应式必须放最后，且保留 @media 包裹——上次漏了这行，手机端规则会全局生效 */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar .who { display: none; }
  .wrap { padding: 16px 14px 40px; }
  .grid { grid-template-columns: 1fr; }
  .nav a { padding: 6px 8px; font-size: 12px; }
  .hero { grid-template-columns: 1fr; }
  .hero-img { aspect-ratio: 16 / 9; }
}

/* ---------- 模板编辑表格 ---------- */
.prop-table { width: 100%; border-collapse: collapse; }
.prop-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card);
  font-size: 11px; font-weight: 500; color: var(--muted);
  text-align: left; padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.prop-table td { padding: 3px 4px; border-bottom: 1px solid var(--line); }
.prop-table tr:last-child td { border-bottom: none; }
.prop-table input:not([type="checkbox"]) {
  width: 100%; padding: 6px 8px; font-size: 12px; border-radius: 8px;
}
.prop-table input[type="number"] { text-align: center; }
.prop-table td.c { text-align: center; }
.prop-table input[type="checkbox"] { width: auto; margin: 0; }
.icon-x {
  border: 0; background: transparent; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.icon-x:hover { color: var(--bad); }

/* 模板卡片上的删除按钮 */
.dev-card { position: relative; }
.model-del {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  opacity: 0; transition: opacity .12s;
}
.dev-card:hover .model-del { opacity: 1; }
.model-del:hover { color: #fff; background: var(--bad); border-color: var(--bad); }

/* 登录页：密码 / 验证码 两个 tab */
.login-tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.login-tabs button {
  flex: 1; padding: 9px 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.login-tabs button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.login-links { margin-top: 12px; text-align: right; }
.login-links a { color: var(--accent); font-size: 13px; text-decoration: none; }
.login-links a:hover { text-decoration: underline; }

/* 顶栏账号入口 */
.who-link {
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 6px 8px; border-radius: 8px;
}
.who-link:hover { background: var(--surface-2); color: var(--text); }

/* 列表筛选条 */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar input {
  width: 260px; padding: 8px 12px; font-size: 13px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
}
.filter-bar select {
  padding: 8px 10px; font-size: 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}

.badge.maintenance { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

/* 设备卡片 / 详情页的两行说明 + 右侧时间 */
.dev-meta-row, .sub-row {
  display: flex; align-items: baseline; gap: 10px; margin-top: 5px;
}
.dev-meta-row .dev-meta, .sub-row .sub { margin-top: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-seen, .sub-seen {
  margin-left: auto; flex: none;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.sub-seen { font-size: 12.5px; }

/* 服务板块 */
.svc-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.svc-item { padding: 14px; border-bottom: 1px solid var(--line); }
.svc-item:last-child { border-bottom: 0; }
.svc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.svc-head strong { font-size: 13.5px; }
.svc-who { margin-left: auto; font-size: 12px; color: var(--muted); }
.svc-desc { margin-top: 8px; font-size: 13px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }
.svc-note { margin-top: 8px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.svc-meta { margin-top: 8px; display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.svc-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.svc-photos { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.svc-photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.doc-list { padding: 4px 0; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-cat { flex: none; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.doc-title { flex: 1; font-size: 13px; color: var(--accent); text-decoration: none; }
.doc-title:hover { text-decoration: underline; }
.doc-meta { font-size: 12px; color: var(--muted); }

/* 设备详情页整体字号加大一号 */
.detail { font-size: 15px; }
.detail .hero h2 { font-size: 22px; }
.detail .hero .sub { font-size: 14px; }
.detail .hero .sub-seen { font-size: 13.5px; }
.detail .section h3 { font-size: 14px; }
.detail table th, .detail table td { font-size: 14px; padding: 10px 12px; }
.detail table th { font-size: 13px; }
.detail .group-row td { font-size: 13px; }
.detail .info-grid .k { font-size: 12px; }
.detail .info-grid .v { font-size: 14.5px; }
.detail .metrics .k { font-size: 12px; }
.detail .metrics .v { font-size: 23px; }
.detail .svc-desc, .detail .svc-note { font-size: 13.5px; }
.detail .doc-title, .detail .svc-head strong { font-size: 14.5px; }
.detail .chart-controls, .detail .dim-hint { font-size: 13px; }

/* AI 助手 */
.ai-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(11, 116, 209, .28); cursor: pointer;
}
.ai-fab:hover { filter: brightness(1.05); }

.ai-drawer {
  position: fixed; right: 24px; bottom: 24px; z-index: 45;
  width: min(540px, calc(100vw - 24px)); height: min(760px, calc(100vh - 32px));
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22); overflow: hidden;
}
.ai-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.ai-head strong { font-size: 15.5px; }
.ai-sub { font-size: 12.5px; color: var(--muted); flex: 1; }
.ai-head .icon-btn { border: 0; background: transparent; font-size: 20px; color: var(--muted); cursor: pointer; }
.ai-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg {
  max-width: 90%; padding: 12px 15px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.78; white-space: pre-wrap; word-break: break-word;
}
.ai-msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.ai-msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.ai-msg.typing::after { content: '▍'; animation: aiblink 1s steps(2) infinite; }
@keyframes aiblink { 50% { opacity: 0; } }
.ai-sources { font-size: 11.5px; color: var(--muted); align-self: flex-start; display: flex; gap: 6px; flex-wrap: wrap; }
.ai-sources em { font-style: normal; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.ai-foot {
  display: flex; align-items: stretch; gap: 10px;
  padding: 10px 16px 14px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.ai-foot textarea {
  flex: 1 1 auto; width: auto; min-width: 0; resize: none; min-height: 78px; max-height: 160px;
  padding: 12px 14px; font-size: 14.5px; line-height: 1.6;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-family: inherit;
}
.ai-foot-col { display: flex; flex-direction: column; gap: 6px; flex: none; width: 108px; }
.ai-foot-col .btn-sm {
  width: 100%; flex: 1 1 0; min-height: 0;
  padding: 6px 8px; font-size: 12.5px; white-space: nowrap;
}

@media (max-width: 560px) {
  .ai-drawer { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 24px); }
  .ai-foot textarea { min-height: 54px; }
}
