:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3d52;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --user: #60a5fa;
  --book: #f59e0b;
  --prestamo: #22c55e;
  --espera: #f97316;
  --historial: #94a3b8;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(245, 158, 11, 0.08), transparent);
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.header__badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.header__stats {
  display: flex;
  gap: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  min-width: 72px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat__val {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}

.stat__lbl {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 1.25rem;
  min-height: 620px;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.card__hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.card__hint code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.ops-list {
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text);
}

.ops-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.ops-list li:last-child {
  border-bottom: none;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend--nodes {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend__item {
  font-size: 0.78rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border-left: 3px solid;
}

.legend__item--prestamo {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--prestamo);
}

.legend__item--espera {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--espera);
}

.legend__item--historial {
  background: rgba(148, 163, 184, 0.12);
  border-color: var(--historial);
}

.legend__dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.legend__dot--user { background: var(--user); }
.legend__dot--book { background: var(--book); }

.input {
  width: 100%;
  margin: 0.5rem 0 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

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

.btn--primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
}

.btn--ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.rec-list {
  list-style: none;
  margin-top: 0.75rem;
  font-size: 0.82rem;
}

.rec-list li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.rec-list li strong {
  color: var(--book);
}

.graph-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 560px;
}

.graph-canvas {
  width: 100%;
  height: 560px;
}

.graph-toolbar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 0.5rem;
}

.detail-box {
  font-size: 0.85rem;
  line-height: 1.55;
}

.detail-placeholder {
  color: var(--muted);
  font-style: italic;
}

.detail-box h3 {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.detail-box .tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}

.tag--user { background: rgba(96, 165, 250, 0.25); color: var(--user); }
.tag--book { background: rgba(245, 158, 11, 0.25); color: var(--book); }

.code-block {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}
