/* 主公的中医 RAG — 样式 */
:root {
  --bg: #f6f3ec;
  --bg-card: #fffdf7;
  --ink: #2a2520;
  --ink-soft: #5a5048;
  --ink-faint: #8a807a;
  --accent: #8b3a2e;
  --accent-hover: #6d2c22;
  --gold: #b08d3c;
  --line: #d8cfbe;
  --line-soft: #e8e0d2;
  --shadow: 0 1px 3px rgba(60,40,20,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", serif;
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶栏 ===== */
.topnav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; background: var(--bg-card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.brand { font-size: 18px; color: var(--accent); letter-spacing: 4px; font-weight: 600; }
.navlinks { display: flex; gap: 28px; }
.navlinks a {
  color: var(--ink-soft); font-size: 14px; letter-spacing: 2px;
  padding: 4px 0; border-bottom: 2px solid transparent; transition: all 0.2s;
}
.navlinks a:hover { color: var(--accent); text-decoration: none; }
.navlinks a.active { color: var(--accent); border-bottom-color: var(--accent); }
.status {
  font-size: 12px; color: var(--ink-faint); display: flex; align-items: center; gap: 6px;
}
.status.ok { color: #4a7c4a; }
.status.err { color: var(--accent); }

/* ===== 主体 ===== */
main { max-width: 920px; margin: 0 auto; padding: 32px 24px 80px; min-height: calc(100vh - 140px); }

/* ===== 通用 ===== */
h1 { font-size: 24px; color: var(--ink); font-weight: 500; margin-bottom: 8px; letter-spacing: 2px; }
h2 { font-size: 18px; color: var(--ink); font-weight: 500; margin: 24px 0 12px; letter-spacing: 1px; }
h3 { font-size: 15px; color: var(--ink-soft); font-weight: 500; margin: 16px 0 8px; }
.sub { color: var(--ink-faint); font-size: 13px; margin-bottom: 24px; letter-spacing: 1px; }

button, .btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 22px;
  font-family: inherit; font-size: 14px; letter-spacing: 2px; cursor: pointer;
  border-radius: 3px; transition: background 0.2s;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled { background: var(--ink-faint); cursor: wait; }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-ghost:hover { background: var(--accent); color: #fff; }

input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--bg-card); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 4px; padding: 18px 22px; margin-bottom: 14px;
  border-left: 3px solid var(--line-soft); box-shadow: var(--shadow);
}
.card:hover { border-left-color: var(--accent); }
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card .title { font-size: 15px; color: var(--accent); font-weight: 600; }
.card .meta { font-size: 11px; color: var(--ink-faint); letter-spacing: 1px; }
.card .body { font-size: 14px; color: var(--ink); white-space: pre-wrap; }
.card .tags { margin-top: 10px; font-size: 11px; color: var(--gold); letter-spacing: 1px; }

/* ===== 检索页 ===== */
.search-box { display: flex; gap: 8px; margin-bottom: 16px; }
.search-box input { flex: 1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; font-size: 13px; }
.filters select { width: auto; min-width: 140px; }
.examples { font-size: 12px; color: var(--ink-soft); margin-bottom: 24px; }
.examples a { margin-right: 14px; cursor: pointer; }

/* ===== 统计 ===== */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.stat {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 4px; padding: 16px; text-align: center;
}
.stat .n { font-size: 24px; color: var(--accent); font-weight: 600; }
.stat .l { font-size: 11px; color: var(--ink-soft); letter-spacing: 1px; margin-top: 4px; }

/* ===== 状态消息 ===== */
.empty, .loading {
  text-align: center; color: var(--ink-soft); padding: 40px; font-size: 14px;
}
.error-box {
  background: #faf0ee; border: 1px solid var(--accent); border-radius: 4px;
  padding: 16px; color: var(--accent); margin: 12px 0;
}

/* ===== 辨证页 ===== */
.ask-input { margin-bottom: 20px; }
.ask-input textarea { min-height: 100px; font-size: 15px; resize: vertical; }
.ask-input button { margin-top: 12px; }

.answer-box {
  background: var(--bg-card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 4px; padding: 24px 28px; margin-top: 20px; line-height: 1.9;
}
.answer-box h3 {
  color: var(--accent); margin-top: 16px; font-size: 15px;
  border-bottom: 1px solid var(--line-soft); padding-bottom: 4px; letter-spacing: 1px;
}
.answer-box h3:first-child { margin-top: 0; }
.answer-box p { margin: 6px 0; }
.answer-box ul { margin: 6px 0 6px 24px; }
.answer-box .disclaimer {
  margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line);
  color: var(--ink-faint); font-size: 12px;
}

.sources-list {
  margin-top: 20px; padding: 16px; background: #fafaf5; border-radius: 4px;
  font-size: 12px;
}
.sources-list .src-item {
  padding: 6px 0; border-bottom: 1px dashed var(--line-soft);
}
.sources-list .src-item:last-child { border-bottom: none; }
.sources-list code { background: #ede6d8; padding: 1px 4px; border-radius: 2px; font-size: 11px; }

/* ===== 书库 ===== */
.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.book-tile {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 4px;
  padding: 16px; cursor: pointer; transition: all 0.2s;
}
.book-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.book-tile .name { font-size: 16px; color: var(--accent); margin-bottom: 4px; font-weight: 600; }
.book-tile .cnt { font-size: 12px; color: var(--ink-faint); }

/* ===== 章节 ===== */
.chunk-list .card { font-size: 13px; }
.chunk-list .card .body { white-space: pre-wrap; max-height: none; }

/* ===== 后台 ===== */
.admin-section { margin-bottom: 32px; }
.admin-form { background: var(--bg-card); border: 1px solid var(--line); padding: 20px; border-radius: 4px; }
.admin-form label { display: block; margin-top: 12px; font-size: 13px; color: var(--ink-soft); }
.admin-form input, .admin-form textarea { margin-top: 4px; }
.admin-form textarea { min-height: 120px; font-family: monospace; font-size: 12px; }

/* ===== footer ===== */
footer {
  text-align: center; padding: 24px; color: var(--ink-faint); font-size: 11px;
  border-top: 1px solid var(--line); margin-top: 60px; letter-spacing: 1px;
}

/* ===== 首页 Hero ===== */
.hero {
  text-align: center;
  padding: 48px 24px;
  margin-bottom: 32px;
  background: linear-gradient(135deg, #fffdf7 0%, #f6f3ec 100%);
  border-radius: 8px;
  border: 1px solid var(--line);
}
.hero h1 {
  font-size: 32px; color: var(--accent); letter-spacing: 6px;
  margin-bottom: 12px; font-weight: 600;
}
.hero p {
  color: var(--ink-soft); font-size: 15px; letter-spacing: 2px; margin-bottom: 24px;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; }
.hero-cta a.btn-ghost {
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
}
.hero-cta a.btn-ghost:hover { background: var(--accent); color: #fff; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.card-grid .card { margin-bottom: 0; }
.card h3 { margin-top: 0; }

/* ===== 中药卡片网格（图 + 文） ===== */
.herb-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.herb-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  transition: all 0.2s;
  display: flex; flex-direction: column;
}
.herb-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.herb-card img {
  width: 100%; height: 180px; object-fit: cover;
  background: #f0ebe0; display: block;
}
.herb-card .img-wrap { position: relative; }
.herb-card .ai-tag {
  position: absolute; top: 8px; right: 8px;
  background: rgba(176, 141, 60, 0.9);
  color: #fff; font-size: 10px;
  padding: 2px 6px; border-radius: 2px;
  letter-spacing: 1px;
}
.herb-card .herb-body { padding: 12px 14px; }
.herb-card .title {
  font-size: 15px; color: var(--accent); font-weight: 600; margin-bottom: 2px;
}
.herb-card .title a { color: inherit; }
.herb-card .meta { font-size: 11px; color: var(--ink-faint); margin-bottom: 8px; letter-spacing: 1px; }
.herb-card .snippet { font-size: 12px; color: var(--ink-soft); line-height: 1.6; }
.muted { color: var(--ink-faint); }
.right { text-align: right; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }


/* ===== 家庭病人档案 ===== */
.patient-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; margin-top: 16px;
}
.patient-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  transition: all 0.2s;
}
.patient-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.patient-card .title {
  display: flex; align-items: center; gap: 8px;
  font-size: 17px; font-weight: 600;
}
.patient-card .meta { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.patient-condition-summary {
  font-size: 13px; margin: 12px 0 8px;
  color: var(--ink);
  padding: 8px 10px; background: #faf6ec; border-left: 3px solid var(--accent);
  border-radius: 2px;
}
.patient-condition-count {
  font-size: 11px; color: var(--ink-faint);
  margin-bottom: 8px;
}
.patient-desc {
  font-size: 12px; color: var(--ink-soft);
  line-height: 1.6; padding: 6px 0;
  border-top: 1px dashed var(--line);
}

.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 1px;
  font-weight: 500;
  vertical-align: middle;
}
.badge-adult { background: #d6e9f5; color: #2a5a8a; }
.badge-elderly { background: #f5e6d6; color: #8a5a2a; }
.badge-child { background: #f5d6e6; color: #8a2a5a; }

/* 档案详情面板 */
.patient-panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 20px;
  margin: 16px 0;
}
.patient-panel h3 {
  margin-top: 0;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.form-grid label {
  display: flex; flex-direction: column;
  font-size: 12px; color: var(--ink-faint);
}
.form-grid label input,
.form-grid label textarea,
.form-grid label select {
  margin-top: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}
.form-grid label textarea {
  resize: vertical; min-height: 50px;
}

#btn-save-profile {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 16px; border-radius: 3px; cursor: pointer;
}
#btn-save-profile:hover { opacity: 0.85; }
#save-status { font-size: 12px; }

/* 既往病史 */
.condition-list { list-style: none; padding: 0; margin: 12px 0; }
.condition-item {
  background: #faf8f3;
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  margin: 8px 0;
  border-radius: 2px;
}
.condition-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
}
.condition-date { font-family: monospace; color: var(--ink-faint); font-size: 12px; }
.condition-type {
  background: #fff; border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 2px;
  font-size: 11px; color: var(--ink-soft);
}
.condition-name { flex: 1; font-weight: 500; }
.condition-pattern, .condition-tongue, .condition-meds {
  font-size: 12px; color: var(--ink-soft); margin-top: 4px;
}
.btn-icon {
  background: transparent; border: none; color: var(--ink-faint);
  cursor: pointer; font-size: 14px;
}
.btn-icon:hover { color: #c44; }

.add-condition-form { margin-top: 12px; }
.add-condition-form summary {
  cursor: pointer; color: var(--accent); font-size: 13px;
  padding: 6px 0;
}
#btn-add-cond {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 14px; border-radius: 3px; cursor: pointer; margin-top: 4px;
}
#btn-add-cond:hover { opacity: 0.85; }

/* 时间线 */
.timeline {
  list-style: none; padding: 0;
  position: relative;
  margin: 12px 0;
}
.timeline::before {
  content: ''; position: absolute;
  left: 90px; top: 0; bottom: 0;
  width: 2px; background: var(--line);
}
.timeline-item {
  display: flex; gap: 16px; padding: 8px 0;
  position: relative;
}
.timeline-item::before {
  content: ''; position: absolute;
  left: 86px; top: 16px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}
.tl-consult::before { background: #4a8a4a; }
.tl-date {
  width: 80px; flex-shrink: 0;
  font-family: monospace; font-size: 12px;
  color: var(--ink-faint); text-align: right;
  padding-top: 12px;
}
.tl-body {
  flex: 1; background: #faf8f3;
  border-radius: 3px; padding: 8px 12px;
  margin-left: 24px;
}
.tl-title { font-size: 14px; font-weight: 500; }
.tl-type {
  font-size: 11px; color: var(--ink-faint);
  margin-left: 6px;
}
.tl-pattern, .tl-tongue, .tl-meds, .tl-question, .tl-answer {
  font-size: 12px; color: var(--ink-soft); margin-top: 4px; line-height: 1.5;
}
.tl-answer {
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* 关联病例 chips */
.related-cases {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.case-chip {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* Prompt 预览 */
.prompt-preview {
  background: #1a1a2e; color: #e8e8d0;
  padding: 12px 16px; border-radius: 4px;
  font-size: 12px; line-height: 1.6;
  white-space: pre-wrap;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .timeline::before { left: 60px; }
  .timeline-item::before { left: 56px; }
  .tl-date { width: 50px; }
  .tl-body { margin-left: 16px; }
}


/* ===== AI 辨证（多轮 + 分段 + 引用回链） ===== */
.ask-input {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.ask-input textarea {
  width: 100%; min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
}
.ask-input textarea:focus { outline: 2px solid var(--accent); }
.ask-input select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  font-size: 13px;
}

/* 对话气泡 */
.ask-turn {
  margin: 16px 0;
  display: flex; flex-direction: column;
  gap: 8px;
}
.ask-bubble {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ask-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #d4a574, #c89860);
  color: #fff;
  border: 1px solid #b8895a;
}
.ask-user .bubble-head { color: rgba(255,255,255,0.85); }
.ask-user .bubble-meta { color: rgba(255,255,255,0.7); font-size: 11px; margin-top: 4px; }
.ask-ai {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 100%;
}
.ask-ai .bubble-head {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}
.bubble-body { word-break: break-word; }
.bubble-meta {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 6px;
  text-align: right;
}
.ask-ai .bubble-meta { color: var(--ink-faint); }

/* 流式光标 */
.streaming-dot {
  display: inline-block; width: 8px; height: 14px;
  background: var(--accent);
  margin-left: 4px; vertical-align: middle;
  animation: blink 1s infinite;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.2; }
}

/* 分段卡片 */
.answer-section {
  background: #faf8f3;
  border-radius: 4px;
  padding: 10px 14px;
  margin: 10px 0;
}
.answer-section-head {
  font-size: 14px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.answer-section-body {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
}
.answer-section-body p { margin: 6px 0; }

/* chunk 引用链接 */
.chunk-ref {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 3px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 11px;
  text-decoration: none;
  font-weight: 500;
}
.chunk-ref:hover {
  background: var(--accent);
  color: #fff;
}

/* 引用原文列表 */
.ask-sources {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f5f0e0;
  border-radius: 4px;
  font-size: 12.5px;
}
.src-link {
  display: flex; align-items: baseline; gap: 10px;
  padding: 4px 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
}
.src-link:last-child { border-bottom: none; }
.src-link:hover { background: #ede4c8; }
.src-link .src-id {
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
  font-size: 12px;
}
.src-link .src-source {
  flex: 1; font-size: 12px; color: var(--ink-soft);
}

.disclaimer {
  margin-top: 12px; padding: 8px 10px;
  background: #fff8e0; border-left: 3px solid #d4a020;
  font-size: 11.5px; color: #6a4a00;
  border-radius: 2px;
}

@media (max-width: 768px) {
  .ask-bubble { max-width: 95%; }
}


/* ===== Phase 10 后台治理 ===== */

/* 标签云 */
#tag-cloud {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  align-items: baseline;
  padding: 12px 0;
}
.tag-chip {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 4px;
  border-bottom: 1px dashed transparent;
  transition: all 0.2s;
}
.tag-chip:hover {
  border-bottom-color: var(--accent);
  background: #faf6ec;
}
.tag-chip sup {
  font-size: 10px;
  color: var(--ink-faint);
  margin-left: 2px;
  vertical-align: super;
}

/* 草稿列表 */
.draft-item {
  background: #faf8f3;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 3px;
}
.draft-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; flex-wrap: wrap;
}
.draft-head a { font-weight: 600; color: var(--accent); }
.draft-meta { color: var(--ink-faint); font-size: 12px; }
.draft-tags { margin-top: 4px; }
.tag-chip-mini {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  margin-right: 4px;
}

/* mini 按钮 */
.btn-mini {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
}
.btn-mini:hover { background: #f5f0e0; }
.btn-mini-primary {
  background: #4a8a4a; color: #fff; border-color: #3a7a3a;
}
.btn-mini-primary:hover { background: #3a7a3a; }
.btn-mini-danger {
  background: #c44; color: #fff; border-color: #a33;
}
.btn-mini-danger:hover { background: #a33; }

/* 导出表单 */
.export-form {
  background: #faf8f3;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 16px;
}
.export-form label {
  display: flex; flex-direction: column;
  font-size: 11px; color: var(--ink-faint);
}
.export-form select,
.export-form input {
  margin-top: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 13px;
  min-width: 100px;
}

/* 状态统计小卡 */
#chunks-by-status {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.stat-mini {
  text-align: center;
  background: #faf8f3;
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 4px;
  min-width: 100px;
}
.stat-mini-n {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}
.stat-mini-l { font-size: 11px; margin-top: 2px; }

/* 系统状态徽章 */
.stat .badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  margin: 1px;
  border-radius: 8px;
}


/* ===== Phase 11 访问统计后台 ===== */

/* 总览 stat-grid 已在 app.css 现有 */

/* UA 分布行 */
.ua-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}
.ua-name { font-weight: 500; }
.ua-bar {
  background: #f0ebe0;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
}
.ua-fill {
  background: linear-gradient(90deg, #4a7a8a, #6a9aaa);
  height: 100%;
  border-radius: 8px;
  transition: width 0.4s;
}
.ua-count { text-align: right; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* 流量趋势条形图 */
.timeline-chart {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 140px;
  padding: 8px 0;
  overflow-x: auto;
}
.tl-day {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  max-width: 80px;
}
.tl-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 80px;
}
.tl-bar {
  width: 12px;
  border-radius: 2px 2px 0 0;
  transition: height 0.4s;
  min-height: 1px;
}
.tl-pv { background: #4a7a8a; }
.tl-ev { background: #d4a020; }
.tl-label {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 4px;
  font-family: ui-monospace, monospace;
}
.tl-meta {
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 1px;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.legend-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* 排名 chips */
.rank-chip {
  display: inline-block;
  background: #faf6ec;
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  margin: 2px;
  font-family: ui-monospace, monospace;
}

/* 表格 */
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.analytics-table th,
.analytics-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.analytics-table th {
  background: #faf8f3;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 12px;
}
.analytics-table tbody tr:hover {
  background: #faf6ec;
}
.analytics-table code {
  font-size: 12px;
  color: var(--accent);
}

/* 搜索词条 */
.query-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.query-row {
  display: grid;
  grid-template-columns: 40px 1fr 200px 50px;
  gap: 12px;
  align-items: center;
  padding: 6px 8px;
  background: #faf8f3;
  border-radius: 3px;
  font-size: 13px;
}
.query-rank {
  color: var(--accent);
  font-weight: 600;
  font-family: ui-monospace, monospace;
}
.query-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.query-bar {
  background: #f0ebe0;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
}
.query-fill {
  background: linear-gradient(90deg, #d4a020, #e8b840);
  height: 100%;
  border-radius: 7px;
  transition: width 0.4s;
}
.query-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-weight: 500;
}

/* 最近事件流 */
.recent-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 500px;
  overflow-y: auto;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
}
.recent-row {
  display: grid;
  grid-template-columns: 80px 80px 160px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px dashed var(--line);
}
.recent-row:hover { background: #faf6ec; }
.recent-time { color: var(--ink-faint); }
.recent-kind {
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  text-align: center;
  font-weight: 600;
}
.recent-search { background: #fff3d4; color: #8a6a00; }
.recent-ask { background: #f5d6e6; color: #8a2a5a; }
.recent-pageview { background: #d6e9f5; color: #2a5a8a; }
.recent-herbs { background: #d4f0d4; color: #2a5a2a; }
.recent-formula { background: #f0d4e9; color: #5a2a8a; }
.recent-ingest { background: #e9e9d4; color: #5a5a2a; }
.recent-patient_view { background: #f0e9d4; color: #8a5a2a; }
.recent-case_view { background: #d4e9f0; color: #2a8a5a; }
.recent-page { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-detail { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-ua { color: var(--ink-faint); text-align: right; }

@media (max-width: 768px) {
  .recent-row {
    grid-template-columns: 60px 60px 1fr;
    gap: 6px;
  }
  .recent-page, .recent-ua { display: none; }
  .query-row {
    grid-template-columns: 30px 1fr 50px;
    gap: 6px;
  }
  .query-bar { display: none; }
}


/* ============ 症状自查 (symptom check) ============ */
.sc-intake { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.sc-intake textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px; font-family: inherit; font-size: 14px; box-sizing: border-box; }
.sc-area-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-area-chip {
  padding: 6px 12px; border: 1px solid var(--accent); border-radius: 16px;
  cursor: pointer; user-select: none; display: inline-block; font-size: 14px;
  background: #fff; color: var(--accent);
}
.sc-area-chip.active { background: var(--accent); color: #fff; }
.sc-patient-select { padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.sc-start-btn {
  padding: 10px 20px; background: var(--accent); color: #fff;
  border: none; border-radius: 6px; font-size: 15px; cursor: pointer;
}
.sc-start-btn:hover { filter: brightness(1.1); }
.sc-progress { margin: 12px 0; font-size: 13px; color: var(--ink-soft); }
.sc-progress-bar { height: 6px; background: #eee; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.sc-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.sc-quick-replies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sc-quick-reply {
  padding: 6px 12px; border: 1px solid #aaa; border-radius: 16px;
  background: #f9f6ec; cursor: pointer; font-size: 13px; color: var(--ink);
  transition: all 0.15s;
}
.sc-quick-reply:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.sc-answer-bar { display: flex; gap: 8px; margin-top: 12px; }
.sc-answer-bar input {
  flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 14px;
}
.sc-answer-bar button {
  padding: 10px 18px; background: var(--accent); color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.sc-final-box { background: #fffdf5; border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-top: 12px; }
.sc-final-actions { margin-top: 12px; display: flex; gap: 8px; }
.sc-final-actions button { padding: 8px 14px; border: 1px solid var(--accent); border-radius: 6px; background: #fff; color: var(--accent); cursor: pointer; font-size: 13px; }
.sc-final-actions button:hover { background: var(--accent); color: #fff; }
