/* ===========================================================
   Trinsfer Speed — style.css (Tailwind-assisted, light/dark)
   Matches Trinsfer file-transfer brand: #0066FF + #8B5CF6
   =========================================================== */

:root {
    --primary: #0066FF;
    --secondary: #0052CC;
    --accent: #8B5CF6;
    --text-strong: #1e293b;
    --text-mid: #64748b;
    --text-soft: #94a3b8;
    --border-soft: rgba(0, 0, 0, 0.06);
    --border-mid: rgba(0, 0, 0, 0.08);
    --panel: rgba(255, 255, 255, 0.8);
    --panel-strong: rgba(255, 255, 255, 0.9);
    --bg-subtle: #f8fafc;
}

.dark {
    --text-strong: #f1f5f9;
    --text-mid: #94a3b8;
    --text-soft: #71717a;
    --border-soft: rgba(255, 255, 255, 0.08);
    --border-mid: rgba(255, 255, 255, 0.12);
    --panel: rgba(20, 20, 25, 0.6);
    --panel-strong: rgba(20, 20, 25, 0.8);
    --bg-subtle: rgba(30, 30, 38, 0.5);
}

html { scroll-behavior: smooth; }
* { box-sizing: border-box; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--primary); color: #fff; }

/* ---------- Ambient background ---------- */
.mesh-gradient {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; overflow: hidden; pointer-events: none;
}
.mesh-gradient::before {
    content: '';
    position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(0, 102, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 80% at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 50% 60% at 60% 80%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
    animation: meshMove 25s ease-in-out infinite;
}
.dark .mesh-gradient::before {
    background:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(0, 102, 255, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse 60% 80% at 80% 20%, rgba(139, 92, 246, 0.14) 0%, transparent 50%),
        radial-gradient(ellipse 50% 60% at 60% 80%, rgba(236, 72, 153, 0.10) 0%, transparent 50%);
}
@keyframes meshMove {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, 3%) rotate(1deg); }
    50% { transform: translate(-1%, 2%) rotate(-1deg); }
    75% { transform: translate(1%, -2%) rotate(0.5deg); }
}
.noise-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1; pointer-events: none; opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}
.dark .noise-overlay { opacity: 0.04; }

/* ---------- Header (alineado con trinsfer.com/index.php) ---------- */
.header-2026 {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    padding: 16px 24px;
    transition: padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.header-2026.scrolled { padding: 12px 24px; }

.header-inner {
    max-width: 1400px; margin: 0 auto;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    padding: 12px 24px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 16px;
}
.dark .header-inner {
    background: rgba(20, 20, 25, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}
.header-2026.scrolled .header-inner { border-radius: 16px; }

/* Logo (imagen, como en index.php) + sufijo "Speed" opcional */
.logo-container {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0; text-decoration: none;
}
.logo-light { display: block; }
.logo-dark  { display: none; }
.dark .logo-light { display: none; }
.dark .logo-dark  { display: block; }

.logo-suffix {
    font: 800 1.1rem 'Inter', sans-serif;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #0066FF 0%, #8B5CF6 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-left: -2px;
}

/* Nav links */
.nav-links { display: none; align-items: center; gap: 8px; }
@media (min-width: 960px) { .nav-links { display: flex; } }
.nav-link {
    padding: 10px 18px;
    color: #595c61;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 12px;
    display: inline-flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}
.nav-link:hover { color: #1e293b; background: rgba(0, 0, 0, 0.04); }
.dark .nav-link { color: #a1a1aa; }
.dark .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.nav-link svg { width: 18px; height: 18px; }

/* Server picker alineado a 44px de altura */
.server-picker {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px;
    padding: 0 14px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    transition: all .2s ease;
}
.dark .server-picker {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}
.server-picker:hover { background: rgba(0, 102, 255, 0.08); border-color: rgba(0, 102, 255, 0.3); }
.server-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
    color: #94a3b8; font-weight: 700;
}
.server-picker select {
    background: transparent; border: none; color: var(--text-strong);
    font: 600 13px 'Inter', sans-serif; cursor: pointer; outline: none;
}
.server-picker select option { background: #fff; color: #1e293b; }
.dark .server-picker select option { background: #1e1e26; color: #fff; }
@media (max-width: 520px) { .server-picker { display: none; } }

/* Theme toggle (44px como en index.php) */
.theme-toggle {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
}
.theme-toggle:hover { background: rgba(0, 0, 0, 0.08); color: #1e293b; }
.dark .theme-toggle {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #a1a1aa;
}
.dark .theme-toggle:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .sun-icon { display: block; }
.theme-toggle .moon-icon { display: none; }
.dark .theme-toggle .sun-icon { display: none; }
.dark .theme-toggle .moon-icon { display: block; }

/* Icon button (login/avatar, idéntico al index.php) */
.icon-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    color: #64748b;
    cursor: pointer; text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; overflow: hidden;
}
.dark .icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #a1a1aa;
}
.icon-btn:hover {
    background: rgba(0, 102, 255, 0.1);
    color: #0066FF;
    transform: translateY(-2px);
    border-color: rgba(0, 102, 255, 0.2);
}
.dark .icon-btn:hover { background: rgba(0, 102, 255, 0.15); color: #fff; }
.icon-btn svg { width: 20px; height: 20px; }
.user-btn-active {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(0, 102, 255, 0.2);
}
.avatar-small {
    width: 28px; height: 28px;
    border-radius: 8px;
    object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; color: #fff;
    background: linear-gradient(135deg, #0066FF, #8B5CF6);
    text-transform: uppercase;
}

/* Mobile menu btn */
.mobile-menu-btn {
    display: flex;
    padding: 10px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
}
.mobile-menu-btn:hover { background: rgba(0, 0, 0, 0.08); color: #1e293b; }
.dark .mobile-menu-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #a1a1aa;
}
.dark .mobile-menu-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
@media (min-width: 960px) { .mobile-menu-btn { display: none; } }

/* ---------- Main layout ---------- */
.main-content {
    position: relative; z-index: 10;
    min-height: 100vh;
    padding: 110px 16px 40px;
}
@media (min-width: 768px) { .main-content { padding: 120px 24px 60px; } }

/* ---------- Hero ---------- */
.status-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px;
    background: var(--panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--text-mid);
}
.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #22c55e; box-shadow: 0 0 8px #22c55e;
    animation: pulseDot 2s infinite;
}
.status-chip.busy .status-dot { background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.status-chip.done .status-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.hero-title {
    font-size: clamp(36px, 5.2vw, 58px);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.035em;
    color: var(--text-strong);
}
.gradient-text {
    background: linear-gradient(135deg, #0066FF 0%, #8B5CF6 50%, #ec4899 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    background-size: 200% 200%;
    animation: gradShift 8s ease infinite;
}
@keyframes gradShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.hero-sub {
    color: var(--text-mid);
    font-size: 16px; max-width: 520px;
    line-height: 1.55;
}

.current-conn { display: flex; flex-direction: column; gap: 10px; }
.current-conn-head {
    display: inline-flex; align-items: center; gap: 8px;
    font: 700 11px 'Inter', sans-serif;
    text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--primary);
    align-self: flex-start;
    padding: 6px 12px 6px 10px;
    background: rgba(0, 102, 255, 0.08);
    border: 1px solid rgba(0, 102, 255, 0.18);
    border-radius: 999px;
}
.current-conn-head svg { flex-shrink: 0; }

.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 28px;
    padding: 22px 24px;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
}
.dark .meta-grid { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); }
.meta-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta-label {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.14em; color: var(--text-soft); font-weight: 700;
}
.meta-value {
    font-size: 14px; font-weight: 600; color: var(--text-strong);
    font-family: 'Inter', monospace;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Gauge (canvas-based to prevent needle misalignment) ---------- */
.gauge-wrap {
    position: relative;
    width: 100%; max-width: 360px;
    aspect-ratio: 1 / 1;
    filter: drop-shadow(0 20px 60px rgba(0, 102, 255, 0.12));
}
.gauge-canvas {
    width: 100%; height: 100%;
    display: block;
}
.gauge-center {
    position: absolute;
    left: 50%; top: 52%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    width: 70%;
}
.gauge-label-top {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--primary);
    margin-bottom: 2px;
}
.gauge-value {
    font-size: clamp(40px, 6vw, 60px);
    font-weight: 800;
    line-height: 1;
    color: var(--text-strong);
    letter-spacing: -0.03em;
}
.gauge-unit {
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--text-mid);
    margin-top: 6px;
}
.gauge-phase {
    margin-top: 10px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.2em;
    color: var(--text-soft);
}

/* ---------- Start button ---------- */
.start-btn {
    position: relative;
    padding: 16px 44px;
    background: linear-gradient(135deg, #0066FF 0%, #0052CC 100%);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 102, 255, 0.35), 0 2px 6px rgba(0, 102, 255, 0.2);
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.start-btn::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}
.start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(0, 102, 255, 0.5), 0 4px 10px rgba(139, 92, 246, 0.3);
}
.start-btn:hover:not(:disabled)::before { transform: translateX(100%); }
.start-btn:active:not(:disabled) { transform: translateY(0); }
.start-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.start-btn.running {
    background: linear-gradient(135deg, #6366f1 0%, #8B5CF6 100%);
    animation: runPulse 1.6s ease-in-out infinite;
}
@keyframes runPulse {
    0%, 100% { box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 10px 40px rgba(139, 92, 246, 0.55); }
}
.start-btn-icon { transition: transform .25s ease; }
.start-btn:hover:not(:disabled) .start-btn-icon { transform: translateX(2px); }

/* ---------- Progress bar ---------- */
.progress-wrap {
    width: 100%; max-width: 360px;
    height: 3px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
    overflow: hidden;
}
.dark .progress-wrap { background: rgba(255, 255, 255, 0.06); }
.progress-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #0066FF, #8B5CF6, #ec4899);
    transition: width .4s ease;
    box-shadow: 0 0 12px rgba(0, 102, 255, 0.4);
}

/* ---------- Metric cards ---------- */
.metric-card {
    padding: 18px 20px;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    display: flex; flex-direction: column; gap: 8px;
    transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
    position: relative; overflow: hidden;
}
.metric-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 102, 255, 0.2);
    box-shadow: 0 12px 30px rgba(0, 102, 255, 0.08);
}
.metric-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(0, 102, 255, 0.08);
    color: var(--primary);
}
.metric-icon-jitter { background: rgba(139, 92, 246, 0.1); color: var(--accent); }
.metric-icon-down { background: rgba(0, 102, 255, 0.1); color: var(--primary); }
.metric-icon-up { background: rgba(236, 72, 153, 0.1); color: #ec4899; }
.metric-icon-ping { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.metric-label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--text-soft);
}
.metric-value-row {
    display: flex; align-items: baseline; gap: 5px;
}
.metric-value {
    font-size: 26px; font-weight: 800; letter-spacing: -0.02em;
    color: var(--text-strong);
}
.metric-unit {
    font-size: 12px; font-weight: 500; color: var(--text-soft);
}
.metric-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(0, 102, 255, 0.2), 0 8px 24px rgba(0, 102, 255, 0.12);
}

/* ---------- Quality cards ---------- */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 768px) {
    .quality-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}
.quality-card {
    padding: 20px 12px 18px;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    transition: transform .25s ease, border-color .25s ease;
}
.quality-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 102, 255, 0.2);
}
.quality-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-soft);
    color: var(--text-mid);
    transition: all .3s ease;
}
.dark .quality-icon { background: rgba(255, 255, 255, 0.03); }
.quality-card[data-score="5"] .quality-icon,
.quality-card[data-score="4"] .quality-icon {
    background: linear-gradient(135deg, rgba(0,102,255,0.14), rgba(139,92,246,0.14));
    color: var(--primary); border-color: rgba(0, 102, 255, 0.3);
}
.quality-card[data-score="3"] .quality-icon {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent); border-color: rgba(139, 92, 246, 0.28);
}
.quality-card[data-score="2"] .quality-icon,
.quality-card[data-score="1"] .quality-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b; border-color: rgba(245, 158, 11, 0.25);
}
.quality-label {
    font-size: 12px; font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-strong);
    text-align: center;
}
.quality-dots { display: flex; gap: 5px; }
.qd {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    transition: all .3s ease;
}
.dark .qd { background: rgba(255, 255, 255, 0.1); }
.qd.on { background: var(--primary); box-shadow: 0 0 8px rgba(0, 102, 255, 0.6); }
.quality-card[data-score="3"] .qd.on { background: var(--accent); box-shadow: 0 0 8px rgba(139, 92, 246, 0.6); }
.quality-card[data-score="2"] .qd.on,
.quality-card[data-score="1"] .qd.on { background: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); }

/* ---------- Action bar ---------- */
.action-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 20px;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    flex-wrap: wrap;
}
.action-info {
    display: flex; align-items: center; gap: 10px;
    font-size: 12px; color: var(--text-mid);
}
.action-info svg { color: var(--primary); flex-shrink: 0; }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    color: var(--text-mid);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
}
.dark .btn-ghost { background: rgba(255, 255, 255, 0.04); }
.btn-ghost:hover:not(:disabled) {
    background: rgba(0, 102, 255, 0.08);
    border-color: rgba(0, 102, 255, 0.25);
    color: var(--primary);
    transform: translateY(-1px);
}
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ---------- History ---------- */
.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.history-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 36px 20px;
    color: var(--text-soft);
    background: var(--panel);
    border: 1px dashed var(--border-soft);
    border-radius: 16px;
    font-size: 13px;
}
.history-item {
    padding: 14px 18px;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    display: flex; flex-direction: column; gap: 8px;
    transition: transform .25s ease, border-color .25s ease;
}
.history-item:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 102, 255, 0.2);
}
.history-date {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--text-soft);
}
.history-metrics {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.history-metric { display: flex; flex-direction: column; gap: 1px; }
.history-metric-label {
    font-size: 9px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--text-soft);
}
.history-metric-value {
    font-size: 13px; font-weight: 700;
    color: var(--text-strong);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 32px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 22px;
    background: var(--panel-strong);
    backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-mid);
    border-radius: 999px;
    color: var(--text-strong);
    font-size: 13px; font-weight: 500;
    opacity: 0; pointer-events: none;
    transition: opacity .3s, transform .3s;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.site-footer {
    position: relative; z-index: 10;
    max-width: 1280px; margin: 40px auto 0;
    padding: 24px 40px;
    text-align: center;
    font-size: 12px;
    color: var(--text-soft);
    letter-spacing: 0.04em;
}

/* ---------- Animations ---------- */
.slide-up { animation: slideUp 0.7s cubic-bezier(0.4, 0, 0.2, 1) both; }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Auth: user chip legacy (dashboard/otras páginas) ---------- */
.user-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    color: var(--text-strong);
    transition: all .2s ease;
    text-decoration: none;
}
.dark .user-chip { background: rgba(255, 255, 255, 0.05); }
.user-chip:hover { border-color: rgba(0, 102, 255, 0.35); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font: 700 13px 'Inter', sans-serif;
}
.user-avatar-fallback { background: linear-gradient(135deg, #0066FF, #8B5CF6); text-transform: uppercase; }
.user-name-label { font: 600 13px 'Inter', sans-serif; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .user-name-label { display: none; } }
.user-logout {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    color: var(--text-soft);
    transition: all .18s ease;
    text-decoration: none;
}
.user-logout:hover { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

/* ---------- Dashboard table ---------- */
.dash-wrap { padding-block: 32px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.dash-title { font: 800 28px/1.1 'Inter', sans-serif; letter-spacing: -0.02em; }
.dash-sub   { color: var(--text-soft); font-size: 14px; margin-top: 4px; }

.dash-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (min-width: 700px) { .dash-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.dash-stat {
    padding: 18px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
}
.dark .dash-stat { background: rgba(15, 15, 25, 0.55); }
.dash-stat-label { font: 700 10px 'Inter', sans-serif; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-soft); }
.dash-stat-value { font: 800 28px 'Inter', sans-serif; margin-top: 6px; color: var(--text-strong); }
.dash-stat-unit  { font: 600 13px 'Inter', sans-serif; color: var(--text-soft); margin-left: 4px; }

.dash-table-wrap {
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(14px);
}
.dark .dash-table-wrap { background: rgba(15, 15, 25, 0.55); }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dash-table th, .dash-table td { padding: 14px 10px; text-align: left; border-bottom: 1px solid var(--border-soft); }
.dash-table th {
    font: 700 10px 'Inter', sans-serif; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--text-soft); background: rgba(0, 0, 0, 0.02);
}
.dark .dash-table th { background: rgba(255, 255, 255, 0.03); }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: rgba(0, 102, 255, 0.035); }
.dash-table .num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-strong); }
.dash-table .muted { color: var(--text-soft); }
.dash-actions { display: inline-flex; gap: 2px; }
.dash-actions a, .dash-actions button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px;
    color: var(--text-soft); background: transparent; border: 1px solid transparent;
    cursor: pointer; transition: all .18s ease;
}
.dash-actions a:hover, .dash-actions button:hover { color: var(--primary); background: rgba(0, 102, 255, 0.08); border-color: rgba(0, 102, 255, 0.25); }
.dash-actions .danger:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }
.dash-actions svg { width: 15px; height: 15px; }

.dash-empty {
    padding: 60px 24px; text-align: center;
    color: var(--text-soft);
}
.dash-empty h3 { font: 700 18px 'Inter', sans-serif; color: var(--text-strong); margin-bottom: 6px; }

/* Mobile dashboard: cards instead of table */
@media (max-width: 760px) {
    .dash-table, .dash-table thead, .dash-table tbody, .dash-table tr, .dash-table th, .dash-table td { display: block; }
    .dash-table thead { display: none; }
    .dash-table tr { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
    .dash-table td { padding: 4px 0; border: none; display: flex; justify-content: space-between; gap: 8px; }
    .dash-table td::before {
        content: attr(data-label);
        font: 700 10px 'Inter', sans-serif; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-soft);
    }
}

/* ---------- Public share page (r.php) ---------- */
.share-card {
    margin: 40px auto; max-width: 720px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-soft);
    border-radius: 24px;
}
.dark .share-card { background: rgba(15, 15, 25, 0.55); }
.share-hero { text-align: center; margin-bottom: 24px; }
.share-hero-download { font: 900 72px/1 'Inter', sans-serif; color: var(--text-strong); letter-spacing: -0.03em; }
.share-hero-unit { font: 700 18px 'Inter', sans-serif; color: var(--text-soft); margin-left: 6px; }
.share-hero-caption { font: 600 11px 'Inter', sans-serif; text-transform: uppercase; letter-spacing: 0.18em; color: var(--primary); margin-top: 8px; }
.share-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.share-metric {
    padding: 14px; border-radius: 14px;
    background: rgba(0, 0, 0, 0.03); border: 1px solid var(--border-soft); text-align: center;
}
.dark .share-metric { background: rgba(255, 255, 255, 0.04); }
.share-metric-label { font: 700 10px 'Inter', sans-serif; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-soft); margin-bottom: 4px; }
.share-metric-value { font: 800 22px 'Inter', sans-serif; color: var(--text-strong); }
.share-footer { margin-top: 28px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--text-soft); }

/* Active nav link */
.nav-link.active {
    color: #0066FF !important;
    background: rgba(0, 102, 255, 0.08);
}
.dark .nav-link.active {
    color: #60a5fa !important;
    background: rgba(0, 102, 255, 0.15);
}

/* CTA en header de página de share (r.php) */
.share-run-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px;
    padding: 0 18px;
    background: linear-gradient(135deg, #0066FF 0%, #0052CC 100%);
    color: #fff;
    border-radius: 12px;
    font: 600 0.9rem 'Inter', sans-serif;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 6px 18px -4px rgba(0, 102, 255, 0.45);
    white-space: nowrap;
}
.share-run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -4px rgba(0, 102, 255, 0.6);
}
.share-run-btn svg { flex-shrink: 0; }
@media (max-width: 480px) {
    .share-run-btn span { display: none; }
    .share-run-btn { padding: 0 14px; }
}

/* ============================================================
   Mostrar métricas + quality solo después de iniciar el test
   ============================================================ */
#metrics,
#quality {
    display: none;
}
body.test-started #metrics {
    display: grid;
    animation: slideUp 0.55s cubic-bezier(0.4, 0, 0.2, 1) both;
}
body.test-started #quality {
    display: block;
    animation: slideUp 0.55s cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: 0.08s;
}

/* ============================================================
   Estabilizar el gauge (evita que "desaparezca" al scrollear)
   ============================================================ */
.gauge-wrap {
    width: 100%;
    max-width: 380px;
    aspect-ratio: 1 / 1;
    contain: layout paint;        /* aísla del reflow del scroll */
    will-change: transform;       /* evita repaints fantasma */
    min-height: 280px;            /* fallback si aspect-ratio no resuelve */
}
.gauge-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}






/* ============================================================
   Visibilidad: ocultar Quality + Ping/Jitter + Download/Upload
   hasta que se inicie el test
   ============================================================ */
#quality,
#metricsSecondary,
#metricsPrimary {
    display: none;
}
body.test-started #quality          { display: grid; animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1) both; }
body.test-started #metricsSecondary { display: flex; animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1) both; animation-delay: 0.05s; }
body.test-started #metricsPrimary   { display: grid; animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1) both; animation-delay: 0.1s; }

/* ============================================================
   PING / JITTER — chips tooltip ultracompactas (2026 style)
   ============================================================ */
.metric-tooltips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 380px;
}
.metric-tooltip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: all .2s ease;
    height: 32px;
}
.dark .metric-tooltip {
    background: rgba(20, 20, 25, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.metric-tooltip:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 102, 255, 0.3);
    box-shadow: 0 6px 18px rgba(0, 102, 255, 0.1);
}
.metric-tooltip-icon {
    width: 13px;
    height: 13px;
    color: var(--primary);
    flex-shrink: 0;
}
.metric-tooltip-label {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    font-size: 9px;
    color: var(--text-soft);
    line-height: 1;
}
.metric-tooltip-value {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
}
.metric-tooltip-unit {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-soft);
    margin-left: 2px;
}
.metric-tooltip.active {
    border-color: var(--primary);
    background: rgba(0, 102, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.15), 0 6px 18px rgba(0, 102, 255, 0.12);
}

/* ============================================================
   DOWNLOAD / UPLOAD — cards compactas, lado a lado
   ============================================================ */
.metrics-primary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 380px;
}
.metric-card.metric-card-featured {
    padding: 14px 16px;
    background:
        linear-gradient(135deg, rgba(0, 102, 255, 0.06) 0%, rgba(139, 92, 246, 0.06) 100%),
        var(--panel);
    border: 1px solid rgba(0, 102, 255, 0.18);
    border-radius: 16px;
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: 0 6px 20px rgba(0, 102, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.dark .metric-card.metric-card-featured {
    background:
        linear-gradient(135deg, rgba(0, 102, 255, 0.12) 0%, rgba(139, 92, 246, 0.10) 100%),
        var(--panel);
    border-color: rgba(0, 102, 255, 0.28);
}
.metric-card.metric-card-featured::before {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 90px; height: 90px;
    background: radial-gradient(circle, rgba(0, 102, 255, 0.12) 0%, transparent 70%);
    pointer-events: none;
}
.metric-card.metric-card-featured:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 102, 255, 0.12);
}
.metric-card.metric-card-featured > .metric-icon {
    width: 30px; height: 30px;
    border-radius: 9px;
}
.metric-card.metric-card-featured > .metric-icon svg { width: 15px; height: 15px; }
.metric-card.metric-card-featured > .metric-label {
    font-size: 10px;
    letter-spacing: 0.16em;
    color: var(--primary);
    font-weight: 800;
}
.dark .metric-card.metric-card-featured > .metric-label { color: #60a5fa; }
.metric-card.metric-card-featured > .metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: auto;
}
.metric-card.metric-card-featured > .metric-value-row > .metric-value {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    background: linear-gradient(135deg, #0066FF 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-variant-numeric: tabular-nums;
}
.dark .metric-card.metric-card-featured > .metric-value-row > .metric-value {
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.metric-card.metric-card-featured > .metric-value-row > .metric-unit {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-mid);
}
.metric-card.metric-card-featured.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.2), 0 12px 30px rgba(0, 102, 255, 0.18);
    transform: translateY(-2px);
}

/* ============================================================
   Quality grid en columna izquierda — más compacta
   ============================================================ */
#quality.quality-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.quality-card {
    padding: 14px 6px 12px;
    gap: 8px;
    border-radius: 14px;
}
.quality-card .quality-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
}
.quality-card .quality-icon svg { width: 18px; height: 18px; }
.quality-card .quality-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.qd { width: 5px; height: 5px; }
.quality-dots { gap: 4px; }

@media (max-width: 480px) {
    #quality.quality-grid { gap: 8px; }
    .quality-card { padding: 12px 4px 10px; }
    .quality-card .quality-icon { width: 30px; height: 30px; }
    .quality-card .quality-icon svg { width: 14px; height: 14px; }
}

/* ============================================================
   MÓVIL: aplanar el grid de 2 columnas y reordenar elementos
   Prioridad visual:
   1. status-chip
   2. hero-title + hero-sub
   3. gauge (PRIORIDAD)
   4. start button + progress
   5. ping / jitter (chips)
   6. download / upload (metrics)
   7. quality
   8. current-connection (al final)
   ============================================================ */
@media (max-width: 1023px) {
    /* Convertimos #test en un flex column plano */
    #test {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
    }

    /* Las dos columnas (izq/der) se vuelven "transparentes":
       sus hijos pasan a ser hijos directos de #test */
    #test > div {
        display: contents !important;
    }

	#test > div.space-y-6 > * {
    margin-top: 0 !important;
}

    /* Orden visual en móvil */
    .status-chip       { order: 1; align-self: flex-start; }
    .hero-title        { order: 2; }
    .hero-sub          { order: 3; }
    .gauge-wrap        { order: 4; align-self: center; }
    #startBtn          { order: 5; align-self: center; }
    .progress-wrap     { order: 6; align-self: center; }
    #metricsSecondary  { order: 7; align-self: center; }
    #metricsPrimary    { order: 8; align-self: center; }
    #quality           { order: 9; }
    .current-conn      { order: 10; }
}


/* ============================================================
   Espaciado del botón Start: pegado al gauge,
   separado de la progress bar
   ============================================================ */

/* Desktop (los valores anteriores funcionan bien aquí) */
#startBtn {
    margin-top: -18px;
}
.progress-wrap {
    margin-top: 14px;
}

/* Móvil / tablet: el canvas del gauge deja mucho espacio vacío abajo
   (el arco es semicircular y solo usa ~65% del alto), así que el
   botón necesita un pull-up mucho mayor para parecer pegado al gauge */
@media (max-width: 1023px) {
    #startBtn {
        margin-top: -70px;
    }
    .progress-wrap {
        margin-top: 32px;
    }
}

/* Móvil pequeño: el gauge es ligeramente menor, ajustamos proporciones */
@media (max-width: 480px) {
    #startBtn {
        margin-top: -55px;
    }
    .progress-wrap {
        margin-top: 26px;
    }
}