:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687280;
  --line: #dfe5ec;
  --accent: #0f7b6c;
  --accent-2: #2b6fdd;
  --danger: #d9483b;
  --warn: #b7791f;
  --ok: #21845a;
  --shadow: 0 16px 48px rgba(20, 31, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(15, 123, 108, 0.08), transparent 34%),
    linear-gradient(180deg, #fbfcfd, var(--bg));
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #101820;
  color: #f8fbfc;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #21a18d, #3b82f6);
  border-radius: 8px;
  font-weight: 800;
}

.brand span,
.model-card span,
.model-card small,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sidebar .brand span,
.sidebar .model-card span,
.sidebar .model-card small {
  color: #a7b4c2;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost,
.primary {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item {
  padding: 12px 14px;
  color: #c9d3de;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.model-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.mini-button {
  width: 100%;
  height: 34px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fbfc;
  cursor: pointer;
}

.mini-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.health-result {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.health-result small {
  color: #a7b4c2;
}

main {
  padding: 28px;
  overflow: hidden;
}

.topbar,
.section-title,
.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

.top-actions select,
.primary,
.ghost {
  height: 40px;
  padding: 0 14px;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ghost {
  background: #eef3f6;
  color: var(--ink);
}

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

.trust-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: -4px 0 22px;
}

.metric,
.panel,
.chart-card,
.trust-strip article,
.assumption-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric strong,
.chart-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.metric small {
  color: var(--muted);
}

.metric strong span {
  font: inherit;
}

.trust-strip article,
.assumption-box {
  padding: 14px;
}

.trust-strip p,
.assumption-box p,
.chart-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.view {
  display: none;
}

.view.active {
  display: grid;
}

#workspace {
  grid-template-columns: minmax(340px, 0.8fr) minmax(520px, 1.2fr);
  gap: 18px;
}

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

.product-list,
.knowledge-list,
.risk-list,
.result-area,
.analysis-box {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.upload-zone {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed #b8c7d4;
  border-radius: 8px;
  background: #f7fafb;
  cursor: pointer;
}

.upload-zone strong {
  font-size: 13px;
  color: var(--accent);
}

.upload-zone input {
  display: none;
}

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

.image-preview img,
.thumb-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.thumb-img {
  height: 112px;
  aspect-ratio: auto;
}

.analysis-box,
.kb-upload {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
  padding: 14px;
}

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

.analysis-item p {
  margin-top: 6px;
  color: #46515d;
}

.kb-upload {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.kb-upload p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.scope-bar {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 123, 108, 0.18);
  border-radius: 8px;
  background: rgba(15, 123, 108, 0.06);
}

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

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #46515d;
  font-size: 14px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.compact-form textarea {
  min-height: 64px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mini-action {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.danger-action {
  color: var(--danger);
  background: rgba(217, 72, 59, 0.08);
}

.copy-input {
  min-height: 72px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.6;
  resize: vertical;
}

.copy-input:focus {
  outline: 2px solid rgba(15, 123, 108, 0.22);
  outline-offset: 4px;
}

.feedback-save {
  margin-top: 12px;
}

.feedback-save.saved {
  background: rgba(33, 132, 90, 0.1);
  color: var(--ok);
}

.source-link {
  color: var(--accent-2);
  text-decoration: none;
}

.product-card,
.knowledge-item,
.copy-card,
.risk-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.product-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  cursor: pointer;
}

.product-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.knowledge-item.style-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 123, 108, 0.65);
}

.style-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.thumb {
  height: 112px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  position: relative;
  overflow: hidden;
}

.thumb::after {
  content: "";
  position: absolute;
  left: 20%;
  top: 18%;
  width: 42%;
  height: 70%;
  background: rgba(255, 255, 255, 0.58);
  border-radius: 38% 38% 12% 12%;
  transform: skew(-4deg);
}

.tags,
.copy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f6;
  color: #3b4652;
  font-size: 12px;
}

.tag.ok {
  background: rgba(33, 132, 90, 0.1);
  color: var(--ok);
}

.tag.warn {
  background: rgba(183, 121, 31, 0.12);
  color: var(--warn);
}

.tag.danger {
  background: rgba(217, 72, 59, 0.1);
  color: var(--danger);
}

.empty-state,
.loading {
  margin-top: 16px;
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.loading span {
  width: 22px;
  height: 22px;
  border: 3px solid #c9d4df;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none;
}

.copy-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.copy-card p,
.knowledge-item p,
.risk-item p {
  color: #46515d;
  line-height: 1.7;
}

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

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

.field {
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.bar {
  height: 8px;
  background: #e6ebf0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.chart-card {
  padding: 18px;
}

.assumption-box {
  margin-top: 14px;
}

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

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

  .sidebar {
    position: static;
  }

  #workspace,
  .status-grid,
  .chart-grid,
  .trust-strip,
  .eval-metrics {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    width: 100%;
  }

  .top-actions select,
  .top-actions button {
    flex: 1;
  }
}
