/* Catppuccin Mocha palette */
:root {
  --base: #1e1e2e;
  --mantle: #181825;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --text: #cdd6f4;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --red: #f38ba8;
  --mauve: #cba6f7;
  --teal: #94e2d5;
  --overlay0: #6c7086;
}

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

body {
  background: var(--base);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header { text-align: center; margin-bottom: 1.5rem; }
header h1 { font-size: 1.8rem; color: var(--blue); }
header .subtitle { color: var(--overlay0); font-size: 0.95rem; margin-top: 0.3rem; }

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  max-width: 700px;
  margin: 0 auto 1.5rem;
}

.search-bar input {
  flex: 1;
  padding: 0.7rem 1rem;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus { border-color: var(--blue); }
.search-bar input.input-error { border-color: var(--red); }

.search-bar button {
  padding: 0.7rem 1.2rem;
  background: var(--blue);
  color: var(--base);
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}

.search-bar button:hover { opacity: 0.9; }
.search-bar button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Messages */
.error-msg {
  max-width: 700px;
  margin: 0 auto 1rem;
  padding: 0.8rem 1rem;
  background: rgba(243, 139, 168, 0.15);
  border: 1px solid var(--red);
  border-radius: 6px;
  color: var(--red);
}

/* Loading status */
.loading-status {
  text-align: center;
  color: var(--subtext1);
  font-size: 1rem;
  padding: 1rem 0;
  margin-bottom: 1rem;
}

.loading-status i {
  margin-right: 0.4em;
  color: var(--blue);
}

/* Skeleton loaders */
.skeleton { padding: 0.5rem 0; }

.skel-line {
  height: 1rem;
  margin: 0.5rem 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface0) 25%, var(--surface1) 50%, var(--surface0) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skel-block {
  height: 4rem;
  margin: 0.7rem 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface0) 25%, var(--surface1) 50%, var(--surface0) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.w40 { width: 40%; } .w50 { width: 50%; } .w60 { width: 60%; }
.w70 { width: 70%; } .w80 { width: 80%; } .w90 { width: 90%; }
.indent { margin-left: 1.5rem; } .indent2 { margin-left: 3rem; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Org networks panel */
.org-networks-panel {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.org-networks-panel h2 {
  font-size: 0.95rem;
  color: var(--subtext0);
  margin-bottom: 0.6rem;
}
.org-networks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.org-net-btn {
  background: var(--surface0);
  border: 1px solid var(--surface1, #45475a);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.org-net-btn:hover {
  background: var(--surface1, #45475a);
  border-color: var(--blue);
}
.org-net-btn.active {
  background: var(--blue);
  color: var(--base);
  border-color: var(--blue);
  font-weight: 600;
}
.org-net-btn .org-net-prefix {
  font-weight: 600;
}
.org-net-btn .org-net-name {
  font-size: 0.72rem;
  opacity: 0.7;
}

/* Results layout */
.results-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.tree-panel {
  flex: 1;
  min-width: 0;
}

.detail-panel {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: 1rem;
  max-height: 90vh;
  overflow-y: auto;
}

.tree-panel h2, .detail-panel h2 {
  font-size: 1.1rem;
  color: var(--subtext1);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--surface1);
}

/* Tree nodes */
.tree-node {
  margin-left: 1.2rem;
  border-left: 1px solid var(--surface1);
  padding-left: 0;
}

.tree-node.root {
  margin-left: 0;
  border-left: none;
}

.tree-node-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  margin: 2px 0;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.tree-node-header:hover {
  background: var(--surface0);
}

.tree-node-header.selected {
  background: rgba(137, 180, 250, 0.15);
  border: 1px solid var(--blue);
  margin: 1px -1px;
}

.tree-node-header.query-match {
  border-left: 3px solid var(--green);
  padding-left: calc(0.6rem - 3px);
}

.tree-toggle {
  width: 1.2em;
  text-align: center;
  color: var(--overlay0);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.tree-prefix {
  color: var(--blue);
  font-weight: bold;
  font-size: 0.95rem;
}

.tree-name {
  color: var(--overlay0);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-type {
  color: var(--mauve);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.tree-type-route { color: var(--teal); }

.tree-node-header.route-node .tree-prefix {
  color: var(--teal);
  font-weight: normal;
  font-style: italic;
}

/* RPKI badges */
.rpki-badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: bold;
  vertical-align: middle;
  line-height: 1.4;
}

.rpki-valid { background: var(--green); color: var(--base); }
.rpki-invalid { background: var(--red); color: var(--base); }
.rpki-unknown { background: var(--surface2); color: var(--subtext0); }
.rpki-not-found { background: var(--yellow); color: var(--base); }

.tree-children { overflow: hidden; }
.tree-children.collapsed { display: none; }

/* Detail panel */
.hint { color: var(--overlay0); font-style: italic; }

.detail-section {
  margin-bottom: 1.2rem;
}

.detail-section h3 {
  font-size: 0.9rem;
  color: var(--mauve);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--surface0);
  padding-bottom: 0.2rem;
}

/* Definition list layout for key-value pairs */
.detail-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.8rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.detail-dl dt {
  color: var(--overlay0);
  white-space: nowrap;
}

.detail-dl dd {
  color: var(--text);
  word-break: break-word;
}

.detail-dl dd a {
  color: var(--blue);
  text-decoration: none;
}

.detail-dl dd a:hover {
  text-decoration: underline;
}

/* Contact cards */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

.contact-card {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.contact-card .contact-role {
  color: var(--mauve);
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
}

.contact-card .contact-name {
  color: var(--text);
  font-weight: bold;
}

.contact-card .contact-handle {
  color: var(--overlay0);
  font-size: 0.8rem;
}

.contact-card .contact-info {
  color: var(--subtext0);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.contact-card .contact-info a {
  color: var(--blue);
  text-decoration: none;
}

.contact-card .contact-info a:hover {
  text-decoration: underline;
}

/* Entity cards (origin AS, etc.) */
.entity-card {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.entity-card .entity-handle {
  color: var(--blue);
  font-weight: bold;
}

.entity-card .entity-roles {
  color: var(--mauve);
  font-size: 0.8rem;
}

.entity-card .entity-detail {
  color: var(--subtext0);
  margin-top: 0.2rem;
}

.remark-block {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.remark-block .remark-title {
  color: var(--yellow);
  font-weight: bold;
  margin-bottom: 0.2rem;
}

.remark-block .remark-text {
  color: var(--subtext0);
  white-space: pre-wrap;
}

/* Transfer cards */
.transfer-card {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.transfer-date {
  color: var(--subtext0);
  font-weight: bold;
}

.transfer-type-badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: bold;
  vertical-align: middle;
  line-height: 1.4;
}

.transfer-type-xfer { background: var(--mauve); color: var(--base); }
.transfer-type-ma { background: var(--teal); color: var(--base); }

.transfer-prefix {
  color: var(--blue);
  font-size: 0.8rem;
}

.transfer-adjacent {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: bold;
  background: var(--surface2);
  color: var(--subtext0);
  vertical-align: middle;
}

.transfer-detail-row {
  margin-top: 0.15rem;
  color: var(--text);
}

.transfer-label {
  color: var(--overlay0);
}

.transfer-country {
  color: var(--overlay0);
  font-size: 0.8rem;
}

/* Org resource lists */
.resource-subhead {
  color: var(--overlay0);
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.5rem;
  margin-bottom: 0.2rem;
}

.resource-list {
  max-height: 20rem;
  overflow-y: auto;
  border: 1px solid var(--surface1);
  border-radius: 4px;
  padding: 0.3rem;
  margin-bottom: 0.5rem;
}

.resource-row {
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  border-radius: 3px;
}

.resource-row:hover {
  background: var(--surface0);
}

.resource-row.resource-current {
  background: rgba(137, 180, 250, 0.1);
  border-left: 2px solid var(--blue);
  padding-left: calc(0.4rem - 2px);
}

.resource-prefix {
  color: var(--blue);
  font-weight: bold;
}

.resource-current-label {
  color: var(--green);
}

.resource-link {
  text-decoration: none;
}

.resource-link:hover {
  text-decoration: underline;
}

.resource-name {
  color: var(--overlay0);
}

.resource-type {
  color: var(--surface2);
  font-size: 0.7rem;
}

/* POC resources (expandable on click) */
.poc-resources {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--surface1);
}

.poc-resources-title {
  color: var(--mauve);
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 0.2rem;
}

.poc-link-count {
  display: inline-block;
  background: var(--blue);
  color: var(--base);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* ASPA badges and neighbor cards */
.aspa-provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.aspa-badge {
  display: inline-block;
  background: var(--teal);
  color: var(--base);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: bold;
}

.aspa-badge a {
  color: var(--base);
  text-decoration: none;
}

.aspa-badge a:hover {
  text-decoration: underline;
}

.aspa-badge-name {
  font-weight: normal;
  font-size: 0.8rem;
}

.aspa-highlight {
  color: var(--teal);
}

.aspa-paths {
  margin-top: 0.3rem;
  font-size: 0.8rem;
}

.aspa-paths code {
  color: var(--subtext0);
}

.conf-bar {
  display: inline-block;
  width: 50px;
  height: 5px;
  background: var(--surface1);
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
}

.conf-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
}

/* Responsive */
@media (max-width: 900px) {
  .results-layout {
    flex-direction: column;
  }
  .detail-panel {
    position: static;
    max-height: none;
  }
  .contact-grid {
    grid-template-columns: 1fr;
  }
}
