:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --border: #d8dee7;
  --text: #1f2933;
  --muted: #64748b;
  --primary: #1264a3;
  --primary-dark: #0b4d7c;
  --danger: #a83f39;
  --success: #247b4d;
  --warning: #b45309;
  --code-bg: #101820;
  --code-text: #e5edf5;
  --line-bg: #17212b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  background: #1d2733;
  color: #fff;
  border-bottom: 1px solid #111827;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.sample-select {
  height: 36px;
  min-width: 260px;
  max-width: 420px;
  border: 1px solid #b9c2cf;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: #16202a;
  font-size: 14px;
}

.sample-select:disabled {
  opacity: 0.55;
}

.button {
  height: 36px;
  padding: 0 12px;
  border: 1px solid #b9c2cf;
  border-radius: 6px;
  background: #fff;
  color: #16202a;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #f8fafc;
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.button.success {
  border-color: var(--success);
  color: var(--success);
}

.layout {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 330px minmax(420px, 1fr) 360px;
  overflow: hidden;
}

.sidebar,
.inspector {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

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

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.filters {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.search,
.select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

.rule-list {
  height: calc(100vh - 72px - 153px);
  overflow-y: auto;
  padding: 8px;
}

.rule-group {
  margin: 12px 6px 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.rule-type-group {
  margin-top: 16px;
  color: var(--primary-dark);
}

.rule-segment-group {
  margin-top: 8px;
  padding-left: 8px;
  border-left: 3px solid #cbd5e1;
  color: #475569;
}

.rule-item {
  width: 100%;
  padding: 10px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.rule-item:hover {
  background: #eef4fa;
}

.rule-item.active {
  border-color: #8bb6d9;
  background: #e6f1fa;
}

.rule-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.rule-desc {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.tag,
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  font-size: 12px;
  white-space: nowrap;
}

.tag.segment,
.badge.segment {
  border-color: #6aa1cc;
  color: #0b4d7c;
  background: #e6f1fa;
}

.tag.sub,
.badge.sub {
  border-color: #d0a35e;
  color: #8a560f;
  background: #fff6e5;
}

.tag.param,
.badge.param {
  border-color: #8cc3a4;
  color: #1f6b42;
  background: #ebf7f0;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.editor-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.editor-header h1 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.25;
}

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

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.editor-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: 62px 1fr;
  background: var(--code-bg);
}

.line-numbers,
.code-editor {
  margin: 0;
  border: 0;
  outline: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 22px;
}

.line-numbers {
  padding: 14px 10px;
  overflow: hidden;
  color: #91a4b7;
  background: var(--line-bg);
  text-align: right;
  user-select: none;
}

.code-editor {
  width: 100%;
  height: 100%;
  resize: none;
  padding: 14px 16px;
  color: var(--code-text);
  background: var(--code-bg);
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.code-editor:disabled {
  color: #93a4b5;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  margin-bottom: 14px;
  overflow: hidden;
}

.panel h2 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  font-size: 14px;
}

.panel-body {
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
}

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

.hidden {
  display: none !important;
}

.warning-list,
.report-list {
  margin: 0;
  padding-left: 18px;
}

.report-filter-note {
  margin-top: 4px;
  color: var(--muted);
}

.report-hierarchy {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.report-type-row {
  color: var(--primary-dark);
  font-weight: 700;
}

.report-segment-row {
  margin-top: 2px;
  padding-left: 8px;
  border-left: 3px solid #cbd5e1;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.report-rule-list {
  display: grid;
  gap: 6px;
}

.report-rule-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #f8fafc;
}

.report-rule-row strong,
.report-rule-row span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.report-rule-row span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.case-detail-block {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.detail-title {
  margin-bottom: 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.case-detail-list {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.case-detail-item {
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #f8fafc;
}

.case-detail-item span {
  color: var(--muted);
  font-size: 12px;
}

.case-detail-item code {
  color: #1f2933;
  font-family: Consolas, monospace;
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.warning-list li {
  margin: 0 0 6px;
  color: var(--warning);
}

.dim-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.dim-token {
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 2px 6px;
  background: #f8fafc;
  font-family: Consolas, monospace;
  font-size: 12px;
}


.logic-body {
  display: grid;
  gap: 12px;
}

.logic-overview p {
  margin: 0 0 6px;
}

.logic-section {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.logic-title {
  margin-bottom: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.logic-list {
  margin: 0;
  padding-left: 18px;
}

.logic-list li {
  margin-bottom: 7px;
  overflow-wrap: anywhere;
}

.logic-list code {
  display: inline;
  padding: 1px 4px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #1f2933;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.logic-list span,
.logic-list em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.logic-note {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.diff-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.diff-col {
  min-width: 0;
}

.diff-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.diff-line {
  margin: 0 0 4px;
  padding: 5px 6px;
  border-radius: 4px;
  background: #f8fafc;
  color: #334155;
  font-family: Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-line.changed-old {
  background: #fff1f0;
}

.diff-line.changed-new {
  background: #edf7ed;
}

.empty {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 280px minmax(360px, 1fr);
  }

  .inspector {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    height: auto;
    min-height: calc(100vh - 132px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 320px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .rule-list {
    height: 168px;
  }

  .workspace {
    min-height: 620px;
  }
}
