/* MOJOY 服务前端样式（无外部依赖，系统字体栈） */
:root {
  --teal-900: #0b3b40;
  --teal-700: #0e5e63;
  --teal-600: #11707a;
  --blue-800: #16324f;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #dde3e8;
  --text: #24313c;
  --muted: #6b7a87;
  --danger: #b4372f;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15.5px;
  line-height: 1.7;
}

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

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* 头部 */
.site-header {
  background: var(--teal-900);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--teal-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 17px; letter-spacing: 1px; }
.brand-text small { font-size: 12px; color: rgba(255,255,255,.75); }

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.site-nav a {
  color: rgba(255,255,255,.85);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.site-nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.site-nav a.active { background: var(--teal-600); color: #fff; }
.nav-login { border: 1px solid rgba(255,255,255,.5); }
.nav-user { display: inline-flex; align-items: center; gap: 8px; }
.nav-username { color: rgba(255,255,255,.85); font-size: 14px; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 8px;
  font-size: 18px;
  padding: 4px 10px;
  cursor: pointer;
}

/* 提示条 */
.banner {
  max-width: 1000px;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
}
.banner-error { background: #fdecea; color: var(--danger); border: 1px solid #f2c4c0; }
.banner-notice { background: #e7f4f5; color: var(--teal-700); border: 1px solid #bfe2e5; }

/* 主体 */
.site-main { max-width: 1000px; margin: 0 auto; padding: 20px 16px 40px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.page-title { font-size: 21px; margin: 0 0 8px; color: var(--blue-800); }
.section-title { font-size: 17px; margin: 0 0 12px; color: var(--blue-800); }

/* 按钮 */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  background: #eef1f4;
  color: var(--text);
  font-family: inherit;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--teal-700); color: #fff; }
.btn-primary:hover { background: var(--teal-600); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--teal-700); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* 表单 */
.form { margin-top: 12px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfcfd;
}
.form-row input:focus, .form-row textarea:focus {
  outline: 2px solid rgba(17,112,122,.35);
  border-color: var(--teal-600);
}
.form-error { color: var(--danger); font-size: 14px; margin: 6px 0 10px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.inline-form { display: inline; }

/* 登录 / 错误 */
.auth-wrap { display: flex; justify-content: center; padding-top: 6vh; }
.auth-card { width: 100%; max-width: 380px; }
.error-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.error-card { text-align: center; max-width: 420px; width: 100%; }
.error-code { font-size: 40px; font-weight: 700; color: var(--teal-600); margin: 0; }

/* 文档页 */
.doc-wrap { max-width: 860px; margin: 0 auto; }
.doc-card h2 { font-size: 17px; color: var(--blue-800); margin: 26px 0 8px; }
.doc-card p { margin: 8px 0; }
.doc-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14.5px; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.doc-table thead th { background: #eef4f5; color: var(--blue-800); }

/* 对话页 */
.chat-layout { display: flex; gap: 18px; align-items: flex-start; }
.chat-side {
  width: 230px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  max-height: 70vh;
  overflow-y: auto;
}
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-head h2 { font-size: 15px; margin: 0; color: var(--blue-800); }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-empty { font-size: 13px; }
.history-item { padding: 8px 6px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.history-item:hover { background: #f0f6f7; }
.history-q { margin: 0; font-size: 13.5px; overflow: hidden; }
.history-ts { font-size: 12px; }

.chat-panel { flex: 1; min-width: 0; max-width: 860px; margin: 0 auto; }
.chat-card { padding: 16px 18px; }
.chat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chat-title { font-size: 18px; margin: 0; color: var(--blue-800); }
.side-toggle { display: none; }

.chat-scroll {
  height: 52vh;
  min-height: 320px;
  overflow-y: auto;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-empty { text-align: center; margin: auto; font-size: 14px; }
.bubble-row { display: flex; }
.row-user { justify-content: flex-end; }
.row-ai { justify-content: flex-start; }
.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  position: relative;
  font-size: 15px;
}
.bubble-user { background: var(--teal-700); color: #fff; border-bottom-right-radius: 4px; }
.bubble-ai { background: #eef3f4; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble-text { word-break: break-word; white-space: normal; }
.ai-badge {
  position: absolute;
  top: -9px;
  right: 10px;
  background: var(--blue-800);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
}
.chat-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.chat-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfcfd;
}
.chat-form textarea:focus { outline: 2px solid rgba(17,112,122,.35); border-color: var(--teal-600); }
.chat-note { font-size: 12.5px; margin: 8px 2px 0; }

.disclosure-card { margin-top: 16px; padding: 12px 18px; }
.disclosure-card summary { cursor: pointer; font-weight: 600; color: var(--blue-800); }
.disclosure-list { margin: 10px 0 4px; padding-left: 20px; }
.disclosure-list li { margin: 4px 0; font-size: 14.5px; }

/* 管理台 */
.admin-wrap { display: flex; flex-direction: column; gap: 14px; }
.admin-keybar { padding: 14px 18px; }
.keybar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.keybar-label { font-size: 13.5px; color: var(--muted); }
.key-mask {
  background: #f0f4f5;
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  letter-spacing: 1px;
}
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.badge-ok { background: #e3f4ec; color: #1d7a4f; }
.badge-warn { background: #fdf3e0; color: #a06a10; }
.badge-info { background: #e8f1f8; color: #2b5d8c; font-size: 12.5px; margin-right: 8px; }

.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 16px;
  font-size: 14px;
  color: var(--text);
}
.tab.active { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.tab:hover { text-decoration: none; }

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.data-table thead th { background: #eef4f5; color: var(--blue-800); white-space: nowrap; }
.excerpt { max-width: 280px; overflow-wrap: anywhere; }

.filter-form { margin: 6px 0 10px; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-row label { font-size: 13.5px; color: var(--muted); }
.filter-row input, .filter-row select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.pager { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 14px; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 14px; }
.stat {
  background: #f0f6f7;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  min-width: 130px;
}
.stat strong { font-size: 16px; color: var(--blue-800); }
.stat span { font-size: 12.5px; color: var(--muted); }
.test-result { font-size: 13.5px; }
.test-result.ok { color: #1d7a4f; }
.test-result.err { color: var(--danger); }

/* 页脚 */
.site-footer { border-top: 1px solid var(--line); background: #eef1f3; margin-top: 20px; }
.footer-inner { max-width: 1000px; margin: 0 auto; padding: 18px 16px; text-align: center; }
.footer-inner p { margin: 4px 0; font-size: 13px; color: var(--muted); }
.footer-links a { color: var(--teal-700); margin: 0 4px; }

/* 移动端 */
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }
  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-top: 8px;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 10px 12px; }

  .chat-layout { flex-direction: column; }
  .side-toggle { display: inline-block; }
  .chat-side {
    position: fixed;
    top: 54px;
    left: 0;
    bottom: 0;
    width: 260px;
    max-height: none;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 30;
  }
  .chat-side.open { transform: translateX(0); }

  .chat-form { flex-direction: column; }
  .chat-form .btn { width: 100%; }
  .bubble { max-width: 92%; }
  .stat-row { gap: 8px; }
  .stat { flex: 1; min-width: 100px; }
}
