/* DNSLog 平台 —— 视觉对齐 callback.red */

:root {
  --page-bg: #0f172a;   /* 页面底色 */
  --bg: #111827;        /* 顶栏 + 内容区 */
  --panel: #0b1220;     /* 凭证块 */
  --bar: #1e52e3;       /* 凭证块左侧竖条 */
  --line: #273243;      /* 分隔线 */

  --text: #f3f4f6;
  --text-dim: #9ca3af;
  --text-faint: #6b7280;

  --teal: #33cabb;
  --blue: #48b0f7;
  --green: #15c377;
  --orange: #faa64b;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* hidden 属性只是 UA 的 display:none，会被 .modal{display:flex} 这类规则盖掉 */
[hidden] { display: none !important; }

html { background: var(--page-bg); }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app { background: var(--bg); min-height: 100%; }

h1, h2, h3 { margin: 0; font-weight: 600; }

code { font-family: var(--mono); }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

::selection { background: rgba(30, 82, 227, .45); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2b3648;
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #3b4761; background-clip: content-box; }

/* ── 顶栏 ───────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 74px;
  padding: 14px 50px;
  background: var(--bg);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
}

.brand-name {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: .2px;
  color: #fff;
  white-space: nowrap;
}

.brand-sub {
  font-size: 15px;
  color: var(--text-dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

/* 服务切换标签（渲染在回连记录区上方） */
.svc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  padding: 5px 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: color .13s, background .13s, border-color .13s;
}
.tab:hover { color: #fff; border-color: #3b4761; }
.tab.is-active {
  color: #fff;
  background: rgba(72, 176, 247, .16);
  border-color: var(--blue);
}

/* ── 布局 ───────────────────────────────────────────────────── */

.shell {
  max-width: 1900px;
  margin: 0 auto;
  padding: 32px 50px 70px;
}

/* ── 回连凭证 ───────────────────────────────────────────────── */

.creds {
  padding: 22px 24px 20px;
  background: var(--panel);
  border-left: 3px solid var(--bar);
}

/* 固定 label 列宽，让各行的值都从同一个位置开始 */
.cred {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 0 12px;
  margin: 0 -10px;
  padding: 0 10px;
  border-radius: 3px;
  font-size: 17px;
  line-height: 2.15;
  cursor: pointer;
  transition: background .12s;
}
.cred:hover { background: rgba(255, 255, 255, .035); }

.cred-label { color: #fff; }

.cred-value {
  color: #fff;
  word-break: break-all;
}
.cred.is-empty .cred-value { color: var(--text-faint); }

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity .14s, color .14s, background .14s;
}
.btn-copy svg { width: 15px; height: 15px; }
.cred:hover .btn-copy { opacity: 1; }
.btn-copy:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, .09); }
.btn-copy:disabled { cursor: not-allowed; opacity: 0 !important; }
.btn-copy.is-done { opacity: 1; color: var(--green); }

.hint {
  margin: 14px 0 0;
  padding: 12px 16px;
  background: rgba(250, 166, 75, .1);
  border-left: 3px solid var(--orange);
  color: #f5c88a;
  font-size: 13.5px;
  line-height: 1.7;
}
.hint code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

/* ── 按钮 ───────────────────────────────────────────────────── */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 17px;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
  transition: filter .13s, transform .06s;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:hover { filter: brightness(1.09); }
.btn:active { transform: translateY(1px); }

.btn-teal { background: var(--teal); }
.btn-blue { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-orange { background: var(--orange); }

.btn-danger { background: #ef4444; }

/* 分享开着时给按钮一个明确的开启态 */
.btn.is-on { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }

.btn-sm { padding: 5px 13px; font-size: 13.5px; }
.btn-sm svg { width: 15px; height: 15px; }

.btn-plain {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-plain:hover { color: #fff; border-color: #3b4761; filter: none; background: rgba(255, 255, 255, .04); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  transition: background .14s, color .14s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  transition: color .12s;
}
.link-btn:hover { color: #fff; }

/* ── 回连记录 ───────────────────────────────────────────────── */

.results { margin-top: 42px; }

.results-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.results-head h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 26px;
  font-weight: 600;
  color: #fff;
}

.count {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-faint);
}

.results-head .link-btn { margin-left: auto; }

/* ── 表格 ───────────────────────────────────────────────────── */

/* overflow-x:auto 会让这里成为滚动容器，表头的 sticky 必须按
   「容器内粘顶」写（top:0），写成 top:Npx 会被当成距容器顶 Npx */
.table-wrap {
  position: relative;
  overflow: auto;
  max-height: clamp(320px, 62vh, 900px);
  overscroll-behavior: contain;
}

.records { width: 100%; border-collapse: collapse; font-size: 15px; }

.records thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.records thead th:first-child { padding-left: 2px; }

.records tbody tr {
  border-bottom: 1px solid rgba(39, 50, 67, .55);
  cursor: pointer;
  transition: background .12s;
}
.records tbody tr:hover { background: rgba(255, 255, 255, .035); }
.records tbody tr.is-new { animation: rowIn .55s ease-out; }

@keyframes rowIn {
  from { background: rgba(72, 176, 247, .16); }
  to   { background: transparent; }
}

.records td {
  padding: 11px 16px;
  vertical-align: top;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}
.records td:first-child { padding-left: 2px; }

.col-idx { width: 62px; }
.col-type { width: 168px; }
.col-ip { width: 190px; }
.col-time { width: 205px; }
.col-data { width: 28%; }

.records td.col-idx { color: var(--text-faint); }
.records td.col-ip,
.records td.col-time { font-family: var(--mono); font-size: 13.5px; }
.records td.col-target { color: var(--text); }

/* 类型标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .2px;
}
.tag-dns  { background: rgba(72, 176, 247, .17); color: #7cc4fb; }
.tag-http { background: rgba(21, 195, 119, .17); color: #4ddc9a; }
.tag-ldap { background: rgba(167, 139, 250, .17); color: #b9a6fb; }
.tag-rmi  { background: rgba(250, 166, 75, .17); color: #fbc07e; }

.empty {
  padding: 18px 2px;
  color: var(--text-dim);
  font-size: 15px;
}

/* ── 弹窗 ───────────────────────────────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, .7);
  animation: fadeIn .16s ease-out;
}

.modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  animation: boxIn .17s cubic-bezier(.2, .9, .3, 1.1);
}

.modal-box-lg { max-width: 780px; }
.modal-box-sm { max-width: 420px; }
.modal-box-xl { max-width: 1120px; }

/* ── MCP 接入弹窗 ───────────────────────────────────────────── */

.mcp-hint { margin-right: 6px; font-size: 12px; color: var(--text-faint); }

.mcp-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.mcp-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0; /* 关键：不加这句，flex 子元素会被内容撑开，下面 pre 的滚动就失效 */
  border-right: 1px solid var(--line);
}
.mcp-pane:last-child { border-right: none; }

.mcp-pane-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
}
.mcp-pane-head b {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.mcp-pane-head span { font-size: 11.5px; color: var(--text-faint); }

.mcp-pane pre {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  background: #0a0f16;
  font-size: 12px;
  line-height: 1.7;
  color: #c9d4e3;
  white-space: pre;
  tab-size: 4;
}

/* 语法高亮配色 */
.tk-kw  { color: #ff7b72; }
.tk-str { color: #a5d6ff; }
.tk-com { color: #5d6b80; font-style: italic; }
.tk-num { color: #79c0ff; }
.tk-key { color: #7ee787; }

.mcp-foot { display: flex; align-items: center; justify-content: space-between; }
.mcp-foot > span { font-size: 12px; color: var(--text-faint); }
.mcp-foot code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .07);
  color: var(--text-dim);
}

@media (max-width: 900px) {
  .mcp-body { grid-template-columns: minmax(0, 1fr); }
  .mcp-pane { border-right: none; border-bottom: 1px solid var(--line); }
  .mcp-pane:last-child { border-bottom: none; }
}

.confirm-text { margin: 0; color: var(--text); font-size: 14.5px; line-height: 1.75; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes boxIn {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 16px; color: #fff; }
.modal-head-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.modal-body {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}
pre.modal-body { flex: 1; min-height: 130px; font-family: var(--mono); }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
}

.seg { display: inline-flex; padding: 2px; background: rgba(255, 255, 255, .06); border-radius: 5px; }
.seg-btn {
  padding: 3px 11px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  font-size: 13px;
  transition: background .14s, color .14s;
}
.seg-btn.is-active { background: rgba(255, 255, 255, .12); color: #fff; }

/* ── Toast ──────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.toast {
  padding: 10px 16px;
  background: #1b2537;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: toastIn .2s ease-out;
}
.toast.is-error { border-left-color: #ef4444; }
.toast.is-out { animation: toastOut .22s ease-in forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(14px); } }

/* ── 响应式 ─────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .topbar { padding: 12px 20px; min-height: 62px; }
  .brand-name { font-size: 20px; }
  .brand-sub { font-size: 13.5px; }
  .shell { padding: 22px 20px 50px; }
  .cred { font-size: 15px; line-height: 1.95; grid-template-columns: 56px minmax(0, 1fr) 26px; gap: 0 10px; }
  .cred-status { font-size: 15px; }
  .results { margin-top: 30px; }
  .results-head h2 { font-size: 22px; }
  .records { font-size: 14px; }
  .records td { max-width: 200px; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; gap: 12px; }
  .brand-sub { display: none; }
  .svc-tabs { gap: 6px; margin-bottom: 14px; }
  .tab { padding: 4px 12px; font-size: 13px; }
  .shell { padding: 16px 14px 40px; }
  .creds { padding: 16px 16px 14px; }
  .cred { font-size: 14px; grid-template-columns: 54px minmax(0, 1fr); gap: 0 8px; }
  .btn-copy { display: none; }
  .actions { gap: 9px; }
  .btn { padding: 7px 13px; font-size: 13.5px; }
  .btn svg { width: 16px; height: 16px; }
  .table-wrap { max-height: 60vh; }
  .records thead th { padding: 10px 8px; font-size: 13px; }
  .records td { padding: 9px 8px; max-width: 150px; }
  /* 窄屏只留最要紧的列，其余点进详情看 */
  .col-idx, .col-ip, .col-data { display: none; }
}
