:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e0dc;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --green: #15803d;
  --red: #b91c1c;
  --shadow: 0 16px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: #111827;
  color: #f8fafc;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #e6fffb;
  color: #0f766e;
  font-weight: 800;
}

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

.sidebar .eyebrow {
  color: #94a3b8;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  font-size: 18px;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 18px;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
}

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

.scope-card {
  display: grid;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.scope-card label {
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
}

.scope-card select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #1f2937;
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.topbar-actions,
.approval-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.danger-button {
  background: #fff7ed;
  border-color: #fed7aa;
  color: var(--red);
}

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

.metric-card,
.panel,
.flow-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
}

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

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.flow-panel,
.panel {
  padding: 18px;
}

.flow-panel {
  margin-bottom: 16px;
  overflow: hidden;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.candidate {
  background: #eff6ff;
  color: var(--blue);
}

.status-pill.alert {
  background: #fff7ed;
  color: var(--amber);
}

.status-pill.stable {
  background: #ecfdf5;
  color: var(--green);
}

.flow-diagram {
  display: block;
  width: 100%;
  min-height: 170px;
}

.flow-diagram line {
  stroke: #9ca3af;
  stroke-width: 2;
}

.flow-node rect {
  fill: #f9fafb;
  stroke: #cfd8d3;
  stroke-width: 2;
}

.flow-node text {
  text-anchor: middle;
  fill: #344054;
  font-size: 14px;
  font-weight: 700;
}

.flow-node text + text {
  fill: #667085;
  font-size: 12px;
  font-weight: 600;
}

.flow-node.active rect {
  fill: #ecfdf5;
  stroke: #86efac;
}

.flow-node.warning rect {
  fill: #fff7ed;
  stroke: #fdba74;
}

.flow-node.candidate-node rect {
  fill: #eff6ff;
  stroke: #93c5fd;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.title-sample {
  max-width: 360px;
  color: #1f2937;
  font-weight: 700;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.tag.bad {
  background: #fef2f2;
  color: var(--red);
}

.tag.good {
  background: #ecfdf5;
  color: var(--green);
}

.diff-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.diff-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.remove,
.add {
  margin: 8px 0;
  padding: 10px;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.remove {
  background: #fef2f2;
  color: #991b1b;
}

.add {
  background: #ecfdf5;
  color: #166534;
}

.rule-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rule-row,
.gate-row,
.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.rule-row span,
.gate-row span,
.version-row span {
  color: var(--muted);
  font-size: 13px;
}

.score-board {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.score-ring {
  display: grid;
  width: 136px;
  height: 136px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 56%, transparent 57%),
    conic-gradient(var(--accent) 0 86%, #e5e7eb 86% 100%);
}

.score-ring span {
  font-size: 34px;
  font-weight: 900;
  color: var(--accent-strong);
}

.gate-list,
.version-timeline {
  display: grid;
  gap: 10px;
}

.gate-row.pass strong,
.version-row.active strong {
  color: var(--green);
}

.gate-row.warning strong {
  color: var(--amber);
}

.approval-row {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.version-row strong {
  white-space: nowrap;
}

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

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

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

  .scope-card {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .scope-card label {
    display: none;
  }

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

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

  .topbar-actions,
  .approval-row {
    width: 100%;
  }

  .primary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }

  .nav-list,
  .scope-card,
  .metric-grid,
  .score-board {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 24px;
  }

  .metric-card strong {
    font-size: 28px;
  }
}
