:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --download: #4cc9f0;
    --upload: #f72585;
    --background: #f8f9fa;
    --card-bg: #ffffff;
    --text: #2b2d42;
    --text-light: #8d99ae;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --graph-bg: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --primary: #4895ef;
    --secondary: #4361ee;
    --background: #121212;
    --card-bg: #1e1e1e;
    --text: #f8f9fa;
    --text-light: #adb5bd;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --graph-bg: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--background);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    color: var(--text);
}

.container {
    width: 100%;
    max-width: 1200px;
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px;
    overflow: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

h1 {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(67, 97, 238, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.dashboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.main-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.speed-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.speed-card.download {
    border-top: 4px solid var(--download);
}

.speed-card.upload {
    border-top: 4px solid var(--upload);
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
}

.speed-icon {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: 8px;
}

.speed-card.download .speed-icon {
    color: var(--download);
}

.speed-card.upload .speed-icon {
    color: var(--upload);
}

.speed-value {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.speed-unit {
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: var(--text-light);
    margin-bottom: 8px;
}

.speed-label {
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.speed-graph {
    height: 4px;
    width: 100%;
    background-color: var(--graph-bg);
    border-radius: 5px;
    overflow: hidden;
    margin-top: auto;
}

.speed-graph::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--width, 0%);
    transition: width 0.5s ease;
}

#download-graph::after {
    background-color: var(--download);
}

#upload-graph::after {
    background-color: var(--upload);
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    align-content: start;
}

.info-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.info-card i {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--primary);
    margin-bottom: 8px;
}

.info-value {
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    font-weight: 600;
    line-height: 1;
    margin-bottom: 4px;
}

.info-label {
    font-size: clamp(0.65rem, 1.2vw, 0.8rem);
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-chart {
    width: 100%;
    height: clamp(150px, 25vh, 200px);
    min-height: 150px;
}

.byline {
    font-size: 0.8em;
    color: var(--text-light);
    font-weight: normal;
}

.byline a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.byline a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .main-cards {
        grid-template-columns: 1fr;
    }
    
    .info-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
        border-radius: 12px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .connection-info {
        order: 1;
        width: 100%;
        justify-content: center;
    }
    
    .info-cards {
        grid-template-columns: 1fr;
    }
    
    .speed-card {
        padding: 20px;
    }
    
    .header h1 {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .byline {
        margin-left: 28px;
        font-size: 0.7em;
    }
}