/* 手机管控助手 · 管理后台样式 */

:root {
  --primary: #5b5bd6;
  --primary-dark: #4747b8;
  --bg: #f4f5f8;
  --card: #ffffff;
  --border: #e3e5ec;
  --text: #1b1c22;
  --muted: #6b7280;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 22, 40, .06), 0 6px 18px rgba(20, 22, 40, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- 连接遮罩（需求 9） ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 60;
  background: linear-gradient(135deg, #4f46c9, #7c3aed 60%, #a855f7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.connect-card { width: 100%; max-width: 400px; }
.connect-card h2 { margin: 0 0 6px; font-size: 20px; }

/* ---------- 头部 ---------- */
header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 11px;
  border: 2.5px solid #fff; border-radius: 3px;
}
.title { font-size: 16px; font-weight: 650; }
.subtitle { font-size: 12px; color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 8px; }
.dev-chip {
  background: #eef0ff; color: var(--primary-dark);
  padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 4px; padding: 10px 20px 0;
  background: var(--card); border-bottom: 1px solid var(--border);
  overflow-x: auto; position: sticky; top: 61px; z-index: 29;
}
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 9px 15px; font-size: 14px; color: var(--muted);
  border-bottom: 2.5px solid transparent; white-space: nowrap;
  font-family: inherit; border-radius: 8px 8px 0 0;
}
.tab:hover { background: #f7f7fb; color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 布局 ---------- */
.content { max-width: 1240px; margin: 0 auto; padding: 18px 20px 60px; }
.page { display: none; flex-direction: column; gap: 16px; }
.page.active { display: flex; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-hd h3 { margin: 0; }
.card-hd p { margin: 4px 0 0; }
.hd-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; z-index: 20; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
label.mt, .mt { margin-top: 12px; }

input, textarea, select {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, .12);
}
textarea { resize: vertical; min-height: 60px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.inline-unit { display: flex; align-items: center; gap: 8px; }
.inline-unit input { flex: 1; }
.unit { color: var(--muted); font-size: 13px; }
.search { width: 200px; }
select.mini { width: auto; padding: 7px 9px; font-size: 13px; }
.inline.chk { display: flex; align-items: center; gap: 5px; margin: 0; white-space: nowrap; }
.inline.chk input { width: auto; }

button {
  border: 0; border-radius: 9px; padding: 10px 15px;
  font-size: 14px; font-family: inherit; cursor: pointer;
  background: var(--primary); color: #fff; font-weight: 500;
}
button:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: #eef0f4; color: var(--text); }
button.ghost:hover { background: #e2e5ec; }
button.sm { padding: 7px 12px; font-size: 13px; }
button.block { width: 100%; margin-top: 14px; }
.btn-file {
  display: inline-block; margin: 0; padding: 7px 12px; font-size: 13px;
  background: #eef0f4; border-radius: 9px; cursor: pointer; color: var(--text);
}
.btn-file:hover { background: #e2e5ec; }

/* ---------- 通用文本 ---------- */
.muted { color: var(--muted); }
.muted.sm { font-size: 12.5px; }
.err { color: var(--err); min-height: 18px; margin: 8px 0 0; font-size: 13px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.hide { display: none !important; }
code { background: #f0f0f4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 设备列表 ---------- */
.dev-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.dev-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px;
  cursor: pointer; transition: .15s;
}
.dev-item:hover { border-color: var(--primary); background: #fafaff; }
.dev-item.sel { border-color: var(--primary); background: #f2f2ff; box-shadow: inset 3px 0 0 var(--primary); }
.dev-main { flex: 1; min-width: 0; }
.dev-name { font-weight: 600; font-size: 14px; }
.dev-id { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: #eef0f4; color: var(--muted); white-space: nowrap;
}
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.err { background: #fee2e2; color: #b91c1c; }

/* ---------- 键值信息框 ---------- */
.kv-box { display: flex; flex-direction: column; gap: 7px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed #eef0f4; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 550; text-align: right; word-break: break-all; }

/* ---------- 地图 ---------- */
#map { height: 380px; border-radius: 11px; overflow: hidden; margin-top: 12px; z-index: 1; }
#mapFallback { padding: 14px; font-size: 13px; color: var(--muted); line-height: 1.8; margin-top: 12px; }

/* ---------- 用量条 ---------- */
.usage { display: flex; flex-direction: column; gap: 9px; max-height: 340px; overflow-y: auto; }
.u-row { display: grid; grid-template-columns: 130px 1fr 68px; align-items: center; gap: 10px; }
.u-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-track { height: 9px; background: #eef0f4; border-radius: 20px; overflow: hidden; }
.u-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--primary), #a855f7); transition: width .4s; }
.u-fill.over { background: linear-gradient(90deg, var(--err), #f97316); }
.u-val { font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 分组 ---------- */
.grp { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-top: 12px; background: #fcfcfe; }
.grp-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.grp-idx { font-size: 12px; color: var(--muted); }
.grp-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.grp-pkgs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.pkg-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #eef0ff; color: var(--primary-dark);
  padding: 3px 9px; border-radius: 20px; font-size: 12px;
}
.pkg-chip button { background: none; color: inherit; padding: 0; font-size: 14px; line-height: 1; }
.grp-hint { font-size: 12px; color: var(--muted); }

/* ---------- 勾选列表 ---------- */
.check-list { display: flex; flex-direction: column; gap: 7px; max-height: 260px; overflow-y: auto; }
.check-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.check-row:hover { border-color: var(--primary); }
.check-row input { width: auto; flex: 0 0 auto; }
.check-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row .pk { font-size: 11.5px; color: var(--muted); }

/* ---------- 应用列表 ---------- */
.caps { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.cap { border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; }
.cap-n { font-size: 13px; font-weight: 600; }
.cap-s { font-size: 12px; color: var(--muted); margin-top: 3px; }

.app-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.app-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 10px;
}
.app-row input { width: auto; flex: 0 0 auto; }
.app-row .nm { font-weight: 550; }
.app-row .pk { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row .tail { margin-left: auto; }

/* ---------- 命令记录 ---------- */
.cmd-list { display: flex; flex-direction: column; gap: 7px; max-height: 340px; overflow-y: auto; }
.cmd-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; }
.cmd-act { font-weight: 600; font-size: 13px; }
.cmd-param { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cmd-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ---------- 聊天 ---------- */
.chat-card { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 460px; }
.chat-box { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 4px 2px 10px; }
.msg { max-width: 74%; padding: 9px 13px; border-radius: 14px; font-size: 14px; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: #eef0f4; border-bottom-left-radius: 4px; }
.msg .t { font-size: 10.5px; opacity: .65; margin-top: 3px; }
.msg img { max-width: 100%; border-radius: 9px; display: block; }
.chat-input { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chat-tools { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.chat-tools .btn-file, .chat-tools button { margin: 0; }
.recording { background: var(--err) !important; color: #fff !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #23262f; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: .25s; z-index: 99; pointer-events: none;
  max-width: 84vw;
}
.toast.show { opacity: .96; }