:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2a37;
  --muted: #667085;
  --line: #d9e1ec;
  --brand: #146c5b;
  --brand-2: #0f766e;
  --warn: #b45309;
  --risk: #b42318;
  --ok: #087443;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  transition: grid-template-columns .18s ease;
}

aside {
  background: #17202c;
  color: #fff;
  padding: 28px 22px;
  overflow: hidden;
  transition: padding .18s ease, opacity .18s ease;
}

body.sidebar-collapsed .shell {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-collapsed aside {
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  pointer-events: none;
}

aside h1 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

aside p {
  color: rgba(255, 255, 255, .72);
  line-height: 1.7;
  margin: 0 0 24px;
}

.scenario-group {
  margin: 0 0 18px;
}

.scenario-group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 9px;
  padding: 0 2px;
}

.scenario-group-title b {
  font-size: 14px;
  line-height: 1.3;
}

.scenario-group-title span {
  color: rgba(255, 255, 255, .62);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.scenario-group.strategic .scenario-group-title b { color: #93c5fd; }
.scenario-group.green .scenario-group-title b { color: #86efac; }
.scenario-group.yellow .scenario-group-title b { color: #fde68a; }
.scenario-group.red .scenario-group-title b { color: #fca5a5; }

.scenario {
  display: block;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  color: #fff;
  text-align: left;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  text-decoration: none;
}

.scenario.strategic { border-left: 5px solid #3b82f6; }
.scenario.green { border-left: 5px solid #22c55e; }
.scenario.yellow { border-left: 5px solid #f59e0b; }
.scenario.red { border-left: 5px solid #ef4444; }

.scenario.active,
.scenario:hover {
  background: #fff;
  color: #17202c;
}

.scenario strong {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 15px;
  line-height: 1.35;
}

.scenario-code {
  flex: 0 0 auto;
  min-width: 42px;
  border-radius: 6px;
  padding: 2px 6px;
  font-style: normal;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  background: rgba(255, 255, 255, .14);
  color: currentColor;
}

.scenario.active .scenario-code,
.scenario:hover .scenario-code {
  background: #eef8f5;
  color: var(--brand);
}

.scenario span {
  display: block;
  color: currentColor;
  opacity: .72;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
}

.scenario-tags,
.system-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.scenario-tags {
  margin-top: 9px;
}

.scenario-tags span,
.system-tags span {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .1);
  color: currentColor;
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.scenario.active .scenario-tags span,
.scenario:hover .scenario-tags span {
  border-color: #c8e7df;
  background: #eef8f5;
  color: var(--brand);
}

.system-tags {
  margin: -4px 0 18px;
}

.system-tags span {
  border-color: #c8e7df;
  background: #eef8f5;
  color: var(--brand);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.scenario-directory {
  overflow-x: auto;
}

.scenario-directory table {
  min-width: 980px;
}

.scenario-directory tr.active-directory-row td {
  background: #eef8f5;
}

.directory-code,
.directory-title {
  text-decoration: none;
  font-weight: 800;
}

.directory-code {
  display: inline-flex;
  min-width: 44px;
  justify-content: center;
  border-radius: 6px;
  padding: 3px 7px;
  color: #fff;
  font-size: 12px;
}

.directory-code.strategic { background: #2563eb; }
.directory-code.green { background: #16a34a; }
.directory-code.yellow { background: #d97706; }
.directory-code.red { background: #dc2626; }

.directory-title {
  color: var(--ink);
}

.directory-title:hover {
  color: var(--brand);
}

.directory-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 360px;
}

.directory-tags span {
  border: 1px solid #d7e2ee;
  border-radius: 999px;
  background: #f8fafc;
  color: #42526b;
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.directory-actions {
  white-space: nowrap;
}

.directory-actions a,
.directory-actions span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  border: 1px solid #c8e7df;
  border-radius: 6px;
  padding: 4px 8px;
  margin-right: 6px;
  background: #eef8f5;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.directory-actions a:last-child {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.directory-actions span {
  border-color: #d7e2ee;
  background: #f8fafc;
  color: var(--muted);
}

main {
  padding: 32px;
  max-width: 1320px;
  width: 100%;
}

body.sidebar-collapsed main,
body[data-page="scenario"] main {
  max-width: none;
}

body.overview-mode .scenario-detail,
body.detail-mode .overview-only {
  display: none !important;
}

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

h2, h3, h1 { letter-spacing: 0; }

h2 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.2;
}

.summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  max-width: 820px;
}

.primary,
.back,
button.primary,
.copy-btn {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.back {
  background: #263241;
}

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

.copy-btn {
  border: 1px solid #b7ded3;
  background: #eef8f5;
  color: var(--brand);
}

.copy-btn.copied {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.sidebar-toggle {
  position: fixed;
  top: 96px;
  left: 306px;
  z-index: 30;
  width: 34px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-left: 0;
  border-radius: 0 10px 10px 0;
  background: #17202c;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: left .18s ease, background .18s ease;
}

.sidebar-toggle:hover {
  background: #263241;
}

body.sidebar-collapsed .sidebar-toggle {
  left: 0;
}

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

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

.score {
  padding: 18px;
  min-height: 126px;
}

.score label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.score strong {
  display: block;
  color: var(--brand);
  font-size: 28px;
  line-height: 1.15;
}

.score small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.verdict {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 20px;
  padding: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--brand);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 8px;
}

.verdict h3,
.panel h3,
.panel h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.verdict p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.verdict-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

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

.verdict-item b {
  display: block;
  font-size: 15px;
}

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

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

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

code {
  display: inline-block;
  max-width: 100%;
  color: #0f3f36;
  background: #eef8f5;
  border: 1px solid #c8e7df;
  border-radius: 6px;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

details summary {
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
}

details pre {
  max-height: 280px;
  overflow: auto;
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #243044;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  margin-bottom: 12px;
}

button.primary {
  width: 100%;
  margin-bottom: 14px;
}

button.primary:disabled {
  opacity: .55;
  cursor: wait;
}

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

.sample {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.sample:hover {
  border-color: var(--brand);
  background: #eef8f5;
}

.sample strong,
.sample span {
  display: block;
}

.sample span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sample em {
  display: inline-block;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  padding: 1px 6px;
  margin-right: 6px;
  font-style: normal;
  font-size: 11px;
}

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

.node {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

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

.node b {
  display: block;
  line-height: 1.4;
}

.node.active {
  border-color: var(--warn);
  background: #fff7ed;
}

.node.done {
  border-color: #82cbb8;
  background: #eef8f5;
}

.result {
  border-left: 5px solid var(--ok);
  background: #f0fdf4;
  border-radius: 8px;
  padding: 16px;
  line-height: 1.75;
  margin-bottom: 18px;
}

.result.risk {
  border-left-color: var(--risk);
  background: #fff1f1;
}

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

.live-status div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  min-width: 0;
}

.live-status span,
.live-status strong {
  display: block;
}

.live-status span {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.live-status strong {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.live-status.live div {
  border-color: #82cbb8;
  background: #eef8f5;
}

.live-status.loading div {
  border-color: #f3bc73;
  background: #fff7ed;
}

.live-status.fallback div,
.live-status.error div {
  border-color: #f3b0ad;
  background: #fff1f1;
}

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

.action {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  line-height: 1.55;
}

.action b {
  display: inline-block;
  min-width: 48px;
  color: var(--brand);
}

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

  body.sidebar-collapsed .shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed aside {
    display: none;
  }

  aside {
    position: static;
  }

  main {
    padding: 20px;
  }

  .top {
    flex-direction: column;
  }

  .score-row,
  .flow,
  .live-status {
    grid-template-columns: 1fr;
  }

  .primary,
  .back,
  .copy-btn {
    width: 100%;
    text-align: center;
  }

  .sidebar-toggle {
    top: 84px;
    left: auto;
    right: 0;
    width: 34px;
    height: 54px;
  }

  body.sidebar-collapsed .sidebar-toggle {
    left: auto;
    right: 0;
  }

  .top-actions {
    width: 100%;
  }
}
