:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --page: #f4f7fb;
  --brand: #276749;
  --brand-strong: #1f513a;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #027a48;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  margin-bottom: 14px;
}

h3 {
  font-size: 14px;
  margin: 18px 0 10px;
}

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

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

nav a,
.text-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

nav a {
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff;
}

.layout,
.admin-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
}

.admin-layout {
  display: grid;
  gap: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

section + section {
  margin-top: 20px;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 120px;
  padding: 10px;
  resize: vertical;
  line-height: 1.55;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  min-height: 38px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--brand-strong);
}

.actions,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions {
  margin-top: 20px;
}

.effect-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecfdf3;
  color: var(--ok);
  border: 1px solid #abefc6;
  font-weight: 600;
}

.chip.secondary {
  background: #fff7ed;
  color: var(--accent);
  border-color: #fed7aa;
}

.empty {
  color: var(--muted);
  line-height: 1.7;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.metrics div,
.kv-list div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

dt,
.kv-list b {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 4px 0 0;
  font-weight: 700;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #f8fafc;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #f6fef9;
}

tr.generation-row-selected {
  border-left: 3px solid var(--brand);
  background: #ecfdf3;
}

tr.generation-row-selected:hover {
  background: #dcfae6;
}

tr.generation-row-selected td:first-child {
  font-weight: 800;
  color: var(--brand-strong);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.pagination div {
  display: flex;
  gap: 8px;
}

.formula-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.detail-section {
  padding: 0;
  overflow: hidden;
}

.detail-section > summary {
  display: grid;
  grid-template-columns: minmax(140px, auto) minmax(0, 1fr) 24px;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.detail-section > summary::-webkit-details-marker {
  display: none;
}

.detail-section > summary::after {
  content: "+";
  justify-self: end;
  grid-column: 3;
  color: var(--brand-strong);
  font-size: 18px;
  font-weight: 800;
}

.detail-section[open] > summary::after {
  content: "-";
}

.detail-section > summary span {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.detail-section > summary small {
  min-width: 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.detail-section > :not(summary) {
  margin: 0 18px 18px;
}

.formula-editor-toolbar select {
  min-width: 260px;
}

.revision-status {
  display: block;
  margin: 8px 0;
}

.ratio-input {
  width: 96px;
  min-height: 32px;
}

.removed-row {
  background: #fff1f3;
  color: #7a271a;
}

.removed-row td {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.removed-row td:last-child {
  text-decoration: none;
}

.change-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.formula-diff-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.formula-diff-panel.empty {
  color: var(--muted);
}

.formula-diff-panel h3 {
  margin-bottom: 10px;
}

.diff-grid {
  display: grid;
  gap: 8px;
}

.diff-row {
  display: grid;
  grid-template-columns: 72px minmax(180px, 1fr) 110px 110px 90px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.diff-row b {
  color: var(--brand-strong);
}

.diff-row.added b {
  color: var(--ok);
}

.diff-row.removed b {
  color: var(--danger);
}

.diff-row.changed b {
  color: var(--accent);
}

.row-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.request-variant-panel {
  display: grid;
  gap: 12px;
}

.variant-snapshot-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

.variant-snapshot-summary.empty {
  display: block;
  color: var(--muted);
}

.variant-snapshot-summary div,
.variant-readonly-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.variant-snapshot-summary span,
.variant-readonly-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.variant-snapshot-summary strong,
.variant-readonly-grid strong {
  display: block;
  margin-top: 4px;
  line-height: 1.45;
  word-break: break-word;
}

.request-variant-modal {
  width: min(1180px, 100%);
}

.request-variant-body {
  display: grid;
  gap: 14px;
}

.variant-readonly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.variant-editor-form {
  display: grid;
  gap: 14px;
}

.variant-editor-form section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.variant-editor-form h3 {
  margin: 0;
}

.variant-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

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

.variant-editor-grid .span-all {
  grid-column: 1 / -1;
}

.variant-field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.variant-change-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #abefc6;
  border-radius: 6px;
  background: #ecfdf3;
  color: var(--ok);
  line-height: 1.45;
}

.variant-change-preview.empty {
  border-color: var(--line);
  background: #f8fafc;
  color: var(--muted);
}

.variant-change-preview span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #abefc6;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.variant-modal-actions {
  position: sticky;
  bottom: -18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 34%);
}

.variant-chain {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.variant-version-timeline {
  scroll-snap-type: x proximity;
}

.variant-chain.empty {
  color: var(--muted);
}

.variant-chain button {
  display: grid;
  gap: 4px;
  flex: 0 0 min(360px, 82vw);
  min-height: 88px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  scroll-snap-align: start;
}

.variant-chain button.active {
  border-color: var(--brand);
  background: #f5fbf8;
}

.variant-chain small {
  color: var(--muted);
  line-height: 1.45;
}

.variant-diff-section {
  display: grid;
  gap: 10px;
}

.variant-diff-section ul {
  margin-left: 18px;
}

@media (max-width: 900px) {
  .variant-editor-grid,
  .variant-snapshot-summary,
  .variant-readonly-grid {
    grid-template-columns: 1fr;
  }
}

.material-picker-modal {
  width: min(1120px, 100%);
}

.material-picker-body {
  display: grid;
  gap: 14px;
}

.material-picker-searchbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, auto);
  gap: 12px;
  align-items: end;
}

.material-picker-searchbar label {
  display: grid;
  gap: 6px;
}

.material-picker-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.material-picker-filters button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.material-picker-filters button.active {
  border-color: #98d8b1;
  background: #ecfdf3;
  color: var(--brand-strong);
}

.material-picker-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 360px);
  gap: 14px;
  min-height: 420px;
}

.material-picker-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 56vh;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.material-picker-option {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 92px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  overflow: visible;
  white-space: normal;
}

.material-picker-option:hover,
.material-picker-option.selected {
  border-color: #98d8b1;
  background: #ecfdf3;
}

.material-picker-option span {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.material-picker-option small {
  color: var(--muted);
  line-height: 1.45;
}

.material-picker-preview {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.material-picker-preview.empty {
  color: var(--muted);
  background: #fbfcfe;
}

.material-picker-preview p {
  margin: 0;
  line-height: 1.55;
}

.material-picker-confirm {
  display: grid;
  grid-template-columns: 180px minmax(280px, 1fr) auto minmax(120px, auto);
  gap: 10px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.material-picker-confirm label {
  display: grid;
  gap: 6px;
}

.pagination button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.pagination button[disabled]:hover {
  background: var(--brand);
}

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

.kv-list.empty {
  display: block;
}

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

.event-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  line-height: 1.6;
}

.process-check {
  display: grid;
  gap: 14px;
}

.process-check-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.process-check-summary.empty {
  display: block;
}

.process-check-summary div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.process-check-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.process-check-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.3;
}

.process-check-summary .pass {
  border-color: #abefc6;
  background: #ecfdf3;
  color: var(--ok);
}

.process-check-summary .warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--accent);
}

.process-check-summary .fail {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.process-check-groups {
  display: grid;
  gap: 10px;
}

.process-check-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.process-check-details summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  cursor: pointer;
  background: #f8fafc;
  font-weight: 700;
}

.process-check-details summary b {
  color: var(--muted);
  font-size: 12px;
}

.process-check-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.process-check-item {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) auto minmax(260px, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  line-height: 1.55;
}

.process-check-item b,
.process-check-item p {
  min-width: 0;
  word-break: break-word;
}

.process-check-item p {
  color: var(--muted);
}

.process-check-item:not(.pass):not(.warn):not(.fail) {
  grid-template-columns: minmax(180px, 0.35fr) minmax(260px, 1fr);
}

.process-check-item:not(.pass):not(.warn):not(.fail) p {
  grid-column: 2;
}

.process-check-item.warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.process-check-item.fail {
  border-color: #fecaca;
  background: #fef2f2;
}

.process-check-item.empty {
  display: block;
  color: var(--muted);
}

.full-request {
  display: grid;
  gap: 18px;
}

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

.request-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #ffffff;
}

.request-card h3 {
  margin: 0 0 12px;
}

.request-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.request-fields div {
  min-height: 54px;
  border: 1px solid #e6ebf2;
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

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

.request-fields strong {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.request-fields .highlight {
  border-color: #abefc6;
  background: #ecfdf3;
}

.request-fields .warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.effect-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.effect-pill-list span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: var(--ok);
  font-weight: 700;
}

.effect-pill-list small {
  color: var(--muted);
  font-weight: 600;
}

.muted-line {
  color: var(--muted);
  margin-top: 12px;
}

.request-raw-details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.request-raw-details article {
  margin-top: 16px;
}

.request-raw-details article + article {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.request-table th {
  width: 220px;
  background: #f8fafc;
}

.request-table th small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}

.request-table td {
  line-height: 1.7;
}

.nested-kv {
  display: grid;
  gap: 6px;
}

.nested-kv div {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 8px;
}

.nested-kv b {
  color: var(--muted);
  font-weight: 600;
}

.nested-kv ul,
.request-table ul {
  margin: 0;
  padding-left: 18px;
}

.product-rule-toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 290px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.rules-page {
  max-width: 1680px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.rules-page > .surface:first-child {
  grid-column: 1;
  padding: 14px 16px;
}

.rules-page > .surface:first-child .section-head h2 {
  margin-bottom: 0;
}

.rules-page > .surface:first-child .module-note {
  margin: 8px 0 12px;
  padding: 9px 12px;
}

.rules-page > .rule-ops-overview,
.rules-page > [data-rule-panel] {
  grid-column: 1;
}

.rules-section-menu {
  position: sticky;
  top: 12px;
  z-index: 8;
  display: grid;
  grid-column: 1;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rules-section-menu button {
  min-height: 52px;
  padding: 10px 12px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.rules-section-menu button:hover {
  background: #f6fef9;
  border-color: #98d8b1;
}

.rules-section-menu button.active {
  color: var(--brand-strong);
  background: #ecfdf3;
  border-color: #98d8b1;
  box-shadow: inset 0 3px 0 var(--brand);
}

.rules-section-menu strong,
.rules-section-menu span {
  display: block;
}

.rules-section-menu span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 500;
}

[data-rule-panel][hidden] {
  display: none !important;
}

.rule-ops-overview {
  display: grid;
  gap: 14px;
}

.rule-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.rule-health-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.rule-health-grid article.health-pass {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.rule-health-grid article.health-warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

.rule-health-grid article.health-fail {
  border-color: #fecaca;
  background: #fef2f2;
}

.rule-health-grid span,
.rule-ops-title p,
.rule-scenario-card p,
.rule-layer-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.rule-health-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

.rule-health-grid p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rule-ops-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.rule-ops-grid > section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.rule-ops-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.rule-ops-title h3 {
  margin: 0;
}

.rule-scenario-grid,
.rule-layer-list {
  display: grid;
  gap: 10px;
}

.rule-path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 10px;
  align-items: start;
}

.rule-path-toolbar,
.rule-path-purpose-note {
  grid-column: 1 / -1;
}

.rule-scenario-card,
.rule-path-card,
.rule-layer-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.rule-path-purpose-note {
  border: 1px solid #bfdbfe;
  border-left: 4px solid #175cd3;
  border-radius: 8px;
  padding: 10px 12px;
  background: #eff6ff;
}

.rule-overview-purpose-note {
  grid-column: 1 / -1;
  border: 1px solid #d1fadf;
  border-left: 4px solid #12b76a;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f0fdf4;
}

.rule-path-purpose-note strong,
.rule-overview-purpose-note strong {
  color: #175cd3;
  font-size: 12px;
  line-height: 1.45;
}

.rule-overview-purpose-note strong {
  color: #027a48;
}

.rule-scenario-policy {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #d1fadf;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f0fdf4;
}

.rule-scenario-policy.warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

.rule-scenario-policy p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rule-scenario-policy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.rule-scenario-card > div:first-child,
.rule-scenario-head,
.rule-path-card header,
.rule-layer-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.rule-scenario-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rule-path-card header > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rule-path-card header span,
.rule-scenario-head > span,
.rule-layer-card header span,
.risk-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.rule-status-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.rule-status-pill.pass {
  border-color: #86efac;
  background: #ecfdf3;
  color: #027a48;
}

.rule-status-pill.warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #b54708;
}

.rule-status-pill.fail {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b42318;
}

.rule-status-pill.info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #175cd3;
}

.rule-path-card.pass {
  border-left: 4px solid #12b76a;
}

.rule-path-card.warning {
  border-left: 4px solid #f79009;
  background: #fffdf7;
}

.rule-path-card.fail {
  border-left: 4px solid #f04438;
  background: #fffafa;
}

.rule-path-meta {
  display: grid;
  gap: 4px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
}

.rule-path-meta span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rule-path-meta span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.rule-scenario-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.6fr);
  gap: 8px;
}

.rule-scenario-meta div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: #f8fafc;
}

.rule-scenario-meta span,
.rule-scenario-relation-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.rule-scenario-meta strong {
  display: block;
  margin-top: 4px;
  line-height: 1.55;
}

.rule-scenario-relation-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  padding-top: 2px;
}

.risk-badge.high {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b42318;
}

.risk-badge.medium {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #b54708;
}

.risk-badge.low {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #067647;
}

.rule-checkpoint-box {
  display: grid;
  gap: 5px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 8px 10px;
  background: #eff6ff;
}

.rule-checkpoint-box > strong {
  color: #175cd3;
  font-size: 12px;
  line-height: 1.35;
}

.rule-checkpoint-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  color: #344054;
  font-size: 12px;
  line-height: 1.45;
}

.rule-test-flow {
  display: grid;
  gap: 8px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 10px;
  background: #f6fef9;
}

.rule-test-flow-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.rule-test-flow-head strong {
  color: #027a48;
  font-size: 13px;
}

.rule-test-flow-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rule-test-flow ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.rule-test-flow li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  color: #344054;
  font-size: 12px;
  line-height: 1.45;
}

.rule-test-flow li b {
  display: block;
  color: var(--ink);
  font-size: 12px;
}

.rule-test-flow li p {
  margin-top: 2px;
  color: var(--muted);
}

.rule-test-flow li small {
  display: block;
  margin-top: 2px;
  color: #027a48;
  font-size: 12px;
  line-height: 1.35;
}

.rule-test-action {
  text-decoration: none;
  white-space: nowrap;
}

.rule-module-section-list {
  display: grid;
  gap: 8px;
}

.rule-module-section {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 9px;
  background: #f8fafc;
}

.rule-module-section.primary {
  border-left-color: #12b76a;
  background: #f6fef9;
}

.rule-module-section.related {
  border-left-color: #2e90fa;
}

.rule-module-section.validation {
  border-left-color: #f79009;
  background: #fffdf7;
}

.rule-module-section-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.rule-module-section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rule-module-section p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rule-chip-row.scope-row {
  align-items: stretch;
}

.rule-module-scope-item {
  display: grid;
  gap: 5px;
  min-width: 190px;
  max-width: 260px;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  padding: 7px;
  background: #fff;
}

.rule-module-scope-item .rule-module-chip {
  width: 100%;
}

.rule-scope-summary {
  display: grid;
  gap: 2px;
}

.rule-scope-summary span {
  color: #175cd3;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.rule-scope-summary small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rule-match-explain {
  display: grid;
  gap: 4px;
  border-top: 1px dashed #dbeafe;
  padding-top: 6px;
}

.rule-match-explain > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.rule-match-row {
  display: grid;
  gap: 2px;
}

.rule-match-row strong {
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.rule-match-row small,
.rule-match-explain > small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.rule-governance-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 10px;
  align-items: start;
}

.rule-path-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rule-governance-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.rule-config-entry {
  justify-self: start;
  border-color: #86efac;
  background: #ecfdf3;
  color: #027a48;
  font-weight: 700;
}

.rule-config-entry.secondary {
  background: #fff;
  border: 1px solid #98d8b1;
}

.rule-path-card .rule-config-entry {
  justify-self: end;
}

.rule-detail-toolbar,
.rule-card-actions,
.rule-layer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.rule-card-actions {
  justify-content: flex-start;
}

.rule-layer-actions {
  margin-top: 8px;
}

.rule-governance-item span {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.rule-governance-item strong {
  display: block;
  line-height: 1.4;
}

.rule-governance-item p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.rule-governance-item.pass {
  border-left-color: #12b76a;
}

.rule-governance-item.warning {
  border-left-color: #f79009;
  background: #fffdf7;
}

.rule-governance-item.info {
  border-left-color: #2e90fa;
}

.rule-governance-item.fail {
  border-left-color: #f04438;
  background: #fffafa;
}

.rule-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rule-module-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: 0 10px;
  background: #eff6ff;
  color: #175cd3;
  font-size: 12px;
  font-weight: 700;
}

.rule-module-chip:hover {
  border-color: #86efac;
  background: #ecfdf3;
  color: #027a48;
}

.rule-module-chip b {
  color: var(--muted);
}

.rule-workbench {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: 680px;
}

.rule-workbench-sidebar,
.rule-list-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rule-workbench-sidebar,
.rule-list-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.rule-workbench-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.rule-workbench-head h2 {
  margin-bottom: 4px;
}

.rule-workbench-head p {
  color: var(--muted);
  line-height: 1.5;
}

.compact-search {
  gap: 6px;
}

.rule-module-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.rule-module-item {
  min-height: auto;
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  text-align: left;
}

.rule-module-item:hover,
.rule-module-item.active {
  border-color: #86efac;
  background: #ecfdf3;
  color: var(--ink);
}

.rule-module-item span,
.rule-module-item small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rule-module-item strong {
  line-height: 1.35;
}

.rule-count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #175cd3;
  border: 1px solid #bfdbfe;
  font-weight: 700;
  white-space: nowrap;
}

.rule-list-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rule-list-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.rule-list-table {
  min-width: 1080px;
}

.rule-list-table td:nth-child(1) {
  min-width: 220px;
}

.rule-list-table td:nth-child(2) {
  min-width: 260px;
}

.rule-list-table td:nth-child(3) {
  min-width: 260px;
}

.rule-list-table th:nth-child(5),
.rule-list-table td:nth-child(5) {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 128px;
  min-width: 128px;
  background: #fff;
  box-shadow: -8px 0 14px rgba(15, 23, 42, 0.08);
}

.rule-list-table th:nth-child(5) {
  z-index: 4;
  background: #f8fafc;
}

.rule-list-condition {
  display: block;
  color: var(--muted);
  line-height: 1.55;
  max-width: 360px;
}

.rule-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rule-trigger-note {
  display: grid;
  gap: 5px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #175cd3;
  border-radius: 6px;
  padding: 10px 12px;
  background: #eff6ff;
}

.rule-trigger-note span {
  color: #175cd3;
  font-size: 12px;
  font-weight: 700;
}

.rule-trigger-note strong {
  line-height: 1.55;
  color: var(--ink);
}

.scenario-editor-intro,
.scenario-editor-section-title,
.scenario-config-builder {
  display: grid;
  gap: 6px;
}

.scenario-editor-intro {
  border: 1px solid #d1fadf;
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  padding: 10px 12px;
  background: #f0fdf4;
}

.scenario-editor-section-title {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.scenario-editor-section-title strong,
.scenario-editor-intro strong {
  color: var(--ink);
}

.scenario-editor-section-title p,
.scenario-editor-intro p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.scenario-config-builder {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.scenario-section-picker {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.scenario-section-picker.primary {
  border-left-color: #12b76a;
}

.scenario-section-picker.related {
  border-left-color: #2e90fa;
}

.scenario-section-picker.validation {
  border-left-color: #f79009;
}

.scenario-section-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.scenario-section-picker-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.scenario-section-picker-head span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eff6ff;
  color: #175cd3;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.scenario-module-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px;
}

.scenario-module-option {
  min-height: 56px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  border: 1px solid #e6ebf2;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
}

.scenario-module-option input {
  width: 16px;
  height: 16px;
}

.scenario-module-option span,
.scenario-module-option small {
  min-width: 0;
  line-height: 1.35;
}

.scenario-module-option small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.scenario-module-scope-select {
  grid-column: 2;
  width: 100%;
  min-height: 32px;
  border-radius: 6px;
  font-size: 12px;
}

.scenario-module-scope-select:disabled {
  color: var(--muted);
  background: #f2f4f7;
  cursor: not-allowed;
}

.scenario-manual-rule-select {
  grid-column: 2;
  width: 100%;
  min-height: 74px;
  border-radius: 6px;
  font-size: 12px;
}

.scenario-manual-rule-help {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.required-role-safety-guide,
.dependency-conflict-guide {
  display: grid;
  gap: 8px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #175cd3;
  border-radius: 6px;
  padding: 12px;
  background: #eff6ff;
}

.required-role-safety-guide div,
.dependency-conflict-guide div {
  display: grid;
  gap: 4px;
}

.required-role-safety-guide span,
.dependency-conflict-guide span,
.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.required-role-safety-guide strong,
.dependency-conflict-guide strong {
  color: var(--ink);
  line-height: 1.55;
}

.dependency-flow {
  grid-template-columns: minmax(76px, auto) minmax(0, 1fr) auto minmax(0, 1fr) minmax(76px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  padding: 10px;
  border-radius: 6px;
  background: #ffffff;
}

.dependency-flow em {
  color: #175cd3;
  font-style: normal;
  font-weight: 700;
  text-align: center;
}

.dependency-flow small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .dependency-flow {
    grid-template-columns: 1fr;
  }

  .dependency-flow em {
    text-align: left;
  }
}

.rule-coverage-note {
  display: grid;
  gap: 6px;
  border: 1px solid #abefc6;
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  padding: 10px 12px;
  background: #ecfdf3;
}

.rule-coverage-note.warning {
  border-color: #fed7aa;
  border-left-color: var(--accent);
  background: #fff7ed;
}

.rule-coverage-note span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rule-coverage-note strong,
.rule-coverage-note p {
  line-height: 1.55;
}

.rule-coverage-note p {
  color: var(--muted);
}

.rule-coverage-note .small-btn {
  width: max-content;
  margin-top: 4px;
}

.rule-status {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #ecfdf3;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.rule-status.warning {
  background: #fff7ed;
  color: #b45309;
}

.rule-summary,
.rule-binding,
.rule-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.rule-summary div,
.rule-binding div,
.rule-card-grid article {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.rule-summary span,
.rule-binding span,
.rule-table small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.rule-summary strong,
.rule-binding strong,
.rule-card-grid b {
  display: block;
  margin-top: 4px;
  line-height: 1.45;
  word-break: break-word;
}

.rule-card-grid p {
  color: var(--muted);
  margin-top: 6px;
}

.module-note {
  border: 1px solid #d1fadf;
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  background: #f0fdf4;
  color: #344054;
  line-height: 1.75;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.rule-editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.rule-template,
.condition-helper {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
  line-height: 1.6;
}

.rule-template b {
  display: block;
  margin-bottom: 4px;
}

.rule-editor-form {
  display: grid;
  gap: 14px;
}

.rule-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.option-help {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.option-picker-panel,
.ordered-select-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.material-picker-panel {
  background: #f8fafc;
}

.material-picker-search {
  display: grid;
  gap: 6px;
}

.material-picker-search input {
  background: #fff;
}

.material-picker-options {
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.option-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.option-picker-head strong {
  color: var(--ink);
}

.option-picker-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.option-picker-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 12px;
}

.option-picker-options,
.selected-option-list,
.ordered-select-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 132px;
}

.option-picker-button {
  min-height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  justify-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.option-picker-button:hover,
.option-picker-button.selected {
  border-color: #86efac;
  background: #ecfdf3;
  color: var(--ink);
}

.option-picker-button b,
.option-picker-button small {
  display: block;
  line-height: 1.45;
}

.option-picker-button small {
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}

.option-picker-button em {
  color: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.selected-option-list {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.selected-option-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.ordered-select-item {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.selected-option-item b,
.selected-option-item small {
  display: block;
  line-height: 1.45;
}

.selected-option-item small {
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}

.selected-option-item button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.role-requirement-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.role-requirement-rows {
  display: grid;
  gap: 10px;
}

.role-requirement-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(110px, 140px) minmax(260px, 1.4fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.role-requirement-row label {
  min-width: 0;
}

.role-requirement-reason input {
  min-width: 0;
}

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

.role-requirement-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}

.structured-list-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

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

.structured-list-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(110px, 140px) minmax(120px, 150px) minmax(240px, 1.2fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.structured-list-row label {
  min-width: 0;
}

.structured-list-reason input {
  min-width: 0;
}

.structured-list-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}

.span-all {
  grid-column: 1 / -1;
}

.condition-helper {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.condition-helper strong {
  display: block;
  margin-bottom: 8px;
}

.condition-builder {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
}

.condition-builder-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.condition-builder-head span {
  color: var(--muted);
  font-size: 12px;
}

.condition-builder-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.condition-builder select[multiple] {
  height: auto;
  min-height: 112px;
  padding: 8px;
}

.condition-builder-actions {
  display: flex;
  gap: 8px;
}

.condition-value-panel {
  display: grid;
  gap: 6px;
}

.condition-value-panel > span {
  color: var(--muted);
  font-size: 13px;
}

.condition-checkbox-grid {
  max-height: 190px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.condition-checkbox-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  min-height: 42px;
  border: 1px solid #e6ebf2;
  border-radius: 6px;
  padding: 7px;
  background: #f8fafc;
  color: var(--ink);
}

.condition-checkbox-item input {
  width: 16px;
  height: 16px;
}

.condition-checkbox-item span,
.condition-checkbox-item small {
  min-width: 0;
  line-height: 1.35;
}

.condition-checkbox-item small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.condition-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.condition-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #abefc6;
  border-radius: 999px;
  background: #ecfdf3;
  color: var(--ok);
  font-weight: 700;
}

.condition-chip button {
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #d92d20;
  font-size: 12px;
}

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

.helper-chip-list span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.rule-edit-btn {
  min-height: 30px;
  padding: 0 10px;
  margin-top: 8px;
}

body.modal-open {
  overflow: hidden;
}

.rule-editor-launcher .rule-editor-grid,
.rule-editor-launcher .rule-editor-form {
  display: none;
}

.rule-editor-launcher {
  display: none;
}

.rule-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.rule-modal-backdrop.open {
  display: flex;
}

.rule-modal-backdrop[data-similarity-member-manager] {
  z-index: 1100;
}

.rule-modal {
  width: min(1120px, 100%);
  max-height: min(88vh, 860px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.rule-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.rule-modal-head h2 {
  margin-bottom: 4px;
}

.rule-modal-head p {
  color: var(--muted);
  line-height: 1.5;
}

.rule-modal-body {
  overflow: auto;
  padding: 18px;
}

.similarity-member-modal {
  width: min(980px, 100%);
}

.operator-path-modal {
  width: min(1180px, 100%);
}

.operator-path-form {
  display: grid;
  gap: 16px;
}

.operator-path-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.operator-path-section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.operator-path-section-head h3 {
  margin: 0 0 4px;
}

.operator-path-section-head p,
.operator-product-panel p,
.operator-module-option small,
.operator-path-basic-grid small {
  color: var(--muted);
  line-height: 1.5;
}

.operator-path-basic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.operator-path-basic-grid label,
.operator-section-editor-head label,
.operator-product-panel {
  display: grid;
  gap: 6px;
}

.operator-path-active {
  align-self: end;
  padding: 8px 0;
}

.operator-product-panel {
  padding-top: 4px;
}

.operator-choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.operator-choice,
.operator-module-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-height: 36px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.operator-choice input,
.operator-module-option input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.operator-choice:has(input:checked),
.operator-module-option:has(input:checked) {
  border-color: #98d8b1;
  background: #ecfdf3;
}

.operator-section-list {
  display: grid;
  gap: 12px;
}

.operator-section-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #fff;
}

.operator-section-editor-head {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 12px;
}

.operator-module-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 8px;
}

.operator-module-option span {
  display: grid;
  gap: 2px;
}

.operator-checkpoint-list {
  display: grid;
  gap: 8px;
}

.operator-checkpoint-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.operator-checkpoint-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 6px;
  background: #eef2f6;
  color: var(--muted);
  font-weight: 700;
}

.operator-path-actions {
  position: sticky;
  bottom: -18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 34%);
}

.similarity-member-body {
  display: grid;
  gap: 14px;
}

.similarity-member-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 12px;
  align-items: stretch;
}

.similarity-member-list {
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.similarity-member-table th:first-child,
.similarity-member-table td:first-child {
  width: 110px;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-line input {
  width: 16px;
  height: 16px;
}

.rule-modal-body .rule-editor-grid,
.rule-modal-body .rule-editor-form {
  display: grid;
}

.rule-readable {
  border: 1px solid #d1fadf;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f0fdf4;
  line-height: 1.65;
}

.rule-readable.warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

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

.rule-readable strong {
  display: block;
  color: var(--ink);
  font-weight: 700;
  word-break: break-word;
}

.raw-json-details {
  margin-top: 8px;
}

.raw-json-details summary {
  cursor: pointer;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.raw-json-details .rule-condition {
  margin-top: 8px;
}

.condition-preview-panel {
  display: grid;
  gap: 8px;
}

.rule-table td {
  line-height: 1.55;
}

.rule-condition {
  max-width: 360px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
}

.material-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(150px, 200px) minmax(240px, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.material-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.material-stats div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.material-stats span,
.material-table small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.material-stats strong,
.material-table b {
  display: block;
  line-height: 1.45;
  word-break: break-word;
}

.material-table th:first-child,
.material-table td:first-child {
  width: 92px;
}

.material-table th:last-child,
.material-table td:last-child {
  width: 88px;
}

.scope-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 26px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.scope-badge.on {
  color: var(--ok);
  background: #ecfdf3;
  border-color: #abefc6;
}

.scope-badge.off {
  color: var(--muted);
  background: #f2f4f7;
}

.tag-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ecfdf3;
  color: var(--ok);
  border: 1px solid #abefc6;
  font-size: 12px;
  font-weight: 700;
}

.mini-tag.secondary {
  background: #eff6ff;
  color: #175cd3;
  border-color: #bfdbfe;
}

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

.risk-note {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 6px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 12px;
  font-weight: 700;
}

.small-btn {
  min-height: 32px;
  padding: 0 10px;
}

.secondary-btn {
  background: #fff;
  color: var(--brand);
  border: 1px solid #98d8b1;
}

.secondary-btn:hover {
  background: #ecfdf3;
  color: var(--brand-strong);
}

.danger-btn {
  background: var(--danger);
}

.danger-btn:hover {
  background: #912018;
}

.status-pass {
  color: var(--ok);
}

.status-warn {
  color: var(--accent);
}

.status-fail {
  color: var(--danger);
}

@media (max-width: 980px) {
  .layout,
  .detail-grid,
  .rules-page {
    grid-template-columns: 1fr;
  }

  .rules-page > .surface:first-child,
  .rules-page > .rule-ops-overview,
  .rules-page > [data-rule-panel],
  .rules-section-menu {
    grid-column: 1;
  }

  .request-card-grid {
    grid-template-columns: 1fr;
  }

  .rule-summary,
  .rule-binding,
  .rule-card-grid,
  .rule-health-grid,
  .process-check-summary,
  .material-stats {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

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

  .material-toolbar {
    grid-template-columns: 1fr;
  }

  .product-rule-toolbar {
    grid-template-columns: 1fr;
  }

  .rules-section-menu {
    position: static;
    grid-row: auto;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .rule-ops-grid {
    grid-template-columns: 1fr;
  }

  .rule-workbench {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .rule-workbench-sidebar,
  .rule-list-panel {
    max-height: none;
  }

  .rule-module-list {
    max-height: 280px;
  }

  .rule-editor-grid,
  .process-check-item,
  .condition-helper,
  .condition-builder-grid,
  .ordered-select-panel,
  .role-requirement-row,
  .structured-list-row,
  .condition-checkbox-grid,
  .option-picker-grid,
  .operator-path-basic-grid,
  .operator-section-editor-head,
  .operator-module-options,
  .scenario-module-picker-grid,
  .material-picker-searchbar,
  .material-picker-layout,
  .material-picker-confirm {
    grid-template-columns: 1fr;
  }

  .rule-field-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  nav {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .admin-layout {
    padding: 14px;
  }

  .grid,
  .metrics,
  .kv-list,
  .request-fields,
  .rule-summary,
  .rule-binding,
    .rule-card-grid,
    .rule-field-grid,
    .rule-health-grid,
    .process-check-summary,
    .material-stats,
    .rules-section-menu,
    .operator-module-options,
    .scenario-module-picker-grid,
    .material-picker-layout,
    .material-picker-confirm {
    grid-template-columns: 1fr;
  }

  .rule-modal-backdrop {
    padding: 12px;
  }

  .operator-path-section-head,
  .operator-checkpoint-row {
    grid-template-columns: 1fr;
  }

  .operator-checkpoint-row {
    display: grid;
  }

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

  .pagination div {
    justify-content: flex-end;
  }
}

@media print {
  body.printing-formula {
    background: #fff;
  }

  body.printing-formula .topbar,
  body.printing-formula .admin-layout > :not(#formulaPrintSection),
  body.printing-formula #fullRequestSection,
  body.printing-formula #requestVariantPanel,
  body.printing-formula .no-print,
  body.printing-formula .row-action-buttons,
  body.printing-formula #materialPickerModal {
    display: none !important;
  }

  body.printing-formula .admin-layout {
    max-width: none;
    padding: 0;
    display: block;
  }

  body.printing-formula #formulaPrintSection {
    display: block !important;
    border: 0;
    padding: 0;
    box-shadow: none;
    background: #fff;
  }

  body.printing-formula #formulaPrintSection .section-head {
    align-items: flex-start;
    border-bottom: 1px solid #000;
    padding-bottom: 8px;
    margin-bottom: 10px;
  }

  body.printing-formula #formulaPrintSection h2 {
    font-size: 18px;
    margin: 0;
  }

  body.printing-formula .formula-editor-toolbar {
    display: none;
  }

  body.printing-formula .revision-status,
  body.printing-formula .formula-diff-panel {
    color: #000;
  }

  body.printing-formula table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  body.printing-formula th,
  body.printing-formula td {
    border: 1px solid #000;
    padding: 6px;
    color: #000;
  }

  body.printing-formula #formulaPrintSection th:last-child,
  body.printing-formula #formulaPrintSection td:last-child {
    display: none !important;
  }

  body.printing-formula .table-wrap {
    overflow: visible;
  }

  body.printing-formula .formula-diff-panel {
    border: 1px solid #000;
    background: #fff;
    padding: 6px;
    margin-top: 10px;
    font-size: 10.5px;
    line-height: 1.3;
  }

  body.printing-formula .formula-diff-panel h3 {
    margin-bottom: 6px;
    font-size: 12px;
  }

  body.printing-formula .diff-grid {
    gap: 4px;
  }

  body.printing-formula .diff-row {
    border-color: #000;
    border-radius: 2px;
    grid-template-columns: 42px minmax(0, 1fr) 62px 62px 52px;
    gap: 4px;
    padding: 4px 6px;
    font-size: 10.5px;
    line-height: 1.3;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.printing-formula .diff-row b {
    font-size: 10.5px;
  }

  body.printing-formula input,
  body.printing-formula select,
  body.printing-formula textarea {
    border: 0;
    padding: 0;
    height: auto;
  }
}
