:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-border: rgba(15, 23, 42, 0.08);
  --shadow: 0 24px 55px rgba(15, 23, 42, 0.1);
  --text-primary: #0f172a;
  --text-secondary: rgba(15, 23, 42, 0.65);
  --text-faint: rgba(71, 85, 105, 0.6);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-strong: rgba(37, 99, 235, 0.22);
  --success: #22c55e;
  --danger: #dc2626;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, #ffffff 15%, var(--bg) 70%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem clamp(2rem, 8vw, 6rem) 1.5rem;
  gap: 2rem;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.brand-logo {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.app-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: var(--shadow);
}

.nav-link {
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.app-main {
  flex: 1;
  padding: 1rem clamp(1.5rem, 5vw, 4rem) 3rem;
}

.atlas-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 1.75rem;
  align-items: stretch;
}

.graph-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border-radius: 28px;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  padding: 0.5rem 1.6rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.92);
}

.graph-toolbar h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.graph-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
}

.metric-chip {
  background: var(--surface-muted);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 0.45rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.metric-chip span:first-child {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.metric-chip span:last-child {
  font-weight: 600;
}

.graph-stage {
  position: relative;
  min-height: clamp(520px, 70vh, 760px);
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(226, 232, 240, 0.45), rgba(255, 255, 255, 0.92));
}

#graph {
  width: 100%;
  height: 100%;
}

.graph-tag {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.18);
}

.legend-panel {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  font-size: 0.85rem;
}

.graph-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: auto;
}

.control-btn {
  border: none;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 48px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.control-btn:hover {
  background: rgba(37, 99, 235, 0.8);
  transform: translateY(-1px);
}

.control-btn:active {
  transform: translateY(0);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.15);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.panel {
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.pill-button {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.pill-button:hover {
  background: rgba(37, 99, 235, 0.2);
  transform: translateY(-1px);
}

.control-grid {
  display: grid;
  gap: 0.9rem;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.control-field span {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

input[type='search'],
select,
.chat-form input[type='text'] {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary);
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type='search']::placeholder,
.chat-form input[type='text']::placeholder {
  color: rgba(100, 116, 139, 0.6);
}

input[type='search']:focus,
select:focus,
.chat-form input[type='text']:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.search-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#search-clear {
  border: none;
  border-radius: 12px;
  padding: 0.45rem 0.9rem;
  background: rgba(226, 232, 240, 0.8);
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

#search-clear:hover {
  background: rgba(148, 163, 184, 0.35);
}

.empty-state {
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.persona-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.persona-headline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.persona-headline h3 {
  margin: 0;
  font-size: 1.4rem;
}

.persona-headline p {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
}

.persona-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
}

.persona-stat {
  background: rgba(248, 250, 252, 0.95);
  border-radius: 14px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.persona-stat span:first-child {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.persona-stat span:last-child {
  font-weight: 600;
}

.persona-notes {
  display: grid;
  gap: 0.6rem;
}

.persona-notes .note-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.note-item span:first-child {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.note-item span:last-child {
  font-weight: 500;
}

.persona-accordion {
  display: grid;
  gap: 0.6rem;
}

.persona-accordion details {
  background: rgba(241, 245, 249, 0.75);
  border-radius: 16px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  padding: 0.6rem 0.8rem;
}

.persona-accordion summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.persona-accordion summary::-webkit-details-marker {
  display: none;
}

.persona-accordion summary::after {
  content: '+';
  font-weight: 700;
  color: var(--accent);
  margin-left: auto;
  transition: transform 0.2s ease;
}

.persona-accordion details[open] summary::after {
  transform: rotate(45deg);
}

.persona-accordion ul {
  margin: 0.6rem 0 0;
  padding: 0 0 0 1.1rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.chat-window {
  flex: 1;
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  background: rgba(248, 250, 252, 0.95);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chat-placeholder {
  margin: auto;
  text-align: center;
  color: rgba(100, 116, 139, 0.9);
  font-size: 0.95rem;
  line-height: 1.4;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-message .sender {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.chat-message .bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  line-height: 1.4;
  font-size: 0.92rem;
}

.chat-message.user .bubble {
  align-self: flex-end;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.chat-message.persona .bubble {
  background: rgba(244, 244, 249, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.6);
}

.chat-message.system .bubble {
  background: rgba(248, 113, 113, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.chat-message.system .sender {
  color: rgba(190, 18, 60, 0.85);
}

.chat-message.typing .bubble {
  font-style: italic;
  color: var(--text-secondary);
}

.chat-form {
  display: flex;
  gap: 0.75rem;
}

.chat-form button {
  border: none;
  border-radius: 14px;
  padding: 0.65rem 1.2rem;
  background: linear-gradient(125deg, rgba(37, 99, 235, 0.25), rgba(14, 165, 233, 0.25));
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chat-form button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chat-form button:not(:disabled):hover {
  background: linear-gradient(125deg, rgba(37, 99, 235, 0.38), rgba(14, 165, 233, 0.4));
  transform: translateY(-1px);
}

.app-footer {
  padding: 1.6rem clamp(2rem, 8vw, 6rem) 2.4rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

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

/* Company view */

.company-main {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  padding: 0 clamp(1.5rem, 6vw, 6rem) 3rem;
}

.company-hero {
  background: var(--surface);
  border-radius: 28px;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  padding: 1.8rem 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 2rem;
}

.company-hero h1 {
  margin: 0 0 0.6rem;
  font-size: 1.8rem;
}

.company-hero p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 640px;
  line-height: 1.5;
  font-size: 1rem;
}

.hero-meta {
  display: grid;
  gap: 0.6rem;
}

.hero-meta .metric-chip {
  min-width: 180px;
}

.company-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.4rem;
}

.company-card {
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.company-card h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.company-card span.label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.list-dot,
.list-card {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.list-dot li::before {
  content: '-';
  color: var(--accent);
  margin-right: 0.5rem;
}

.list-pill {
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.list-pill li {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
  font-size: 0.85rem;
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.info-grid {
  display: grid;
  gap: 0.6rem;
}

.info-grid .info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
  padding-bottom: 0.4rem;
}

.info-grid .info-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.info-grid .info-label {
  font-weight: 600;
  color: var(--text-primary);
}

.info-grid .info-value {
  color: var(--text-secondary);
}

.glossary-grid {
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.glossary-grid dt {
  font-weight: 600;
  color: var(--text-primary);
}

.glossary-grid dd {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.team-grid {
  display: grid;
  gap: 0.9rem;
}

.team-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(203, 213, 225, 0.6);
  border-radius: 18px;
  padding: 0.85rem 1rem;
}

.team-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.team-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.2);
}

.team-card h3 {
  margin: 0;
  font-size: 1rem;
}

.team-card-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.team-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  color: var(--accent);
  font-size: 0.8rem;
}

.team-chip strong {
  font-size: 0.95rem;
}

.team-summary {
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.list-card li {
  background: rgba(248, 250, 252, 0.95);
  border-radius: 16px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.span-2 {
  grid-column: span 2;
}

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

  .graph-shell {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .graph-stage {
    min-height: 520px;
  }

  .company-main {
    padding: 0 clamp(1.25rem, 5vw, 3rem) 2.5rem;
  }

  .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-nav {
    width: 100%;
    justify-content: space-between;
  }

  .atlas-layout {
    gap: 1rem;
  }

  .graph-shell {
    padding: 1.2rem;
  }

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

  .sidebar {
    gap: 1rem;
  }

  .panel {
    padding: 1.1rem;
  }

  .company-hero {
    flex-direction: column;
    gap: 1rem;
  }
}
.graph-stage {
  position: relative;
  min-height: clamp(520px, 70vh, 760px);
  overflow: hidden;
  background: linear-gradient(160deg, rgba(226, 232, 240, 0.45), rgba(255, 255, 255, 0.92));
}
