:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --text: #172033;
  --muted: #697386;
  --line: #dce2ea;
  --line-strong: #c7d0dd;
  --blue: #2563eb;
  --green: #0f9f6e;
  --amber: #b7791f;
  --red: #dc2626;
  --violet: #7c3aed;
  --teal: #0f766e;
  --shadow: 0 16px 36px rgba(31, 41, 55, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #111827;
  color: #e5e7eb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 22px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  color: #cbd5e1;
}

.nav a:hover,
.nav a.active {
  background: rgba(37, 99, 235, 0.22);
  color: #fff;
}

.nav-icon {
  width: 20px;
  text-align: center;
}

.sidebar-foot {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.6;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

.btn.danger {
  border-color: #fecaca;
  background: #fff5f5;
  color: var(--red);
}

.content {
  padding: 24px 28px 36px;
}

.section {
  margin-bottom: 22px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section h2 {
  margin: 0;
  font-size: 17px;
}

.section-note {
  color: var(--muted);
  font-size: 13px;
}

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

.kpi {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
}

.kpi-trend {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 16px;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-weight: 800;
}

.panel-body {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #f7fbff;
}

.status,
.tag,
.severity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.running,
.tag.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.status.done,
.tag.green {
  background: #dcfce7;
  color: #15803d;
}

.status.warning,
.tag.amber,
.severity.medium {
  background: #fef3c7;
  color: #92400e;
}

.status.failed,
.tag.red,
.severity.high {
  background: #fee2e2;
  color: #b91c1c;
}

.severity.low {
  background: #e0f2fe;
  color: #0369a1;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.chart {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 250px;
  padding: 8px 0 30px;
}

.bar {
  position: relative;
  flex: 1;
  min-width: 16px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #2563eb, #0f766e);
}

.bar.warning {
  background: linear-gradient(180deg, #f59e0b, #dc2626);
}

.bar::after {
  content: attr(data-label);
  position: absolute;
  right: 0;
  bottom: -24px;
  left: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.metric-list {
  display: grid;
  gap: 10px;
}

.metric-row {
  display: grid;
  grid-template-columns: 110px 1fr 70px;
  align-items: center;
  gap: 10px;
}

.mentor-row {
  display: grid;
  grid-template-columns: 130px 1fr 58px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.mentor-row:last-child {
  border-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.6;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  padding: 0 12px;
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #111827;
  color: #fff;
}

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

.bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.7;
}

.bubble.user {
  background: #f7fbff;
}

.bubble.ai {
  background: #fff;
}

.bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.score {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.score strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.report-block {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.report-block:last-child {
  border-bottom: 0;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
}

.system-intro[hidden] {
  display: none;
}

.system-intro .panel-body {
  display: grid;
  gap: 16px;
}

.system-intro-audio {
  width: 100%;
}

.system-architecture-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1220;
}

.system-architecture-img {
  display: block;
  width: 100%;
  min-width: 860px;
  height: auto;
}

.mono {
  font-family: Consolas, Monaco, monospace;
}

.guide-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid #1d4ed8;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 18px 44px rgba(37, 99, 235, 0.28);
  cursor: pointer;
  font-weight: 800;
}

.guide-panel {
  position: fixed;
  right: 22px;
  bottom: 82px;
  z-index: 49;
  display: none;
  width: min(430px, calc(100vw - 36px));
  height: min(650px, calc(100vh - 112px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.guide-panel.open {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.guide-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #111827;
  color: #fff;
}

.guide-title {
  font-weight: 800;
}

.guide-subtitle {
  margin-top: 2px;
  color: #cbd5e1;
  font-size: 12px;
}

.guide-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.guide-alert {
  padding: 10px 14px;
  border-bottom: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  line-height: 1.5;
}

.guide-messages {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  background: #f8fafc;
}

.guide-msg {
  max-width: 92%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.65;
}

.guide-msg.user {
  justify-self: end;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.guide-msg.assistant {
  justify-self: start;
}

.guide-msg h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.guide-msg p {
  margin: 0 0 8px;
}

.guide-msg p:last-child {
  margin-bottom: 0;
}

.guide-msg ul,
.guide-msg ol {
  margin: 6px 0 8px 20px;
  padding: 0;
}

.guide-msg code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef2ff;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
}

.guide-msg pre {
  overflow-x: auto;
  padding: 10px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
}

.guide-msg pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.guide-quick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 10px;
  overflow-x: auto;
  background: #f8fafc;
}

.guide-quick button {
  flex: 0 0 auto;
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
}

.guide-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.guide-compose textarea {
  min-height: 42px;
  max-height: 92px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  line-height: 1.45;
}

.guide-compose button {
  width: 72px;
}

.typing-caret::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 16px;
  margin-left: 2px;
  background: #2563eb;
  vertical-align: -3px;
  animation: caretBlink 0.8s infinite;
}

@keyframes caretBlink {
  0%, 40% { opacity: 1; }
  41%, 100% { opacity: 0; }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .sidebar-foot {
    position: static;
    margin-top: 18px;
  }

  .kpi-grid,
  .grid-3,
  .grid-2,
  .form-grid,
  .score-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 18px;
  }

  .metric-row,
  .mentor-row {
    grid-template-columns: 1fr;
  }

  .system-architecture-img {
    min-width: 720px;
  }

  .guide-panel {
    right: 12px;
    bottom: 72px;
    width: calc(100vw - 24px);
  }

  .guide-launcher {
    right: 12px;
    bottom: 14px;
  }
}
