/* ═══════════════════════════════════════════════════════════
   通用组件：卡片 / 按钮 / 表格 / 标签 / 空态 / 骨架屏 / 弹窗
   ═══════════════════════════════════════════════════════════ */

/* ── 卡片 ── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 42px;
}

.card-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-head .hint { font-size: 11.5px; color: var(--fg-2); flex: none; }
.card-body { padding: 13px; }
.card-body.flush { padding: 0; }

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--fg-1);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  user-select: none;
}

.btn:hover { background: var(--bg-hover); color: var(--fg-0); border-color: #333c4b; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #5f9aff; border-color: #5f9aff; color: #fff; }

.btn-danger { color: var(--err); border-color: rgba(229, 72, 77, 0.35); background: var(--err-soft); }
.btn-danger:hover { background: rgba(229, 72, 77, 0.22); color: #ff6b70; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; }

.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn-sm { height: 27px; padding: 0 10px; font-size: 12px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg-0); }

/* ── 输入 ── */
.input, .select {
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--fg-0);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.13s, box-shadow 0.13s;
  min-width: 0;
}

.input:focus, .select:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder { color: var(--fg-3); }

.select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236f7a8d' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-wrap svg { position: absolute; left: 9px; color: var(--fg-3); pointer-events: none; }
.search-wrap .input { padding-left: 29px; width: 210px; }

/* ── 工具栏 ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1 1 auto; }

/* ── 表 ── */
.table-wrap { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

table.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 11px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg-2);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.tbl td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--fg-1);
  vertical-align: top;
}

table.tbl tbody tr:hover td { background: var(--bg-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }

table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono, table.tbl th.mono { font-family: var(--mono); font-size: 11.5px; }

table.tbl td .strong { color: var(--fg-0); font-weight: 550; }

/* 可点击行 */
table.tbl tbody tr.clickable { cursor: pointer; }

/* ── 标签 ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  font-size: 11px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  background: var(--bg-3);
  color: var(--fg-1);
}

.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-err { background: var(--err-soft); color: var(--err); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-ch { background: var(--ch-soft, var(--bg-3)); color: var(--ch, var(--fg-1)); }
.tag-mute { background: transparent; color: var(--fg-3); border: 1px dashed var(--line); }

/* 状态点 */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--fg-3);
}
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot-err { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.dot-idle { background: var(--fg-3); }
.dot-live { background: var(--ok); animation: pulse 1.8s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(47, 191, 113, 0); }
}

/* ── 空态 ── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 44px 20px;
  color: var(--fg-2);
  text-align: center;
}

.empty svg { opacity: 0.35; }
.empty .t { font-size: 13px; font-weight: 550; color: var(--fg-1); }
.empty .d { font-size: 12px; max-width: 340px; line-height: 1.6; }
.empty .acts { margin-top: 4px; display: flex; gap: 8px; }

/* ── 骨架屏 ── */
.sk {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.sk-line { height: 11px; margin-bottom: 8px; }
.sk-line:last-child { margin-bottom: 0; width: 62%; }

/* ── 提示条 ── */
.notice {
  display: flex;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--line);
  background: var(--bg-2);
  margin-bottom: 12px;
}
.notice svg { flex: none; margin-top: 1px; }
.notice b { color: var(--fg-0); }
.notice-warn { border-color: rgba(226, 163, 60, 0.3); background: var(--warn-soft); }
.notice-err { border-color: rgba(229, 72, 77, 0.3); background: var(--err-soft); }
.notice-info { border-color: rgba(76, 141, 255, 0.28); background: var(--info-soft); }

/* ── Toast ── */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 220px;
  max-width: 400px;
  padding: 9px 13px;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  color: var(--fg-0);
  animation: toast-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--err); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.out { animation: toast-out 0.18s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(4px) scale(0.98); }
}

/* ── 弹窗 ── */
/*
  ★ 必须显式处理 [hidden]。
  HTML 的 hidden 属性只是 UA 样式表里的 display:none，一旦我们自己写了
  display:grid / display:block，就会把它覆盖掉 —— 结果是弹窗和侧栏遮罩
  「看不见但一直盖在页面上」，表现为整页发暗、点不动。
  这是本项目踩过的真实坑，别删这两条。
*/
[hidden] { display: none !important; }

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
}

.modal {
  width: min(760px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: modal-in 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.modal-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; flex: 1 1 auto; }
.modal-body { padding: 15px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 15px;
  border-top: 1px solid var(--line-soft);
  flex: none;
}

/* ── 代码/JSON 块 ── */
.code {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  background: var(--bg-0);
  border: 1px solid var(--line-soft);
  color: var(--fg-1);
  overflow: auto;
  max-height: 380px;
  white-space: pre-wrap;
  word-break: break-word;
}

.code .k { color: #7fb2ff; }
.code .s { color: #8fd18f; }
.code .n { color: #e2a33c; }
.code .b { color: #b06bff; }

/* ── 分页 ── */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 13px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--fg-2);
  flex-wrap: wrap;
}
.pager .spacer { flex: 1 1 auto; }

/* ── 描述列表 ── */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--fg-2); white-space: nowrap; }
.kv dd { margin: 0; color: var(--fg-0); min-width: 0; word-break: break-all; }
