:root {
  --bg: #f4f7f8;
  --panel: #ffffff;
  --line: #d7dde4;
  --text: #1f2933;
  --muted: #65758a;
  --blue: #1769e0;
  --green: #237a57;
  --amber: #a46213;
  --red: #bd2f2f;
  --cyan: #0f766e;
  --shadow: 0 8px 22px rgba(32, 44, 57, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
.topbar-actions a {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover,
.topbar-actions a:hover {
  border-color: var(--blue);
  color: var(--blue);
}

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

.primary:hover {
  color: #fff;
  filter: brightness(0.96);
}

.secondary {
  background: #fff;
}

.full {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p,
.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(560px, 1fr) 360px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.sidebar,
.main-stage,
.detail-pane {
  min-width: 0;
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.3;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e8f1ff;
  color: #1554b3;
  font-size: 12px;
  white-space: nowrap;
}

label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  resize: vertical;
}

textarea,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.schema-list,
.flow-list,
.validation-result,
.detail-grid {
  display: grid;
  gap: 8px;
}

.schema-item {
  width: 100%;
  text-align: left;
  min-height: 74px;
  border-color: #e8edf3;
  background: #fbfcfe;
}

.schema-item.active,
.schema-item:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(23, 105, 224, 0.08);
}

.schema-item span,
.detail-card span,
.flow-item span,
.field-row span,
.validation-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.schema-item strong,
.detail-card strong,
.flow-item strong,
.field-row strong,
.validation-item strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.schema-item p,
.flow-item p,
.field-row p,
.validation-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.detail-card,
.flow-item,
.validation-item {
  padding: 10px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #fbfcfe;
}

.field-table {
  display: grid;
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 110px 100px 1.3fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #fbfcfe;
}

.required-pill,
.optional-pill,
.recommended-pill {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.required-pill {
  background: #fee2e2;
  color: var(--red);
}

.recommended-pill {
  background: #fff3cd;
  color: var(--amber);
}

.optional-pill {
  background: #e6f4ea;
  color: var(--green);
}

.sample-panel pre,
.report-panel pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #111827;
  color: #e5eef8;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.validation-result {
  margin-top: 10px;
}

.validation-item.ok {
  border-left: 4px solid var(--green);
}

.validation-item.warn {
  border-left: 4px solid var(--amber);
}

.validation-item.error {
  border-left: 4px solid var(--red);
}

.flow-item {
  border-left: 4px solid var(--cyan);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px 1fr;
  }

  .detail-pane {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar,
  .workspace {
    display: block;
  }

  .topbar-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .detail-grid,
  .field-row {
    grid-template-columns: 1fr;
  }
}
