:root {
  color-scheme: dark;
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  background: #0b0e14;
  color: #e6e9f2;
  --bg-primary: #0b0e14;
  --bg-secondary: #111624;
  --bg-tertiary: #141b2d;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-primary: #f7f8fc;
  --text-secondary: #a9b1c7;
  --accent: #7c6bff;
  --accent-soft: rgba(124, 107, 255, 0.15);
  --success: #35d39a;
  --danger: #ff6b6b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1a2040 0%, #0b0e14 55%, #080a0f 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(7, 10, 18, 0.78);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.search {
  position: relative;
  flex: 1;
  max-width: 480px;
}

.search input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  display: none;
  z-index: 20;
}

.search-results.open {
  display: block;
}

.search-result {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover,
.search-result:focus {
  background: rgba(124, 107, 255, 0.14);
  outline: none;
}

.search-result__title {
  font-weight: 600;
}

.search-result__meta {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(124, 107, 255, 0.2);
  color: var(--text-primary);
  font-size: 12px;
  border: 1px solid var(--border-subtle);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  padding: 24px 32px 40px;
  flex: 1;
}

.graph-panel {
  background: rgba(14, 18, 31, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 520px;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.graph-stage {
  position: relative;
  flex: 1;
  border-radius: 18px;
  background: radial-gradient(circle at top, rgba(124, 107, 255, 0.12), transparent 55%);
  overflow: hidden;
}

.graph-svg {
  width: 100%;
  height: 100%;
}

.graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  background: rgba(10, 13, 23, 0.78);
  color: var(--text-secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.graph-loading.active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sidebar {
  background: rgba(12, 16, 28, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__empty {
  color: var(--text-secondary);
  font-size: 14px;
}

.detail-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.detail-value {
  font-size: 15px;
  font-weight: 600;
}

.form-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-block label {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-inline {
  display: flex;
  gap: 8px;
}

.form-inline input,
.form-inline select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-inline input:focus,
.form-inline select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.btn {
  border: 1px solid transparent;
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-subtle);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn--danger {
  background: rgba(255, 107, 107, 0.18);
  border-color: rgba(255, 107, 107, 0.5);
  color: #ffd0d0;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  min-width: 220px;
  box-shadow: var(--shadow);
}

.toast--success {
  border-color: rgba(53, 211, 154, 0.5);
  background: rgba(53, 211, 154, 0.15);
}

.toast--error {
  border-color: rgba(255, 107, 107, 0.6);
  background: rgba(255, 107, 107, 0.14);
}

.node {
  cursor: pointer;
  transition: transform 0.3s ease;
}

.node circle {
  fill: rgba(17, 22, 36, 0.95);
  stroke: rgba(124, 107, 255, 0.6);
  stroke-width: 2;
  transition: fill 0.2s ease, stroke 0.2s ease, r 0.2s ease;
}

.node text {
  fill: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.node--center circle {
  fill: rgba(124, 107, 255, 0.2);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.node--selected circle {
  fill: rgba(124, 107, 255, 0.35);
  stroke: #c4bdff;
  r: 34;
}

.node:hover circle {
  fill: rgba(124, 107, 255, 0.3);
}

.link-line {
  stroke: rgba(124, 107, 255, 0.35);
  stroke-width: 1.4;
}

@media (max-width: 1024px) {
  .content {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    right: 24px;
    top: 88px;
    bottom: 24px;
    width: min(90vw, 360px);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 40;
  }

  .sidebar.sidebar--open {
    transform: translateX(0);
  }
}

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

  .topbar__actions {
    justify-content: space-between;
  }

  .graph-panel {
    min-height: 420px;
  }
}
