/* default gateway GmbH-speedtest stylesheet */

:root {
  --c-brand: #0b5cff;
  --c-brand-dark: #0846c2;
  --c-brand-soft: #e8f0ff;
  --c-bg: #f7f8fb;
  --c-surface: #ffffff;
  --c-surface-alt: #f0f3f9;
  --c-text: #15181f;
  --c-text-soft: #515768;
  --c-text-mute: #8a90a2;
  --c-border: #e2e6ef;
  --c-good: #1f9d55;
  --c-ok: #d49b1c;
  --c-poor: #d84545;
  --c-down: #0b5cff;
  --c-up: #7a4cff;
  --c-idle: #1f9d55;
  --c-load-cpu: #d49b1c;
  --c-load-rx:  #0fa3a3;
  --c-load-tx:  #d84545;

  --shadow-sm: 0 1px 2px rgba(15, 22, 40, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 22, 40, 0.08);
  --radius: 14px;
  --radius-sm: 8px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg: #0f1218;
    --c-surface: #181c25;
    --c-surface-alt: #20242f;
    --c-text: #ecedf2;
    --c-text-soft: #a8aebd;
    --c-text-mute: #6c7385;
    --c-border: #2b3140;
    --c-brand-soft: #16233f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --c-bg: #0f1218;
  --c-surface: #181c25;
  --c-surface-alt: #20242f;
  --c-text: #ecedf2;
  --c-text-soft: #a8aebd;
  --c-text-mute: #6c7385;
  --c-border: #2b3140;
  --c-brand-soft: #16233f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1100px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 1.05rem; }
.brand-name { letter-spacing: -0.01em; }
.brand-tag { color: var(--c-text-mute); font-weight: 500; font-size: 0.85em; }
.brand-link { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-link:hover { color: var(--c-brand); }
.footer .brand-link { color: var(--c-text-soft); }
.footer .brand-link:hover { color: var(--c-brand); }
.lang { display: flex; gap: 4px; }
.lang-btn {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text-soft);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 120ms;
}
.lang-btn:hover { border-color: var(--c-brand); color: var(--c-brand); }
.lang-btn.active { background: var(--c-brand); border-color: var(--c-brand); color: white; }

.theme-btn { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; }
.theme-btn .theme-icon-sun  { display: none; }
.theme-btn .theme-icon-moon { display: inline; }
:root[data-theme="dark"] .theme-btn .theme-icon-sun  { display: inline; }
:root[data-theme="dark"] .theme-btn .theme-icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .theme-icon-sun  { display: inline; }
  :root:not([data-theme="light"]) .theme-btn .theme-icon-moon { display: none; }
}

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 120ms;
}
.btn:hover { background: var(--c-surface-alt); }
.btn.primary { background: var(--c-brand); border-color: var(--c-brand); color: white; }
.btn.primary:hover { background: var(--c-brand-dark); border-color: var(--c-brand-dark); }
.btn.big { padding: 16px 36px; font-size: 1.05rem; font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.icon { padding: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--c-text-soft); }
.btn.icon:hover { color: var(--c-brand); border-color: var(--c-brand); background: var(--c-surface); }

/* split button-two buttons fused into one visual unit with a divider line.
   First child rounds its left side; last child rounds its right and gets a
   subtle border-left as the separator. */
.btn-split { display: inline-flex; align-items: stretch; }
.btn-split > .btn {
  margin: 0;
  border-radius: 0;
}
.btn-split > .btn:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.btn-split > .btn:last-child  { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.btn-split > .btn + .btn { border-left: 1px solid rgba(255, 255, 255, 0.25); }
.btn-split > .btn.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 16px;
  padding-right: 16px;
}

/* settings dialog */
.settings-dialog {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--c-surface);
  color: var(--c-text);
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-md);
}
.settings-dialog::backdrop { background: rgba(15, 22, 40, 0.45); }
.settings-form { display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-head h3 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }
.settings-close {
  background: transparent; border: 0; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: var(--c-text-mute);
  padding: 4px 8px; border-radius: var(--radius-sm);
}
.settings-close:hover { color: var(--c-text); background: var(--c-surface-alt); }
.settings-lede { margin: 0; color: var(--c-text-soft); font-size: 0.9rem; }
.settings-row { display: flex; flex-direction: column; gap: 6px; }
.settings-label { font-size: 0.92rem; font-weight: 500; }
.settings-control { display: flex; align-items: center; gap: 12px; }
.settings-control input[type="range"] { flex: 1; accent-color: var(--c-brand); }
.settings-readout {
  display: inline-block; min-width: 32px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--c-brand);
}
.settings-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.settings-reset {
  background: transparent; border: 0; cursor: pointer;
  color: var(--c-text-soft); font: inherit; font-size: 0.9rem; text-decoration: underline;
  padding: 0;
}
.settings-reset:hover { color: var(--c-brand); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 64px 16px 32px; }
.hero h1 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); margin: 0 0 12px; letter-spacing: -0.02em; }
.hero .lead { color: var(--c-text-soft); max-width: 640px; margin: 0 auto 28px; font-size: 1.05rem; }

/* ---------- dashboard ---------- */
.dashboard { display: grid; gap: 24px; padding-top: 24px; scroll-margin-top: 80px; }
.phase {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.phase-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.phase-step {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: white;
  background: var(--c-brand);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.phase-name { font-weight: 600; flex: 1; }

/* group palette-used by both step chunks and legend dots */
:root {
  --g-setup:     #14b8a6;
  --g-dl:        #0b5cff;
  --g-pause:     #94a3b8;
  --g-ul:        #7a4cff;
  --g-stability: #d49b1c;
}

/* step track: 9 individual chunks showing state */
.step-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.step {
  position: relative;
  padding: 8px 6px 7px;
  border-radius: 8px;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-bottom: 3px solid var(--g-setup);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-mute);
  opacity: 0.55;
  transition: all 220ms ease;
  user-select: none;
  overflow: hidden;
}
.step .step-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* group color → border indicator */
.step.g-setup     { border-bottom-color: var(--g-setup); }
.step.g-dl        { border-bottom-color: var(--g-dl); }
.step.g-pause     { border-bottom-color: var(--g-pause); }
.step.g-ul        { border-bottom-color: var(--g-ul); }
.step.g-stability { border-bottom-color: var(--g-stability); }

/* state: done-fill with the group's tint, no longer faded */
.step.done {
  opacity: 1;
  color: var(--c-text);
  border-color: transparent;
}
.step.done.g-setup     { background: color-mix(in oklab, var(--g-setup)     22%, var(--c-surface)); }
.step.done.g-dl        { background: color-mix(in oklab, var(--g-dl)        18%, var(--c-surface)); }
.step.done.g-pause     { background: color-mix(in oklab, var(--g-pause)     18%, var(--c-surface)); }
.step.done.g-ul        { background: color-mix(in oklab, var(--g-ul)        18%, var(--c-surface)); }
.step.done.g-stability { background: color-mix(in oklab, var(--g-stability) 22%, var(--c-surface)); }
.step.done .step-num   { color: var(--c-text-mute); }

/* state: active-pulsing ring in group color */
.step.active {
  opacity: 1;
  color: var(--c-text);
  transform: translateY(-1px);
  border-bottom-width: 3px;
  animation: stepPulse 1.4s ease-in-out infinite;
}
.step.active.g-setup     { background: color-mix(in oklab, var(--g-setup)     30%, var(--c-surface)); border-color: var(--g-setup); }
.step.active.g-dl        { background: color-mix(in oklab, var(--g-dl)        28%, var(--c-surface)); border-color: var(--g-dl); }
.step.active.g-pause     { background: color-mix(in oklab, var(--g-pause)     28%, var(--c-surface)); border-color: var(--g-pause); }
.step.active.g-ul        { background: color-mix(in oklab, var(--g-ul)        28%, var(--c-surface)); border-color: var(--g-ul); }
.step.active.g-stability { background: color-mix(in oklab, var(--g-stability) 30%, var(--c-surface)); border-color: var(--g-stability); }

@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50%      { box-shadow: 0 0 0 4px rgba(11, 92, 255, 0.10); }
}

/* legend below the track */
.step-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--c-text-soft);
  margin-top: 6px;
}
.step-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.step-legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; }
.step-legend i.g-setup     { background: var(--g-setup); }
.step-legend i.g-dl        { background: var(--g-dl); }
.step-legend i.g-pause     { background: var(--g-pause); }
.step-legend i.g-ul        { background: var(--g-ul); }
.step-legend i.g-stability { background: var(--g-stability); }

@media (max-width: 720px) {
  .step-track { gap: 4px; }
  .step { padding: 6px 4px 5px; font-size: 0.68rem; }
}
.streams-info { font-size: 0.85rem; color: var(--c-text-soft); margin-top: 4px; }
.streams-info b { color: var(--c-brand); font-weight: 700; font-variant-numeric: tabular-nums; }

/* live loss panel (shown only during the loss step) */
.loss-live {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.loss-live-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; gap: 12px; }
.loss-live-head h3 { margin: 0; font-size: 0.95rem; color: var(--c-text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.loss-live-meta { font-size: 0.92rem; color: var(--c-text-soft); font-variant-numeric: tabular-nums; font-weight: 600; }

/* per-stream live chart */
.streams-live, .probe-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.streams-head, .probe-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; gap: 12px; }
.streams-head h3, .probe-head h3 { margin: 0; font-size: 0.95rem; color: var(--c-text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.streams-meta, .probe-meta { font-size: 0.85rem; color: var(--c-text-mute); font-variant-numeric: tabular-nums; }
#streams-canvas { width: 100%; height: 180px; display: block; }
.streams-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.85rem; color: var(--c-text-soft); margin-top: 8px; }
.streams-legend > span { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.streams-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 1px; }

/* probe list rows */
.probe-list { list-style: none; padding: 0; margin: 0; }
.probe-row {
  display: grid;
  grid-template-columns: 36px 90px 1fr 76px 110px;
  gap: 14px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--c-border);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  animation: probeFadeIn 240ms ease;
}
.probe-row:last-child { border-bottom: none; }
.probe-idx  { color: var(--c-text-mute); font-family: var(--font-mono); font-size: 0.85rem; }
.probe-size { color: var(--c-text); font-weight: 600; }
.probe-time { color: var(--c-text-soft); text-align: right; }
.probe-mbps { color: var(--c-brand); font-weight: 700; text-align: right; }
.probe-bar  { height: 8px; background: var(--c-surface-alt); border-radius: 4px; overflow: hidden; }
.probe-bar i { display: block; height: 100%; width: 0%; background: var(--c-brand); transition: width 320ms ease; }

/* upload context: tint probe bars purple */
.probe-panel.upload .probe-mbps { color: var(--c-up); }
.probe-panel.upload .probe-bar i { background: var(--c-up); }

@keyframes probeFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
  .probe-row { grid-template-columns: 28px 70px 1fr 60px 90px; gap: 8px; font-size: 0.85rem; }
}

.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .gauges { grid-template-columns: 1fr; } }

.speed-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 32px 24px 28px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.speed-card h3 {
  margin: 0 0 18px;
  font-size: 0.95rem;
  color: var(--c-text-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.speed-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.speed-value {
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--c-text);
  transition: color 240ms ease;
}
.speed-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--c-text-mute);
}

/* tier coloring while a profile is selected. We pick five distinct hues so
   the value's "health" is readable at a glance as it ramps. */
.speed-value.tier-vg { color: #0f8a47; }
.speed-value.tier-g  { color: #2ba858; }
.speed-value.tier-ok { color: #d49b1c; }
.speed-value.tier-b  { color: #d76a3a; }
.speed-value.tier-vb { color: #b81f1f; }

.latency-live {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.latency-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.latency-head h3 { margin: 0; font-size: 0.95rem; color: var(--c-text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.latency-current { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.latency-current .unit { color: var(--c-text-mute); font-size: 0.85rem; font-weight: 500; }
#latency-canvas { width: 100%; height: 180px; display: block; }
.latency-legend { display: flex; gap: 18px; font-size: 0.85rem; color: var(--c-text-soft); margin-top: 8px; flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.legend-dot.idle { background: var(--c-idle); }
.legend-dot.down { background: var(--c-down); }
.legend-dot.up   { background: var(--c-up); }

/* ---------- results ---------- */
.results { padding-top: 32px; }
.results h2 { font-size: 1.6rem; margin: 0 0 20px; letter-spacing: -0.01em; }

/* real-feel headline card */
.real-feel {
  background: linear-gradient(135deg, var(--c-brand-soft), var(--c-surface));
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  margin-bottom: 24px;
  align-items: center;
}
@media (max-width: 720px) { .real-feel { grid-template-columns: 1fr; } }
.rf-left { display: flex; align-items: center; gap: 18px; }
.rf-circle { position: relative; width: 140px; height: 140px; }
.rf-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rf-track { fill: none; stroke: var(--c-surface-alt); stroke-width: 10; }
.rf-fill { fill: none; stroke: var(--c-brand); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 0 314.16; transition: stroke-dasharray 600ms ease; }
.rf-number { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rf-meta .rf-label { color: var(--c-text-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.rf-meta .rf-grade { font-size: 1.6rem; font-weight: 700; }
.rf-bar { display: flex; height: 22px; border-radius: 999px; overflow: hidden; background: var(--c-surface-alt); border: 1px solid var(--c-border); }
.rf-bar > span { transition: flex-grow 600ms ease; }
.rf-bar-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 0.85rem; color: var(--c-text-soft); }
.rf-bar-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.rf-bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.rf-explain { margin: 0 0 14px; line-height: 1.55; }
.rf-explain strong { font-weight: 700; }

/* ---------- impact panel (real-world use cases) ---------- */
.impact {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.impact h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.impact-lede {
  margin: 0 0 16px;
  color: var(--c-text-soft);
  font-size: 0.92rem;
}
.impact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 720px) { .impact-list { grid-template-columns: 1fr; } }
.impact-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
}
.impact-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.impact-row.impact-good   .impact-status { background: rgba(31,157,85,0.15); color: var(--c-good); }
.impact-row.impact-partial .impact-status { background: rgba(212,155,28,0.18); color: var(--c-ok); }
.impact-row.impact-poor   .impact-status { background: rgba(216,69,69,0.15); color: var(--c-poor); }
.impact-content {
  min-width: 0;
}
.impact-content strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.impact-content p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--c-text-soft);
  line-height: 1.45;
}
.impact-grade {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  align-self: center;
}
.impact-row.impact-good   .impact-grade { background: rgba(31,157,85,0.15); color: var(--c-good); }
.impact-row.impact-partial .impact-grade { background: rgba(212,155,28,0.18); color: var(--c-ok); }
.impact-row.impact-poor   .impact-grade { background: rgba(216,69,69,0.15); color: var(--c-poor); }

/* ---------- bandwidth budget calculator ---------- */
.budget {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.budget h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.budget-lede {
  margin: 0 0 16px;
  color: var(--c-text-soft);
  font-size: 0.92rem;
}
.budget-scenarios {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.budget-row {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
}
.budget-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.budget-row-head strong {
  font-size: 0.98rem;
}
.budget-status {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.budget-status.fits         { background: rgba(31,157,85,0.15); color: var(--c-good); }
.budget-status.tight        { background: rgba(212,155,28,0.18); color: var(--c-ok); }
.budget-status.exceeds      { background: rgba(216,69,69,0.15); color: var(--c-poor); }
.budget-row-detail {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--c-text-soft);
  line-height: 1.45;
}
.budget-bar-set {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.budget-bar-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
}
.budget-bar-row .bb-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-mute);
  font-size: 0.7rem;
}
.budget-bar {
  position: relative;
  height: 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}
.budget-bar > span {
  display: block;
  height: 100%;
  background: var(--c-brand);
  transition: width 240ms ease;
}
.budget-bar.over {
  border-color: rgba(216,69,69,0.55);
  box-shadow: inset 0 0 0 1px rgba(216,69,69,0.3);
}
.budget-bar.over > span { background: var(--c-poor); }
.budget-bar-meta { white-space: nowrap; }
.budget-services {
  margin-top: 8px;
  border-top: 1px solid var(--c-border);
  padding-top: 12px;
}
.budget-services summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  list-style: none;
  position: relative;
  padding: 6px 0;
  user-select: none;
}
.budget-services summary::-webkit-details-marker { display: none; }
.budget-services summary::after {
  content: "+";
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font-size: 1.2rem; color: var(--c-text-mute);
}
.budget-services[open] summary::after { content: "−"; }
.services-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.88rem; margin-top: 8px; }
.services-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-mute); padding: 6px 8px; border-bottom: 1px solid var(--c-border); }
.services-table td { padding: 6px 8px; border-bottom: 1px solid var(--c-border); }
.services-table td:first-child { font-weight: 500; }
.services-table td:nth-child(2),
.services-table td:nth-child(3),
.services-table th:nth-child(2),
.services-table th:nth-child(3) { text-align: right; color: var(--c-text-soft); }

/* deep-dive section uses the same look as .explanations */
.deep { margin-top: 32px; }

/* static history charts in details */
.history-chart {
  margin: 12px 0 18px;
}
.history-chart canvas { width: 100%; height: 160px; display: block; }
.history-chart h4 { margin: 0 0 6px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-mute); }
.history-chart .h-meta { font-size: 0.78rem; color: var(--c-text-mute); margin-bottom: 4px; }

/* per-metric cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-flow: dense;
  gap: 16px;
}
@media (max-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.card.card-wide { grid-column: 1 / -1; }
.card.card-large { grid-column: span 2; padding: 28px 28px 24px; }
.card.card-large .big-number { font-size: 3rem; }
.card.card-large .speed-stats { gap: 32px; margin: 14px 0 18px; }
.card.card-large .speed-stats .stat-side { min-width: 64px; }
.card.card-large .speed-stats .stat-side .stat-value { font-size: 1.25rem; }
.card.card-large .kv { font-size: 0.95rem; }
@media (max-width: 480px) { .card.card-large { grid-column: span 1; padding: 22px; } .card.card-large .big-number { font-size: 2.4rem; } }

.card header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.card h3 { margin: 0; font-size: 0.95rem; color: var(--c-text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.card-grade {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-surface-alt);
  color: var(--c-text-soft);
  letter-spacing: 0.04em;
}
.card-grade.big { font-size: 1.3rem; padding: 6px 18px; }
.card-grade.good { background: rgba(31,157,85,0.15); color: var(--c-good); }
.card-grade.ok   { background: rgba(212,155,28,0.18); color: var(--c-ok); }
.card-grade.poor { background: rgba(216,69,69,0.15); color: var(--c-poor); }
.big-number { font-size: 2.1rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.big-number .unit, .big-number > .unit { font-size: 0.85rem; font-weight: 500; color: var(--c-text-mute); margin-left: 6px; }
.big-number.delta { color: var(--c-brand); }
.speed-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 6px 0 14px;
}
.speed-stats .big-number { margin: 0; }
.speed-stats .stat-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  color: var(--c-text-mute);
}
.speed-stats .stat-side .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.speed-stats .stat-side .stat-value {
  font-size: 1.05rem;
  color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.kv { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--c-text-soft); margin-top: 6px; font-variant-numeric: tabular-nums; }
.card-verdict { font-size: 0.92rem; color: var(--c-text-soft); margin: 14px 0 0; line-height: 1.5; }
.card-note {
  font-size: 0.78rem;
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}
.card-note.ok   { background: rgba(31,157,85,0.10); color: var(--c-good); border: 1px solid rgba(31,157,85,0.25); }
.card-note.warn { background: rgba(212,155,28,0.12); color: var(--c-ok); border: 1px solid rgba(212,155,28,0.3); }
.results-note   { font-size: 0.85rem; margin: 10px 0 18px; padding: 10px 14px; line-height: 1.5; }
.results-note code { font-family: var(--font-mono); font-size: 0.85em; padding: 1px 4px; border-radius: 3px; background: rgba(0,0,0,0.06); }

/* mini bars (jitter) */
.mini-bars { width: 100%; height: 70px; margin-top: 12px; }
.mini-bars rect { fill: var(--c-brand); }

/* loss donut */
.loss-donut { position: relative; width: 130px; height: 130px; margin: 8px auto; }
.loss-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: var(--c-surface-alt); stroke-width: 10; }
.donut-fill  { fill: none; stroke: var(--c-poor); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 0 314.16; transition: stroke-dasharray 600ms ease; }
.donut-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-center .unit { font-size: 0.85rem; color: var(--c-text-mute); margin-left: 2px; }

/* dns scale */
.dns-scale { margin-top: 18px; position: relative; }
.dns-zones { display: flex; height: 10px; border-radius: 999px; overflow: hidden; }
.dns-zones .z-good { flex: 0 0 25%; background: var(--c-good); }
.dns-zones .z-ok   { flex: 0 0 25%; background: var(--c-ok); }
.dns-zones .z-poor { flex: 1; background: var(--c-poor); }
.dns-marker {
  position: absolute; top: -4px; left: 0%;
  width: 4px; height: 18px; background: var(--c-text);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 600ms ease;
}
.dns-ticks { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--c-text-mute); margin-top: 4px; font-family: var(--font-mono); }


.actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; }

/* connection panel (server / client / time) */
.connection-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.conn-row { display: inline-flex; align-items: baseline; gap: 8px; }
.conn-label { color: var(--c-text-mute); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; }
.conn-value { color: var(--c-text); font-weight: 600; font-family: var(--font-mono); font-size: 0.95rem; }

/* real-feel formula breakdown-collapsible <details>, sits right under
   the real-feel card. Closed by default; the hint button in the card and the
   summary itself both toggle it. */
.rf-formula {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.rf-formula > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 14px 22px;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--c-text);
}
.rf-formula > summary::-webkit-details-marker { display: none; }
.rf-formula > summary:hover { background: var(--c-surface-alt); }
.rf-formula[open] > summary { border-bottom: 1px solid var(--c-border); }
.rf-formula-summary-chevron {
  color: var(--c-text-mute);
  font-size: 0.95rem;
  transition: transform 160ms ease;
}
.rf-formula[open] .rf-formula-summary-chevron { transform: rotate(180deg); }
.rf-formula-body { padding: 18px 22px 22px; }
.rf-formula-body > p:first-child { margin: 0 0 16px; color: var(--c-text-soft); font-size: 0.92rem; }

.rf-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rf-table th { text-align: left; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-mute); padding: 8px 10px; border-bottom: 1px solid var(--c-border); }
.rf-table td { padding: 10px 10px; border-bottom: 1px solid var(--c-border); font-size: 0.92rem; }
.rf-table td:first-child { font-weight: 600; }
.rf-table td:nth-child(2),
.rf-table td:nth-child(3),
.rf-table td:nth-child(4),
.rf-table td:nth-child(5) { text-align: right; }
.rf-table th:nth-child(2),
.rf-table th:nth-child(3),
.rf-table th:nth-child(4),
.rf-table th:nth-child(5) { text-align: right; }
.rf-table td .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }
.rf-table tfoot td { font-weight: 700; font-size: 1rem; padding-top: 14px; border-bottom: none; color: var(--c-brand); }
.rf-weight-explain { margin-top: 16px; padding: 12px 14px; background: var(--c-surface-alt); border-radius: var(--radius-sm); color: var(--c-text-soft); font-size: 0.9rem; line-height: 1.55; }
.rf-weight-explain strong { color: var(--c-text); }
.rf-weight-explain ul { margin: 8px 0 0; padding-left: 20px; }
.rf-weight-explain li { margin-bottom: 4px; }

@media (max-width: 600px) {
  .rf-table th, .rf-table td { padding: 6px 4px; font-size: 0.82rem; }
}

/* grading scales table-nested inside the rf-formula body */
.grading-scales {
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  margin: 16px 0;
  overflow: hidden;
}
.grading-scales summary {
  cursor: pointer;
  padding: 18px 22px;
  font-weight: 600;
  list-style: none;
  position: relative;
  user-select: none;
  font-size: 1rem;
}
.grading-scales summary::-webkit-details-marker { display: none; }
.grading-scales summary::after {
  content: "+";
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  font-size: 1.3rem; color: var(--c-text-mute);
}
.grading-scales[open] summary::after { content: "−"; }
.scales-body { padding: 0 22px 22px; }
.scales-lede { color: var(--c-text-soft); margin: 0 0 12px; font-size: 0.9rem; }
.scales-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.scales-table th, .scales-table td { padding: 8px 10px; border-bottom: 1px solid var(--c-border); text-align: left; }
.scales-table th:first-child, .scales-table td:first-child { font-weight: 600; }
.scales-table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-mute); }
.scales-table td.s-good { background: rgba(31,157,85,0.10); color: var(--c-good); font-weight: 600; }
.scales-table td.s-ok   { background: rgba(212,155,28,0.12); color: var(--c-ok); font-weight: 600; }
.scales-table td.s-poor { background: rgba(216,69,69,0.10); color: var(--c-poor); font-weight: 600; }
.scales-table td.s-excellent { background: rgba(11,92,255,0.10); color: var(--c-brand); font-weight: 600; }
.scales-table th .s-pct {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-text-mute);
  letter-spacing: 0;
  text-transform: none;
  margin-top: 2px;
}
.scales-table td.scales-your,
.scales-table td.scales-score {
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.scales-table th:nth-child(n+2),
.scales-table td:nth-child(n+2) { text-align: right; }

/* loss train (packet visualization) */
.loss-row { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 24px; align-items: start; }
@media (max-width: 700px) { .loss-row { grid-template-columns: 1fr; } }
.loss-stats { min-width: 110px; }
.loss-train-wrap { min-width: 0; }
.loss-train-label { font-size: 0.78rem; color: var(--c-text-mute); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.loss-train {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14px, 1fr));
  gap: 4px;
}
.loss-train .pkt {
  display: block;
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--c-good);
  animation: pktDrop 240ms ease;
}
.loss-train .pkt.lost { background: var(--c-poor); }
.loss-train .pkt.pending { background: var(--c-surface-alt); animation: none; }
.loss-train-legend { margin-top: 10px; display: flex; gap: 14px; font-size: 0.85rem; color: var(--c-text-soft); }
.loss-train-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pkt-legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c-good); }
.pkt-legend.lost { background: var(--c-poor); }
@keyframes pktDrop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: none; }
}

/* details panel */
.details-panel {
  background: linear-gradient(135deg, var(--c-brand-soft), var(--c-surface));
  border: 1px solid var(--c-brand);
  border-radius: var(--radius);
  margin-top: 24px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.details-panel summary {
  cursor: pointer;
  padding: 16px 22px;
  font-weight: 400;
  font-size: 1rem;
  list-style: none;
  position: relative;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
.details-panel summary:hover { background: rgba(11, 92, 255, 0.06); }
.details-panel summary::-webkit-details-marker { display: none; }
.details-panel-title { flex: 1; }
.details-panel summary::after {
  content: "+";
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--c-brand);
  color: white;
  font-size: 1.1rem; font-weight: 600; line-height: 1;
  transition: transform 200ms ease;
}
.details-panel[open] summary::after { content: "−"; transform: rotate(180deg); }
.details-body {
  padding: 4px 22px 22px;
  font-size: 0.9rem;
  background: var(--c-surface);
}
.details-section { margin-bottom: 22px; }
.details-section h4 { margin: 0 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-mute); }
.details-section table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.details-section th, .details-section td { padding: 5px 8px; border-bottom: 1px solid var(--c-border); text-align: left; }
.details-section th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-text-mute); }
.details-section td:not(:first-child), .details-section th:not(:first-child) { text-align: right; }
.details-section .ping-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
  gap: 2px;
  margin-top: 4px;
}
.details-section .ping-strip i {
  display: block;
  background: var(--c-brand);
  border-radius: 1px;
}

/* explanations */
.explanations { margin-top: 64px; }
.explanations h2 { font-size: 1.4rem; margin: 0 0 8px; letter-spacing: -0.01em; }
.explain-lede { color: var(--c-text-soft); margin: 0 0 24px; max-width: 1080px; }
.explanations details {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.explanations summary {
  cursor: pointer;
  padding: 18px 22px;
  font-weight: 600;
  list-style: none;
  position: relative;
  user-select: none;
}
.explanations summary::-webkit-details-marker { display: none; }
.explanations summary::after {
  content: "+";
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  font-size: 1.4rem; font-weight: 400; color: var(--c-text-mute);
}
.explanations details[open] summary::after { content: "−"; }
.explain-body {
  padding: 0 22px 22px;
  color: var(--c-text-soft);
  line-height: 1.65;
}
.explain-body p { margin: 0 0 12px; }
.explain-body p:last-child { margin-bottom: 0; }
.explain-body strong { color: var(--c-text); }
.explain-body ul { padding-left: 22px; margin: 0 0 12px; }
.explain-body li { margin-bottom: 4px; }
.explain-body code, .explain-body kbd {
  font-family: var(--font-mono);
  background: var(--c-surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* footer */
.footer { text-align: center; padding: 32px 16px; color: var(--c-text-mute); font-size: 0.9rem; border-top: 1px solid var(--c-border); margin-top: 48px; }

/* utility */
[hidden] { display: none !important; }
.fade-in { animation: fadeIn 320ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
