:root {
  --bg: #f4f6f2;
  --ink: #172033;
  --muted: #667282;
  --line: #dce2db;
  --panel: #ffffff;
  --side: #111a22;
  --green: #1f7f62;
  --blue: #3655d8;
  --amber: #b46b18;
  --red: #ba3b36;
  --shadow: 0 18px 50px rgba(23, 32, 51, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23,32,51,.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23,32,51,.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  color: #dfe8ef;
  background: var(--side);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #355060;
  border-radius: 10px;
  color: #bce8d7;
  background: #1b2a34;
  font-weight: 900;
}

.brand strong, .brand small { display: block; }
.brand small { color: #93a3b2; margin-top: 2px; }
.side-block { margin-bottom: 24px; }
.side-title {
  margin: 0 0 9px;
  color: #7d8d9d;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.project-card, .source {
  width: 100%;
  border: 1px solid #283844;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  color: #cbd8e4;
  background: #16232d;
  text-align: left;
}

.project-card.active, .source.active {
  border-color: #83d0b3;
  background: #1d3140;
}

.project-card b, .project-card span, .source b, .source span {
  display: block;
}

.project-card span, .source span {
  margin-top: 5px;
  color: #8fa0ad;
  font-size: 12px;
}

.ghost-button {
  width: 100%;
  min-height: 38px;
  border: 1px dashed #405260;
  border-radius: 9px;
  color: #bce8d7;
  background: transparent;
  font-weight: 800;
}

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

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

.label {
  display: block;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { margin-top: 4px; font-size: 30px; line-height: 1.15; }
h2 { font-size: 17px; }
h3 { font-size: 17px; }
.actions { display: flex; gap: 9px; }

.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  background: #fff;
  color: #283648;
  font-size: 13px;
  font-weight: 850;
}

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

.button.secondary { background: #f8fbf8; }
.text-button {
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 900;
}

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

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

.flow-step {
  min-height: 86px;
  padding: 14px;
  border-top: 4px solid #c8d2cc;
}

.flow-step.active { border-top-color: var(--green); }
.flow-step b, .flow-step span { display: block; }
.flow-step span { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.45; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, .82fr) minmax(360px, 1fr) minmax(320px, .86fr);
  gap: 16px;
  align-items: start;
}

.panel { overflow: hidden; }
.panel-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #eef2ed;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px 0;
}

.tab, .chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  font-weight: 850;
}

.tab.active, .chip.active {
  color: #fff;
  border-color: var(--side);
  background: var(--side);
}

.tab-panel { display: none; padding: 14px; }
.tab-panel.active { display: block; }
.type-list, .rule-list, .candidate-list {
  display: grid;
  gap: 10px;
}

.type-item, .rule-list article, .candidate {
  border: 1px solid #e2e8e1;
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfa;
}

.type-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
}

.type-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.type-item b, .type-item span, .rule-list b, .rule-list span {
  display: block;
}

.type-item span, .rule-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.counter {
  border-radius: 999px;
  padding: 5px 9px;
  color: #1f684f;
  background: #e8f6ef;
  font-size: 12px;
  font-weight: 900;
}

.candidate-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 14px 0;
}

.candidate-list { padding: 14px; }
.candidate {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.candidate h3 { font-size: 14px; }
.candidate p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  padding: 4px 8px;
  color: #536172;
  background: #eef2ed;
  font-size: 11px;
  font-weight: 850;
}

.pill.warn { color: #8a500f; background: #fff2dc; }
.pill.good { color: #17684d; background: #e8f6ef; }
.candidate-actions {
  display: grid;
  gap: 7px;
  align-content: start;
}

.mini {
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
}

.mini.confirm { color: #fff; background: var(--green); }
.mini.reject { color: #9d312d; background: #fff0ee; }
.mini.evidence { color: #2748b7; background: #eef2ff; }

.graph {
  height: 320px;
  background: radial-gradient(circle at 50% 42%, #fff 0, #f8faf7 58%, #edf3ef 100%);
}

.graph svg { width: 100%; height: 100%; display: block; }
.edge { fill: none; stroke: #9aa7a0; stroke-width: 1.7; }
.edge-label { fill: #627168; font-size: 10px; font-weight: 900; text-anchor: middle; }
.node { cursor: pointer; }
.node circle { fill: var(--green); stroke: #fff; stroke-width: 5; filter: drop-shadow(0 8px 14px rgba(23,32,51,.16)); }
.node.warn circle { fill: var(--amber); }
.node.selected circle { fill: var(--blue); }
.node text { fill: #fff; font-size: 12px; font-weight: 900; text-anchor: middle; pointer-events: none; }

.inspector {
  padding: 16px;
}

.inspector h3 { margin-bottom: 8px; }
.inspector p { margin: 0 0 12px; color: var(--muted); line-height: 1.6; }
.kv {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #edf2ed;
  font-size: 13px;
}
.kv span:first-child { color: var(--muted); }
.quote {
  margin-top: 12px;
  border-left: 3px solid var(--green);
  padding: 10px;
  color: #405043;
  background: #f6faf6;
  font-size: 13px;
  line-height: 1.6;
}

.modal {
  width: 520px;
  max-width: 94vw;
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(23, 32, 51, .28);
}
.modal::backdrop { background: rgba(17,26,34,.42); }
.modal form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 22px;
}
.modal h3, .modal .full, .modal-actions { grid-column: 1 / -1; }
.modal label { color: var(--muted); font-size: 12px; font-weight: 900; }
.modal input, .modal select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 10px;
  padding: 11px 14px;
  color: #fff;
  background: var(--side);
  box-shadow: 0 16px 40px rgba(0,0,0,.22);
  font-size: 13px;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .app { grid-template-columns: 230px minmax(0, 1fr); }
  .layout { grid-template-columns: 1fr; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app { display: block; }
  .sidebar { position: static; height: auto; }
  .workspace { padding: 18px 14px 38px; }
  .topbar { display: block; }
  .actions { margin-top: 14px; }
  .actions .button { flex: 1; }
  .flow { grid-template-columns: 1fr; }
  .candidate { grid-template-columns: 1fr; }
  .candidate-actions { grid-template-columns: 1fr 1fr 1fr; }
  .modal form { grid-template-columns: 1fr; }
}
