:root {
  --bg: #0f1115;
  --panel: #161a21;
  --panel-2: #1d232c;
  --line: #262d38;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.pad { padding: 16px; }
.error { color: var(--err); min-height: 18px; font-size: 13px; }

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
button.small { padding: 4px 10px; font-size: 12px; }
button.danger { background: var(--err); }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
textarea { min-height: 60px; resize: vertical; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

/* 顶栏 */
header {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; font-size: 16px; }
.brand .muted { margin-left: 8px; }
nav { display: flex; gap: 6px; }
nav button {
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 8px;
}
nav button.active { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* 布局 */
.tab { display: flex; height: calc(100vh - 57px); }
#tab-messages, #tab-global { display: block; overflow: auto; padding: 16px; }
#tab-global .detail { max-width: 720px; margin: 0 auto; }

.list {
  width: 300px; flex: 0 0 300px;
  border-right: 1px solid var(--line);
  overflow: auto;
  background: var(--panel);
}
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
#device-list { list-style: none; margin: 0; padding: 0; }
#device-list li {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
#device-list li:hover { background: var(--panel-2); }
#device-list li.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.dev-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 8px; }
.dot.online { background: var(--ok); }
.dev-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.detail { flex: 1; overflow: auto; padding: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 500; }
.row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.row > label { color: var(--muted); font-size: 12px; }
.inline { display: flex; gap: 8px; align-items: center; }
.actions { display: flex; gap: 12px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

/* 配置项 */
.field { display: grid; grid-template-columns: 24px 150px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.field:last-child { border-bottom: 0; }
.field .name { font-size: 13px; }
.field small { color: var(--muted); font-size: 11px; display: block; }
.field.off .val { opacity: .45; pointer-events: none; }
.check { width: 16px; height: 16px; accent-color: var(--accent); }

/* 表格 */
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 140px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--panel-2); }
td.body { max-width: 520px; white-space: pre-wrap; word-break: break-word; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); }
.tag.ok { color: var(--ok); border-color: rgba(34,197,94,.4); }
.tag.no { color: var(--warn); border-color: rgba(245,158,11,.4); }
.tag.sms { color: #60a5fa; border-color: rgba(96,165,250,.4); }
.tag.imessage { color: #34d399; border-color: rgba(52,211,153,.4); }
.tag.call { color: #f472b6; border-color: rgba(244,114,182,.4); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 100;
}
.toast.err { border-color: var(--err); color: #fecaca; }
.token-box { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--muted); }
