/* Custom CSS Design Tokens (Cloudflare Speed & Dark Neon Palette) */
:root {
    --bg-dark: #090c10;
    --card-bg: rgba(22, 27, 34, 0.75);
    --card-border: rgba(48, 54, 61, 0.8);
    --card-hover: rgba(33, 38, 45, 0.9);
    
    --cf-orange: #f38020;
    --cyan-accent: #00f2fe;
    --purple-accent: #7f53ac;
    --green-accent: #64dd17;
    --red-accent: #ff3d00;
    --yellow-accent: #ffd600;

    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-glow-cyan: 0 0 25px rgba(0, 242, 254, 0.25);
    --shadow-glow-orange: 0 0 25px rgba(243, 128, 32, 0.25);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.5;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
}

/* Typography Helpers */
.accent-text {
    color: var(--cf-orange);
}

/* Header & Navbar (bufferbloattesti.com Menu Style) */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(9, 12, 16, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.75rem 1.5rem;
    width: 100%;
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--cf-orange), #ff4e00);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    box-shadow: var(--shadow-glow-orange);
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Navigation Links Container */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(13, 17, 23, 0.7);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(48, 54, 61, 0.5);
}

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--cf-orange), #e65100);
    box-shadow: 0 3px 12px rgba(243, 128, 32, 0.35);
}

/* Mobile Toggle Hamburger Button */
.mobile-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    font-size: 1.3rem;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-toggle:hover, .mobile-toggle:active {
    background: var(--card-border);
    color: var(--cf-orange);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, var(--cf-orange), #e65100);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(243, 128, 32, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 128, 32, 0.5);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-hero {
    padding: 0.85rem 2.2rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(243, 128, 32, 0.45);
    min-height: 48px;
}

.btn-secondary {
    background: rgba(48, 54, 61, 0.6);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(68, 76, 86, 0.8);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}

/* Main Container */
.main-container {
    max-width: 1280px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    width: 100%;
    overflow-x: hidden;
}

/* Live Status & Progress Section */
.test-progress-bar-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.test-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

.network-badges-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.badge {
    background: rgba(33, 38, 45, 0.9);
    border: 1px solid var(--card-border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.server-badge {
    border-color: rgba(0, 242, 254, 0.3);
    color: var(--cyan-accent);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.status-label {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-percent {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--cf-orange);
    font-size: 1.1rem;
}

.progress-track {
    height: 8px;
    background: rgba(48, 54, 61, 0.5);
    border-radius: var(--radius-full);
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cf-orange), var(--cyan-accent));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.phase-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    width: 100%;
}

.step-item {
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    background: rgba(22, 27, 34, 0.4);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step-item.active {
    color: var(--cyan-accent);
    border-color: rgba(0, 242, 254, 0.4);
    background: rgba(0, 242, 254, 0.08);
}

.step-item.completed {
    color: var(--green-accent);
}

/* Cards & Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, 1fr);
    gap: 1.25rem;
    width: 100%;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.card:hover {
    border-color: rgba(139, 148, 158, 0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-mini {
    font-size: 0.68rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(48, 54, 61, 0.5);
    color: var(--text-secondary);
}

.down-badge { color: var(--cyan-accent); background: rgba(0, 242, 254, 0.1); }
.up-badge { color: var(--purple-accent); background: rgba(127, 83, 172, 0.15); }

/* Overall Bufferbloat Grade Card */
.grade-card {
    background: linear-gradient(145deg, rgba(22, 27, 34, 0.9), rgba(13, 17, 23, 0.95));
    border-color: rgba(243, 128, 32, 0.3);
}

.grade-body {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.grade-badge-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    font-weight: 800;
    border: 4px solid var(--text-muted);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.grade-aplus { border-color: var(--cyan-accent); color: var(--cyan-accent); box-shadow: var(--shadow-glow-cyan); }
.grade-a { border-color: var(--green-accent); color: var(--green-accent); box-shadow: 0 0 20px rgba(100, 221, 23, 0.3); }
.grade-b { border-color: var(--yellow-accent); color: var(--yellow-accent); }
.grade-c { border-color: var(--cf-orange); color: var(--cf-orange); }
.grade-d { border-color: #ff9100; color: #ff9100; }
.grade-f { border-color: var(--red-accent); color: var(--red-accent); box-shadow: 0 0 20px rgba(255, 61, 0, 0.4); }

.grade-details h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.grade-details p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(33, 38, 45, 0.8);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.metric-pill .value {
    font-weight: 700;
    color: var(--cf-orange);
}

/* Metric Cards Numbers */
.metric-value-container {
    margin: 0.5rem 0;
}

.main-metric {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.main-metric .number {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
}

.main-metric .unit {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.down-color .number { color: var(--cyan-accent); }
.up-color .number { color: var(--purple-accent); }

.metric-sub-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-top: 1px solid rgba(48, 54, 61, 0.5);
    padding-top: 0.5rem;
    font-size: 0.78rem;
}

.sub-stat {
    display: flex;
    justify-content: space-between;
}

.sub-label { color: var(--text-secondary); }
.sub-val { font-weight: 600; font-family: var(--font-mono); }
.spike-tag { color: var(--cf-orange); }

/* Measurements Breakdown Section */
.breakdown-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    width: 100%;
    box-sizing: border-box;
}

.breakdown-heading {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
}

.breakdown-card h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chunk-progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.chunk-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
    width: 100%;
}

.chunk-name {
    width: 52px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.chunk-bar {
    flex: 1;
    height: 6px;
    background: rgba(48, 54, 61, 0.5);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.chunk-fill {
    height: 100%;
    width: 0%;
    background: var(--cyan-accent);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.breakdown-card:last-child .chunk-fill {
    background: var(--purple-accent);
}

.chunk-val {
    width: 84px;
    white-space: nowrap;
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 600;
    flex-shrink: 0;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    width: 100%;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chart-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-legend-custom {
    display: flex;
    gap: 1rem;
    font-size: 0.78rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-speed .dot { background: var(--cyan-accent); }
.legend-ping .dot { background: var(--cf-orange); }

.chart-wrapper {
    position: relative;
    height: 240px;
    width: 100%;
}

/* History Section (Last 10 Test Results Table) */
.history-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.history-table-container {
    overflow-x: auto;
    margin-top: 1rem;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
    white-space: nowrap;
}

.history-table th {
    background: rgba(33, 38, 45, 0.7);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border);
}

.history-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.4);
    font-family: var(--font-mono);
}

.history-table tr:hover td {
    background: rgba(33, 38, 45, 0.4);
}

.empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

.history-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.8rem;
    text-align: center;
    min-width: 32px;
}

/* SQM & Calculator Section (PREVENT OVERFLOW FLAWLESSLY) */
.sqm-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.section-title-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.title-icon {
    width: 44px;
    height: 44px;
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cyan-accent);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.section-title-box h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.section-title-box p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.sqm-calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

.sqm-box {
    background: rgba(13, 17, 23, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.sqm-box h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.box-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.percentage-selector {
    margin-bottom: 1.25rem;
    width: 100%;
}

.percentage-selector label {
    font-size: 0.82rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.radio-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: rgba(22, 27, 34, 0.8);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.radio-btn span {
    word-break: break-word;
    white-space: normal;
}

.radio-btn.active {
    border-color: var(--cyan-accent);
    background: rgba(0, 242, 254, 0.08);
    color: var(--cyan-accent);
}

.sqm-calculated-results {
    background: rgba(22, 27, 34, 0.9);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    box-sizing: border-box;
}

.sqm-result-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    gap: 0.5rem;
}

.res-label { color: var(--text-secondary); }
.res-value { font-family: var(--font-mono); font-weight: 700; color: var(--cyan-accent); }

.sqm-algorithm-select {
    width: 100%;
}

.sqm-algorithm-select select {
    width: 100%;
    max-width: 100%;
    padding: 0.6rem;
    background: var(--bg-dark);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85rem;
    margin-top: 0.3rem;
    box-sizing: border-box;
    text-overflow: ellipsis;
}

.algo-note {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    word-break: break-word;
}

/* Config Output Box */
.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

.tab-buttons {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-dark);
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--card-border);
    color: var(--text-primary);
    font-weight: 600;
}

.code-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.code-container pre {
    background: #05070a;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #e6edf3;
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    max-height: 240px;
    -webkit-overflow-scrolling: touch;
}

.code-container .btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* Guide Section */
.guide-section {
    margin-top: 1rem;
    width: 100%;
}

.section-heading {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    width: 100%;
}

.guide-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    width: 100%;
    box-sizing: border-box;
}

.guide-icon {
    font-size: 1.5rem;
    color: var(--cf-orange);
    margin-bottom: 0.75rem;
}

.guide-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.guide-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    border-top: 1px solid var(--card-border);
    padding: 1.5rem;
    margin-top: 3rem;
    background: rgba(9, 12, 16, 0.92);
    width: 100%;
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

/* ==========================================
   FLAWLESS MOBILE RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================== */

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
    .grade-card {
        grid-column: span 2;
    }
    .charts-section {
        grid-template-columns: 1fr;
    }
    .sqm-calculator-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 1rem;
    }

    .nav-container {
        position: relative;
    }

    .mobile-toggle {
        display: flex;
    }

    /* Mobile Dropdown Menu Drawer */
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(9, 12, 16, 0.98);
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        border: 1px solid var(--card-border);
        border-top: none;
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
        gap: 0.5rem;
        box-shadow: 0 15px 35px rgba(0,0,0,0.8);
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }

    .nav-menu.open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
        border-radius: var(--radius-sm);
    }

    .main-container {
        padding: 0 1rem;
        margin: 1rem auto;
        gap: 1.25rem;
    }

    .test-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-hero {
        width: 100%;
        justify-content: center;
    }

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

    .grade-card {
        grid-column: span 1;
    }

    .grade-body {
        flex-direction: column;
        text-align: center;
    }

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

    .sqm-calculator-grid {
        grid-template-columns: 1fr;
    }

    .guide-cards {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .brand-title {
        font-size: 1.05rem;
    }
    .brand-subtitle {
        font-size: 0.65rem;
    }

    .main-metric .number {
        font-size: 1.9rem;
    }

    .phase-steps {
        grid-template-columns: repeat(2, 1fr);
    }

    .history-section, .sqm-section, .breakdown-section, .chart-card {
        padding: 0.85rem;
    }

    .sqm-box {
        padding: 0.85rem;
    }

    .tab-buttons {
        width: 100%;
    }

    .tab-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 360px) {
    .phase-steps {
        grid-template-columns: 1fr;
    }
    .grade-badge-circle {
        width: 76px;
        height: 76px;
        font-size: 2.2rem;
    }
}

/* ==========================================
   Ağ Kalitesi Skoru (Cloudflare AIM)
   ========================================== */
.aim-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    width: 100%;
    box-sizing: border-box;
}

.heading-note {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(48, 54, 61, 0.5);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
}

.aim-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.aim-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(33, 38, 45, 0.55);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 0.9rem;
    min-width: 0;
}

.aim-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: rgba(48, 54, 61, 0.6);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.aim-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.aim-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aim-value {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Sınıflandırma renkleri: great → bad */
.aim-value.aim-great   { color: var(--green-accent); }
.aim-value.aim-good    { color: var(--cyan-accent); }
.aim-value.aim-average { color: var(--yellow-accent); }
.aim-value.aim-poor    { color: var(--cf-orange); }
.aim-value.aim-bad     { color: var(--red-accent); }

.aim-card:has(.aim-great)   { border-color: rgba(100, 221, 23, 0.35); }
.aim-card:has(.aim-good)    { border-color: rgba(0, 242, 254, 0.3); }
.aim-card:has(.aim-average) { border-color: rgba(255, 214, 0, 0.3); }
.aim-card:has(.aim-poor)    { border-color: rgba(243, 128, 32, 0.35); }
.aim-card:has(.aim-bad)     { border-color: rgba(255, 61, 0, 0.4); }

@media (max-width: 768px) {
    .aim-card {
        padding: 0.65rem;
        gap: 0.55rem;
    }

    .aim-icon {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
}

/* .aim-card display:flex tasidigi icin [hidden] ozniteligini eziyordu;
   gizlenmesi gereken kartlar gorunur kaliyordu. */
.aim-section[hidden],
.aim-card[hidden] {
    display: none !important;
}

/* ==========================================
   Bağlantı Ayrıntıları (Cloudflare Edge + TCP)
   ========================================== */
#netinfo-section[hidden] {
    display: none !important;
}

.netinfo-list {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.netinfo-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.4);
}

.netinfo-row:last-child {
    border-bottom: none;
}

.netinfo-key {
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.netinfo-val {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    word-break: break-all;
    min-width: 0;
}

/* IPv6/IPv4 gibi küçük etiketler */
.netinfo-tag {
    display: inline-block;
    font-family: var(--font-main);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.35rem;
    margin-left: 0.35rem;
    border-radius: var(--radius-sm);
    background: rgba(48, 54, 61, 0.7);
    color: var(--text-secondary);
    vertical-align: middle;
}

/* Kuyruk gecikmesi ve yeniden gönderim için durum renkleri */
.netinfo-val.net-good  { color: var(--green-accent); }
.netinfo-val.net-warn  { color: var(--yellow-accent); }
.netinfo-val.net-bad   { color: var(--red-accent); }

@media (max-width: 480px) {
    .netinfo-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    .netinfo-val {
        text-align: left;
    }
}

.netinfo-note {
    display: block;
    font-size: 0.62rem;
    color: var(--text-muted);
}


/* ==========================================
   Test Ayrıntıları bandı
   AIM skorları, ölçüm katmanları ve bağlantı bilgisi tek bantta.
   ========================================== */
.details-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    width: 100%;
    box-sizing: border-box;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    align-items: start;
    width: 100%;
}

.details-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}

.details-card[hidden] {
    display: none !important;
}

.details-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border);
}

/* Aynı sütunda ikinci bir başlık (Bağlantı → TCP Katmanı) */
.details-title-sub {
    margin-top: 0.6rem;
}

.details-note {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(48, 54, 61, 0.5);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
}

/* 4 sütun ancak geniş ekranda sığıyor */
@media (max-width: 1180px) {
    .details-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem 1.25rem;
    }
}

@media (max-width: 640px) {
    .details-section {
        padding: 0.85rem;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 1.1rem;
    }
}

/* TCP bloğu ayrı bir sarmalayıcı; hidden'ı garantiye al */
#netinfo-tcp[hidden] {
    display: none !important;
}

.aim-section[hidden] {
    display: none !important;
}

@media (max-width: 640px) {
    .aim-section {
        padding: 0.85rem;
    }
}
