:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --surface-soft: #f2f5f3;
  --surface-strong: #eef2f0;
  --text: #26332f;
  --muted: #66736d;
  --faint: #8a9691;
  --line: #e1e7e4;
  --line-strong: #cfd9d4;
  --accent: #0f766e;
  --accent-deep: #0c514d;
  --blue: #365a8c;
  --amber: #9a6b26;
  --violet: #6d5c91;
  --danger: #a43f46;
  --success-soft: #e8f4ef;
  --blue-soft: #eaf0f7;
  --amber-soft: #fbf2e2;
  --danger-soft: #fae9ea;
  --shadow: 0 14px 34px rgba(38, 51, 47, 0.07);
  --shadow-soft: 0 8px 20px rgba(38, 51, 47, 0.05);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fbfcfb 0, var(--bg) 280px);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
  color: var(--text);
  padding: 22px 16px;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--accent-deep);
  border: 1px solid #cfe1da;
  font-weight: 800;
}

.brand-name {
  font-weight: 800;
  font-size: 17px;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  position: relative;
  border: 0;
  border-radius: var(--radius);
  padding: 11px 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--success-soft);
  color: var(--accent-deep);
  border: 1px solid #cfe1da;
  box-shadow: var(--shadow-soft);
}

.main {
  min-width: 0;
  padding: 28px 32px 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 850;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
  font-weight: 800;
}

.topbar p {
  color: var(--muted);
  margin-top: 7px;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #cfe1da;
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--accent-deep);
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 700;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.icon-btn,
.small-btn,
.primary-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-btn:hover,
.small-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
}

.icon-btn {
  width: 38px;
  height: 38px;
}

.small-btn {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 11px 14px;
  font-weight: 800;
}

.primary-btn:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 116px;
  padding: 18px;
}

.metric::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  height: 3px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.metric:nth-child(1)::after {
  background: #ccdcd7;
}

.metric:nth-child(2)::after {
  background: #cdd8e7;
}

.metric:nth-child(3)::after {
  background: #e2d2b8;
}

.metric:nth-child(4)::after {
  background: #d9d0e5;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin-top: 12px;
  font-weight: 850;
}

.cloud-panel {
  margin-bottom: 14px;
}

.cloud-box {
  display: grid;
  gap: 12px;
}

.cloud-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) 120px;
  gap: 12px;
}

.cloud-grid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.cloud-grid code {
  display: block;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cloud-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 24px;
}

.client-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag-ok {
  background: var(--success-soft);
  color: var(--accent-deep);
  border-color: #cfe1da;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.78fr);
  gap: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel.wide {
  grid-column: span 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

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

.two-column {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(0, 1.08fr);
  gap: 14px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid .full,
.form-grid button,
.form-grid .check {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: #98b7ae;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.10);
}

.form-grid textarea {
  resize: vertical;
}

.check {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
}

.check input {
  width: auto;
}

.separated {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.terminal-panel {
  min-height: 560px;
}

.terminal-log {
  background: #fbfcfb;
  color: var(--text);
  border: 1px solid var(--line);
  min-height: 500px;
  max-height: 680px;
  overflow: auto;
  border-radius: var(--radius);
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.log-row {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  word-break: break-word;
}

.log-time {
  color: var(--accent);
}

.insight-box {
  display: grid;
  gap: 10px;
  line-height: 1.7;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue);
  padding: 4px 8px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
  border: 1px solid rgba(54, 90, 140, 0.08);
}

.flow-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.flow-list li {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  color: var(--muted);
}

.table {
  overflow: auto;
}

.table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  z-index: 1;
}

.table tbody tr:hover td {
  background: #fafbfa;
}

.action-col {
  width: 86px;
  min-width: 86px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}

.table tbody tr:hover .action-col {
  background: #fafbfa;
}

.table-action-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 7px 10px;
  white-space: nowrap;
}

.table-action-btn:hover {
  transform: translateY(-1px);
}

.table-action-btn:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.danger-action {
  border-color: #edcdd0;
  background: var(--danger-soft);
  color: var(--danger);
}

.doc-list,
.patient-list {
  display: grid;
  gap: 12px;
}

.patient-workspace {
  grid-template-columns: minmax(620px, 1.38fr) minmax(320px, 0.62fr);
}

.patient-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.profile-hero,
.patient-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  color: var(--accent-deep);
  border: 1px solid var(--line);
  font-weight: 850;
  font-size: 20px;
  flex: 0 0 auto;
}

.profile-name {
  font-weight: 850;
  font-size: 20px;
  line-height: 1.2;
}

.risk-orb {
  min-width: 112px;
  min-height: 82px;
  border-radius: var(--radius);
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 11px 14px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.risk-orb span,
.risk-orb small {
  font-size: 12px;
  color: currentColor;
  opacity: 0.82;
}

.risk-orb strong {
  font-size: 30px;
  line-height: 1;
  font-weight: 850;
}

.risk-orb-low {
  background: var(--success-soft);
  color: var(--accent-deep);
  border-color: #cfe2da;
}

.risk-orb-attention {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #ead9b8;
}

.risk-orb-urgent {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #edcdd0;
}

.risk-orb-unknown {
  background: var(--surface-soft);
  color: var(--muted);
}

.profile-board {
  display: grid;
  grid-template-columns: 246px minmax(190px, 1fr) minmax(150px, 0.65fr);
  gap: 12px;
  align-items: stretch;
}

.radar-card,
.profile-fact,
.health-pill {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.radar-card {
  display: grid;
  place-items: center;
  min-height: 232px;
  padding: 8px;
}

.profile-radar {
  width: 100%;
  max-width: 224px;
  height: auto;
}

.radar-grid-shape {
  fill: none;
  stroke: #dbe4df;
  stroke-width: 1;
}

.radar-axis {
  stroke: #e8eeeb;
  stroke-width: 1;
}

.profile-radar text {
  fill: var(--muted);
  font-size: 12px;
}

.radar-score-shape {
  fill: rgba(15, 118, 110, 0.13);
  stroke: var(--accent);
  stroke-width: 2;
}

.radar-center {
  fill: var(--accent);
}

.profile-facts,
.health-stack {
  display: grid;
  gap: 10px;
}

.profile-fact {
  padding: 12px;
}

.profile-fact span,
.profile-fact small,
.health-pill span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.profile-fact strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 16px;
}

.health-pill {
  padding: 12px;
  background: #fbfcfb;
}

.health-pill strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
}

.profile-summary {
  margin: 12px 0;
  line-height: 1.7;
  color: var(--text);
}

.domain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.profile-domain-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.domain-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.domain-item strong {
  display: block;
  margin-bottom: 4px;
}

.domain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.domain-row span {
  font-weight: 850;
  color: var(--text);
}

.score-track {
  height: 7px;
  overflow: hidden;
  background: var(--surface-strong);
  border-radius: 999px;
  margin: 8px 0;
}

.score-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.profile-tag-block {
  margin-top: 10px;
}

.profile-tag-block strong {
  display: block;
  margin-bottom: 4px;
}

.risk-low {
  background: var(--success-soft);
  color: var(--accent-deep);
}

.risk-attention {
  background: var(--amber-soft);
  color: var(--amber);
}

.risk-urgent {
  background: var(--danger-soft);
  color: var(--danger);
}

.doc-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.doc-title {
  font-weight: 850;
  margin-bottom: 7px;
}

.pipeline {
  display: grid;
  gap: 9px;
}

.pipeline div {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 800;
}

.ai-result {
  display: grid;
  gap: 12px;
  color: var(--text);
}

.ai-result-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ai-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.ai-block strong {
  display: block;
  margin-bottom: 6px;
}

.ai-task {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

.ai-task:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.ai-task b,
.ai-task span,
.ai-task small {
  display: block;
}

.ai-task span,
.ai-task small {
  color: var(--muted);
  font-size: 12px;
}

.ai-result pre {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

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

#xiaoqi textarea {
  font-family: "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
}

.avatar-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.avatar-preview strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.avatar-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.avatar-preview img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.publish-board {
  display: grid;
  gap: 10px;
}

.publish-step {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.publish-step strong,
.compact-title {
  display: block;
  margin: 0 0 6px;
  color: var(--text);
}

.publish-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.api-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

canvas {
  width: 100%;
  height: 260px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .nav {
    grid-template-columns: repeat(8, max-content);
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    text-align: center;
    white-space: nowrap;
  }

  .main {
    padding: 18px 16px 34px;
  }

  .metric-grid,
  .dashboard-grid,
  .two-column,
  .patient-workspace,
  .profile-board,
  .cloud-grid,
  .api-list {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .metric-grid,
  .profile-domain-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .risk-orb {
    min-width: 0;
    min-height: auto;
    grid-template-columns: auto auto auto;
    align-items: center;
    justify-content: space-between;
  }
}
