*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --on-primary: #fff;
  --error: #d93025;
  --error-light: #fce8e6;
  --surface: #fff;
  --background: #f8f9fa;
  --on-surface: #202124;
  --on-surface-variant: #5f6368;
  --outline: #dadce0;
  --success: #1e8e3e;
  --success-light: #e6f4ea;
  --radius: 12px;
}

html {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  color: var(--on-surface);
  background: var(--background);
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
}

.container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

/* Run button */
.btn-run {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-run:hover:not(:disabled) {
  background: #1765cc;
}

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

/* Spinner inside button */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Step tracker */
.steps {
  width: 100%;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
}

.step-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.step-icon .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--outline);
}

.step-icon .dot.active {
  background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

.step-text {
  flex: 1;
}

.step-text .label {
  font-size: 0.95rem;
  line-height: 1.4;
}

.step-text .detail {
  font-size: 0.8rem;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.step-row.success .label {
  color: var(--primary);
  font-weight: 600;
}

.step-row.error .label {
  color: var(--error);
  font-weight: 600;
}

.step-row.loading .label {
  color: var(--primary);
}

.step-row.done .label {
  color: var(--on-surface-variant);
}

/* Phone number result */
.phone-result {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* Latency card */
.latency-card {
  width: 100%;
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px;
}

.latency-card.error {
  background: var(--error-light);
  border-color: var(--error);
}

.latency-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.latency-row {
  display: flex;
  justify-content: space-evenly;
  gap: 8px;
}

.latency-item {
  text-align: center;
}

.latency-item .label {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
}

.latency-item .value {
  font-size: 1rem;
  font-weight: 600;
}

.latency-item.secondary .label {
  opacity: 0.6;
}

.latency-item.secondary .value {
  font-weight: 400;
  font-size: 0.9rem;
  opacity: 0.7;
}

.latency-divider {
  border: none;
  border-top: 1px solid var(--outline);
  margin: 12px 0;
}

.latency-total {
  text-align: center;
  margin-top: 12px;
}

.latency-total .telco {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.latency-total .e2e {
  font-size: 0.85rem;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.latency-card.error .latency-total .telco {
  color: var(--error);
}

/* Error retry */
.btn-retry {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  margin-top: 4px;
}

.btn-retry:hover {
  text-decoration: underline;
}

/* API not available banner */
.api-banner {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fff3e0;
  border: 1px solid #ffb74d;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: #e65100;
  text-align: center;
}

/* Hidden */
.hidden {
  display: none !important;
}

@media (max-width: 400px) {
  body {
    padding: 16px 8px 32px;
  }
  h1 {
    font-size: 1.25rem;
  }
}
