/* ========================================================================
   全球故障检索雷达 · 深色运维监控风格
   ======================================================================== */

:root {
  --bg: #070b12;
  --panel: #0d1420;
  --panel-2: #111a2a;
  --border: #1c2942;
  --text: #d7e3f4;
  --muted: #7d8db0;
  --accent: #22d3ee;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --purple: #a855f7;
  --gray: #64748b;
  --yellow: #eab308;
  --radius: 10px;
  --mono: "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(34, 211, 238, 0.07), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(59, 130, 246, 0.06), transparent 55%),
    linear-gradient(rgba(28, 41, 66, 0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 41, 66, 0.25) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 48px 48px, 48px 48px, auto;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 56px;
  background: rgba(7, 11, 18, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.nav { display: flex; align-items: center; gap: 6px; }

.nav a {
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.92rem;
}

.nav a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }

.nav a.active { color: var(--accent); background: rgba(34, 211, 238, 0.1); }

.nav-user {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 8px;
  border-left: 1px solid var(--border);
  margin-left: 6px;
}

/* ---------------------------------------------------------- 布局 */

.container { max-width: 1240px; margin: 0 auto; padding: 24px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 28px 0 20px;
}

.section-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.section-desc { color: var(--muted); font-size: 0.88rem; margin-bottom: 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.panel-title {
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------- 按钮 / 表单 */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.5);
  color: var(--accent);
}

.btn-primary:hover { background: rgba(34, 211, 238, 0.22); box-shadow: 0 0 12px rgba(34, 211, 238, 0.25); }

.btn-block { width: 100%; padding: 10px; font-size: 1rem; }

.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.15); }

textarea.input { resize: vertical; min-height: 70px; }

.field { display: block; margin-bottom: 14px; }

.field-label { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }

.field-check { display: flex; align-items: center; gap: 10px; }
.field-check .field-label { margin-bottom: 0; }
.field-check input { width: 16px; height: 16px; accent-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }
.field-wide { grid-column: 1 / -1; }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

.hint { color: var(--muted); font-size: 0.82rem; }
.hint.ok { color: var(--green); }
.hint.err { color: var(--red); }

/* 社媒凭据说明 */
.cred-notes { margin-top: 10px; display: grid; gap: 6px; }
.cred-notes p { color: var(--muted); font-size: 0.8rem; line-height: 1.6; margin: 0; }
.cred-notes strong { color: var(--text); }
.cred-notes .cred-risk { color: var(--amber, #d29922); }

/* 告警测试结果 */
.alert-test-result { margin-top: 10px; display: grid; gap: 4px; }
.alert-test-row { font-size: 0.84rem; }
.alert-test-row.ok { color: var(--green); }
.alert-test-row.err { color: var(--red); }

/* 微信机器人二维码 */
.weixin-qr-wrap { margin-top: 12px; display: grid; gap: 8px; justify-items: start; }
.weixin-qr-box svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; }

/* ---------------------------------------------------------- 登录页 */

.login-wrap {
  min-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px 32px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-logo { font-size: 2.4rem; text-align: center; position: relative; }

.login-title { text-align: center; font-size: 1.3rem; margin: 10px 0 4px; position: relative; }

.login-sub { text-align: center; color: var(--muted); font-size: 0.82rem; margin-bottom: 26px; position: relative; }

.login-card form { position: relative; }

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.radar-rings { position: absolute; inset: 0; pointer-events: none; }

.ring {
  position: absolute;
  top: -120px;
  right: -120px;
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: 50%;
}

.ring-1 { width: 200px; height: 200px; }
.ring-2 { width: 280px; height: 280px; top: -160px; right: -160px; }
.ring-3 { width: 360px; height: 360px; top: -200px; right: -200px; animation: ringPulse 3s ease-in-out infinite; }

@keyframes ringPulse {
  0%, 100% { border-color: rgba(34, 211, 238, 0.1); }
  50% { border-color: rgba(34, 211, 238, 0.3); }
}

/* ---------------------------------------------------------- 统计卡片 */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label { color: var(--muted); font-size: 0.78rem; margin-bottom: 6px; }

.stat-value { font-size: 1.6rem; font-weight: 700; font-family: var(--mono); }
.stat-value.stat-small { font-size: 0.95rem; font-family: inherit; line-height: 1.5; }
.stat-green { color: var(--green); }
.stat-blue { color: var(--blue); }

/* ---------------------------------------------------------- 筛选栏 */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.filter-bar .input { width: auto; }
.filter-bar .input-grow { flex: 1; min-width: 180px; }

.chip-group { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.llm-banner {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: var(--yellow);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------- 事件卡片 */

.incident-list { display: flex; flex-direction: column; gap: 12px; }

.incident-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.15s ease;
}

.incident-card:hover { border-color: rgba(34, 211, 238, 0.35); }

.incident-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.incident-title { font-size: 1rem; font-weight: 700; line-height: 1.5; flex: 1; }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}

.b-red     { color: #fca5a5; border-color: rgba(239, 68, 68, 0.5);  background: rgba(239, 68, 68, 0.12); }
.b-orange  { color: #fcd34d; border-color: rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.12); }
.b-blue    { color: #93c5fd; border-color: rgba(59, 130, 246, 0.5); background: rgba(59, 130, 246, 0.12); }
.b-green   { color: #86efac; border-color: rgba(34, 197, 94, 0.5);  background: rgba(34, 197, 94, 0.12); }
.b-purple  { color: #d8b4fe; border-color: rgba(168, 85, 247, 0.5); background: rgba(168, 85, 247, 0.12); }
.b-gray    { color: #94a3b8; border-color: rgba(100, 116, 139, 0.5); background: rgba(100, 116, 139, 0.12); }
.b-yellow  { color: #fde047; border-color: rgba(234, 179, 8, 0.5);  background: rgba(234, 179, 8, 0.12); }
.b-cyan    { color: #67e8f9; border-color: rgba(34, 211, 238, 0.5); background: rgba(34, 211, 238, 0.12); }

.incident-summary { color: var(--text); font-size: 0.88rem; line-height: 1.65; margin-top: 10px; opacity: 0.9; }

.incident-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 10px;
  font-family: var(--mono);
}

.incident-detail {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 24px; }

.detail-item { font-size: 0.85rem; line-height: 1.6; }

.detail-key { color: var(--muted); font-size: 0.76rem; display: block; margin-bottom: 2px; }

.evidence-groups { margin-top: 12px; }

.evidence-group { margin-bottom: 8px; font-size: 0.83rem; }

.evidence-group-title { color: var(--muted); font-size: 0.76rem; margin-bottom: 3px; }

.evidence-group ul { list-style: none; }
.evidence-group li { margin: 2px 0; word-break: break-all; }

.expand-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 0;
  font-family: inherit;
}

.expand-btn:hover { text-decoration: underline; }

.pending-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--yellow);
  border: 1px dashed rgba(234, 179, 8, 0.6);
  vertical-align: middle;
}

.empty-state { color: var(--muted); text-align: center; padding: 36px 0; font-size: 0.9rem; }

/* ---------------------------------------------------------- 检索页 */

.search-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }

.tpl-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tpl-card:hover { border-color: rgba(34, 211, 238, 0.4); }

.tpl-card.active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.15);
}

.tpl-name { font-weight: 700; font-size: 0.95rem; }
.tpl-desc { color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

.radar-loading {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 30px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.radar-loader {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background:
    radial-gradient(circle, transparent 30%, rgba(34, 211, 238, 0.06) 31%, transparent 32%),
    radial-gradient(circle, transparent 60%, rgba(34, 211, 238, 0.06) 61%, transparent 62%);
  overflow: hidden;
  flex-shrink: 0;
}

.radar-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(34, 211, 238, 0.55), transparent 70deg, transparent 360deg);
  animation: sweep 1.6s linear infinite;
}

@keyframes sweep { to { transform: rotate(360deg); } }

.radar-loading-text { color: var(--muted); font-size: 0.9rem; }

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.history-item:hover { border-color: rgba(34, 211, 238, 0.4); }

.history-item-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }

.history-item-meta { color: var(--muted); font-size: 0.72rem; font-family: var(--mono); }

.history-item-excerpt {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 6px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------- Markdown 渲染 */

.markdown-body { font-size: 0.9rem; line-height: 1.75; }

.markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5 {
  margin: 18px 0 8px;
  font-size: 1.02rem;
  color: var(--accent);
}

.markdown-body h2 { font-size: 1.1rem; }

.markdown-body p { margin: 8px 0; }

.markdown-body ul, .markdown-body ol { margin: 8px 0 8px 22px; }

.markdown-body li { margin: 3px 0; }

.markdown-body strong { color: #fff; }

.md-code {
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  margin: 10px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.md-inline {
  background: rgba(34, 211, 238, 0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }

.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td { padding: 8px 10px; border-bottom: 1px solid rgba(28, 41, 66, 0.5); vertical-align: top; }

.table tr:hover td { background: rgba(17, 26, 42, 0.6); }

.table .mono { font-family: var(--mono); font-size: 0.76rem; }

.access-limits { margin-top: 14px; }

.access-limits .al-title { color: var(--muted); font-size: 0.78rem; margin-bottom: 6px; }

.access-limits ul { list-style: none; }

.access-limits li {
  font-size: 0.8rem;
  color: var(--yellow);
  padding: 3px 0 3px 16px;
  position: relative;
}

.access-limits li::before { content: "⚠"; position: absolute; left: 0; font-size: 0.7rem; }

/* ---------------------------------------------------------- 设置页 */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 20px; }

.panel-wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------- flash */

.flash-area { max-width: 1240px; margin: 14px auto 0; padding: 0 24px; }

.flash {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

/* ---------------------------------------------------------- 登录二次验证 */

.otp-hint { color: var(--muted); font-size: 0.85rem; line-height: 1.6; margin: 0 0 16px; }

#otpCode {
  letter-spacing: 0.5em;
  text-align: center;
  font-size: 1.3rem;
  font-family: var(--mono);
}

.otp-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

.btn-link {
  border: none;
  background: none;
  padding: 4px 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.btn-link:hover { border: none; color: var(--accent); }

/* ---------------------------------------------------------- 用户管理 */

.btn-sm { padding: 3px 10px; font-size: 0.78rem; }

.btn-danger { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { border-color: #ef4444; color: #ef4444; }

.panel-title .btn-sm { font-weight: 400; }

.user-actions { white-space: nowrap; }

/* 告警规则多选框网格 */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 12px; margin-top: 4px; }
.check-grid .field-check { margin-bottom: 0; }

/* ---------------------------------------------------------- 响应式 */

@media (max-width: 960px) {
  .search-layout { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  .brand span:last-child { font-size: 0.95rem; }
  .container { padding: 16px 14px; }
}

/* LLM 通道可用性探测面板 */
.llm-probe-panel { margin-top: 14px; }
.llm-probe-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.probe-card { flex: 1 1 280px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.probe-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.probe-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.probe-dot.ok { background: var(--green); }
.probe-dot.fail { background: var(--red); }
.probe-dot.none { background: var(--gray); }
.probe-meta { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.probe-meta .err-text { color: var(--red); word-break: break-all; }
.probe-history { margin-top: 10px; display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.probe-hist-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--green); flex: none; }
.probe-hist-dot.fail { background: var(--red); }
.probe-hist-label { font-size: 11px; color: var(--muted); margin-right: 4px; }
