:root {
    --bg: #0e1116;
    --panel-bg: #161b22;
    --border: #30363d;
    --fg: #e6edf3;
    --fg-dim: #8b949e;
    --accent: #58a6ff;
    --customer: #f59e0b;
    --provider: #34d399;
    --both: #a78bfa;
    --edge: #4b5563;
    --edge-hi: #58a6ff;
    --consistent: #4b5563;
    --conflict-peer: #f59e0b;
    --conflict-customer: #f87171;
    --no-caida: #6b7280;
    --caida-only: #38bdf8;
    --mutual: #f0abfc;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel-bg);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.meta {
    color: var(--fg-dim);
    font-size: 0.85rem;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

input[type="text"] {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    width: 240px;
    font-size: 0.9rem;
}
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.btn {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn:hover { border-color: var(--accent); }

main {
    position: relative;
    height: calc(100% - 50px);
}

#graph {
    width: 100%;
    height: 100%;
    cursor: grab;
}
#graph:active { cursor: grabbing; }

#graph .node circle,
#graph .node path {
    stroke: #0e1116;
    stroke-width: 1px;
}
#graph .node.customer circle, #graph .node.customer path { fill: var(--customer); }
#graph .node.provider circle, #graph .node.provider path { fill: var(--provider); }
#graph .node.both circle, #graph .node.both path { fill: var(--both); }
#graph .labels text {
    fill: var(--fg);
    font-size: 10px;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: hanging;
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 3px;
    stroke-linejoin: round;
}
#graph .labels text.dim,
#graph .labels text.hide-label { display: none; }
/* In focused mode (a single AS + its neighbourhood is shown), the visible
   set is small enough that all of their labels comfortably fit, so the
   degree threshold is effectively zero for the focused view. The 2× zoom
   that focused mode applies would otherwise make 10px labels render as
   20px on screen — halve the font size so they read at the same on-screen
   size as the unfocused graph. */
#graph.focused .labels text.hide-label:not(.dim) { display: initial; }
#graph.focused .labels text { font-size: 5px; stroke-width: 1.5px; }

/* Section headers shown above the provider line and below the customer
   line while focused on an AS in 1-hop mode. */
#graph .focus-labels text.focus-section-label {
    fill: var(--fg);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-anchor: middle;
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 3px;
    stroke-linejoin: round;
    pointer-events: none;
}
/* Halve the size at 2× focus zoom so the on-screen size matches the
   rest of the focused-mode typography. */
#graph.focused .focus-labels text.focus-section-label {
    font-size: 6px;
    stroke-width: 1.5px;
}

/* "Ghost" duplicate of a mutual (provider+customer) AS rendered on the
   customer line while focused; the real node sits on the provider line.
   The ghost re-uses the .node + colour-class classes so its fill, stroke
   and shape match the real node exactly — pointer-events are disabled
   so clicks fall through to the real node. */
#graph .focus-labels .focus-mutual-ghost-node { pointer-events: none; }
/* Edge connecting the focus to a mutual AS's customer-line ghost. Uses
   the existing .link.mutual visual treatment so it matches the real
   focus → provider-line edge for the same AS. */
#graph .focus-labels line.focus-mutual-edge { pointer-events: none; }
/* Vertical connector linking a mutual AS's two markers. */
#graph .focus-labels line.focus-mutual-connector {
    stroke: var(--accent);
    stroke-opacity: 0.45;
    stroke-width: 1px;
    stroke-dasharray: 4 3;
    pointer-events: none;
}
#graph.focused .focus-labels line.focus-mutual-connector {
    stroke-width: 0.5px;
    stroke-dasharray: 2 1.5;
}
/* Ghost label sits below the ghost circle, mirroring how real node labels
   are positioned (dominant-baseline:hanging, y = node.y + r + 2). */
#graph .focus-labels text.focus-mutual-ghost-label {
    fill: var(--fg);
    font-size: 10px;
    text-anchor: middle;
    dominant-baseline: hanging;
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 3px;
    stroke-linejoin: round;
    pointer-events: none;
}
#graph.focused .focus-labels text.focus-mutual-ghost-label {
    font-size: 5px;
    stroke-width: 1.5px;
}
#graph .node.dim { display: none; }
#graph .node.hi circle, #graph .node.hi path { stroke: var(--accent); stroke-width: 2px; }

#graph .link {
    stroke: var(--edge);
    stroke-opacity: 0.4;
    stroke-width: 0.6px;
    fill: none;
}
#graph .link.dim { display: none; }
#graph .link.hi { stroke: var(--edge-hi); stroke-opacity: 0.95; stroke-width: 1.5px; }

#graph .link.consistent { stroke: var(--consistent); stroke-opacity: 0.18; }
#graph .link.conflict_peer {
    stroke: var(--conflict-peer); stroke-opacity: 0.9; stroke-width: 1.2px;
}
#graph .link.conflict_customer {
    stroke: var(--conflict-customer); stroke-opacity: 0.95; stroke-width: 1.4px;
}
#graph .link.no_caida { stroke: var(--no-caida); stroke-opacity: 0.35; }
#graph .link.caida_only {
    stroke: var(--caida-only); stroke-opacity: 0.75; stroke-width: 1px;
    stroke-dasharray: 4 3;
}
#graph .link.mutual {
    stroke: var(--mutual); stroke-opacity: 0.9; stroke-width: 1.4px;
}

#bottomControls {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    z-index: 5;
}
#legend {
    background: rgba(22, 27, 34, 0.85);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.8rem 0.6rem;
    font-size: 0.8rem;
    line-height: 1.6;
}
.region-filter {
    background: rgba(22, 27, 34, 0.85);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem 0.5rem;
    font-size: 0.78rem;
}
/* Collapsible-panel header (Legend + Region filter share this).
   The chevron rotates 180° when the panel is collapsed and the body
   is hidden, leaving just the title row visible. */
.collapsible-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    cursor: pointer;
    user-select: none;
}
.collapsible-panel .panel-header-title {
    color: var(--fg-dim);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.collapsible-panel .panel-toggle {
    background: transparent;
    border: 0;
    color: var(--fg-dim);
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    font-size: 0.75rem;
    line-height: 1;
    border-radius: 3px;
    transition: transform 120ms ease, color 120ms ease;
}
.collapsible-panel .panel-toggle:hover { color: var(--fg); }
.collapsible-panel.collapsed .panel-toggle i { transform: rotate(180deg); }
.collapsible-panel .panel-toggle i {
    display: inline-block;
    transition: transform 120ms ease;
}
.collapsible-panel.collapsed .panel-body { display: none; }
.collapsible-panel.collapsed .panel-header { margin-bottom: 0; }
.collapsible-panel.collapsed { padding-top: 0.3rem; padding-bottom: 0.3rem; }
.region-filter svg {
    display: block;
    width: 320px;
    height: 150px;
    background: rgba(14, 17, 22, 0.7);
    border-radius: 4px;
    border: 1px solid var(--border);
}
.region-filter-hint {
    color: var(--fg-dim);
    font-size: 0.7rem;
    margin-top: 0.3rem;
    text-align: center;
}
.legend-item { display: flex; align-items: center; gap: 0.5rem; }
.dot {
    display: inline-block;
    width: 10px; height: 10px; border-radius: 50%;
}
.dot-customer { background: var(--customer); }
.dot-provider { background: var(--provider); }
.dot-both { background: var(--both); }
.dot-diamond {
    border-radius: 0;
    transform: rotate(45deg);
    background: var(--fg-dim);
}
.legend-edge .line {
    display: inline-block;
    width: 18px; height: 0; border-top: 1.5px solid var(--edge);
}
.legend-edge .line-default { border-top-color: var(--edge-hi); }
.legend-edge .line-consistent { border-top-color: var(--consistent); }
.legend-edge .line-conflict-peer { border-top-color: var(--conflict-peer); }
.legend-edge .line-conflict-customer { border-top-color: var(--conflict-customer); }
.legend-edge .line-no-caida { border-top-color: var(--no-caida); }
.legend-edge .line-caida-only {
    border-top-style: dashed; border-top-color: var(--caida-only);
}
.legend-edge .line-mutual { border-top-color: var(--mutual); }
.marker-glyph {
    display: inline-block; width: 14px; text-align: center;
    color: var(--no-caida); font-weight: 700;
}
.marker-glyph.plus { color: var(--caida-only); }
#legend hr { border: 0; border-top: 1px solid var(--border); margin: 0.4rem 0; }
#caidaLegend.hidden { display: none; }
.legend-note { color: var(--fg-dim); font-size: 0.75rem; }

.toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    color: var(--fg-dim); font-size: 0.85rem; cursor: pointer;
    user-select: none;
}
.toggle input { accent-color: var(--accent); }

.floating-control {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(22, 27, 34, 0.85);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.8rem;
    font-size: 0.78rem;
    z-index: 10;
    user-select: none;
}
.floating-control .control-row {
    color: var(--fg-dim);
    margin-bottom: 0.35rem;
}
.floating-control .control-row label { cursor: pointer; }
.floating-control #labelThresholdValue {
    color: var(--fg);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.floating-control input[type="range"] {
    width: 200px;
    accent-color: var(--accent);
    vertical-align: middle;
    cursor: pointer;
}
.floating-control .size-select {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    font-size: 0.78rem;
    margin-left: 0.4rem;
    cursor: pointer;
}
.floating-control .size-select:focus { outline: none; border-color: var(--accent); }

.update-banner {
    position: fixed;
    top: 1rem; left: 50%; transform: translateX(-50%);
    z-index: 900;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid #38bdf8;
    color: #e6edf3;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    display: flex; align-items: center; gap: 0.6rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.update-banner.hidden { display: none; }
.update-banner button.ctrl {
    background: #38bdf8; color: #0e1116;
    border: none; padding: 0.3rem 0.7rem;
    border-radius: 999px; font-weight: 600; cursor: pointer;
}
.update-banner button.ctrl:hover { background: #7dd3fc; }
.update-banner button.ghost {
    background: none; color: var(--fg-dim);
    border: none; cursor: pointer; font-size: 0.85rem;
}
.update-banner button.ghost:hover { color: var(--fg); }

/* Tour */
.tour-overlay { position: fixed; inset: 0; z-index: 2000; pointer-events: auto; }
.tour-overlay svg { width: 100%; height: 100%; }
.tour-tooltip {
    position: fixed; z-index: 2001;
    background: #161b22; color: #e6edf3;
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 1.1em 1.4em;
    max-width: 420px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}
.tour-tooltip h3 {
    color: var(--accent);
    margin: 0 0 0.4em;
    font-size: 1.05em;
    font-weight: 600;
}
.tour-tooltip p { margin: 0 0 1em; color: #cbd5e1; }
.tour-tooltip code {
    background: var(--bg);
    padding: 0.05em 0.35em;
    border-radius: 4px;
    font-size: 0.9em;
}
.tour-tooltip .tour-nav {
    display: flex; gap: 0.5em; justify-content: flex-end; align-items: center;
}
.tour-tooltip .tour-step {
    color: var(--fg-dim); font-size: 0.85em; margin-right: auto;
}
.tour-tooltip button {
    padding: 6px 14px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg); color: var(--fg);
    cursor: pointer; font-size: 13px;
}
.tour-tooltip button:hover { border-color: var(--accent); }
.tour-tooltip button.tour-primary {
    background: var(--accent); color: var(--bg); border-color: var(--accent);
    font-weight: 600;
}
.tour-tooltip button.tour-primary:hover { background: #79c0ff; }
/* Raise the highlighted element above the dim overlay. We deliberately
   don't set position: relative here because elements that already use
   position: absolute (e.g. #labelControl, #panel) would snap back to
   their flow position and the cutout would no longer line up. z-index
   alone works for any element that already has its own positioning
   context, which covers all our tour targets. */
.tour-highlight { z-index: 2001; }

/* About modal — header button reveals an explainer panel covering the graph. */
.modal {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 3rem 1rem;
    z-index: 1000;
    overflow-y: auto;
}
.modal.hidden { display: none; }
.modal-content {
    position: relative;
    max-width: 720px;
    width: 100%;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.6rem 1.8rem 1.8rem;
    color: var(--fg);
    line-height: 1.55;
}
.modal-content h2 {
    margin: 0 0 0.6rem;
    color: var(--accent);
    font-size: 1.3rem;
}
.modal-content h3 {
    margin: 1.4rem 0 0.4rem;
    font-size: 1rem;
    color: var(--fg);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.modal-content p { margin: 0.4rem 0; color: #cbd5e1; }
.modal-content a { color: var(--accent); text-decoration: none; }
.modal-content a:hover { text-decoration: underline; }
.modal-content code {
    background: var(--bg);
    padding: 0.05em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e6edf3;
}
.modal-content ul {
    margin: 0.4rem 0 0.4rem 0;
    padding-left: 1.2rem;
    color: #cbd5e1;
}
.modal-content ul li { margin: 0.3rem 0; }
.modal-close {
    position: absolute;
    top: 0.6rem; right: 0.7rem;
    background: none;
    color: var(--fg-dim);
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
}
.modal-close:hover { color: var(--fg); }

.about-logos {
    display: flex; align-items: center; justify-content: center;
    gap: 2rem;
    margin: 0.4rem 0 1.2rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.about-logos img { max-height: 48px; width: auto; display: block; }
.about-logos .logo-i2    { max-height: 36px; }
.about-logos .logo-caida { max-height: 56px; background: white; padding: 0.3rem 0.5rem; border-radius: 4px; }
.about-lead { color: var(--fg) !important; font-size: 0.95rem; }
.about-caveat {
    margin-top: 1.2rem;
    padding: 0.6rem 0.9rem;
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid var(--conflict-peer);
    border-radius: 4px;
    font-size: 0.88rem;
}

.about-nsf-notice {
    margin-top: 1.2rem;
    padding: 0.7rem 0.9rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}
.about-nsf-notice a { color: var(--accent); }

#regionMap { width: 100%; height: auto; display: block; }
#regionMap .region-shape {
    fill-opacity: 0.55;
    stroke: #0e1116; stroke-width: 0.4;
    cursor: pointer;
    transition: fill-opacity 0.15s;
}
#regionMap .region-shape:hover { fill-opacity: 0.85; }
#regionMap .region-shape.off {
    fill: var(--fg-dim) !important;
    fill-opacity: 0.15;
}
#regionMap text.region-label {
    fill: var(--fg);
    font-size: 8px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 2px;
    stroke-linejoin: round;
}
#regionMap text.region-label.off { fill: var(--fg-dim); }
/* Distinct hue per region so adjacent countries stay visually grouped. */
#regionMap .region-americas { fill: #f59e0b; }
#regionMap .region-europe   { fill: #58a6ff; }
#regionMap .region-asia     { fill: #34d399; }
#regionMap .region-africa   { fill: #f87171; }
#regionMap .region-oceania  { fill: #a78bfa; }
#regionMap text.region-label {
    fill: var(--fg); font-size: 11px; font-weight: 600;
    text-anchor: middle; pointer-events: none;
    paint-order: stroke; stroke: var(--bg); stroke-width: 3px;
    stroke-linejoin: round;
}
#regionMap text.region-label.off { fill: var(--fg-dim); }

/* Rank modal */
.rank-modal-content { max-width: 640px; }
.rank-subtitle { color: var(--fg-dim); font-size: 0.88rem; margin: 0 0 0.7rem; }
#rankSearchInput {
    width: 100%;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
    margin: 0.2rem 0 0.4rem;
}
#rankSearchInput:focus { outline: none; border-color: var(--accent); }
.rank-meta {
    color: var(--fg-dim);
    font-size: 0.78rem;
    margin: 0.2rem 0 0.5rem;
}
.rank-list-header {
    display: grid;
    grid-template-columns: 3.5em 1fr 4.5em auto;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-bottom: none;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    background: rgba(14, 17, 22, 0.6);
    color: var(--fg-dim);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}
.rank-list-header .rank-col-cone { text-align: right; }
.rank-list {
    list-style: none; padding: 0; margin: 0;
    max-height: 55vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}
.rank-list li {
    display: grid;
    grid-template-columns: 3.5em 1fr 4.5em auto;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.rank-list li:last-child { border-bottom: none; }
.rank-list li:hover { background: rgba(88, 166, 255, 0.08); }
.rank-list .rank { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.rank-list .name { color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-list .name .asn-tag { color: var(--accent); font-weight: 500; margin-right: 0.3rem; }
.rank-list .cone {
    color: var(--fg);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
}
.rank-list .degree { color: var(--fg-dim); font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.rank-list .empty {
    display: block; padding: 1rem; text-align: center;
    color: var(--fg-dim); cursor: default;
}
.rank-list .empty:hover { background: none; }

#panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 320px;
    max-height: calc(100% - 2rem);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    font-size: 0.9rem;
}
#panel.hidden { display: none; }
#panel .close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    background: none;
    color: var(--fg-dim);
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}
#panel .close:hover { color: var(--fg); }
#panel h2 {
    margin: 0 0 0.2rem 0;
    font-size: 1.1rem;
    color: var(--accent);
}
#panel h3 {
    margin: 1rem 0 0.4rem;
    font-size: 0.9rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.panel-name {
    color: var(--fg-dim);
    margin-bottom: 0.6rem;
    word-break: break-word;
}
.panel-note {
    background: rgba(56, 189, 248, 0.1);
    border-left: 3px solid var(--caida-only);
    border-radius: 4px;
    padding: 0.5rem 0.7rem;
    margin: 0.5rem 0 0.7rem;
    font-size: 0.85rem;
    color: var(--fg);
    line-height: 1.45;
}
.panel-note.hidden { display: none; }
.panel-stats {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.2rem 0.8rem;
    margin: 0;
    font-size: 0.85rem;
}
.panel-stats dt { color: var(--fg-dim); }
.panel-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.panel-cone-toggle {
    display: flex; align-items: center; gap: 0.4rem;
    color: var(--fg-dim); font-size: 0.85rem;
    margin: 0.5rem 0 0.6rem;
    user-select: none; cursor: pointer;
}
.panel-cone-toggle input { accent-color: var(--accent); }
.panel-cone-hops {
    margin: -0.4rem 0 0.6rem 1.4rem;
    color: var(--fg-dim);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.panel-cone-hops.hidden { display: none; }
.panel-cone-hops label {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}
.panel-cone-hops #panelConeHopsValue {
    color: var(--fg);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.panel-cone-hops input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}
.panel-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 220px;
    overflow-y: auto;
}
.panel-list li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.panel-list li:hover { color: var(--accent); }
.panel-list .empty { color: var(--fg-dim); cursor: default; }
.panel-list .empty:hover { color: var(--fg-dim); }
.badge {
    display: inline-block;
    font-size: 0.7em;
    font-weight: 600;
    padding: 0.05em 0.55em;
    margin-right: 0.35em;
    border-radius: 999px;
    line-height: 1.5;
    letter-spacing: 0.02em;
    vertical-align: middle;
    white-space: nowrap;
}
.badge-aspa            { background: rgba(52, 211, 153, 0.18); color: #34d399; }
.badge-caida           { background: rgba(148, 163, 184, 0.20); color: #cbd5e1; }
.badge-caida-conflict  { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }
.badge-caida-only      { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
.badge-re              { background: rgba(148, 226, 213, 0.18); color: #94e2d5; }

.status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--fg-dim);
    font-size: 0.95rem;
}
.status.hidden { display: none; }
.status.error { color: #f87171; }

/* Stats modal */
.stats-modal-content { max-width: 880px; }
.stats-subtitle { color: var(--fg-dim); font-size: 0.88rem; margin: 0 0 0.7rem; }
.stats-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.2rem 0 0.6rem;
    color: var(--fg-dim);
    font-size: 0.85rem;
}
.stats-chart {
    width: 100%;
    background: rgba(14, 17, 22, 0.55);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem;
    box-sizing: border-box;
    min-height: 380px;
}
.stats-chart svg { display: block; width: 100%; height: 380px; }
.stats-chart .stats-bar { fill: var(--accent); }
.stats-chart .stats-bar:hover { fill: var(--edge-hi); }
.stats-chart .stats-axis path,
.stats-chart .stats-axis line {
    stroke: var(--border);
    shape-rendering: crispEdges;
}
.stats-chart .stats-axis text {
    fill: var(--fg-dim);
    font-size: 10px;
}
.stats-chart .stats-axis-label {
    fill: var(--fg-dim);
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
}
.stats-chart .stats-grid line {
    stroke: var(--border);
    stroke-opacity: 0.35;
    shape-rendering: crispEdges;
}
.stats-chart .stats-grid path { stroke: none; }
.stats-caption {
    color: var(--fg-dim);
    font-size: 0.82rem;
    margin-top: 0.7rem;
    line-height: 1.5;
}
.stats-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(22, 27, 34, 0.96);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.55rem;
    color: var(--fg);
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 30;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 80ms ease;
}
.stats-tooltip.visible { opacity: 1; }

/* Inline "fetching" spinner shown next to the RE-ecosystem checkbox while
   the /api/re-ecosystem fetch is in flight. Three small dots pulsing on a
   staggered loop — same pattern the RE-topology report uses for holder-name
   resolution. The spinner is hidden by default; the JS toggles
   .is-loading on the label to reveal it. */
.topbar-toggle .topbar-toggle-spinner {
    display: none;
    margin-left: 4px;
    width: 18px;
    height: 8px;
    background:
        radial-gradient(circle at 3px 4px, currentColor 2px, transparent 2px),
        radial-gradient(circle at 9px 4px, currentColor 2px, transparent 2px),
        radial-gradient(circle at 15px 4px, currentColor 2px, transparent 2px);
    opacity: 0.5;
    animation: topbarToggleSpinner 1s linear infinite;
}
.topbar-toggle.is-loading .topbar-toggle-spinner {
    display: inline-block;
}
@keyframes topbarToggleSpinner {
    0%   { opacity: 0.2; }
    50%  { opacity: 0.9; }
    100% { opacity: 0.2; }
}
@media (prefers-reduced-motion: reduce) {
    .topbar-toggle .topbar-toggle-spinner { animation: none; opacity: 0.6; }
}
