:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-soft: #f0f4f2;
  --text: #18201d;
  --muted: #5d6b64;
  --line: #d9e0dc;
  --accent: #156f65;
  --accent-strong: #0c504a;
  --blue: #275c9d;
  --red: #9d3c2f;
  --amber: #986b1e;
  --shadow: 0 10px 30px rgba(23, 31, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #17211e;
  color: #f5f7f6;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #b6e2d8;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand p,
.sidebar-footer {
  margin: 4px 0 0;
  color: #b9c7c1;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  color: #e9efec;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 10px 11px;
  border-radius: 6px;
  cursor: pointer;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  margin-top: auto;
}

.workspace {
  min-width: 0;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px;
  gap: 12px;
  padding: 16px 22px;
  background: rgba(247, 248, 250, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.search,
.select-wrap {
  display: grid;
  gap: 6px;
}

.search span,
.select-wrap span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.content {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 28px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 820px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

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

.stat strong {
  display: block;
  font-size: 28px;
}

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

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

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

.card {
  padding: 15px;
  display: grid;
  gap: 10px;
  min-height: 160px;
}

.card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

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

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 12px;
}

.pill.high,
.pill.integrated {
  border-color: rgba(21, 111, 101, 0.35);
  color: var(--accent-strong);
  background: #eaf6f2;
}

.pill.medium,
.pill.needs-review {
  border-color: rgba(152, 107, 30, 0.35);
  color: var(--amber);
  background: #fff8e9;
}

.pill.low {
  border-color: rgba(157, 60, 47, 0.35);
  color: var(--red);
  background: #fff1ef;
}

.card button,
.link-button {
  justify-self: start;
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--accent-strong);
  background: #fff;
  cursor: pointer;
}

.card button:hover,
.link-button:hover {
  background: var(--panel-soft);
}

.note-panel {
  overflow: hidden;
}

.note-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.note-body {
  padding: 22px;
  min-width: 0;
}

.note-body h1,
.note-body h2,
.note-body h3 {
  margin-top: 22px;
}

.note-body h1:first-child,
.note-body h2:first-child {
  margin-top: 0;
}

.note-body p,
.note-body li {
  line-height: 1.65;
}

.note-body code {
  background: #eef2ef;
  border-radius: 4px;
  padding: 2px 4px;
}

.note-aside {
  border-left: 1px solid var(--line);
  background: #fafbfb;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.kv {
  display: grid;
  gap: 4px;
}

.kv span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.kv strong,
.kv a {
  color: var(--text);
  word-break: break-word;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  background: #fff;
}

.graph-shell,
.rq-graph-shell {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.graph-toolbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.graph-toolbar p {
  margin: 3px 0 0;
  color: var(--muted);
}

.graph-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.small-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 30px;
}

.icon-button {
  width: 30px;
  border-radius: 999px;
  font-size: 17px;
  line-height: 1;
}

.small-button {
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
}

.icon-button:hover,
.small-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.graph-svg,
.rq-graph-svg {
  width: 100%;
  height: min(72vh, 760px);
  min-height: 520px;
  display: block;
  background:
    radial-gradient(circle at 20% 20%, rgba(42, 132, 84, 0.08), transparent 28%),
    linear-gradient(180deg, #fbfcfc 0%, #f5f8f6 100%);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.rq-graph-shell {
  margin-bottom: 20px;
  box-shadow: none;
}

.rq-graph-svg {
  height: 430px;
  min-height: 340px;
}

.graph-svg:active,
.rq-graph-svg:active {
  cursor: grabbing;
}

.graph-pan-surface {
  fill: transparent;
  pointer-events: all;
}

.graph-edges line {
  stroke: rgba(62, 82, 73, 0.18);
  stroke-linecap: round;
}

.graph-node {
  cursor: move;
}

.graph-node circle {
  stroke: #fff;
  stroke-width: 2;
  filter: drop-shadow(0 4px 8px rgba(22, 35, 29, 0.13));
}

.graph-node:hover circle {
  stroke: var(--text);
  stroke-width: 3;
}

.graph-node.is-focus circle {
  stroke: #17211e;
  stroke-width: 3;
}

.graph-node text {
  fill: var(--text);
  font-size: 11px;
  paint-order: stroke;
  stroke: #fbfcfc;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.graph-tip {
  position: absolute;
  z-index: 3;
  max-width: min(360px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
}

.graph-tip strong,
.graph-tip span,
.graph-tip small {
  display: block;
}

.graph-tip strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.graph-tip span {
  color: var(--accent);
  font-weight: 700;
}

.graph-tip small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .toolbar,
  .note-layout {
    grid-template-columns: 1fr;
  }

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

  .graph-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .note-aside {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
