:root {
    /* Backgrounds */
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-box: #f8fafc;
    --border-box: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;

    /* --- FIXED ACCENT COLORS --- */
    --acc-orange: #f97316;  /* Orange for IP Card */
    --acc-green: #10b93a;   /* Green for Connection */
    --acc-red: #ef4444;     /* Red for Speed Test */
    --acc-blue: #3b9cf6;    /* Blue for System */
    
    /* Soft Tones */
    --soft-blue: #eff6ff;
    --soft-green: #ecfdf5;
}

/* 1. Orange (for Main Public IP Card) */
.accent-blue-top { 
    border-top: 4px solid var(--acc-red) !important; 
}
.text-blue { 
    color: var(--acc-red) !important; 
}

/* 2. Green (for Connection Card) */
.accent-green-top { 
    border-top: 4px solid var(--acc-blue) !important; 
}
.text-green { 
    color: var(--acc-blue) !important; 
}

/* 3. Red (for Speed Test Card) */
.accent-red-top { 
    border-top: 4px solid var(--acc-red) !important; 
}
.text-red { 
    color: var(--acc-red) !important; 
}

/* 4. Blue (for System Card) */
.accent-dark-top { 
    border-top: 4px solid var(--acc-green) !important; 
}
.text-dark { 
    color: var(--acc-green) !important; 
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    margin: 0; min-height: 100vh;
    display: flex; justify-content: center;
    padding: 20px; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.main-wrapper { width: 100%; max-width: 900px; }

/* HEADER */
.header-section { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-wrap: wrap; gap: 15px; }
.title-group h1 { font-size: 1.4rem; font-weight: 800; margin: 0 0 5px 0; color: var(--text-main); }
.status-pill { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 4px 12px; border-radius: 20px; background: var(--soft-green); color: var(--acc-green); border: 1px solid #d1fae5; }

/* TABS */
.nav-tabs { background: #e2e8f0; padding: 3px; border-radius: 30px; display: flex; gap: 0; width: fit-content; }
.tab-btn { border: none; background: transparent; padding: 8px 20px; border-radius: 30px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: 0.2s; white-space: nowrap; }
.tab-btn.active { background-color: var(--acc-blue); color: #ffffff; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3); }
.tab-content { display: none; animation: fadeUp 0.3s ease; }
.tab-content.active-content { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* IP INFO CARD */
.clean-card { background: var(--bg-card); border-radius: 16px; padding: 25px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); margin-bottom: 20px; border: 1px solid #fff; position: relative; overflow: hidden; }
.accent-blue-top { border-top: 4px solid var(--acc-blue); } .accent-green-top { border-top: 4px solid var(--acc-green); } .accent-dark-top { border-top: 4px solid var(--acc-blue); }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.card-label-top { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; }
.icon-badge { font-size: 0.75rem; font-weight: 700; padding: 4px 8px; border-radius: 6px; background: var(--soft-blue); color: var(--acc-blue); }

/* --- CENTERED IP DISPLAY --- */
.ip-display-centered {
    text-align: center; /* Ensures text is centered */
    display: flex;
    flex-direction: column;
    align-items: center; /* Flex center */
    justify-content: center;
    margin-bottom: 25px;
    width: 100%;
}
.ip-display-centered h2 { 
    font-size: 2.5rem; font-weight: 800; margin: 0; 
    color: var(--text-main); word-break: break-all; line-height: 1.1;
}
.location-row { color: var(--text-muted); font-size: 0.95rem; margin-top: 5px; }

.data-box { background: var(--bg-box); border: 1px solid var(--border-box); padding: 12px 15px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; }
.box-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); }
.box-value { font-size: 0.9rem; font-weight: 600; color: var(--text-main); text-align: right; }
.text-blue { color: var(--acc-blue); } .text-green { color: var(--acc-green); } .text-dark { color: var(--acc-dark); }
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.info-stack { display: flex; flex-direction: column; gap: 10px; }
.card-title { margin: 0 0 15px 0; font-size: 1rem; font-weight: 700; }

/* --- SPEED TEST LAYOUT (FIXED OVERLAP) --- */
.speed-dashboard-card { background: #fff; border-radius: 20px; padding: 30px; box-shadow: 0 10px 40px rgba(0,0,0,0.05); }

/* Flex Container for Speed Components */
.speed-flex-layout {
    display: flex;
    flex-wrap: wrap; /* Allows wrapping on small screens */
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
}

/* 1. Gauge Section */
.gauge-area { flex: 0 0 auto; display: flex; justify-content: center; width: 260px; margin: 0 auto; }
.gauge-wrapper-fixed { position: relative; width: 260px; height: 260px; }
#gaugeCanvas { width: 100%; height: 100%; position: absolute; top:0; left:0; z-index: 1; pointer-events: none; }

.gauge-center-text { position: absolute; top: 55%; left: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 5; }
#liveSpeedText { font-size: 3.5rem; font-weight: 300; line-height: 1; color: var(--text-main); }
#liveUnitText { font-size: 1rem; color: var(--text-muted); font-weight: 600; }
.hidden { opacity: 0; pointer-events: none; }

/* GO Button */
.go-circle-btn {
    position: absolute; width: 100%; height: 100%; border-radius: 50%;
    background: #fff; border: 2px solid var(--acc-orange);
    color: var(--acc-orange); font-size: 4rem; font-weight: 300;
    cursor: pointer; box-shadow: 0 0 0 10px rgba(249, 115, 22, 0.05);
    transition: 0.3s; z-index: 10;
}
.go-circle-btn:hover { background: var(--acc-orange); color: #fff; transform: scale(1.02); }
.go-circle-btn.hide { opacity: 0; pointer-events: none; transform: scale(0.5); }

/* Restart Button Style (Dynamic) */
.restart-btn-style { 
    display: flex; align-items: center; justify-content: center;
    border-width: 4px; background: #fff;
}
.restart-btn-style:hover { background: var(--acc-orange); color: #fff; }

/* 2. Stats Section */
.stats-area { flex: 1; display: flex; flex-direction: column; gap: 20px; min-width: 120px; justify-content: center; }
.stat-row-item { display: flex; align-items: center; gap: 10px; }
.si-icon { font-size: 1.2rem; color: var(--text-muted); width: 20px; text-align: center; }
.si-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); }
.si-val { font-size: 1.5rem; font-weight: 300; color: var(--text-main); line-height: 1; }
.si-val small { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }

/* 3. Graphs Section */
.graphs-area { flex: 1; display: flex; flex-direction: column; gap: 15px; min-width: 180px; }
.graph-box {
    border: 1px solid var(--border-box); border-radius: 8px; padding: 10px 15px;
    background: #fff; position: relative; overflow: hidden; height: 90px;
    display: flex; flex-direction: column; justify-content: center;
}
.graph-box.active { border-color: var(--acc-orange); box-shadow: 0 4px 10px rgba(249, 115, 22, 0.1); }
.gb-head { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
.gb-val { font-size: 1.8rem; font-weight: 300; color: var(--text-main); position: relative; z-index: 2; }
.mini-chart { position: absolute; bottom: 0; left: 0; width: 100%; height: 50px; z-index: 1; pointer-events: none; }

/* Footer */
.speed-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-box); padding-top: 20px; flex-wrap: wrap; gap: 15px; }
.sf-item { display: flex; flex-direction: column; gap: 2px; }
.sf-item.right { text-align: right; }
.sf-label { font-size: 0.7rem; font-weight: 700; color: #cbd5e1; }
.sf-sub { font-size: 0.8rem; color: var(--text-muted); }
.sf-item strong { color: var(--text-main); font-size: 0.95rem; }
.sf-center { font-weight: 700; color: var(--acc-orange); text-transform: uppercase; font-size: 0.9rem; }

.footer-area { text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border-box); color: var(--text-muted); font-size: 0.8rem; }
.dev-link { color: var(--acc-blue); text-decoration: none; font-weight: 600; }

/* --- RESPONSIVE FIXES --- */
@media (max-width: 900px) {
    /* Tablet/Small Laptop: Wrap nicely */
    .speed-flex-layout { justify-content: center; }
    .stats-area { flex-direction: row; width: 100%; justify-content: space-around; order: 2; }
    .gauge-area { order: 1; margin-bottom: 10px; }
    .graphs-area { width: 100%; order: 3; flex-direction: row; }
    .graph-box { flex: 1; }
}

@media (max-width: 600px) {
    /* Mobile */
    body { padding: 15px 10px; }
    .header-section { flex-direction: column; text-align: center; gap: 15px; }
    .grid-2-col { grid-template-columns: 1fr; }
    .ip-display-centered h2 { font-size: 2rem; }
    
    .graphs-area { flex-direction: column; } /* Stack graphs on mobile */
    .speed-footer { justify-content: center; text-align: center; }
    .sf-item.right { text-align: center; }
    
    .gauge-wrapper-fixed { width: 240px; height: 240px; }
    .go-circle-btn { font-size: 3rem; }
    #liveSpeedText { font-size: 3rem; }
}