/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #22252f;
  --border: #2a2d37;
  --text: #e4e5e8;
  --text-muted: #8b8d95;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

/* === Header === */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  font-size: 1.2em;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 1rem;
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card-header {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* === Location Card === */
.location-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.loc-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loc-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.loc-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

/* === Action Bar === */
.action-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.btn-run {
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-run:hover {
  background: #2563eb;
}

.btn-run:active {
  transform: scale(0.97);
}

.btn-run:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* === Table === */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

tr:last-child td {
  border-bottom: none;
}

/* Latency color coding */
.latency-good { color: var(--green); font-weight: 700; }
.latency-ok   { color: var(--yellow); font-weight: 700; }
.latency-bad  { color: var(--red); font-weight: 700; }

/* Bar chart in table */
.bar-cell {
  width: 140px;
}

.bar-track {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s;
}

.bar-fill.good { background: var(--green); }
.bar-fill.ok   { background: var(--yellow); }
.bar-fill.bad  { background: var(--red); }

/* === Results Footer === */
.results-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
}

.results-footer strong {
  color: var(--text);
}

/* === Sparkline dots === */
.spark-cell {
  white-space: nowrap;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 3px;
  opacity: 0.85;
}

.dot.good        { background: var(--green); }
.dot.ok          { background: var(--yellow); }
.dot.latency-bad { background: var(--red); }

/* === Error Banner === */
.error-banner {
  background: #3b1117;
  border: 1px solid #5c1a24;
  color: #fca5a5;
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* === Footer === */
.footer {
  text-align: center;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-small {
  margin-top: 4px;
  font-size: 0.8rem;
}

.footer a {
  color: var(--blue);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* === Responsive === */
@media (max-width: 500px) {
  .container {
    padding: 24px 12px;
  }
  .location-info {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .action-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  th, td {
    padding: 8px 6px;
    font-size: 0.82rem;
  }
}
