/* ============ 基础 ============ */
:root {
  --bg: #0b1020;
  --bg-soft: #111832;
  --panel: #ffffff;
  --panel-soft: #f5f7fb;
  --text: #1c2438;
  --text-soft: #5b6478;
  --line: #e5e9f2;
  --brand: #4f6ef7;
  --brand-2: #7c5cff;
  --brand-grad: linear-gradient(135deg, #4f6ef7 0%, #7c5cff 55%, #a855f7 100%);
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(17, 24, 50, .10);
  --shadow-lg: 0 24px 60px rgba(17, 24, 50, .18);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100vh;
  background: var(--panel-soft);
  color: var(--text);
  line-height: 1.6;
}

code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .9em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-soft); }

/* ============ 头部 ============ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand-grad);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; box-shadow: 0 6px 16px rgba(79, 110, 247, .35);
}
.brand-center { justify-content: center; font-size: 20px; }
.header-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.header-nav a { color: var(--text-soft); font-size: 14.5px; font-weight: 500; }
.header-nav a:hover { color: var(--brand); text-decoration: none; }
.nav-admin {
  padding: 6px 14px; border-radius: 999px;
  background: var(--brand-grad); color: #fff !important;
  box-shadow: 0 6px 16px rgba(79, 110, 247, .3);
}
.lang-switch { display: inline-flex; gap: 4px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang-switch button {
  padding: 5px 12px; border: 0; border-radius: 999px;
  background: transparent; cursor: pointer; font-size: 12.5px; color: var(--text-soft);
  transition: all .18s;
}
.lang-switch button.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.08); }

/* ============ Hero ============ */
.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 500px at 50% -10%, #2b3a8f 0%, var(--bg) 55%);
  color: #eef1ff;
  padding: 72px 20px 64px;
  text-align: center;
}
.hero-glow {
  position: absolute; inset: auto -20% -60% -20%; height: 320px;
  background: radial-gradient(closest-side, rgba(124, 92, 255, .45), transparent);
  filter: blur(20px); pointer-events: none;
}
.hero-inner { position: relative; max-width: 860px; margin: 0 auto; z-index: 1; }
.hero-badge {
  display: inline-block; padding: 6px 16px; border-radius: 999px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22);
  font-size: 13px; letter-spacing: .12em; color: #cdd6ff;
}
.hero-title { font-size: clamp(28px, 5vw, 46px); line-height: 1.25; margin: 20px 0 14px; font-weight: 800; }
.hero-subtitle { font-size: clamp(14.5px, 2vw, 17px); color: #b9c2e8; max-width: 720px; margin: 0 auto; }
.hero-actions { display: flex; gap: 14px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 40px; justify-content: center; margin-top: 44px; flex-wrap: wrap; }
.hero-stats .stat { display: flex; flex-direction: column; gap: 2px; }
.hero-stats strong { font-size: 26px; font-weight: 800; background: linear-gradient(90deg, #a5b4ff, #d8b4fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { font-size: 13px; color: #9aa4d0; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: 12px; border: 1px solid transparent;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
  text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 10px 24px rgba(79, 110, 247, .35); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 30px rgba(79, 110, 247, .45); }
.btn-ghost { background: rgba(255,255,255,.08); color: #dfe4ff; border-color: rgba(255,255,255,.25); }
.section .btn-ghost, .panel .btn-ghost, .admin-app .btn-ghost, .modal .btn-ghost {
  background: #fff; color: var(--text-soft); border-color: var(--line);
}
.section .btn-ghost:hover, .panel .btn-ghost:hover, .admin-app .btn-ghost:hover, .modal .btn-ghost:hover { color: var(--brand); border-color: var(--brand); }
.btn-small { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn.danger:hover { color: var(--err); border-color: var(--err); }

/* ============ 区块 ============ */
.section { padding: 54px 20px; }
.section-alt { background: #eef1f8; }
.section-inner { max-width: 1120px; margin: 0 auto; }
.section-head { margin-bottom: 24px; }
.section-head.row, .panel-head.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.section-head h2, .panel-head h2 { font-size: 24px; font-weight: 800; }
.section-head p { color: var(--text-soft); margin-top: 6px; font-size: 14.5px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 24px;
}
.panel-narrow { max-width: 480px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-hint { font-size: 12.5px; color: var(--text-soft); }

.field-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-soft); margin: 14px 0 6px; }
.log-input, .text-input {
  width: 100%; padding: 13px 15px; border-radius: 11px;
  border: 1.5px solid var(--line); background: #fbfcff;
  font-size: 14px; font-family: inherit; color: var(--text);
  transition: border-color .15s, box-shadow .15s; resize: vertical;
}
.log-input { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.55; }
.log-input:focus, .text-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 110, 247, .15);
  background: #fff;
}
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.form-msg { font-size: 13.5px; color: var(--ok); min-height: 20px; }
.form-msg.error { color: var(--err); }
#login-msg, #pwd-msg, #rule-msg { margin: 10px 0; }

/* ============ 结果 ============ */
.result-meta {
  display: grid; gap: 14px; background: var(--panel-soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 20px;
}
.meta-item { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.meta-key { font-size: 13px; font-weight: 700; color: var(--text-soft); min-width: 84px; }
.task-code {
  background: #101733; color: #a5f3d0; padding: 4px 10px; border-radius: 7px; font-size: 13px;
  word-break: break-all;
}
.err-lines { list-style: none; display: grid; gap: 6px; }
.err-lines li { font-size: 13.5px; color: var(--text); word-break: break-all; }
.err-lines code { background: #fff2f0; color: var(--err); padding: 2px 8px; border-radius: 6px; border: 1px solid #ffd7d1; }
.result-sub { font-size: 16px; font-weight: 800; margin: 22px 0 12px; }

.rule-card {
  border: 1px solid var(--line); border-left: 4px solid var(--err);
  border-radius: 12px; padding: 18px 20px; background: #fff; margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(17,24,50,.06);
}
.rule-card.is-warning { border-left-color: var(--warn); }
.rule-card-top { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.rule-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.rule-summary { font-size: 14.5px; color: var(--text-soft); margin-bottom: 10px; }
.rule-card h4 { font-size: 13.5px; font-weight: 700; color: var(--text); margin: 12px 0 6px; }
.rule-list { padding-left: 20px; display: grid; gap: 5px; font-size: 14px; color: #38415a; }
.alert {
  background: #fff8ec; border: 1px solid #ffe1b0; border-radius: 12px;
  padding: 18px 20px;
}
.alert strong { color: var(--warn); }
.alert p { font-size: 14.5px; color: var(--text-soft); margin-top: 6px; }

.chip {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.chip-err { background: #fdeceb; color: var(--err); }
.chip-warn { background: #fef3e2; color: var(--warn); }
.chip-ok { background: #e7f7ee; color: var(--ok); }
.chip-cat { background: #eef1ff; color: var(--brand); }
.chip-badge { background: #f3e8ff; color: #7c3aed; }

/* ============ 知识库 ============ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.kb-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: 0 4px 14px rgba(17,24,50,.05);
  transition: box-shadow .2s, transform .2s;
}
.kb-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kb-card summary { cursor: pointer; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; list-style: none; }
.kb-card summary::-webkit-details-marker { display: none; }
.kb-title { font-weight: 700; font-size: 15px; flex: 1; min-width: 160px; }
.kb-card[open] summary { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.kb-card h4 { font-size: 13px; font-weight: 700; margin: 10px 0 5px; color: var(--text); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.table th {
  text-align: left; padding: 13px 16px; background: #f7f9fd;
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft);
  border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbff; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ============ 页脚 ============ */
.site-footer { background: var(--bg-soft); color: #9aa4c7; padding: 26px 20px; font-size: 13.5px; }
.footer-inner { max-width: 1120px; margin: 0 auto; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.site-footer a { color: #a5b4ff; }

/* ============ AI 生成标识 ============ */
.ai-badge {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  background: rgba(16, 23, 51, .88); color: #cdd6ff;
  border: 1px solid rgba(165, 180, 255, .45);
  padding: 6px 14px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  pointer-events: none; user-select: none;
}

/* ============ 管理后台 ============ */
.admin-body { background: var(--panel-soft); }
.admin-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(900px 480px at 50% -10%, #2b3a8f 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: 18px; padding: 34px 32px; box-shadow: var(--shadow-lg);
}
.login-sub { text-align: center; color: var(--text-soft); font-size: 14px; margin: 10px 0 18px; }
.login-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; font-size: 13.5px;
}
.admin-main { max-width: 1120px; margin: 0 auto; padding: 30px 20px 80px; }
.admin-user { font-size: 13.5px; color: var(--text-soft); font-weight: 600; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.tab {
  padding: 9px 20px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-soft);
  transition: all .16s;
}
.tab:hover { border-color: var(--brand); color: var(--brand); }
.tab.active { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(79,110,247,.3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card strong { font-size: 30px; font-weight: 800; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card span { font-size: 13px; color: var(--text-soft); }
.top-list { list-style: none; display: grid; gap: 10px; }
.top-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 15px; background: var(--panel-soft);
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
}
.top-list strong { color: var(--brand); }

.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(11, 16, 32, .55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 760px; background: #fff;
  border-radius: 16px; padding: 24px 26px 28px; box-shadow: var(--shadow-lg);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.rule-form .form-actions { justify-content: flex-start; }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .header-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .header-nav { justify-content: space-between; gap: 10px; }
  .header-nav a { font-size: 13.5px; }
  .hero { padding: 52px 18px 46px; }
  .hero-stats { gap: 24px; }
  .section { padding: 38px 16px; }
  .panel { padding: 18px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .meta-key { min-width: 100%; }
  .ai-badge { right: 10px; bottom: 10px; font-size: 11.5px; padding: 5px 11px; }
}
