/* Atlas Design System */
:root {
  --bg: #05070b;
  --panel-bg: #0a0f1a;
  --card-bg: #0f1520;
  --card-border: #262c38;
  --accent: #c144d2;
  --accent-soft: #9f6bff;
  --text-main: #ffffff;
  --text-muted: #a6bec8;
  --pill-bg: #1f2933;
  --pill-text: #e5e7eb;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.6);
  --radius-lg: 18px;
  --radius-pill: 999px;
  --transition-fast: 160ms ease-out;
  --max-width: 1120px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Lexend", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

img {
  display: block;
  max-width: 100%;
}

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

main {
  flex: 1;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 16px;
}

.main-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Header */
header {
  border-bottom: 1px solid #111827;
  background: radial-gradient(circle at top left, rgba(193, 68, 210, 0.18), transparent 55%);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-logo {
  height: 32px;
  width: auto;
}

.brand-texts,
.brand-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-text-main {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-text-sub {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.nav-link {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-link strong {
  color: var(--text-main);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: center;
}

.hero.panel {
  background: radial-gradient(circle at 10% 10%, rgba(193, 68, 210, 0.12), rgba(15, 23, 42, 0.85));
  padding: 20px 18px;
}

.hero-card,
.panel,
.card,
.form-surface {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.hero-card {
  padding: 16px;
  background: radial-gradient(circle at 10% 20%, rgba(193, 68, 210, 0.1), rgba(15, 23, 42, 0.85));
}

.hero-card-title {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 10px;
}

.hero-card-body {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-lg);
  padding: 14px;
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.5;
}

.hero-title {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
}

.hero-highlight {
  color: var(--accent);
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.pill {
  font-size: 11px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--pill-bg);
  color: var(--pill-text);
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-app {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #4ade80;
}

/* Buttons */
.btn {
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(17, 24, 39, 0.9);
  color: var(--text-main);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(120deg, #c144d2, #fda24f);
  border-color: transparent;
  color: #0b0f18;
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(193, 68, 210, 0.6);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(148, 163, 184, 0.25);
  color: var(--text-main);
}

/* Panels and cards */
.panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.card-link,
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover,
.card-link:hover {
  border-color: rgba(193, 68, 210, 0.5);
  transform: translateY(-1px);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
}

.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-link-action {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
}

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

/* Forms */
.form-surface {
  padding: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--card-border);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.input,
.select,
.search-input,
.select-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--card-border);
  background: #0b1220;
  color: var(--text-main);
}

.search-input {
  flex: 1;
  min-width: 200px;
}

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.page-title {
  font-size: 22px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  color: var(--text-muted);
}

.page-btn,
.page-current {
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

.page-btn {
  border: 1px solid var(--card-border);
  background: var(--panel-bg);
  color: var(--text-main);
}

.page-current {
  background: rgba(193, 68, 210, 0.14);
  border: 1px solid rgba(193, 68, 210, 0.4);
  color: var(--text-main);
}

/* Graph layout */
.layout {
  flex: 1;
  display: flex;
  min-height: calc(100vh - 52px);
}

.graph-area {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px;
  background: radial-gradient(circle at top left, rgba(193, 68, 210, 0.12), #020617 35%, #000000 100%);
  position: relative;
}

.graph-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.98), #020617);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

#cy {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.graph-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgba(31, 41, 55, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(31, 41, 55, 0.28) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.24;
}

.graph-label {
  position: absolute;
  left: 16px;
  top: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  z-index: 5;
}

.graph-caption {
  position: absolute;
  left: 16px;
  bottom: 10px;
  font-size: 10px;
  color: var(--text-muted);
  z-index: 5;
}

#side-panel {
  width: 340px;
  max-width: 100%;
  background: var(--panel-bg);
  border-left: 1px solid #111827;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#panel-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

#panel-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 2px;
}

#panel-content {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.5;
}

#panel-content p {
  margin: 4px 0;
}

#panel-content ul {
  margin: 4px 0;
  padding-left: 16px;
}

#panel-content li {
  margin-bottom: 3px;
}

.panel-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #111827;
}

.panel-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-item input {
  accent-color: #f7931a;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-item input {
  accent-color: var(--accent);
}

#legend {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #374151;
}

.legend-color.central {
  background: #f7931a;
}

.legend-color.persona {
  background: #e8a87c;
}

.legend-color.inst-padre {
  background: #4b5563;
}

.legend-color.inst-central {
  background: #a855f7;
}

.legend-color.inst-hija {
  background: #6366f1;
}

.legend-color.personas {
  background: #e8a87c;
}

.legend-color.line {
  border-radius: 2px;
  background: #9aa0a6;
}

.chip-pill,
.person-chip,
.chip-link {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #111827;
  border: 1px solid #1f2937;
  color: var(--text-main);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 120ms ease;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip-pill:hover,
.person-chip:hover,
.chip-link:hover {
  background: #1f2937;
  border-color: #4b5563;
  transform: translateY(-1px);
}

#related-people,
#related-institutions,
#people-chips,
#institutions-chips,
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips-row {
  margin-bottom: 6px;
}

#debug {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 320px;
  max-height: 25vh;
  background: rgba(0, 0, 0, 0.85);
  color: #e5e7eb;
  font-size: 11px;
  padding: 4px 8px;
  overflow: auto;
  z-index: 9999;
  white-space: pre-wrap;
}

footer {
  border-top: 1px solid #111827;
  padding: 14px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Responsive */
@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .graph-area {
    height: 52vh;
  }

  #side-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid #111827;
  }

  #debug {
    right: 0;
  }

  #panel-title {
    font-size: 15px;
  }

  #panel-content {
    font-size: 13px;
  }
}
