/* ==========================================================
   NETWORK QUALITY ANALYZER — instrumentation aesthetic
   Palette: deep navy + phosphor green + signal amber + alert red
   ========================================================== */

:root {
    --bg-0: #060a14;
    --bg-1: #0c1322;
    --bg-2: #131c30;
    --bg-3: #1a2540;
    --line: #34466b;
    --line-2: #4d6090;
    --ink-0: #ffffff;
    --ink-1: #f1f5fc;     /* main body text — near-white */
    --ink-2: #c8d2eb;     /* secondary labels — clearly readable */
    --ink-3: #94a3c4;     /* tertiary, e.g. timestamps — still legible */
    --phosphor: #6effa8;
    --phosphor-dim: #22c55e;
    --signal: #fde047;
    --signal-dim: #d97706;
    --alert: #ff7b8e;
    --alert-dim: #e11d48;
    --cyan: #7dd3fc;
    --magenta: #f0abfc;
    --grid-color: rgba(110, 255, 168, 0.06);

    --font-mono: ui-monospace, 'Cascadia Code', 'Consolas', monospace, 'SF Mono', Menlo, Consolas, monospace;
    --font-display: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif, system-ui, sans-serif;

    --shadow-glow: 0 0 24px rgba(93, 255, 160, 0.2);
    --shadow-deep: 0 8px 32px rgba(0, 0, 0, 0.6);
}

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

html, body {
    background: var(--bg-0);
    color: var(--ink-0);
    font-family: var(--font-mono);
    font-size: 14px;     /* was 13px — bumped base */
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background: subtle grid + noise */
.grid-bg {
    position: fixed; inset: 0; z-index: 0;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}
.grid-bg::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at top, transparent 0%, var(--bg-0) 80%);
}
.noise {
    position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============== TOP BAR ============== */
.topbar {
    position: relative; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 16px;
    max-width: 1800px;
    margin: 0 auto;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(10,15,26,0.95), rgba(10,15,26,0.7));
    backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo-mark {
    color: var(--phosphor);
    filter: drop-shadow(0 0 6px rgba(74,222,128,0.5));
    animation: pulse-glow 3s ease-in-out infinite;
}
@keyframes pulse-glow {
    50% { filter: drop-shadow(0 0 12px rgba(74,222,128,0.9)); }
}
.brand-text h1 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--ink-0);
}
.brand-text p {
    font-size: 12px;
    color: var(--ink-2);
    letter-spacing: 0.05em;
    margin-top: 3px;
    font-weight: 500;
}

.status-cluster { display: flex; align-items: center; gap: 16px; }
.status-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 16px;
    border: 1px solid var(--line-2);
    background: var(--bg-2);
    font-size: 12px;
    letter-spacing: 0.13em;
    font-weight: 700;
}
.status-pill .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ink-2);
    box-shadow: 0 0 6px currentColor;
}
.status-pill.running .dot { background: var(--phosphor); animation: blink 0.8s infinite; }
.status-pill.running { color: var(--phosphor); border-color: var(--phosphor-dim); }
.status-pill.error .dot { background: var(--alert); }
.status-pill.error { color: var(--alert); border-color: var(--alert-dim); }
.status-pill.done .dot { background: var(--cyan); }
.status-pill.done { color: var(--cyan); border-color: var(--cyan); }
@keyframes blink { 50% { opacity: 0.3; } }

.time-readout {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--phosphor);
    letter-spacing: 0.1em;
    padding: 7px 14px;
    border: 1px solid var(--line-2);
    background: var(--bg-1);
    font-weight: 600;
}

/* ============== LAYOUT ============== */
.layout {
    position: relative; z-index: 5;
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-areas:
        "control live"
        "control capacity"
        "breakpoint breakpoint"
        "bloatfree bloatfree"
        "stepped stepped"
        "voip voip"
        "log log";
    gap: 16px;
    padding: 16px;
    max-width: 1800px;
    margin: 0 auto;
}
.panel-control { grid-area: control; }
.panel-live { grid-area: live; }
.panel-capacity { grid-area: capacity; }
.panel-breakpoint { grid-area: breakpoint; }
.panel-bloatfree { grid-area: bloatfree; }
.panel-stepped { grid-area: stepped; }
.panel-voip { grid-area: voip; }
.panel-log { grid-area: log; }

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "control" "live" "capacity" "breakpoint" "bloatfree" "stepped" "voip" "log";
    }
}

/* ============== PANELS ============== */
.panel {
    background: var(--bg-1);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}
.panel::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--phosphor-dim), transparent);
    opacity: 0.4;
}

.panel-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-2);
}
.panel-tag {
    font-size: 12px;
    color: var(--phosphor);
    background: rgba(93,255,160,0.12);
    padding: 3px 9px;
    border: 1px solid var(--phosphor-dim);
    letter-spacing: 0.1em;
    font-weight: 700;
}
.panel-head h2 {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--ink-0);
    flex: 1;
}

/* ============== CONTROL PANEL ============== */
.control-grid { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.setting label {
    display: block;
    font-size: 12px;
    color: var(--ink-1);
    letter-spacing: 0.12em;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-weight: 600;
}
.seg {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    gap: 4px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    padding: 3px;
}
.seg button {
    background: transparent;
    border: none;
    color: var(--ink-1);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.05em;
}
.seg button:hover { background: var(--bg-3); color: var(--ink-0); }
.seg button.active {
    background: var(--phosphor-dim);
    color: var(--bg-0);
    font-weight: 700;
    box-shadow: 0 0 12px rgba(74,222,128,0.4);
}

.run-btn {
    margin: 6px 18px 18px;
    position: relative;
    background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
    border: 1px solid var(--phosphor-dim);
    color: var(--phosphor);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.16em;
    padding: 18px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
}
.run-btn:hover:not(:disabled) {
    background: var(--phosphor-dim);
    color: var(--bg-0);
    box-shadow: 0 0 32px rgba(74,222,128,0.4);
}
.run-btn:disabled {
    opacity: 0.5; cursor: not-allowed; border-color: var(--line-2); color: var(--ink-2);
}
.run-btn-inner { display: flex; align-items: center; justify-content: center; gap: 10px; position: relative; z-index: 2; }
.run-btn-arrow { font-size: 10px; }
.run-btn-glow {
    position: absolute; inset: 0;
    background: radial-gradient(circle, rgba(74,222,128,0.3), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}
.run-btn:hover:not(:disabled) .run-btn-glow { opacity: 1; }

/* Phase indicator */
.phase-indicator {
    margin: 0 18px 18px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}
.phase {
    display: flex; flex-direction: column; align-items: center;
    padding: 10px 4px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    transition: all 0.3s;
}
.phase-num {
    font-size: 13px;
    color: var(--ink-1);
    font-weight: 700;
    margin-bottom: 4px;
}
.phase-name {
    font-size: 11px;
    color: var(--ink-1);
    letter-spacing: 0.08em;
    text-align: center;
    font-weight: 500;
}
.phase.active {
    background: rgba(74,222,128,0.1);
    border-color: var(--phosphor);
    box-shadow: 0 0 12px rgba(74,222,128,0.3);
}
.phase.active .phase-num { color: var(--phosphor); }
.phase.active .phase-name { color: var(--phosphor); }
.phase.done {
    border-color: var(--cyan);
    background: rgba(34,211,238,0.05);
}
.phase.done .phase-num { color: var(--cyan); }
.phase.done .phase-num::before { content: '✓ '; }

/* ============== LIVE TELEMETRY ============== */
.live-indicator {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--ink-3);
}
.live-indicator.active {
    background: var(--alert);
    animation: live-pulse 1.2s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(244,63,94,0); }
}

.readout-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line);
    border-bottom: 1px solid var(--line);
}
@media (max-width: 1100px) {
    .readout-grid { grid-template-columns: repeat(2, 1fr); }
}
.readout {
    background: var(--bg-1);
    padding: 14px 16px;
}
.readout-label {
    font-size: 12px;
    color: var(--ink-1);
    letter-spacing: 0.15em;
    margin-bottom: 8px;
    font-weight: 600;
}
.readout-value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 800;
    color: var(--phosphor);
    line-height: 1;
    letter-spacing: -0.02em;
}
.readout-value-text {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--signal);
    line-height: 1;
    letter-spacing: 0.1em;
    padding: 6px 0;
}
.readout-value .unit {
    font-size: 12px;
    color: var(--ink-2);
    margin-left: 5px;
    font-weight: 500;
    letter-spacing: 0.08em;
}
.readout-bar {
    margin-top: 10px;
    height: 3px;
    background: var(--bg-3);
    overflow: hidden;
    position: relative;
}
.readout-bar-fill {
    height: 100%;
    background: var(--phosphor);
    width: 0%;
    transition: width 0.2s ease;
    box-shadow: 0 0 6px var(--phosphor);
}

.panel-live { display: flex; flex-direction: column; }
.live-chart-wrap {
    padding: 16px;
    position: relative;
    flex: 1 1 auto;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}
.chart-axis-label {
    position: absolute;
    bottom: 6px; left: 50%; transform: translateX(-50%);
    font-size: 12px; color: var(--ink-1);
    letter-spacing: 0.1em;
    font-weight: 500;
}
#liveChart {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: block;
}

/* ============== CAPACITY ============== */
.capacity-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line);
}
.cap-stat {
    background: var(--bg-1);
    padding: 22px 18px;
    text-align: center;
    position: relative;
}
.cap-label {
    font-size: 12px;
    color: var(--ink-1);
    letter-spacing: 0.15em;
    margin-bottom: 10px;
    font-weight: 600;
}
.cap-val {
    font-family: var(--font-mono);
    font-size: 42px;
    font-weight: 800;
    color: var(--ink-0);
    line-height: 1;
    letter-spacing: -0.03em;
}
.cap-stat:nth-child(1) .cap-val { color: var(--cyan); }
.cap-stat:nth-child(2) .cap-val { color: var(--magenta); }
.cap-stat:nth-child(3) .cap-val { color: var(--phosphor); }
.cap-stat:nth-child(4) .cap-val { color: var(--signal); }
.cap-unit {
    font-size: 13px;
    color: var(--ink-2);
    margin-top: 8px;
    letter-spacing: 0.15em;
    font-weight: 500;
}
.cap-meta {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line-2);
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
}
.cap-meta-item { font-size: 12.5px; }
.cap-meta-label {
    color: var(--ink-3);
    letter-spacing: 0.12em;
    font-weight: 600;
    margin-right: 6px;
}
.cap-meta-val {
    color: var(--cyan);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ============== BREAKPOINTS ============== */
.break-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--line);
}
.break-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1100px) {
    .break-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
.break-card {
    background: var(--bg-1);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
}
.break-card::before {
    content: '';
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 3px;
}
.break-card.down::before { background: var(--cyan); }
.break-card.up::before { background: var(--magenta); }
.break-card.bloat-down::before { background: var(--signal); }
.break-card.bloat-up::before { background: #fb923c; }

.break-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.break-icon {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border: 1px solid currentColor;
    font-weight: 700;
}
.break-card.down .break-icon { color: var(--cyan); }
.break-card.up .break-icon { color: var(--magenta); }
.break-card.bloat-down .break-icon { color: var(--signal); }
.break-card.bloat-up .break-icon { color: #fb923c; }
.break-title {
    font-size: 13px;
    letter-spacing: 0.15em;
    color: var(--ink-0);
    font-weight: 700;
}
.break-speed {
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 800;
    color: var(--ink-0);
    line-height: 1;
    margin-bottom: 8px;
}
.break-detail {
    font-size: 13px;
    color: var(--ink-1);
    letter-spacing: 0.03em;
    font-weight: 500;
}
.break-meter {
    margin-top: 14px;
    height: 6px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    overflow: hidden;
}
.break-meter-fill {
    height: 100%;
    width: 0%;
    transition: width 0.4s ease, background 0.3s;
}

/* ============== BUFFERBLOAT-FREE SPEED ============== */
.bloatfree-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--line);
}
@media (max-width: 700px) {
    .bloatfree-grid { grid-template-columns: 1fr; }
}
.bloatfree-card {
    background: var(--bg-1);
    padding: 24px 28px;
    position: relative;
    overflow: hidden;
}
.bloatfree-card::before {
    content: '';
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 3px;
}
.bloatfree-card.down::before { background: var(--cyan); }
.bloatfree-card.up::before   { background: var(--magenta); }

.bloatfree-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.bloatfree-icon {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border: 1px solid currentColor;
    font-weight: 700;
}
.bloatfree-card.down .bloatfree-icon { color: var(--cyan); }
.bloatfree-card.up   .bloatfree-icon { color: var(--magenta); }
.bloatfree-title {
    font-size: 13px;
    letter-spacing: 0.15em;
    color: var(--ink-0);
    font-weight: 700;
}

.bloatfree-speed {
    font-family: var(--font-mono);
    font-size: 56px;
    font-weight: 800;
    line-height: 1;
    color: var(--ink-0);
    letter-spacing: -0.03em;
    text-shadow: 0 0 24px currentColor;
    margin-bottom: 6px;
}
.bloatfree-speed .unit {
    font-size: 18px;
    color: var(--ink-2);
    margin-left: 8px;
    font-weight: 500;
    letter-spacing: 0.05em;
}
.bloatfree-speed.grade-good { color: var(--phosphor); }
.bloatfree-speed.grade-warn { color: var(--signal); }
.bloatfree-speed.grade-bad  { color: var(--alert); }

.bloatfree-detail {
    font-size: 13px;
    color: var(--ink-1);
    letter-spacing: 0.03em;
    font-weight: 500;
    margin-bottom: 14px;
}

.bloatfree-meter {
    height: 8px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    overflow: hidden;
    position: relative;
}
.bloatfree-meter-fill {
    height: 100%;
    width: 0%;
    transition: width 0.6s ease;
}
.bloatfree-meter-label {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--ink-2);
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
}

.bloatfree-explainer {
    padding: 14px 28px;
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--ink-1);
    line-height: 1.5;
    letter-spacing: 0.02em;
    font-weight: 500;
}

@media (max-width: 700px) {
    .bloatfree-speed { font-size: 42px; }
    .bloatfree-speed .unit { font-size: 14px; }
}

/* ============== STEPPED ============== */
.legend { display: flex; gap: 14px; }
.legend-item {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px;
    color: var(--ink-1);
    letter-spacing: 0.05em;
    font-weight: 500;
}
.swatch { width: 14px; height: 4px; }
.swatch.dl { background: var(--cyan); }
.swatch.ul { background: var(--magenta); }
.swatch.dl-rtt {
    background: transparent;
    border-top: 2px dashed var(--signal);
    height: 0;
}
.swatch.ul-rtt {
    background: transparent;
    border-top: 2px dashed #fb923c;
    height: 0;
}

.chart-container {
    padding: 18px;
    border-bottom: 1px solid var(--line);
}
#steppedChart { width: 100%; height: 340px; display: block; }

.step-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--line);
}
.step-table-wrap {
    background: var(--bg-1);
    padding: 16px;
    overflow-x: auto;
}
.step-table-title {
    font-size: 14px;
    letter-spacing: 0.12em;
    color: var(--ink-0);
    margin-bottom: 12px;
    font-weight: 700;
}
.step-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.step-table th {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid var(--line-2);
    color: var(--ink-1);
    font-weight: 600;
    letter-spacing: 0.08em;
    font-size: 12px;
    text-transform: uppercase;
}
.step-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-0);
    font-family: var(--font-mono);
    font-weight: 500;
}
.step-table tr.breakpoint-row {
    background: rgba(255,107,129,0.12);
}
.step-table tr.breakpoint-row td {
    color: var(--alert);
    font-weight: 700;
}
.status-tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    letter-spacing: 0.1em;
    font-weight: 700;
}
.status-tag.ok { background: rgba(93,255,160,0.18); color: var(--phosphor); }
.status-tag.warn { background: rgba(252,211,77,0.18); color: var(--signal); }
.status-tag.fail { background: rgba(255,107,129,0.2); color: var(--alert); }
.status-tag.unsat { background: rgba(148,163,196,0.16); color: var(--ink-3); border: 1px dashed rgba(148,163,196,0.4); }
tr.unsat-row td { opacity: 0.6; }
tr.unsat-row td:first-child { opacity: 0.85; }
.unsat-note { color: var(--ink-3); font-size: 0.82em; font-style: italic; }

/* ============== VOIP ============== */
.voip-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line);
    border-bottom: 1px solid var(--line);
}
.voip-stat {
    background: var(--bg-1);
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.voip-stat-label {
    font-size: 12px;
    color: var(--ink-1);
    letter-spacing: 0.12em;
    font-weight: 500;
}
.voip-stat-val {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--phosphor);
    font-weight: 700;
}
.codec-grid {
    padding: 18px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
@media (max-width: 900px) {
    .codec-grid { grid-template-columns: repeat(2, 1fr); }
}
.codec-card {
    background: var(--bg-2);
    border: 1px solid var(--line);
    padding: 18px;
    position: relative;
    transition: all 0.3s;
}
.codec-card:hover { border-color: var(--phosphor-dim); }
.codec-name {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--ink-0);
}
.codec-desc {
    font-size: 12px;
    color: var(--ink-1);
    letter-spacing: 0.03em;
    margin-top: 4px;
    margin-bottom: 16px;
    font-weight: 500;
}
.mos-display {
    display: flex; align-items: baseline; gap: 8px;
    margin-bottom: 10px;
}
.mos-value {
    font-family: var(--font-mono);
    font-size: 40px;
    font-weight: 800;
    color: var(--ink-0);
    line-height: 1;
    letter-spacing: -0.03em;
}
.mos-label {
    font-size: 12px;
    color: var(--ink-2);
    letter-spacing: 0.12em;
    font-weight: 600;
}
.mos-bar {
    height: 5px;
    background: var(--bg-3);
    overflow: hidden;
    margin-bottom: 8px;
}
.mos-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 0.6s ease, background 0.3s;
}
.mos-rating {
    font-size: 12px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-2);
    font-weight: 700;
}
.mos-rating.excellent { color: var(--phosphor); }
.mos-rating.good { color: var(--cyan); }
.mos-rating.fair { color: var(--signal); }
.mos-rating.poor { color: var(--alert); }
.mos-rating.bad { color: var(--alert); }

/* ---- VoIP: idle-vs-load framing note ---- */
.voip-note {
    padding: 14px 18px;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--ink-2);
    border-bottom: 1px solid var(--line);
    background: rgba(125, 211, 252, 0.04);
}
.voip-note b { color: var(--ink-0); font-weight: 700; }

/* ---- Codec card: sublabel + secondary (idle / saturated) readouts ---- */
.mos-sublabel {
    display: block;
    font-size: 9.5px;
    letter-spacing: 0.08em;
    color: var(--signal);
    font-weight: 700;
    margin-top: 3px;
    white-space: nowrap;
}
.mos-secondary {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--ink-3);
}
.mos-sec { text-transform: uppercase; }
.mos-sec-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--ink-1);
    margin-left: 2px;
}
.mos-sec-val.excellent { color: var(--phosphor); }
.mos-sec-val.good { color: var(--cyan); }
.mos-sec-val.fair { color: var(--signal); }
.mos-sec-val.poor,
.mos-sec-val.bad { color: var(--alert); }

/* ---- VoIP: call-quality-vs-load matrix ---- */
.voip-load {
    padding: 6px 18px 18px;
    border-top: 1px solid var(--line);
}
.voip-load-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 12px;
}
.voip-load-head > span:first-child {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--ink-0);
}
.voip-load-sub {
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: 0.04em;
}
.lm-grid {
    display: grid;
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    font-family: var(--font-mono);
}
.lm-head {
    background: var(--bg-3);
    color: var(--ink-2);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: center;
    padding: 8px 4px;
    text-transform: uppercase;
}
.lm-head-load { text-align: left; padding-left: 10px; }
.lm-head-dir  { font-size: 9.5px; }
.lm-load {
    background: var(--bg-2);
    color: var(--ink-1);
    font-weight: 700;
    font-size: 12px;
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    line-height: 1.15;
}
.lm-load-main { font-size: 12px; font-weight: 700; }
.lm-load-sub {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--ink-3);
    letter-spacing: 0.02em;
}
.lm-cell {
    background: var(--bg-1);
    text-align: center;
    padding: 9px 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-0);
    display: flex;
    align-items: center;
    justify-content: center;
}
.lm-dir {
    background: var(--bg-2);
    text-align: center;
    padding: 9px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    justify-content: center;
}
/* rating heat — translucent fill + saturated text so numbers stay legible */
.lm-excellent { background: rgba(110, 255, 168, 0.16); color: var(--phosphor); }
.lm-good      { background: rgba(125, 211, 252, 0.15); color: var(--cyan); }
.lm-fair      { background: rgba(253, 224, 71, 0.15);  color: var(--signal); }
.lm-poor      { background: rgba(255, 123, 142, 0.15); color: var(--alert); }
.lm-bad       { background: rgba(255, 123, 142, 0.28); color: #ffd0d7; }
.lm-caption {
    margin-top: 8px;
    font-size: 10.5px;
    color: var(--ink-3);
    line-height: 1.5;
    letter-spacing: 0.02em;
}

/* ---- VoIP: plain-English verdict banner ---- */
.voip-verdict {
    margin: 0 18px 18px;
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-left-width: 3px;
    background: var(--bg-2);
    font-size: 13px;
    line-height: 1.55;
}
.voip-verdict-tag {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.14em;
    padding: 3px 7px;
    border-radius: 2px;
    margin-top: 1px;
}
.voip-verdict-text { color: var(--ink-1); }
.voip-verdict-good      { border-left-color: var(--phosphor); }
.voip-verdict-good      .voip-verdict-tag { background: rgba(110,255,168,0.18); color: var(--phosphor); }
.voip-verdict-watch     { border-left-color: var(--signal); }
.voip-verdict-watch     .voip-verdict-tag { background: rgba(253,224,71,0.18); color: var(--signal); }
.voip-verdict-bad       { border-left-color: var(--alert); }
.voip-verdict-bad       .voip-verdict-tag { background: rgba(255,123,142,0.2); color: var(--alert); }
.voip-verdict-none      { border-left-color: var(--line-2); }
.voip-verdict-none      .voip-verdict-tag { background: var(--bg-3); color: var(--ink-3); }
.voip-verdict-inconclusive { border-left-color: var(--ink-3); }
.voip-verdict-inconclusive .voip-verdict-tag { background: rgba(148,163,196,0.16); color: var(--ink-3); }

/* Unsaturated / untested cells in the load matrix */
.lm-cell.lm-untested, .lm-load.lm-untested, .lm-dir.lm-untested {
    color: var(--ink-3);
    background: repeating-linear-gradient(45deg, rgba(148,163,196,0.05), rgba(148,163,196,0.05) 6px, transparent 6px, transparent 12px);
    opacity: 0.7;
}
.lm-untested-txt { color: var(--ink-3); font-size: 0.82em; font-style: italic; }
.lm-load-sub-warn { color: var(--signal) !important; }
.lm-warn {
    background: rgba(252,211,77,0.10);
    border: 1px solid rgba(252,211,77,0.35);
    border-radius: 6px;
    color: var(--ink-2);
    font-size: 12px;
    line-height: 1.5;
    padding: 9px 12px;
    margin-bottom: 12px;
}
.lm-warn b { color: var(--signal); }
.headline-note {
    color: var(--signal);
    font-size: 10.5px;
    margin-top: 3px;
    opacity: 0.9;
}

@media (max-width: 620px) {
    .lm-cell, .lm-dir { font-size: 11px; padding: 8px 2px; }
    .lm-head { font-size: 9px; }
    .voip-load-sub { display: none; }
}

/* ============== LOG ============== */
.panel-log .panel-head {
    gap: 10px;
}
.export-btn {
    background: transparent;
    border: 1px solid var(--line-2);
    color: var(--ink-0);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 7px 14px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
    line-height: 1.2;
}
.export-btn:hover {
    border-color: var(--phosphor);
    color: var(--phosphor);
    background: rgba(93,255,160,0.06);
}

.log-container {
    max-height: 320px;
    overflow-y: auto;
    padding: 14px 20px;
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-0);
}
.log-container::-webkit-scrollbar { width: 8px; }
.log-container::-webkit-scrollbar-track { background: var(--bg-1); }
.log-container::-webkit-scrollbar-thumb { background: var(--line-2); }

.log-line {
    padding: 4px 0;
    color: var(--ink-1);
    display: flex;
    gap: 14px;
}
.log-time {
    color: var(--ink-2);
    min-width: 100px;
    font-weight: 500;
}
.log-level {
    min-width: 60px;
    font-weight: 700;
    letter-spacing: 0.08em;
}
.log-level.info { color: var(--cyan); }
.log-level.ok { color: var(--phosphor); }
.log-level.warn { color: var(--signal); }
.log-level.err { color: var(--alert); }
.log-level.phase { color: var(--magenta); }
.log-msg { flex: 1; color: var(--ink-0); font-weight: 500; }

/* ============== FOOTER ============== */
.footer {
    position: relative; z-index: 5;
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    max-width: 1800px;
    margin: 16px auto 0;
    border-top: 1px solid var(--line);
    background: var(--bg-1);
    font-size: 12px;
    color: var(--ink-2);
    letter-spacing: 0.06em;
    font-weight: 500;
}
.footer code {
    color: var(--phosphor);
    background: var(--bg-2);
    padding: 1px 6px;
    border: 1px solid var(--line);
}

/* CRT-ish scanline effect on values, subtle */
.readout-value, .cap-val, .mos-value, .break-speed {
    text-shadow: 0 0 18px currentColor;
}

/* ==========================================================================
   QUEUE OVERLAY — shown when waiting for a slot
   ========================================================================== */
.queue-overlay {
    position: fixed; inset: 0; z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(5, 8, 16, 0.92);
    backdrop-filter: blur(12px);
    animation: fade-in 0.3s ease;
}
.queue-overlay.visible { display: flex; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.queue-card {
    background: var(--bg-1);
    border: 1px solid var(--phosphor-dim);
    box-shadow: 0 0 60px rgba(93,255,160,0.25), inset 0 0 32px rgba(93,255,160,0.04);
    padding: 40px 48px;
    max-width: 520px;
    width: 90%;
    text-align: center;
    position: relative;
}
.queue-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--phosphor), transparent);
}

.queue-icon {
    color: var(--phosphor);
    margin-bottom: 16px;
    filter: drop-shadow(0 0 12px rgba(93,255,160,0.6));
}

.queue-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.2em;
    color: var(--ink-0);
    margin-bottom: 10px;
}

.queue-subtitle {
    font-size: 14px;
    color: var(--ink-1);
    margin-bottom: 28px;
    line-height: 1.5;
    font-weight: 500;
}

.queue-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line-2);
    margin-bottom: 24px;
}
.queue-stat {
    background: var(--bg-2);
    padding: 16px 8px;
}
.queue-stat-label {
    font-size: 11px;
    color: var(--ink-2);
    letter-spacing: 0.12em;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
}
.queue-stat-val {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 800;
    color: var(--phosphor);
    line-height: 1;
    text-shadow: 0 0 14px currentColor;
}

.queue-retry {
    font-size: 14px;
    color: var(--ink-1);
    letter-spacing: 0.05em;
    margin-bottom: 20px;
    font-weight: 500;
}
.queue-retry span {
    color: var(--signal);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 16px;
    text-shadow: 0 0 10px currentColor;
}

.queue-cancel {
    background: transparent;
    border: 1px solid var(--line-2);
    color: var(--ink-1);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.13em;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.15s;
}
.queue-cancel:hover {
    border-color: var(--alert);
    color: var(--alert);
    background: rgba(255,107,129,0.08);
}

/* ==========================================================================
   COMPLETE BANNER — shown when full diagnostic finishes
   ========================================================================== */
.complete-banner {
    position: sticky;
    top: 0;
    z-index: 50;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
    /* Constrain to the same width as the main body so the banner aligns
       with the panels below it */
    max-width: 1800px;
    margin: 0 auto;
}
.complete-banner.visible {
    max-height: 800px;   /* generous on mobile where it stacks vertically */
}

.complete-banner-inner {
    display: flex;
    flex-wrap: wrap;          /* lets headline drop below on narrow screens */
    align-items: stretch;
    gap: 0;
    margin: 16px 16px 0;
    background: linear-gradient(135deg, rgba(93,255,160,0.12), rgba(34,197,94,0.08));
    border: 1px solid var(--phosphor);
    box-shadow: 0 0 40px rgba(93,255,160,0.25);
    position: relative;
    overflow: hidden;
    animation: complete-pulse 2s ease-in-out;
}
@keyframes complete-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(93,255,160,0.7); }
    50%  { box-shadow: 0 0 60px 8px rgba(93,255,160,0.4); }
    100% { box-shadow: 0 0 40px rgba(93,255,160,0.25); }
}

.complete-banner-inner::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--phosphor), transparent);
    animation: shine 2.5s linear infinite;
}
@keyframes shine {
    from { background-position: -200% 0; }
    to   { background-position: 200% 0; }
}

.complete-banner-icon {
    flex: 0 0 80px;           /* fixed-width tick column */
    display: grid;
    place-items: center;
    background: rgba(93,255,160,0.15);
    color: var(--phosphor);
    border-right: 1px solid rgba(93,255,160,0.3);
    filter: drop-shadow(0 0 8px currentColor);
    min-height: 80px;
}

.complete-banner-content {
    flex: 1 1 280px;          /* shrinks down to 280px before wrapping */
    padding: 20px 28px;
    min-width: 0;
}

.complete-banner-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: var(--phosphor);
    margin-bottom: 14px;
    text-shadow: 0 0 16px currentColor;
}

.complete-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 28px;
}
.complete-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
}
.complete-label {
    font-size: 11px;
    color: var(--ink-2);
    letter-spacing: 0.13em;
    text-transform: uppercase;
    font-weight: 600;
}
.complete-val {
    font-family: var(--font-mono);
    font-size: 15px;
    color: var(--ink-0);
    font-weight: 700;
}
.complete-val.complete-ip { color: var(--cyan); }

.complete-banner-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 32px; height: 32px;
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    color: var(--ink-1);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
    z-index: 2;
}
.complete-banner-close:hover {
    border-color: var(--alert);
    color: var(--alert);
}

/* Big headline grade card — the bufferbloat grade is the headline result. */
.complete-banner-headline {
    flex: 0 0 220px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    border-left: 1px solid rgba(110,255,168,0.3);
    text-align: center;
}
.headline-grade {
    font-family: var(--font-display);
    font-size: 80px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    text-shadow: 0 0 32px currentColor;
}
.headline-grade-phosphor { color: var(--phosphor); }
.headline-grade-cyan     { color: var(--cyan); }
.headline-grade-signal   { color: var(--signal); }
.headline-grade-alert    { color: var(--alert); }
.headline-label {
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 0.22em;
    color: var(--ink-1);
    margin-top: 6px;
    font-weight: 700;
}
.headline-detail {
    font-size: 11px;
    color: var(--ink-2);
    margin-top: 6px;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Mobile: tick icon stays narrow on the left, content + headline stack
   vertically below it. */
@media (max-width: 720px) {
    .complete-banner-inner {
        margin: 12px 8px 0;
    }
    .complete-banner-icon {
        flex: 0 0 100%;          /* full-width tick stripe at the top */
        min-height: 48px;
        border-right: none;
        border-bottom: 1px solid rgba(93,255,160,0.3);
    }
    .complete-banner-icon svg {
        width: 28px;
        height: 28px;
    }
    .complete-banner-content {
        flex: 1 1 100%;
        padding: 16px 18px 12px;
        order: 2;
    }
    .complete-banner-title {
        font-size: 16px;
        letter-spacing: 0.14em;
    }
    .complete-banner-headline {
        flex: 1 1 100%;
        order: 3;
        flex-direction: row;
        gap: 16px;
        padding: 14px 18px;
        border-left: none;
        border-top: 1px solid rgba(110,255,168,0.3);
        justify-content: flex-start;
        text-align: left;
    }
    .headline-grade { font-size: 56px; }
    .headline-label, .headline-detail { margin-top: 0; }
    .complete-summary {
        grid-template-columns: 1fr 1fr;
        gap: 4px 14px;
    }
    .complete-val {
        font-size: 13px;
    }
}

@media (max-width: 420px) {
    .complete-summary { grid-template-columns: 1fr; }
}

/* ==================== AUTO-REPEAT / SCHEDULE ==================== */
.setting-repeat label::before {
    content: "↻ ";
    color: var(--cyan);
}
.setting-muted {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.6);
}
.secondary-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: transparent;
    border: 1px solid var(--line-2);
    color: var(--ink-1);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 9px 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.secondary-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(125,211,252,0.06);
}
.schedule-status {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line-2);
    border-left: 3px solid var(--cyan);
    border-radius: 6px;
    background: rgba(125,211,252,0.06);
    color: var(--ink-1);
    font-size: 12.5px;
    line-height: 1.5;
    font-family: var(--font-mono);
}
.schedule-status b { color: var(--cyan); }
.sched-hint { color: var(--ink-3); }
.sched-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--cyan);
    margin-right: 6px;
    animation: sched-pulse 1.4s ease-in-out infinite;
}
@keyframes sched-pulse { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ==================== RUN HISTORY (stacked) ==================== */
.panel-history .panel-head { position: relative; }
.history-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--cyan);
    letter-spacing: 0.08em;
}
.history-wrap { overflow-x: auto; }
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12.5px;
}
.history-table thead th {
    text-align: left;
    color: var(--ink-3);
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 8px 12px;
    border-bottom: 2px solid var(--line-2);
    white-space: nowrap;
}
.history-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-1);
    white-space: nowrap;
}
.history-table tbody tr:hover { background: var(--bg-2); }
.hist-unit { color: var(--ink-3); font-size: 0.82em; margin-left: 2px; }
.hist-ip { color: var(--cyan); font-size: 0.92em; }
.hist-notes { color: var(--ink-3); font-size: 0.92em; white-space: normal; }
.hist-grade {
    display: inline-block;
    min-width: 26px;
    text-align: center;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
}
.hist-grade-phosphor { background: rgba(110,255,168,0.16); color: var(--phosphor); }
.hist-grade-cyan     { background: rgba(125,211,252,0.16); color: var(--cyan); }
.hist-grade-signal   { background: rgba(253,224,71,0.16); color: var(--signal); }
.hist-grade-alert    { background: rgba(255,123,142,0.18); color: var(--alert); }
.hist-tier {
    font-size: 0.82em;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-left: 4px;
}
.hist-tier-good         { color: var(--phosphor); }
.hist-tier-watch        { color: var(--signal); }
.hist-tier-bad          { color: var(--alert); }
.hist-tier-inconclusive { color: var(--ink-3); }
.hist-tier-none         { color: var(--ink-3); }
.history-caption {
    margin-top: 12px;
    color: var(--ink-3);
    font-size: 11.5px;
    line-height: 1.5;
}

/* ============================ PRINT ============================ */
@media print {
    /* Print faithfully in the dark theme — "what you see". */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    @page { margin: 12mm; }
    html, body { background: var(--bg-0) !important; }
    .grid-bg, .scanline, .live-indicator, .run-btn, .secondary-btn,
    .export-btn, #completeBannerClose, .queue-overlay, .schedule-status,
    .panel-control .seg, .panel-control .setting, .panel-control label,
    #liveChart, .live-chart-wrap { display: none !important; }
    /* Hide the whole control panel and live telemetry chrome from print. */
    .panel-control { display: none !important; }
    .panel {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none !important;
        margin-bottom: 10px !important;
    }
    .panel-history, .panel-voip { break-inside: auto; page-break-inside: auto; }
    .history-table { font-size: 10.5px; }
    .lm-cell, .lm-dir, .lm-load { font-size: 10px; padding: 6px 3px; }
    /* A small print-only header line is added via body::before content below. */
    body::before {
        content: "Bufferbloat Diagnostic — printed report";
        display: block;
        color: var(--phosphor);
        font-family: var(--font-mono);
        font-size: 13px;
        letter-spacing: 0.1em;
        padding-bottom: 6px;
        margin-bottom: 8px;
        border-bottom: 1px solid var(--line-2);
    }
}

/* ============================================================================
   VOIP STABILITY MONITOR — page-specific additions
   Uses the shared phosphor theme tokens defined in :root above.
   ============================================================================ */

/* --- connection panel --- */
.field-label,
.setting-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-bottom: 6px;
    display: block;
}
.setting-group { margin-bottom: 16px; }

.text-input {
    width: 100%;
    background: var(--bg-0);
    border: 1px solid var(--line-2);
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--ink-0);
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.01em;
    margin-bottom: 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus {
    outline: none;
    border-color: var(--phosphor);
    box-shadow: 0 0 0 3px rgba(110, 255, 168, 0.12);
}

.conn-state {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--bg-0);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 0;
    margin-bottom: 14px;
}
.conn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 11px;
    font-family: var(--font-mono);
    font-size: 11.5px;
}
.conn-row span { color: var(--ink-3); letter-spacing: 0.03em; }
.conn-row b { color: var(--ink-1); font-weight: 600; }
.st-ok    { color: var(--phosphor) !important; }
.st-warn  { color: var(--signal) !important; }
.st-alert { color: var(--alert) !important; }

.control-divider {
    height: 1px;
    background: var(--line);
    margin: 6px 0 16px;
}
.setting-hint {
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--ink-3);
    margin-top: 7px;
}
.seg.seg-wrap { flex-wrap: wrap; }

/* --- run button (connect / start) --- */
.run-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
    border: 1px solid var(--phosphor-dim);
    border-radius: 7px;
    color: var(--phosphor);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 12px 14px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
    margin-bottom: 10px;
}
.run-button:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(110,255,168,0.12), var(--bg-3));
    box-shadow: 0 0 18px rgba(110, 255, 168, 0.18);
}
.run-button:active:not(:disabled) { transform: translateY(1px); }
.run-button:disabled { opacity: 0.4; cursor: not-allowed; color: var(--ink-2); border-color: var(--line-2); }
.run-icon { font-size: 12px; line-height: 1; }

/* --- session panel (capacity-area reuse) --- */
.cap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}
.cap-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--ink-0);
    margin: 2px 0;
}
.cap-value.phosphor { color: var(--phosphor); }
.cap-value.cyan { color: var(--cyan); }
.cap-value.signal { color: var(--signal); }
.cap-value.magenta { color: var(--magenta); }
.cap-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 11px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}
.cap-meta span { color: var(--ink-3); letter-spacing: 0.05em; }
.cap-meta b { color: var(--cyan); font-weight: 600; }

/* --- readout bar colour variants --- */
.readout-bar-fill.bar-phosphor { background: linear-gradient(90deg, var(--phosphor-dim), var(--phosphor)); }
.readout-bar-fill.bar-cyan     { background: linear-gradient(90deg, rgba(125,211,252,0.4), var(--cyan)); }
.readout-bar-fill.bar-signal   { background: linear-gradient(90deg, var(--signal-dim), var(--signal)); }
.readout-bar-fill.bar-alert    { background: linear-gradient(90deg, var(--alert-dim), var(--alert)); }

/* MOS text colours (live readout + inline) */
.mos-excellent { color: var(--phosphor); }
.mos-good      { color: var(--cyan); }
.mos-fair      { color: var(--signal); }
.mos-poor      { color: #ffab5e; }
.mos-bad       { color: var(--alert); }

/* --- generic result bits --- */
.panel-caption {
    font-size: 11px;
    line-height: 1.5;
    color: var(--ink-3);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.panel-caption b { color: var(--ink-1); font-weight: 600; }
.sub-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-bottom: 8px;
}
.chart-sm { height: 240px; }

/* --- PDV summary grid --- */
.pdv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 10px;
}
.pdv-cell {
    background: var(--bg-0);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 11px 13px;
}
.pdv-cell.pdv-warn { border-color: var(--alert-dim); background: rgba(255, 123, 142, 0.05); }
.pdv-label {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 5px;
    line-height: 1.3;
}
.pdv-val {
    font-family: var(--font-mono);
    font-size: 21px;
    font-weight: 700;
    color: var(--ink-0);
}
.pdv-cell.pdv-warn .pdv-val { color: var(--alert); }
.pdv-unit { font-size: 11px; color: var(--ink-3); margin-left: 3px; font-weight: 500; }

/* --- data table (jitter-buffer sim) --- */
.table-scroll { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
}
.data-table thead th {
    text-align: left;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-2);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-1);
    white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--bg-2); }
.data-table tr.jb-best {
    background: rgba(110, 255, 168, 0.06);
    box-shadow: inset 3px 0 0 var(--phosphor);
}
.data-table tr.jb-best:hover { background: rgba(110, 255, 168, 0.09); }
.jb-sub { color: var(--ink-3); font-size: 10px; margin-left: 3px; }
.jb-star { color: var(--phosphor); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; }
.jb-verdict { font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.04em; }
.jb-good { color: var(--phosphor); }
.jb-fair { color: var(--signal); }
.jb-bad  { color: var(--alert); }

/* MOS pills inside the table */
.mos-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11.5px;
}
.mos-tag.mos-excellent { color: var(--phosphor); background: rgba(110, 255, 168, 0.12); }
.mos-tag.mos-good      { color: var(--cyan); background: rgba(125, 211, 252, 0.12); }
.mos-tag.mos-fair      { color: var(--signal); background: rgba(253, 224, 71, 0.12); }
.mos-tag.mos-poor      { color: #ffab5e; background: rgba(255, 160, 90, 0.12); }
.mos-tag.mos-bad       { color: var(--alert); background: rgba(255, 123, 142, 0.14); }

/* --- spike log + histogram --- */
.spike-layout {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
}
.spike-list { display: flex; flex-direction: column; gap: 6px; }
.spike-row {
    display: grid;
    grid-template-columns: 62px 1fr 58px;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 11.5px;
}
.spike-t { color: var(--ink-3); }
.spike-bar {
    height: 8px;
    background: var(--bg-0);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.spike-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--signal), var(--alert));
}
.spike-ms { color: var(--alert); font-weight: 700; text-align: right; }
.spike-empty { color: var(--phosphor); font-size: 12px; line-height: 1.5; padding: 12px 0; }

.periodicity {
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--bg-0);
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--ink-2);
}
.periodicity b { font-weight: 600; }
.peri-yes { color: var(--signal); }
.peri-no  { color: var(--cyan); }

/* --- verdict --- */
.verdict-box { font-size: 13px; line-height: 1.6; color: var(--ink-1); }
.verdict-lead {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-0);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.verdict-box p { margin: 0 0 10px; }
.verdict-box b { color: var(--ink-0); font-weight: 600; }
.verdict-note {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--ink-3);
    font-style: italic;
    line-height: 1.5;
}

/* complete-banner extra colour variant used by this page */
.complete-val.cyan { color: var(--cyan); }

/* --- footer --- */
.page-footer {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 24px 16px 40px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--ink-3);
    letter-spacing: 0.03em;
}

/* --- responsive --- */
@media (max-width: 820px) {
    .spike-layout { grid-template-columns: 1fr; }
    .cap-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Schedule / repeat, client-IP badge, on-page log (extension)
   ============================================================ */

/* full-width panel that spans the whole layout grid */
.panel-full { grid-column: 1 / -1; }

/* YOUR PUBLIC IP badge */
.ip-badge {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 10px 12px; margin-bottom: 14px;
    background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
    border: 1px solid var(--line-2); border-radius: 8px;
}
.ip-label { font-size: 10px; letter-spacing: .1em; color: var(--ink-2); font-weight: 600; }
.ip-value { font-family: var(--font-mono); font-weight: 700; color: var(--cyan); font-size: 15px; letter-spacing: .02em; }

/* repeat checkbox row */
.chk {
    display: flex; align-items: center; gap: 9px; cursor: pointer;
    font-size: 12.5px; color: var(--ink-1); user-select: none; padding: 2px 0;
}
.chk input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin: 0;
    border: 1px solid var(--line-2); border-radius: 4px; background: var(--bg-0);
    cursor: pointer; position: relative; flex: 0 0 auto; transition: all .12s;
}
.chk input[type="checkbox"]:checked { background: var(--phosphor); border-color: var(--phosphor); }
.chk input[type="checkbox"]:checked::after {
    content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: var(--bg-0); font-size: 12px; font-weight: 800;
}
.chk input[type="checkbox"]:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }

.repeat-opts { margin-top: 10px; padding-left: 2px; }
.repeat-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 12px; color: var(--ink-2);
}
.mini-select {
    background: var(--bg-0); color: var(--ink-0); border: 1px solid var(--line-2);
    border-radius: 6px; padding: 5px 8px; font-family: var(--font-mono); font-size: 12px; cursor: pointer;
}
.mini-select:focus { outline: none; border-color: var(--phosphor); box-shadow: 0 0 0 3px rgba(110,255,168,.12); }

/* scheduled-series status block */
.series-status {
    margin-top: 12px; padding: 12px; border: 1px solid var(--line-2); border-radius: 8px;
    background: var(--bg-1);
}
.series-row {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 4px 0; font-size: 12px; color: var(--ink-2);
}
.series-row b { color: var(--phosphor); font-family: var(--font-mono); font-weight: 700; font-size: 13px; }

/* on-page log save indicator */
.log-status { margin-left: auto; font-size: 11px; font-family: var(--font-mono); letter-spacing: .02em; }
.log-ok    { color: var(--phosphor); }
.log-warn  { color: var(--signal); }
.log-alert { color: var(--alert); }

.hist-empty { text-align: center; color: var(--ink-3); padding: 20px 0; font-size: 12px; }

.data-table td.sm2 { font-size: 11px; color: var(--ink-2); }

/* osir integration: the "I'm human" gate card sits above the grid (full width); the .layout grid keeps its named areas. */
.voip-main { position: relative; }
.voip-main > .hg-card { max-width: 560px; margin: 20px auto; }

/* osir: top-bar navigation back to the site + clickable logo */
a.logo-mark { display: inline-flex; cursor: pointer; }
.voip-nav { display: flex; gap: 14px; align-items: center; margin-right: 14px; }
.voip-nav a { color: #cbd5e1; opacity: .85; text-decoration: none; font-size: 13px; white-space: nowrap; }
.voip-nav a:hover { opacity: 1; color: #fff; text-decoration: underline; }
@media (max-width: 640px) { .voip-nav { display: none; } }
