/* ================================================
   Buttons
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
  line-height: 1.6;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-primary:active {
  background: #1e50c8;
}

.btn-default {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-default:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #d63131;
  border-color: #d63131;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #2aaf1c;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover {
  background: #e06e00;
}

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

.btn-lg {
  padding: 9px 22px;
  font-size: 15px;
}

.btn:disabled,
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ================================================
   Card
   ================================================ */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-white);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
}

/* ================================================
   Stat Card
   ================================================ */
.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 4px;
}

.stat-card-trend {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-card-trend.up   { color: var(--danger); }
.stat-card-trend.down { color: var(--success); }

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ================================================
   Data Table
   ================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-white);
}

.data-table thead tr {
  background: #FAFAFA;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  color: var(--text-primary);
  border-bottom: 1px solid #F2F3F5;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:nth-child(even) td {
  background: #FAFAFA;
}

.data-table tbody tr:hover td {
  background: var(--primary-light);
}

/* ================================================
   Form
   ================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: var(--transition);
  line-height: 1.6;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(51,112,255,.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-placeholder);
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%238F959E' d='M4.7 6.3l3.3 3.3 3.3-3.3.7.7-4 4-4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-placeholder);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
}

/* Inline form row */
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* ================================================
   Modal
   ================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlayIn .18s ease;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .22s ease;
}

.modal-content.modal-lg { max-width: 780px; }
.modal-content.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ================================================
   Tags & Badges
   ================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-default  { background: #F2F3F5; color: var(--text-secondary); }
.tag-primary  { background: var(--primary-light); color: var(--primary); }
.tag-success  { background: var(--success-light); color: #1aac0e; }
.tag-warning  { background: var(--warning-light); color: #cc6400; }
.tag-danger   { background: var(--danger-light); color: #c52b2b; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  background: var(--danger);
  color: #fff;
}

/* ================================================
   Tabs
   ================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 400;
  user-select: none;
}

.tab-item:hover {
  color: var(--primary);
}

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ================================================
   Search Box
   ================================================ */
.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-box-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-placeholder);
  pointer-events: none;
}

.search-box input {
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: var(--transition);
  width: 220px;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(51,112,255,.15);
  width: 280px;
}

.search-box input::placeholder {
  color: var(--text-placeholder);
}

/* ================================================
   Empty State
   ================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  opacity: .4;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-placeholder);
}

/* ================================================
   Breadcrumb
   ================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

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

.breadcrumb-item a {
  color: var(--primary);
  transition: var(--transition);
}

.breadcrumb-item a:hover {
  color: var(--primary-hover);
}

.breadcrumb-sep {
  color: var(--text-placeholder);
  font-size: 12px;
}

/* ================================================
   Pagination
   ================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  padding: 12px 0 4px;
}

.pagination-item {
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-white);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0 8px;
  user-select: none;
}

.pagination-item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.pagination-item.disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ================================================
   Toolbar / Filter Bar
   ================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ================================================
   Info Row
   ================================================ */
.info-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.info-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 72px;
}

.info-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ================================================
   Stats Grid
   ================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ================================================
   Chart Container
   ================================================ */
.chart-container {
  width: 100%;
  height: 300px;
}

.chart-container-lg {
  width: 100%;
  height: 400px;
}

/* ================================================
   Progress Bar
   ================================================ */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-page);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width .4s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger); }

/* ================================================
   Divider
   ================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ================================================
   Loading Spinner
   ================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(51,112,255,.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

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

/* ================================================
   Step / Status Indicator
   ================================================ */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.success { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.danger  { background: var(--danger); }
.status-dot.info    { background: var(--primary); }
.status-dot.gray    { background: #C9CDD4; }

/* ================================================
   Tooltip (CSS-only)
   ================================================ */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1F2329;
  color: #fff;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  z-index: 9999;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ================================================
   Grid Layout Helpers
   ================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ================================================
   AI对话模块
   ================================================ */

/* 对话页面整体布局 */
.chat-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
  flex: 1;
}

/* 左侧对话列表 */
.chat-sidebar {
  width: 260px;
  min-width: 260px;
  background: #F0F1F3;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-new-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  justify-content: center;
}

.chat-new-btn:hover {
  background: var(--primary-hover);
}

.chat-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
}

.chat-conv-list::-webkit-scrollbar {
  width: 4px;
}
.chat-conv-list::-webkit-scrollbar-track {
  background: transparent;
}
.chat-conv-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.12);
  border-radius: 2px;
}

.chat-conv-empty {
  text-align: center;
  color: var(--text-placeholder);
  font-size: 13px;
  padding: 32px 16px;
  line-height: 1.8;
}

.chat-conv-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
}

.chat-conv-item:hover {
  background: rgba(0,0,0,.05);
}

.chat-conv-item.active {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.chat-conv-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.chat-conv-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-conv-preview {
  font-size: 12px;
  color: var(--text-placeholder);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-conv-time {
  font-size: 11px;
  color: var(--text-placeholder);
  flex-shrink: 0;
}

/* 右侧对话主区 */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
}

.chat-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-meta {
  font-size: 12px;
  color: var(--text-placeholder);
  flex-shrink: 0;
}

/* 消息地带 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.1);
  border-radius: 3px;
}

/* 欢迎展示区 */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 300px;
  color: var(--text-secondary);
  gap: 12px;
  text-align: center;
}

.chat-welcome-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
}

.chat-welcome h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-placeholder);
}

/* 消息行 */
.chat-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 860px;
}

.chat-msg-user {
  flex-direction: row-reverse;
  margin-left: auto;
  max-width: 70%;
}

.chat-msg-assistant {
  flex-direction: row;
  max-width: 80%;
}

/* AI头像 */
.chat-ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* 消息内容包装 */
.chat-msg-content-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg-content-wrap.user {
  align-items: flex-end;
}

.chat-msg-content-wrap.assistant {
  align-items: flex-start;
}

/* 气泡 */
.chat-bubble {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble.user {
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 4px;
  white-space: pre-wrap;
}

.chat-bubble.assistant {
  background: #F5F6F7;
  color: var(--text-primary);
  border-top-left-radius: 4px;
  white-space: normal;
}

/* 消息时间 */
.chat-msg-time {
  font-size: 11px;
  color: var(--text-placeholder);
  padding: 0 4px;
}

/* 光标闪烁 */
.chat-cursor {
  display: inline-block;
  color: var(--primary);
  animation: blink .8s infinite;
  font-weight: 300;
  margin-left: 1px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 思考中状态 */
.chat-thinking-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}

.chat-thinking-text {
  font-size: 13px;
  color: var(--text-placeholder);
}

.chat-thinking-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: thinkPulse 1.2s infinite;
}

.chat-thinking-dots span:nth-child(2) { animation-delay: .2s; }
.chat-thinking-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes thinkPulse {
  0%, 100% { opacity: .3; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* 消息出现动画 */
.chat-msg-appear {
  animation: msgAppear .2s ease;
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Markdown 渲染样式 */
.chat-bubble.assistant p {
  margin-bottom: 6px;
}

.chat-bubble.assistant p:last-child {
  margin-bottom: 0;
}

.chat-bubble.assistant strong {
  font-weight: 700;
  color: var(--text-primary);
}

.chat-bubble.assistant br {
  display: block;
  content: '';
  margin-bottom: 4px;
}

.chat-bubble.assistant li {
  list-style: disc;
  margin-left: 18px;
  margin-bottom: 3px;
  color: var(--text-primary);
}

.chat-code-block {
  background: #f0f1f3;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  overflow-x: auto;
  white-space: pre;
  margin: 6px 0;
}

.chat-inline-code {
  background: #eef3ff;
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.chat-table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.chat-table th {
  background: #e8eaed;
  color: var(--text-primary);
  font-weight: 600;
  padding: 7px 10px;
  text-align: left;
  border: 1px solid var(--border);
}

.chat-table td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.chat-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}

/* 输入区域 */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 -2px 12px rgba(0,0,0,.05);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.chat-input-wrap {
  background: #F5F6F7;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.chat-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(51,112,255,.12);
  background: #fff;
}

.chat-textarea {
  width: 100%;
  padding: 12px 16px 6px;
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  line-height: 1.6;
  min-height: 44px;
  max-height: 160px;
  display: block;
}

.chat-textarea::placeholder {
  color: var(--text-placeholder);
}

.chat-input-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 10px;
  gap: 10px;
}

.chat-input-hint {
  font-size: 12px;
  color: var(--text-placeholder);
}

.chat-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.chat-send-btn:hover {
  background: var(--primary-hover);
}

.chat-send-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* page-chat 容器无内边距，占满内容区高度 */
#page-chat {
  padding: 0 !important;
  overflow: hidden !important;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 上传表格按钮 */
.chat-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: #F4F6FF;
  color: var(--primary);
  border: 1px solid #D1DEFF;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.chat-upload-btn:hover {
  background: #E8EDFF;
  border-color: var(--primary);
}
.chat-upload-btn svg {
  flex-shrink: 0;
}

/* ================================================
   Chat Mention / Command Panel (@学校 / 考试)
   ================================================ */
@keyframes mentionFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-mention-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #E5E8F0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  animation: mentionFadeIn 0.15s ease;
  scrollbar-width: thin;
  scrollbar-color: #D1D5E0 transparent;
}

.chat-mention-panel::-webkit-scrollbar {
  width: 4px;
}
.chat-mention-panel::-webkit-scrollbar-track {
  background: transparent;
}
.chat-mention-panel::-webkit-scrollbar-thumb {
  background: #D1D5E0;
  border-radius: 2px;
}

.chat-mention-panel.hidden {
  display: none;
}

.chat-mention-header {
  padding: 8px 12px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #F0F2F5;
}

.chat-mention-header-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-mention-header-icon.at {
  background: #E8EDFF;
  color: #3370FF;
}
.chat-mention-header-icon.slash {
  background: #FFF0E8;
  color: #FF6A00;
}

.chat-mention-header-text {
  font-size: 12px;
  color: #86909C;
  font-weight: 500;
}

.chat-mention-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: #C2C7D0;
}

.chat-mention-group {
  padding: 6px 0 2px;
}

.chat-mention-group-title {
  padding: 2px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #C2C7D0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chat-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.1s ease;
  user-select: none;
}

.chat-mention-item:hover,
.chat-mention-item.active {
  background: #F4F6FF;
}

.chat-mention-item.active {
  background: #EAF0FF;
}

.mention-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.mention-item-icon.district {
  background: linear-gradient(135deg, #E8F4FF, #D0E8FF);
}
.mention-item-icon.school {
  background: linear-gradient(135deg, #F0FFF0, #D4F0D4);
}
.mention-item-icon.exam {
  background: linear-gradient(135deg, #FFF4E8, #FFE4C4);
}

.mention-item-body {
  flex: 1;
  min-width: 0;
}

.mention-item-name {
  font-size: 13px;
  color: #1D2129;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mention-item-sub {
  font-size: 11px;
  color: #86909C;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mention-tag {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.mention-tag.status-done {
  background: #E8F7EE;
  color: #00B42A;
}
.mention-tag.status-ongoing {
  background: #FFF4E8;
  color: #FF7D00;
}
.mention-tag.status-pending {
  background: #F5F5F5;
  color: #86909C;
}
.mention-tag.level {
  background: #EAF0FF;
  color: #3370FF;
}
.mention-tag.district {
  background: #F0FFF0;
  color: #00A854;
}

/* 确保输入区容器有相对定位，并允许绝对定位子元素（mention面板）溢出显示 */
.chat-input-wrap {
  position: relative;
  overflow: visible;
}

/* ================================================
   考试分析报告模块专用样式
   ================================================ */

/* 工具栏 */
.report-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.report-toolbar-left {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.report-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* 标签页 */
.report-tabs {
  margin-bottom: 20px;
}

/* 内容区 */
.report-tab-content {
  min-height: 400px;
}

/* 考试信息卡片（蓝色渐变） */
.report-info-card {
  background: linear-gradient(135deg, #3370FF 0%, #2957D1 60%, #1E3FAB 100%);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(51, 112, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.report-info-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

.report-info-card-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.report-info-left {
  flex: 1;
}

.report-info-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.report-info-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 14px;
  opacity: 0.9;
}

.report-info-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.report-info-meta strong {
  font-size: 17px;
  font-weight: 700;
}

.report-info-right {
  flex-shrink: 0;
}

.report-info-lines {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.report-info-line-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 10px 18px;
  min-width: 80px;
  text-align: center;
}

.report-info-line-label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.report-info-line-val {
  font-size: 22px;
  font-weight: 700;
}

/* 六大类核心数据卡片网格（2行3列） */
.report-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .report-stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .report-stat-grid { grid-template-columns: 1fr; }
}

/* 单个核心数据卡片 */
.report-stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  /* border-top 颜色由 JS 内联设置 */
}

.report-stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.report-stat-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.report-stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.report-stat-card-title {
  font-size: 14px;
  font-weight: 700;
}

.report-stat-card-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.report-stat-card-item {
  flex: 1;
  min-width: 72px;
}

.report-stat-card-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.report-stat-card-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* 报告段落容器 */
.report-section {
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.report-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  margin: 0;
  background: var(--bg-white);
}

/* 图表容器 */
.chart-container {
  width: 100%;
  min-height: 300px;
  padding: 16px 20px;
  box-sizing: border-box;
}

/* 图表占位提示 */
.report-chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 320px;
  color: var(--text-secondary);
  gap: 10px;
  text-align: center;
  background: #FAFBFF;
  border-radius: var(--radius-sm);
  border: 2px dashed #D1DEFF;
}

.report-chart-placeholder-icon {
  font-size: 40px;
  opacity: 0.6;
}

.report-chart-placeholder p {
  font-size: 14px;
  color: var(--text-placeholder);
  margin: 0;
}

.report-chart-placeholder small {
  font-size: 12px;
  color: #C9CDD4;
  font-family: monospace;
}

/* 空状态引导 */
.report-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  gap: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.report-empty-icon {
  font-size: 56px;
  line-height: 1;
}

.report-empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.report-empty-state p {
  font-size: 14px;
  color: var(--text-placeholder);
  margin: 0;
  max-width: 380px;
}

/* 分类页面标题区 */
.report-category-header {
  margin-bottom: 20px;
  padding: 20px 0 0;
}

.report-category-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
}

.report-category-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* 小尺寸上传按钮 */
.chat-upload-btn-sm {
  padding: 4px 8px !important;
  font-size: 12px !important;
}

/* 小尺寸发送按钮 */
.chat-send-btn-sm {
  padding: 5px 12px !important;
  font-size: 13px !important;
}
