.metric-card {
    min-width: 260px;
}
.left-meta {
    min-width: 220px;
}
@media (max-width: 640px) {
    .metric-card {
        min-width: 0 !important;
        padding: 8px 4px !important;
    }
    .left-meta {
        min-width: 0 !important;
    }
    .left-meta > .ping-jitter-row {
        gap: 0.3em !important;
    }
    .left-meta article {
        min-width: 60px !important;
        padding: 0 1px !important;
    }
    .left-meta h2 {
        font-size: 0.82rem !important;
    }
    .left-meta p {
        font-size: 1.05rem !important;
    }
}

.left-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}
:root {
    font-synthesis: weight;
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/SpaceGrotesk-400.ttf") format("truetype");
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/SpaceGrotesk-500.ttf") format("truetype");
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/SpaceGrotesk-700.ttf") format("truetype");
}

:root {
    --bg: #f1f1f1;
    --panel: #f8f8f8;
    --ink: #262626;
    --muted: #747474;
    --accent: #111111;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", sans-serif;
    color: var(--ink);
    background: var(--bg);
    overflow-x: hidden;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 18px 20px 34px;
    display: grid;
    gap: 14px;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 6px 10px;
}

.brand img {
    display: block;
    height: 54px;
    width: auto;
    object-fit: contain;
}

.title {
    margin: 0;
    font-size: 2rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-weight: 600;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.03fr) minmax(0, 0.97fr);
    gap: 18px;
    align-items: stretch;
}

.left-zone {
    padding: 18px 18px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.meter-wrap {
    display: grid;
    place-items: center;
    margin: 8px 0 4px;
}

.gauge-client-info {
    width: min(100%, 330px);
    margin: 8px auto 0;
    padding: 12px 14px 11px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 246, 246, 0.96));
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    display: grid;
    gap: 2px;
    text-align: center;
    color: var(--muted);
}

.gauge-client-info strong {
    display: block;
    color: var(--ink);
    font-size: 0.94rem;
    font-weight: 600;
}

.gauge-client-info span {
    display: block;
    margin-top: 0;
    font-size: 0.78rem;
}

.gauge-location {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
    color: var(--ink);
    font-size: 0.8rem;
}

.gauge-location-icon {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
    fill: #2a2dd4;
    opacity: 0.85;
    transform: translateY(-0.5px);
}

.gauge-location strong {
    display: inline;
    color: var(--ink);
    font-weight: 600;
    font-size: inherit;
}

.gauge-location-status {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-size: 0.7rem;
    font-style: normal;
}

.gauge-client-info strong#resultToken {
    display: inline;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.78rem;
}

.gauge-client-info a {
    color: inherit;
    text-decoration: none;
}

.gauge-client-info a:hover strong#resultToken {
    text-decoration: underline;
}

.speedometer {
    --needle-angle: -130deg;
    --progress-pct: 0;
    width: min(100%, 460px);
    aspect-ratio: 1;
    height: auto;
    position: relative;
}

.gauge-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.gauge-arc-base,
.gauge-arc-progress {
    fill: none;
    stroke-width: 34;
    stroke-linecap: butt;
}

.gauge-arc-base {
    stroke: #c7c9cd;
}

.gauge-arc-progress {
    stroke: #2a2dd4;
    stroke-dasharray: var(--progress-pct) 100;
    transition: stroke-dasharray 120ms linear;
}

.gauge-needle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 7px;
    height: 82px;
    border-radius: 999px;
    background: linear-gradient(95deg, #3b3b3b 0%, #d0d0d0 75%, #f4f4f4 100%);
    transform-origin: 50% 100%;
    transform: translate(-50%, -100%) rotate(var(--needle-angle));
    transition: transform 120ms linear;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.2);
}

.speedometer.high-speed .gauge-needle {
    box-shadow: 0 0 16px rgba(42, 45, 212, 0.4);
    animation: needlePulse 460ms ease-in-out infinite alternate;
}

.gauge-hub {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 11px;
    height: 11px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid #ececec;
    background: #3b3b3b;
}

.gauge-label {
    position: absolute;
    transform: translate(-50%, -50%);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 400;
    pointer-events: none;
}

.gauge-readout {
    position: absolute;
    left: 50%;
    bottom: 18.5%;
    transform: translateX(-50%);
    text-align: center;
}

.gauge-readout span {
    font-family: "Space Grotesk", sans-serif;
    font-size: 2.35rem;
    line-height: 1;
    font-weight: 400;
}

.gauge-readout small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.72rem;
}

.gauge-readout em {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-style: normal;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}


.left-meta {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}
.left-meta > .ping-jitter-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 1.2em !important;
        align-items: flex-end !important;
        flex-wrap: nowrap !important;
}

@media (max-width: 640px) {
    .left-meta > .ping-jitter-row {
        gap: 0.5em !important;
    }
    .left-meta article {
        min-width: 80px !important;
        padding: 0 2px !important;
    }
    .left-meta h2 {
        font-size: 0.95rem !important;
    }
    .left-meta p {
        font-size: 1.3rem !important;
    }
}
.left-meta #bufferbloatInfo {
    margin-top: 4px;
}
.bufferbloat-desc {
    font-size: 0.85em;
    opacity: 0.7;
    display: block;
    margin-top: 2px;
}

.left-meta article {
    min-width: 110px;
}

.left-meta h2,
.chart-card h2 {
    margin: 0;
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

.left-meta p,
.chart-card p {
    margin: 7px 0 0;
    font-size: 2.1rem;
    font-weight: 400;
    line-height: 1;
}

.left-meta small,
.chart-card small {
    font-size: 0.9rem;
    color: var(--muted);
}

.right-zone {
    display: grid;
    gap: 14px;
    height: 100%;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.chart-card {
    padding: 14px 18px;
    min-height: 206px;
    display: flex;
    flex-direction: column;
}

.metric-card {
    padding: 14px 18px;
    align-self: end;
    min-height: 128px;
}

.metric-card .left-meta {
    justify-content: space-between;
}

.sparkline {
    --wave-stroke: #111111;
    --wave-trail: #2a2a2a;
    --wave-fill: rgba(32, 33, 37, 0.12);
    --wave-head: #0f1012;
    margin-top: 12px;
    height: 110px;
    position: relative;
    overflow: hidden;
    border-top: 1px solid #bdbdbd;
    background:
        linear-gradient(90deg, rgba(31, 31, 31, 0.1) var(--spark, 0%), rgba(31, 31, 31, 0.02) var(--spark, 0%)),
        repeating-linear-gradient(
            90deg,
            rgba(0, 0, 0, 0.045) 0,
            rgba(0, 0, 0, 0.045) 1px,
            transparent 1px,
            transparent 12.5%
        ),
        repeating-linear-gradient(
            180deg,
            rgba(0, 0, 0, 0.028) 0,
            rgba(0, 0, 0, 0.028) 1px,
            transparent 1px,
            transparent 25%
        );
    transition: background 220ms linear;
    flex: 1;
}

#downloadSpark {
    --wave-stroke: #b10f1d;
    --wave-trail: #d14b57;
    --wave-fill: rgba(177, 15, 29, 0.14);
    --wave-head: #8f0c18;
}

#uploadSpark {
    --wave-stroke: #1f3a5f;
    --wave-trail: #3b5f8c;
    --wave-fill: rgba(45, 82, 126, 0.15);
    --wave-head: #274b77;
}

.sparkline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -28%;
    width: 28%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
    opacity: 0;
    pointer-events: none;
}

.sparkline svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.sparkline::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 35%);
    pointer-events: none;
}

.wave-latency {
    position: absolute;
    left: 8px;
    top: 6px;
    z-index: 1;
    color: #202125;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(248, 248, 248, 0.72);
    padding: 1px 5px;
    border-radius: 4px;
}

.sparkline polyline {
    fill: none;
    stroke: var(--wave-stroke);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 220ms ease;
}

.sparkline polyline[id$="Trail"] {
    stroke: var(--wave-trail);
    stroke-width: 1.6;
    opacity: 0.35;
}

.sparkline polygon {
    fill: var(--wave-fill);
}

.sparkline circle[id$="Head"] {
    fill: var(--wave-head);
    opacity: 0;
    transition: r 160ms ease, opacity 200ms ease;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.35));
}

.sparkline[data-wave-state="running"] circle[id$="Head"] {
    opacity: 1;
    animation: wave-head-pulse 900ms ease-in-out infinite;
}

.sparkline[data-wave-state="running"]::before {
    opacity: 0.75;
    animation: wave-scan 1700ms linear infinite;
}

.sparkline[data-wave-state="settle"] circle[id$="Head"] {
    opacity: 0.8;
    animation: none;
}

.sparkline[data-wave-state="settle"]::before {
    opacity: 0.25;
    animation: wave-scan 1000ms ease-out 1;
}

.sparkline[data-wave-state="done"] circle[id$="Head"],
.sparkline[data-wave-state="idle"] circle[id$="Head"] {
    opacity: 0;
    r: 0;
    animation: none;
}

.sparkline[data-wave-state="done"]::before,
.sparkline[data-wave-state="idle"]::before {
    opacity: 0;
    animation: none;
}

@keyframes wave-head-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes wave-scan {
    0% { transform: translateX(0); }
    100% { transform: translateX(460%); }
}

.controls-panel {
    padding: 12px 14px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.controls label {
    color: var(--muted);
    font-size: 0.92rem;
}

select {
    height: 38px;
    border-radius: 8px;
    border: 1px solid #cfcfcf;
    background: #fff;
    padding: 0 10px;
    font-family: inherit;
    font-size: 0.9rem;
}

button {
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    border: 1px solid #1f1f1f;
    background: var(--accent);
    color: #fff;
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-secondary {
    border: 1px solid #c7c7c7;
    background: #efefef;
    color: #232323;
}

.phase {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.result-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.result-card {
    width: min(920px, 100%);
    padding: 22px;
}

.result-header-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.result-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.result-head img {
    height: 44px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.result-eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.result-head h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.result-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.result-meta > div,
.result-stat {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 12px;
}

.result-meta span,
.result-stat span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-meta strong,
.result-stat strong {
    display: block;
    font-size: 0.96rem;
    font-weight: 600;
    color: var(--ink);
    word-break: break-word;
}

.result-gps-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.result-gps-line {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    color: var(--ink);
}

.result-gps-line strong,
.result-gps-line span {
    display: inline;
    margin: 0;
    font-size: 0.96rem;
}

.result-gps-card small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    word-break: break-word;
}

.gps-link {
    color: inherit;
    text-decoration: none;
}

.gps-link:hover strong {
    text-decoration: underline;
}

.gps-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    color: var(--ink);
    font-size: 0.86rem;
}

.gps-row strong {
    font-weight: 600;
}

.gps-sep {
    color: var(--muted);
}

.result-stat small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    word-break: break-word;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.result-wave-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.result-wave-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-wave-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.result-wave-head span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-wave-head strong {
    display: block;
    color: var(--ink);
    font-size: 0.96rem;
    font-weight: 600;
}

.result-wave-head small {
    color: var(--muted);
    font-size: 0.76rem;
    text-align: right;
    white-space: nowrap;
}

.result-wave-card[data-wave-empty="true"] .result-wave-head strong,
.result-wave-card[data-wave-empty="true"] .result-wave-head small {
    opacity: 0.7;
}

.result-wave-chart {
    position: relative;
    overflow: hidden;
    height: 118px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 247, 247, 0.98));
}

.result-wave-chart svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.result-wave-chart polygon {
    fill: rgba(32, 33, 37, 0.1);
}

.result-wave-chart polyline {
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#downloadWaveCard {
    --wave-color: #b10f1d;
    --wave-color-soft: rgba(177, 15, 29, 0.12);
}

#uploadWaveCard {
    --wave-color: #1f3a5f;
    --wave-color-soft: rgba(45, 82, 126, 0.12);
}

#downloadWaveCard .result-wave-chart polygon {
    fill: var(--wave-color-soft);
}

#uploadWaveCard .result-wave-chart polygon {
    fill: var(--wave-color-soft);
}

#downloadWaveCard .result-wave-chart polyline {
    stroke: var(--wave-color);
}

#uploadWaveCard .result-wave-chart polyline {
    stroke: var(--wave-color);
}

.result-foot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.result-foot p {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.2;
}

.result-created-foot {
    text-align: right;
}

.result-created-foot span {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-created-foot strong {
    display: block;
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 600;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes needlePulse {
    from {
        opacity: 0.82;
    }
    to {
        opacity: 1;
    }
}

@media (min-width: 900px) {
    .container {
        padding-top: 20px;
    }
}

@media (max-width: 980px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .speedometer {
        width: min(100%, 560px);
    }
}

@media (max-width: 640px) {
    .topbar {
        display: block;
    }

    .title {
        margin-top: 10px;
        font-size: 1.45rem;
    }

    .result-page {
        padding: 16px;
    }

    .result-card {
        padding: 16px;
    }

    .result-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-meta {
        grid-template-columns: 1fr;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .result-wave-grid {
        grid-template-columns: 1fr;
    }

    .speedometer {
        height: 292px;
    }

    .gauge-needle {
        width: 5px;
        height: 68px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    }

    .gauge-hub {
        width: 9px;
        height: 9px;
    }

    .gauge-label {
        font-size: 0.8rem;
    }

    .gauge-readout span {
        font-size: 2.1rem;
    }

    .gauge-readout small {
        font-size: 1rem;
    }

    .left-meta h2,
    .chart-card h2 {
        font-size: 1.1rem;
    }

    .left-meta p,
    .chart-card p {
        font-size: 2.35rem;
    }

    .left-meta small,
    .chart-card small {
        font-size: 1.25rem;
    }
}
