:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #1f2d2a;
  background: #f2f5f4;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
}

button,
input,
textarea {
  font: inherit;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background:
    linear-gradient(135deg, rgba(15, 115, 93, 0.14), rgba(234, 179, 8, 0.08)),
    #f4f7f6;
}

.login-hero {
  width: min(1080px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 420px;
  overflow: hidden;
  border: 1px solid #dce6e2;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(31, 45, 42, 0.12);
}

.login-hero-main {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  background: #12352e;
  color: #ffffff;
}

.login-hero-main::after {
  content: "";
  position: absolute;
  right: 42px;
  bottom: 42px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
}

.login-brand {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 15px;
}

.login-brand span,
.brand {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0f8b6f;
  color: #ffffff;
  font-weight: 800;
}

.login-brand span {
  background: #eab308;
  color: #17231f;
}

.login-brand strong {
  font-size: 16px;
}

.login-hero-main h1 {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 72px 0 0;
  font-size: 40px;
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: 0;
}

.login-hero-main p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 16px;
  line-height: 1.75;
}

.login-highlights {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-highlights span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}

.login-card-head {
  margin-bottom: 28px;
}

.login-card h2 {
  margin: 0;
  color: #132822;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-card p {
  margin: 8px 0 0;
  color: #667a73;
  line-height: 1.6;
}

.login-submit {
  height: 44px;
  margin-top: 4px;
  font-weight: 700;
}

.login-box h1,
.page-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-box p,
.page-head p {
  margin: 8px 0 0;
  color: #667a73;
}

.full-btn {
  width: 100%;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  padding: 20px 14px;
  border-right: 1px solid #dfe8e5;
  background: #ffffff;
}

.sidebar-title {
  padding: 0 10px 18px;
  color: #0f735d;
  font-weight: 800;
}

.sidebar button {
  width: 100%;
  height: 40px;
  margin-bottom: 4px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #40524b;
  text-align: left;
  cursor: pointer;
}

.sidebar button.active {
  background: #e9f5f1;
  color: #0f735d;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid #dfe8e5;
  background: #ffffff;
}

.topbar div {
  display: grid;
  gap: 2px;
}

.topbar span {
  color: #70837c;
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 24px;
  overflow: auto;
}

.page-head {
  margin-bottom: 18px;
}

.page-head.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-head.inline .el-input {
  width: 260px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  padding: 18px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
}

.stat span {
  display: block;
  color: #667a73;
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.inline-form,
.model-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.model-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.student-tools {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(420px, 0.9fr);
  gap: 14px;
  margin-bottom: 16px;
}

.student-tool-panel {
  padding: 16px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
}

.student-tool-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.tool-help {
  margin: -4px 0 12px;
  color: #667a73;
  font-size: 13px;
  line-height: 1.6;
}

.student-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.student-form-grid .el-input,
.student-form-grid .el-input-number,
.student-form-grid .el-date-editor {
  width: 100%;
}

.actions.compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.student-file-import {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.file-input {
  width: 100%;
  padding: 10px;
  border: 1px dashed #b9c9c4;
  border-radius: 8px;
  background: #f8fbfa;
  color: #40524b;
}

.file-name {
  overflow: hidden;
  color: #40524b;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-result {
  color: #40524b;
  font-size: 13px;
}

.import-failures {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: #b42318;
  font-size: 12px;
}

.knowledge-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) minmax(180px, 1fr) minmax(180px, 1fr) minmax(180px, 1.2fr) 100px 150px;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.form-switch-row,
.form-actions-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-switch-row {
  height: 32px;
  color: #40524b;
  font-size: 13px;
}

.form-actions-inline {
  justify-content: flex-end;
}

.batch-import-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 20px;
}

.model-config-panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
}

.quick-model-panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #cde7df;
  border-radius: 8px;
  background: #f8fcfb;
}

.quick-model-head {
  margin-bottom: 12px;
}

.quick-model-head h3 {
  margin: 0;
  font-size: 17px;
}

.quick-model-head p {
  margin: 6px 0 0;
  color: #667a73;
}

.quick-model-grid {
  display: grid;
  grid-template-columns: 180px 240px minmax(280px, 1fr) 130px;
  gap: 12px;
  align-items: end;
}

.model-config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px 14px;
}

.quick-model-panel .el-form-item,
.model-config-panel .el-form-item {
  margin-bottom: 12px;
}

.quick-model-panel .el-select,
.quick-model-panel .el-input,
.model-config-panel .el-select,
.model-config-panel .el-input-number,
.model-config-panel .el-input {
  width: 100%;
}

.agent-workbench {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 420px);
  gap: 18px;
  align-items: start;
}

.agent-config-panel,
.agent-preview-panel {
  padding: 18px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
}

.agent-preview-panel {
  height: clamp(560px, calc(100vh - 170px), 760px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.agent-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.agent-config-panel .el-select,
.agent-config-panel .el-input-number,
.agent-config-panel .el-input {
  width: 100%;
}

.agent-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid #e4ece9;
  background: #ffffff;
}

.agent-preview-head h3 {
  margin: 0;
  font-size: 17px;
}

.agent-preview-head span {
  overflow: hidden;
  color: #667a73;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-preview-chat {
  min-height: 0;
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  background: #f6f8f7;
}

.agent-preview-message-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  max-width: 96%;
}

.agent-preview-message-row.user {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 32px;
}

.agent-preview-message-row.user .agent-preview-avatar {
  grid-column: 2;
  grid-row: 1;
  background: #0f735d;
  color: #ffffff;
}

.agent-preview-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e0ebe7;
  color: #0f735d;
  font-size: 12px;
  font-weight: 700;
}

.agent-preview-bubble {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(21, 43, 36, 0.05);
}

.agent-preview-message-row.user .agent-preview-bubble {
  grid-column: 1;
  grid-row: 1;
  border-color: #cde7df;
  background: #e9f5f1;
}

.agent-preview-message-row.thinking .agent-preview-bubble {
  color: #667a73;
}

.agent-preview-bubble strong {
  display: block;
  margin-bottom: 6px;
  color: #0f735d;
  font-size: 12px;
}

.agent-preview-bubble pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  line-height: 1.75;
}

.agent-preview-thinking {
  margin-bottom: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f3f6f5;
  color: #5f6f69;
}

.agent-preview-thinking summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.agent-preview-thinking pre {
  margin-top: 8px;
  font-size: 13px;
}

.agent-preview-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: end;
  padding: 14px 18px 16px;
  border-top: 1px solid #e4ece9;
  background: #ffffff;
}

.agent-preview-composer .el-button {
  height: 54px;
}

.actions {
  margin-top: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.settings-section {
  padding: 18px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
}

.settings-section-head h3 {
  margin: 0;
  font-size: 17px;
}

.settings-section-head p {
  margin: 6px 0 0;
  color: #667a73;
  font-size: 13px;
  line-height: 1.6;
}

.settings-fields {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.setting-field {
  display: grid;
  gap: 7px;
}

.setting-field span {
  color: #223631;
  font-weight: 600;
}

.setting-field small {
  color: #667a73;
  line-height: 1.5;
}

.setting-field .el-input-number,
.setting-field .el-input {
  width: 100%;
}

.el-drawer .el-date-editor.el-input {
  width: 100%;
}

.record-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.record-filter > .el-input {
  width: 280px;
}

.record-filter > .el-input-number {
  width: 140px;
}

.record-filter > .el-select {
  width: 150px;
}

.record-date-range {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.record-date-sep {
  color: #909399;
  font-size: 13px;
  display: flex;
  align-items: center;
  padding: 0 2px;
  min-height: 40px;
}

.record-date-field {
  width: 210px;
  height: 40px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #ffffff;
  color: #606266;
}

.record-date-field:focus-within {
  border-color: #409eff;
}

.record-date-field span {
  color: #909399;
  font-size: 13px;
  white-space: nowrap;
}

.record-date-field input {
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #303133;
  font-size: 13px;
}

.record-date-field input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.72;
}

.record-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.chat-summary div {
  padding: 12px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #f8fbfa;
}

.chat-summary span {
  display: block;
  font-size: 22px;
  font-weight: 600;
  color: #2a6b56;
  margin-top: 4px;
}

.chat-summary strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: #1f2d2a;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-title {
  margin: 18px 0 10px;
  font-size: 16px;
}

.conversation-list {
  display: grid;
  gap: 12px;
}

.conversation-message {
  padding: 12px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #ffffff;
}

.conversation-message.user {
  border-color: #cde7df;
  background: #f2faf7;
}

.message-meta,
.message-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: #6b7d77;
  font-size: 12px;
}

.message-meta strong {
  color: #0f735d;
}

.conversation-message pre,
.prompt-preview {
  margin: 10px 0;
  padding: 10px;
  overflow-x: auto;
  border-radius: 6px;
  background: #f4f7f6;
  color: #223631;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "PingFang SC", monospace;
  line-height: 1.65;
}

.ai-log-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
  color: #40524b;
  font-size: 13px;
}

.audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #dce8e4;
  border-radius: 6px;
  background: #fbfdfc;
  color: #40524b;
  font-size: 13px;
}

.retrieval-chunks {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}

.retrieval-chunk {
  padding: 12px;
  border: 1px solid #dce8e4;
  border-radius: 6px;
  background: #fbfdfc;
}

.chunk-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  margin-bottom: 8px;
  color: #203832;
}

.chunk-head strong {
  color: #0f735d;
}

.chunk-head span {
  color: #60746d;
  font-size: 13px;
}

.chunk-title {
  margin-bottom: 8px;
  color: #203832;
  font-weight: 600;
  line-height: 1.5;
}

.retrieval-chunk pre {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-radius: 6px;
  background: #f4f7f6;
  color: #263832;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "PingFang SC", monospace;
  line-height: 1.65;
}

.retrieval-chunk a {
  display: inline-flex;
  margin-top: 8px;
  color: #0f735d;
  text-decoration: none;
}

.error-text {
  color: #b42318;
}

@media (max-width: 1120px) {
  .student-tools,
  .agent-workbench,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .audit-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agent-preview-panel {
    height: 620px;
  }
}

@media (max-width: 860px) {
  body {
    min-width: 0;
  }

  .login-page {
    padding: 18px;
  }

  .login-hero {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .login-hero-main {
    padding: 28px;
  }

  .login-hero-main::after {
    width: 160px;
    height: 160px;
    right: 18px;
    bottom: 18px;
  }

  .login-hero-main h1 {
    margin-top: 42px;
    font-size: 28px;
  }

  .login-card {
    padding: 28px;
  }

  .admin-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 6px;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid #dfe8e5;
  }

  .sidebar-title {
    flex: 0 0 auto;
    padding: 0 8px 0 0;
  }

  .sidebar button {
    flex: 0 0 auto;
    width: auto;
    margin-bottom: 0;
    white-space: nowrap;
  }

  .workspace {
    display: block;
  }

  .topbar {
    padding: 12px 16px;
  }

  .content {
    padding: 16px;
  }

  .page-head.inline {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head.inline .el-input {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-summary {
    grid-template-columns: 1fr;
  }

  .student-form-grid,
  .knowledge-form,
  .model-config-grid,
  .quick-model-grid,
  .agent-config-grid,
  .inline-form,
  .model-form {
    grid-template-columns: 1fr;
  }

  .agent-preview-message-row,
  .agent-preview-message-row.user {
    max-width: 100%;
  }
}
