:root {
  --bg: #070d1d;
  --bg-soft: #0d1a34;
  --card: #0e1730;
  --ink: #eef4ff;
  --muted: #9db1cf;
  --primary: #2fd3ff;
  --primary-dark: #2b78ff;
  --ring-track: #233866;
  --ring-fill-a: #32d5ff;
  --ring-fill-b: #61f0c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at 20% 12%, #19305e 0, transparent 40%),
    radial-gradient(circle at 80% 15%, #153a52 0, transparent 38%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 14px;
}

.panel {
  width: 100%;
  max-width: 1180px;
  background: linear-gradient(180deg, rgba(18, 29, 58, .96) 0%, rgba(11, 20, 43, .96) 100%);
  border: 1px solid rgba(64, 99, 158, .4);
  border-radius: 24px;
  padding: 24px 28px 20px;
  box-shadow: 0 24px 60px rgba(2, 8, 24, .45);
  animation: rise .55s ease-out;
}

.brand {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.brand img {
  max-width: 180px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

@keyframes rise {
  from {
    transform: translateY(16px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

h1 {
  margin: 0 0 6px;
  text-align: center;
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  letter-spacing: 1px;
}

.subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  text-align: center;
  font-size: .92rem;
}

.subtitle-note {
  margin-bottom: 12px;
  font-size: .84rem;
  color: #86a0c8;
}

.main-meter {
  position: relative;
  margin: 0 auto 2px;
  width: min(620px, 100%);
  padding: 0;
}

#gauge-main {
  width: 100%;
  height: auto;
  display: block;
}

.meter-readout {
  position: absolute;
  inset: auto 0 -4px;
  text-align: center;
  z-index: 2;
}

.meter-value {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  letter-spacing: .5px;
  font-weight: 700;
}

.meter-unit {
  color: #66d9ff;
  margin-top: 4px;
  font-size: .82rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.meter-label {
  display: none;
}

.status-bar {
  margin: 4px 0 10px;
  text-align: center;
  color: #9ec3ef;
  font-weight: 500;
  min-height: 18px;
  letter-spacing: .4px;
  font-size: .9rem;
}

.status-bar.running {
  color: #56e0ff;
}

.grid {
  display: grid;
  gap: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

label.title {
  font-weight: 700;
  font-size: .88rem;
  color: #cde1ff;
}

select,
input[type="file"] {
  width: 100%;
  border: 1px solid rgba(110, 153, 222, .3);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: #e9f2ff;
  background: rgba(26, 39, 69, .7);
  transition: .2s border-color, .2s box-shadow;
}

select:focus,
input[type="file"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 211, 255, .16);
}

.locations {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.location {
  position: relative;
}

.location input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.location span {
  display: block;
  text-align: center;
  padding: 10px 8px 8px;
  border: 1px solid rgba(110, 153, 222, .3);
  border-radius: 12px;
  background: rgba(26, 39, 69, .7);
  color: #cfe1fa;
  font-weight: 600;
  transition: .2s;
  font-size: .9rem;
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.location span strong {
  display: block;
  font-size: .86rem;
  letter-spacing: .5px;
}

.location span small {
  display: block;
  font-size: .66rem;
  color: #98b0d3;
  line-height: 1.2;
}

.location-s3 span {
  background: linear-gradient(180deg, rgba(26, 39, 69, .78) 0%, rgba(24, 52, 86, .84) 100%);
}

.location input:checked+span {
  border-color: var(--primary);
  background: rgba(47, 211, 255, .14);
  color: #8fe8ff;
  box-shadow: inset 0 0 0 1px rgba(47, 211, 255, .45);
}

.cta {
  margin-top: 2px;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  letter-spacing: .7px;
  color: #031426;
  background: linear-gradient(135deg, #3ce4ff, #61f0c8);
  cursor: pointer;
  transition: .2s transform, .2s filter;
}

.cta:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.cta:disabled {
  opacity: .7;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.result-modal[hidden] {
  display: none;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.result-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 9, 24, .72);
  backdrop-filter: blur(10px);
}

.result-modal__panel {
  position: relative;
  width: min(720px, calc(100% - 28px));
  margin: min(8vh, 56px) auto;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(94, 137, 210, .28);
  background: linear-gradient(180deg, rgba(24, 35, 68, .98) 0%, rgba(12, 20, 41, .98) 100%);
  box-shadow: 0 28px 60px rgba(0, 0, 0, .42);
}

.result-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.result-modal__titlewrap {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.result-modal__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2fd3ff, #61f0c8);
  box-shadow: 0 0 0 5px rgba(47, 211, 255, .09);
  flex: 0 0 12px;
}

.result-modal__title {
  font-size: 1.2rem;
  color: #dbe9ff;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-modal__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(38, 56, 99, .8);
  color: #e7f1ff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.result-modal__metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.result-modal__metric {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(18, 30, 58, .74);
  border: 1px solid rgba(84, 120, 185, .24);
}

.result-modal__metric small {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9cb3d7;
  margin-bottom: 6px;
  font-size: .82rem;
  letter-spacing: .3px;
}

.result-modal__metric small em {
  margin-left: auto;
  font-style: normal;
  font-size: .76rem;
  color: #7da0d2;
}

.metric-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  position: relative;
  flex: 0 0 18px;
}

.metric-icon::before,
.metric-icon::after {
  content: "";
  position: absolute;
}

.metric-icon--download {
  border: 1px solid rgba(59, 220, 255, .45);
}

.metric-icon--download::before {
  width: 2px;
  height: 7px;
  background: #52dcff;
  top: 3px;
}

.metric-icon--download::after {
  width: 6px;
  height: 6px;
  border-right: 2px solid #52dcff;
  border-bottom: 2px solid #52dcff;
  transform: rotate(45deg);
  bottom: 3px;
}

.metric-icon--upload {
  border: 1px solid rgba(177, 103, 255, .5);
}

.metric-icon--upload::before {
  width: 2px;
  height: 7px;
  background: #b17dff;
  bottom: 3px;
}

.metric-icon--upload::after {
  width: 6px;
  height: 6px;
  border-left: 2px solid #b17dff;
  border-top: 2px solid #b17dff;
  transform: rotate(45deg);
  top: 3px;
}

.metric-icon--ping {
  border: 1px solid rgba(255, 205, 92, .45);
  color: #ffcd5c;
}

.metric-icon--ping::before {
  inset: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.metric-icon--ping::after {
  width: 7px;
  height: 2px;
  background: currentColor;
  top: 8px;
  left: 8px;
  transform-origin: left center;
  transform: rotate(-35deg);
}

.result-modal__metric strong {
  display: block;
  font-size: clamp(1.55rem, 3.2vw, 2.25rem);
  line-height: 1;
  color: #f4f8ff;
}

.ping-good {
  color: #61f0c8 !important;
}

.ping-good.metric-icon--ping {
  border-color: rgba(97, 240, 200, .45) !important;
}

.ping-medium {
  color: #ffd166 !important;
}

.ping-medium.metric-icon--ping {
  border-color: rgba(255, 209, 102, .45) !important;
}

.ping-high {
  color: #ff6b6b !important;
}

.ping-high.metric-icon--ping {
  border-color: rgba(255, 107, 107, .45) !important;
}

.result-modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(18, 30, 58, .64);
  border: 1px solid rgba(84, 120, 185, .22);
  color: #cfe1ff;
  letter-spacing: .2px;
}

.chip strong {
  font-weight: 700;
  color: #eef5ff;
}

.chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(154, 175, 210, .85);
  box-shadow: 0 0 0 4px rgba(154, 175, 210, .12);
  flex: 0 0 8px;
}

.chip--good .chip__dot {
  background: rgba(97, 240, 200, .95);
  box-shadow: 0 0 0 4px rgba(97, 240, 200, .12);
}

.result-modal__insight {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: rgba(12, 48, 70, .35);
  border: 1px solid rgba(47, 211, 255, .18);
  color: #d8e8ff;
  margin-bottom: 18px;
}

.result-modal__insighticon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(47, 211, 255, .16);
  border: 1px solid rgba(47, 211, 255, .2);
  position: relative;
}

.result-modal__insighticon::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 2px solid rgba(47, 211, 255, .8);
}

.result-modal__insighticon::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 2px;
  background: rgba(47, 211, 255, .8);
  left: 24px;
  top: 24px;
  transform-origin: left center;
  transform: rotate(-40deg);
}

.result-modal__insighttext {
  line-height: 1.5;
  color: #d2e5ff;
}

.result-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  letter-spacing: .4px;
  cursor: pointer;
}

.btn-primary {
  color: #031426;
  background: linear-gradient(135deg, #3ce4ff, #61f0c8);
}

.btn-secondary {
  color: #dbe9ff;
  background: rgba(26, 39, 69, .8);
  border: 1px solid rgba(84, 120, 185, .22);
}

@media (min-width: 901px) and (max-height: 900px) {
  .panel {
    padding: 18px 24px 16px;
  }

  .brand img {
    max-width: 150px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .subtitle {
    margin-bottom: 4px;
    font-size: .88rem;
  }

  .main-meter {
    width: min(520px, 100%);
  }

  .meter-value {
    font-size: 2.2rem;
  }

  .status-bar {
    margin-bottom: 8px;
    font-size: .82rem;
  }

  .grid {
    gap: 10px;
  }
}

@media (max-width: 900px) {
  .panel {
    padding: 24px;
    border-radius: 18px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

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

  .meter-readout {
    inset: auto 0 4px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .panel {
    padding: 16px 14px 18px;
    border-radius: 16px;
  }

  .brand {
    margin-bottom: 6px;
  }

  .brand img {
    max-width: 140px;
  }

  h1 {
    font-size: 1.08rem;
    line-height: 1.25;
  }

  .subtitle {
    font-size: .74rem;
    margin-bottom: 4px;
    line-height: 1.45;
  }

  .subtitle-note {
    margin-bottom: 10px;
    font-size: .7rem;
  }

  .main-meter {
    width: min(100%, 340px);
    margin-bottom: 8px;
  }

  #gauge-main {
    max-width: 100%;
  }

  .meter-readout {
    inset: auto 0 2px;
  }

  .meter-value {
    font-size: 1.7rem;
    line-height: .95;
  }

  .meter-unit {
    font-size: .68rem;
    letter-spacing: 1.6px;
    margin-top: 2px;
  }

  .meter-label {
    margin-top: 2px;
    font-size: .72rem;
  }

  .status-bar {
    margin: 0 0 10px;
    font-size: .82rem;
    min-height: 16px;
  }

  .grid {
    gap: 10px;
  }

  .field {
    gap: 4px;
  }

  label.title {
    font-size: .82rem;
  }

  select,
  input[type="file"] {
    padding: 9px 11px;
    border-radius: 11px;
  }

  .location span {
    min-height: 56px;
    padding: 8px 6px 7px;
  }

  .location span strong {
    font-size: .8rem;
  }

  .location span small {
    font-size: .62rem;
  }

  .cta {
    padding: 10px 14px;
  }

  .result-modal__panel {
    width: min(100% - 16px, 420px);
    margin: 18px auto;
    padding: 18px 16px;
    border-radius: 18px;
  }

  .result-modal__metrics {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .result-modal__metric strong {
    font-size: 2.2rem;
  }

  .result-modal__title {
    font-size: 1rem;
  }

  .result-modal__insight {
    grid-template-columns: 1fr;
  }

  .result-modal__actions {
    justify-content: stretch;
  }

  .btn-primary,
  .btn-secondary {
    flex: 1;
  }
}

@media (max-width: 400px) {
  .main-meter {
    width: min(100%, 300px);
  }

  .meter-readout {
    inset: auto 0 6px;
    transform: translateY(8px);
  }

  .meter-value {
    font-size: 1.45rem;
  }

  .meter-unit {
    font-size: .62rem;
    letter-spacing: 1.2px;
  }

  .status-bar {
    font-size: .76rem;
  }
}
