/* R&E Ark Mesh Explorer */

:root {
    --bg: #f8fafc;
    --fg: #0f172a;
    --muted: #64748b;
    --panel-bg: #ffffff;
    --border: #e2e8f0;
    --ocean: #eef4fb;
    --land: #dce8d8;
    --land-border: #b8c9b2;
    --marker: #2563eb;
    --marker-stroke: #ffffff;
    --marker-selected: #f59e0b;
    --arc-reached: #2563eb;
    --arc-stopped: #d97706;
    --arc-noresp: #dc2626;
    --arc-notrace: #94a3b8;
    --accent: #2563eb;
    --chip-bg: #f1f5f9;
    --row-hover: #f1f5f9;
    --pinned-bg: #fef3c7;
    --diverge-bg: #fee2e2;
    --diverge-fg: #b91c1c;
    --diverge-row: rgba(220, 38, 38, 0.07);
    --suspect-row: rgba(245, 158, 11, 0.12);
    --lane-ret: #9333ea;
    --t1: #db2777;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --fg: #e2e8f0;
        --muted: #94a3b8;
        --panel-bg: #101a2e;
        --border: #1e293b;
        --ocean: #0b1220;
        --land: #1d2a23;
        --land-border: #2d4034;
        --marker: #60a5fa;
        --marker-stroke: #0b1220;
        --marker-selected: #fbbf24;
        --arc-reached: #60a5fa;
        --arc-stopped: #f59e0b;
        --arc-noresp: #f87171;
        --arc-notrace: #475569;
        --accent: #60a5fa;
        --chip-bg: #1e293b;
        --row-hover: #17233a;
        --pinned-bg: #3b3416;
        --diverge-bg: #4c1d1d;
        --diverge-fg: #fca5a5;
        --diverge-row: rgba(248, 113, 113, 0.1);
        --suspect-row: rgba(245, 158, 11, 0.16);
        --lane-ret: #c084fc;
        --t1: #f472b6;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }
}

* {
    box-sizing: border-box;
}

/* The hidden attribute must always win, even over display:flex rules. */
[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
        Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    display: flex;
    flex-direction: column;
}

/* --- topbar ------------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel-bg);
    flex-wrap: wrap;
}

.topbar h1 {
    font-size: 18px;
    margin: 0;
}

.home-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}

.home-link:hover {
    color: var(--accent);
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
}

/* Measurement-run date picker: the run to view, most recent by default. */
.run-picker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-left: auto; /* carries the auto margin for the right-hand controls */
}

.run-label {
    font-weight: 600;
    white-space: nowrap;
}

.run-date {
    font: inherit;
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-bg);
    color: var(--fg);
}

.run-date:disabled {
    opacity: 0.5;
}

.run-latest {
    font: inherit;
    font-size: 12px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.run-latest:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
}

.run-latest:disabled {
    opacity: 0.5;
    cursor: default;
}

.run-picker.historical .run-date {
    border-color: var(--marker-selected);
}

.size-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.size-toggle ~ .report-btn {
    margin-left: 0; /* the picker carries the auto margin */
}

.legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    color: var(--muted);
    z-index: 10;
}

.legend-scale {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.legend-size {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    display: inline-block;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.75;
}

.legend-end {
    color: var(--muted);
}

.meta-line {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.data-sources-btn {
    font-size: 12px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.data-sources-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* --- stage / map --------------------------------------------------------- */

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.map-wrap {
    position: absolute;
    inset: 0;
}

#map {
    width: 100%;
    height: 100%;
    display: block;
}

#map .ocean {
    fill: var(--ocean);
}

#map .country {
    fill: var(--land);
    stroke: var(--land-border);
    stroke-width: 0.5px;
    vector-effect: non-scaling-stroke;
}

#map .node-dot {
    fill: var(--marker);
    stroke: var(--marker-stroke);
    cursor: pointer;
}

#map .node-dot.selected {
    fill: var(--marker-selected);
    stroke: var(--fg);
}

#map .node-label {
    fill: var(--fg);
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 2.5px;
    stroke-opacity: 0.75;
    pointer-events: none;
    font-weight: 500;
}

.tooltip {
    position: absolute;
    max-width: 240px;
    background: var(--panel-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    white-space: pre-line;
    pointer-events: none;
    box-shadow: var(--shadow);
    z-index: 20;
}

.loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--muted);
    background: var(--bg);
    z-index: 30;
}

.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    box-shadow: var(--shadow);
    z-index: 60; /* above the pair/sankey overlays (50) */
}

/* --- shared overlay chrome ------------------------------------------------- */

/* The × button used by every overlay card (the name predates the
   removal of the side panel). */
.panel-close {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.panel-close:hover {
    color: var(--fg);
    border-color: var(--accent);
}

.chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    background: var(--chip-bg);
    color: var(--muted);
    white-space: nowrap;
}

.chip-stopped_short {
    color: var(--arc-stopped);
}

.chip-no_response {
    color: var(--arc-noresp);
}

.chip-no_trace {
    color: var(--arc-notrace);
}

.chip-reached {
    color: var(--arc-reached);
}

.chip-gap {
    color: var(--arc-stopped);
}

.expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.expand-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.sankey-card {
    width: min(1240px, calc(100vw - 32px));
}

.sankey-scroll {
    overflow: auto;
    max-height: calc(100vh - 230px);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.sankey-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* Live readout for the hovered strand (replaces the delayed native
   tooltip). Fixed two-line height so the graph below never jumps. */
.sankey-hover {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 60px;
    margin: 4px 0 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
    transition: border-color 220ms ease, box-shadow 220ms ease;
}

.sankey-hover.live {
    color: var(--fg);
    border-color: var(--accent);
    background: var(--chip-bg);
}

.sankey-hover .hover-main {
    font-weight: 600;
}

/* Strong delay asymmetry: the whole readout takes the alert colour. */
.sankey-hover.live.alert {
    border-color: var(--arc-noresp);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}

/* Delay-asymmetry gauge: centre mark, fill grows toward the slower leg's
   side; width and colour animate between hovers so the change is seen. */
.hover-asym {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
    font-size: 11px;
    color: var(--muted);
}

.hover-asym-side {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
}

.hover-asym-track {
    position: relative;
    width: 180px;
    height: 10px;
    border-radius: 5px;
    background: var(--chip-bg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.hover-asym-mark {
    position: absolute;
    left: 50%;
    top: -2px;
    bottom: -2px;
    width: 2px;
    margin-left: -1px;
    background: var(--muted);
}

.hover-asym-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--arc-notrace);
    transition: width 220ms ease, background-color 220ms ease;
}

.hover-asym-fill.to-left {
    right: 50%;
    border-radius: 5px 0 0 5px;
}

.hover-asym-fill.to-right {
    left: 50%;
    border-radius: 0 5px 5px 0;
}

.hover-asym-badge {
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 9px;
    background: var(--chip-bg);
    color: var(--muted);
    transition: background-color 220ms ease, color 220ms ease;
}

.hover-asym.level-mild .hover-asym-fill,
.hover-asym.level-mild .hover-asym-badge {
    background: var(--arc-stopped);
    color: #fff;
}

.hover-asym.level-strong .hover-asym-fill,
.hover-asym.level-strong .hover-asym-badge {
    background: var(--arc-noresp);
    color: #fff;
}

/* A short pulse each time a strongly asymmetric strand is hovered (the
   badge is rebuilt per hover, so the animation restarts). */
.hover-asym.level-strong .hover-asym-badge {
    animation: asym-pulse 600ms ease-out 1;
}

@keyframes asym-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
    60% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .hover-asym.level-strong .hover-asym-badge {
        animation: none;
    }

    .hover-asym-fill,
    .hover-asym-badge {
        transition: none;
    }
}

.sankey-hover .hover-sub,
.sankey-hover .hover-rtt {
    color: var(--muted);
    font-weight: 400;
}

.sankey-strand.clickable {
    cursor: pointer;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* "Color strands by" toggle in the flow header */
.mode-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-right: 6px;
}

.mode-btn[aria-pressed="true"] {
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

.header-note {
    font-size: 12px;
    color: var(--muted);
}

.back-btn {
    position: absolute;
    top: -4px;
    right: 34px;
}

.ribbon-traces {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}

.ribbon-trace {
    border: 1px solid var(--border);
    border-radius: 6px;
}

.ribbon-trace summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
}

.ribbon-trace summary::before {
    content: "▸";
    color: var(--muted);
    font-size: 11px;
}

.ribbon-trace[open] summary::before {
    content: "▾";
}

.ribbon-trace[open] summary {
    border-bottom: 1px solid var(--border);
}

.ribbon-trace .pair-direction {
    padding: 10px;
}

.ribbon-city {
    color: var(--muted);
    font-size: 12px;
}

.sankey-header {
    fill: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sankey-node {
    fill: var(--arc-notrace);
    cursor: pointer;
}

.sankey-node.depth-0 {
    fill: var(--marker-selected);
}

/* Tier 1 transit providers stand out at any depth. */
.sankey-node.t1 {
    fill: var(--t1);
}

.sankey-node:hover,
.sankey-node.pinned {
    stroke: var(--fg);
    stroke-width: 1.5px;
}

.sankey-strand {
    /* Fallback for strands without RTT data; strands with data get an
       inline green->red fill from rttColor(). */
    fill: var(--arc-notrace);
    fill-opacity: 0.55;
}

/* Delay-asymmetry color mode: a pair whose one-way delays are below the
   fibre floor (clock offset) gets a dashed outline. */
.sankey-strand.clock-suspect {
    stroke: #b45309;
    stroke-width: 1;
    stroke-dasharray: 3 2;
}

.sankey-strand.active {
    fill-opacity: 0.95;
}

.sankey-strand.dimmed {
    fill-opacity: 0.12;
}

.sankey-rtt-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 2px;
    font-size: 11px;
    color: var(--muted);
}

.sankey-rtt-bar {
    width: 90px;
    height: 8px;
    border-radius: 2px;
}

.sankey-rtt-end {
    white-space: nowrap;
}

.sankey-label {
    fill: var(--fg);
    font-size: 10px;
    pointer-events: none;
}

.sankey-label.t1 {
    fill: var(--t1);
    font-weight: 700;
}

.t1-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--t1);
}

.as-table,
.hop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.as-table th,
.hop-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 5px 6px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.hop-table th {
    cursor: default;
}

.as-table td,
.hop-table td {
    padding: 5px 6px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.as-table tbody tr {
    cursor: pointer;
}

.as-table tbody tr:hover {
    background: var(--row-hover);
}

.as-table tbody tr.pinned {
    background: var(--pinned-bg);
}

.cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-as {
    font-weight: 600;
    white-space: nowrap;
}

.cell-holder {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-ip,
.cell-ptr {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    word-break: break-all;
}

.unmapped {
    color: var(--muted);
}

/* --- pair view -------------------------------------------------------------- */

.pair-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.pair-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
}

.pair-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1040px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.pair-header {
    position: relative;
    padding-right: 30px;
    margin-bottom: 10px;
}

.pair-title {
    margin: 0 0 2px;
    font-size: 18px;
}

.pair-sub {
    font-size: 13px;
    color: var(--muted);
}

.pair-note {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--chip-bg);
    color: var(--muted);
}

.pair-note-ok {
    color: #16a34a;
}

.pair-note-asym {
    color: var(--arc-stopped);
}

.pair-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.pair-caption {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 14px;
}

.pair-route {
    font-weight: 600;
}

.pair-rtt {
    color: var(--muted);
    font-size: 12px;
}

/* this leg's one-way delay in the direction caption */
.pair-owd-leg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
}

.pair-owd-leg .pair-owd-ms {
    color: var(--fg);
}

.pair-owd-slower {
    color: var(--arc-stopped);
    font-weight: 600;
}

.pair-gap-warn {
    font-size: 12px;
    color: var(--arc-stopped);
    margin: 0 0 6px;
}

.pair-empty {
    font-size: 13px;
    color: var(--muted);
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 6px;
}

.hop-table tr.as-change td {
    border-top: 2px solid var(--accent);
}

.as-path-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.as-path-chip {
    background: var(--chip-bg);
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.as-path-chip.diverge {
    background: var(--diverge-bg);
    color: var(--diverge-fg);
}

.as-path-chip.restored {
    outline: 1.5px dashed var(--arc-stopped);
    outline-offset: -1px;
}

.as-path-chip.assumed {
    outline: 1.5px dotted var(--muted);
    outline-offset: -1px;
    color: var(--muted);
}

.as-path-chips.inline {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

.diverge-none {
    color: var(--muted);
    font-style: italic;
}

.pair-note-diverge {
    display: block;
    margin-top: 6px;
    line-height: 1.9;
}

.hop-table tr.hop-diverge td {
    background: var(--diverge-row);
}

.hop-table tr.hop-suspect td {
    background: var(--suspect-row);
}

.chip-suspect {
    color: var(--arc-stopped);
    margin-left: 6px;
}

.pair-suspect-note {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 6px;
}

.chip-link {
    font: inherit;
    font-size: 11px;
    border: none;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

.howto-link {
    display: inline-block;
    background: none;
    border: none;
    padding: 0;
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

/* --- "How to read this page" guide --------------------------------------- */

.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 70; /* above the pair/sankey overlays (50) and toasts (60) */
}

.help-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 22px;
    box-shadow: var(--shadow);
}

.help-body h3 {
    margin: 0 24px 8px 0;
    font-size: 17px;
}

.help-body h4 {
    margin: 16px 0 4px;
    font-size: 14px;
    scroll-margin-top: 12px;
}

.help-body p,
.help-body li {
    font-size: 13px;
    line-height: 1.55;
    color: var(--fg);
}

.help-body ol {
    padding-left: 22px;
    margin: 6px 0;
}

.help-body li {
    margin-bottom: 6px;
}

.help-body code {
    background: var(--chip-bg);
    border-radius: 4px;
    padding: 0 4px;
    font-size: 12px;
}

.help-body .th-flash {
    background: var(--pinned-bg);
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: -6px;
}

/* --- path-diff graph ---------------------------------------------------------- */

.path-diff-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px 2px;
    margin: 10px 0;
}

.path-diff-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 11px;
    color: var(--muted);
}

.path-diff-key {
    display: inline-flex;
    align-items: center;
}

.pd-key {
    display: inline-block;
    width: 16px;
    height: 3px;
    border-radius: 2px;
    margin-right: 5px;
}

.pd-key-out {
    background: var(--accent);
}

.pd-key-ret {
    background: var(--lane-ret);
}

.pd-key-both {
    background: var(--arc-notrace);
}

.path-diff-orient {
    margin-left: auto;
    font-style: italic;
}

.pd-link {
    fill: none;
    stroke-width: 2;
}

.pd-link.pd-both {
    stroke: var(--arc-notrace);
}

.pd-link.pd-out {
    stroke: var(--accent);
}

.pd-link.pd-ret {
    stroke: var(--lane-ret);
}

.pd-box {
    stroke-width: 1.2;
}

.pd-box-common {
    fill: var(--chip-bg);
    stroke: var(--border);
}

.pd-box-restored {
    stroke: var(--arc-stopped);
    stroke-dasharray: 5 3;
}

.pd-box-assumed {
    stroke: var(--muted);
    stroke-dasharray: 2 3;
}

.pd-box-out {
    fill: var(--diverge-bg);
    stroke: var(--accent);
}

.pd-box-ret {
    fill: var(--diverge-bg);
    stroke: var(--lane-ret);
}

.pd-label {
    fill: var(--fg);
    font-size: 11px;
    font-weight: 600;
}

/* one-way delay captions above the outbound lane / below the return lane */
.pd-owd {
    font-size: 11px;
}

.pd-owd-outbound {
    fill: var(--accent);
}

.pd-owd-return {
    fill: var(--lane-ret);
}

.pd-owd-value {
    font-weight: 600;
}

.pd-owd-slow {
    fill: var(--arc-stopped);
    font-weight: 600;
}

.pd-owd-muted {
    fill: var(--muted);
    font-style: italic;
}

.pd-name {
    fill: var(--muted);
    font-size: 9px;
}

.pd-arrow-tail {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.pd-arrow-out .pd-arrow-tail {
    stroke: var(--accent);
}

.pd-arrow-out .pd-arrow-head {
    fill: var(--accent);
}

.pd-arrow-ret .pd-arrow-tail {
    stroke: var(--lane-ret);
}

.pd-arrow-ret .pd-arrow-head {
    fill: var(--lane-ret);
}

.pd-end {
    fill: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.pd-end-city {
    font-weight: 400;
}

.as-path-sep {
    color: var(--muted);
    font-size: 11px;
}

/* --- focus + mobile ----------------------------------------------------------- */

button:focus-visible,
th:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --- one-way delay report ------------------------------------------------- */

.report-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto; /* pushes the right-hand controls to the edge */
    font-size: 12px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
}

.report-btn:hover,
.report-btn:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
}

.report-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.report-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.report-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-left: auto;
}

.report-filter input {
    font: inherit;
    font-size: 13px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-bg);
    color: inherit;
    min-width: 160px;
}

.report-count {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.report-scroll {
    max-height: calc(100vh - 300px);
}

.report-table th[aria-sort] {
    color: var(--accent);
}

/* Numeric headers sit over right-aligned numbers (the base table style
   left-aligns every header). */
.report-table th.cell-num {
    text-align: right;
}

.report-table td {
    vertical-align: middle;
}

.report-table td.cell-pair {
    width: 40%;
}

.report-pair {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.report-cities {
    font-size: 11px;
    color: var(--muted);
}

.cell-delta {
    font-weight: 600;
}

/* AS path asymmetry report: the pair detail's path-diff graph, compact, on
   three labelled tracks (outbound / both / return). Split-track boxes get a
   heavy outline and bold label so the difference reads without colour. */
.report-table td.cell-strip {
    min-width: 320px;
    overflow-x: auto;
}

.path-diff-mini {
    display: block;
    max-width: 100%;
}

.path-diff-mini .pd-link {
    stroke-width: 1.5;
}

.pdm-label {
    font-size: 10px;
}

.pdm-label.pdm-diff {
    font-weight: 700;
}

.path-diff-mini .pd-box-out,
.path-diff-mini .pd-box-ret {
    stroke-width: 2;
}

.pdm-end {
    font-size: 13px;
}

.pdm-end-city {
    font-size: 10px;
}

.pdm-track {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    fill: var(--muted);
}

.pdm-track-out {
    fill: var(--accent);
}

.pdm-track-ret {
    fill: var(--lane-ret);
}

/* the slower leg (by one-way delay): its track label is bold and amber */
.pdm-track.slow {
    fill: var(--arc-stopped);
    font-weight: 700;
}

/* --- asymmetry report: multi-sort headers, delay bars, RTT/geo -------------- */

.report-sort-hint {
    margin: 0 0 6px;
    font-size: 11px;
    color: var(--muted);
}

.report-table th .th-sort,
.report-table th .sort-handle {
    all: unset;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.report-table th.multi-sort {
    cursor: default;
}

.report-table th .th-label {
    display: block;
}

.report-table th .sort-handles {
    display: inline-flex;
    gap: 4px;
    margin-top: 3px;
    text-transform: none;
    letter-spacing: 0;
}

.report-table th .sort-handle {
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 10px;
    color: var(--muted);
}

.report-table th .sort-handle:hover,
.report-table th .th-sort:hover {
    color: var(--accent);
}

/* active sort keys: arrow + priority badge */
.report-table th [data-sort-dir="asc"]::after { content: " \25B4"; }
.report-table th [data-sort-dir="desc"]::after { content: " \25BE"; }

.report-table th [data-sort-rank] {
    color: var(--accent);
    border-color: var(--accent);
}

.report-table th [data-sort-rank]::before {
    content: attr(data-sort-rank);
    display: inline-block;
    min-width: 13px;
    margin-right: 3px;
    padding: 0 3px;
    border-radius: 7px;
    background: var(--chip-bg);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 13px;
    text-align: center;
}

.report-table th [data-sort-rank="1"]::before {
    background: var(--accent);
    color: #fff;
}

.report-table td.cell-state {
    white-space: nowrap;
}

.state-count {
    font-weight: 700;
    font-size: 14px;
}

.state-unit {
    margin-left: 3px;
    font-size: 10px;
    color: var(--muted);
}

.chip-sym-asym {
    color: var(--arc-stopped);
}

.chip-sym-sym {
    color: var(--arc-reached);
}

/* one-way delay bars: outbound over return on one scale, Δ beneath */
.report-table td.cell-delay {
    min-width: 200px;
}

.delay-bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
}

.delay-bar {
    display: grid;
    grid-template-columns: 30px 1fr 52px;
    align-items: center;
    gap: 6px;
}

.delay-bar-leg {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.delay-bar-out .delay-bar-leg {
    color: var(--accent);
}

.delay-bar-ret .delay-bar-leg {
    color: var(--lane-ret);
}

.delay-bar-track {
    display: block;
    height: 8px;
    border-radius: 4px;
    background: var(--chip-bg);
    overflow: hidden;
}

.delay-bar-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: var(--arc-notrace);
}

.delay-bar-out .delay-bar-fill {
    background: var(--accent);
}

.delay-bar-ret .delay-bar-fill {
    background: var(--lane-ret);
}

.delay-bar.slow .delay-bar-fill {
    background: var(--arc-stopped);
}

.delay-bar-ms {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.delay-bar.slow .delay-bar-ms {
    color: var(--arc-stopped);
    font-weight: 700;
}

.delay-delta {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-left: 36px;
}

.delay-delta-label {
    color: var(--muted);
    font-weight: 700;
}

.delay-delta-ms {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.delay-delta-none,
.delay-none {
    color: var(--muted);
    font-style: italic;
}

/* RTT over geo min */
.report-table td.cell-rttgeo {
    white-space: nowrap;
}

.rg-line {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.rg-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    align-self: center;
}

.rg-geo .rg-value {
    color: var(--muted);
}

.pdm-note {
    font-size: 10px;
    font-style: italic;
    fill: var(--muted);
}

.strip-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 8px 0 0;
    font-size: 11px;
    color: var(--muted);
}

.strip-legend-lead {
    font-weight: 600;
}

.strip-key {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.report-table tbody tr.implausible td {
    color: var(--muted);
}

.report-table tbody tr:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.chip-implausible {
    color: var(--arc-stopped);
}

/* "only pairs involving <node>" scope toggle (both reports): on = the
   VP's pairs only, off = every pair. */
.chip-scope {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
    color: var(--muted);
}

.chip-scope i {
    font-size: 14px;
}

.chip-scope.on {
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

.chip-scope:hover {
    color: var(--fg);
}

.chip-clock.on {
    color: var(--arc-stopped);
    border-color: var(--arc-stopped);
}

/* one-way delay summary line at the top of a pair detail */
.pair-owd {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
}

.pair-owd-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.pair-owd-route {
    color: var(--muted);
}

.pair-owd-ms {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.pair-owd-dir.slow .pair-owd-ms {
    color: var(--arc-stopped);
}

.pair-owd-sep,
.pair-owd-none {
    color: var(--muted);
}

@media (max-width: 720px) {
    .topbar {
        gap: 8px;
    }

    .report-filter {
        margin-left: 0;
        width: 100%;
    }

    .report-filter input {
        flex: 1;
    }

    .subtitle,
    .meta-line {
        display: none;
    }

    .pair-columns {
        grid-template-columns: 1fr;
    }
}
