/* ==========================================================================
   Digital Combines — Speed Test
   Tema chiaro, superfici piene, accenti aziendali. Nessuna dipendenza esterna.
   I colori del marchio (rosso/arancio) vengono dal logo; il blu è il colore
   delle azioni e dei dati, così la pagina resta leggibile e sobria.
   ========================================================================== */

:root {
  --bg: #F5F7FB;
  --bg-2: #EDF1F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFD;
  --surface-3: #EFF3FA;

  --line: #E2E7F0;
  --line-2: #CBD4E4;

  --txt: #0B1729;
  --txt-2: #4C5A75;
  --txt-3: #7B89A3;

  --blue: #1F5FE0;
  --blue-dark: #164AB4;
  --cyan: #0EA5E9;
  --violet: #7C3AED;
  --green: #0E9F6E;
  --amber: #D97706;
  --rose: #DC2626;

  --brand-red: #E13624;
  --brand-orange: #F3932F;

  --grad-brand: linear-gradient(135deg, #E13624, #F3932F);
  --grad-primary: linear-gradient(135deg, #1F5FE0, #0EA5E9);
  --grad-gauge: linear-gradient(90deg, #0E9F6E, #1F5FE0 45%, #7C3AED);

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(16, 30, 54, 0.05), 0 10px 26px -20px rgba(16, 30, 54, 0.35);
  --shadow-md: 0 1px 2px rgba(16, 30, 54, 0.06), 0 22px 46px -34px rgba(16, 30, 54, 0.5);
  --shadow-btn: 0 12px 26px -16px rgba(31, 95, 224, 0.75);

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter var", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --navy: #0B1729;
  --navy-2: #12224A;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 12% -6%, rgba(31, 95, 224, 0.07), transparent 65%),
    radial-gradient(760px 400px at 96% -10%, rgba(243, 147, 47, 0.09), transparent 62%),
    var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--txt);
  box-shadow: var(--shadow-md);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* --------------------------------------------------------------- TOPBAR */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--line);
}
.topbar::before {
  content: "";
  display: block;
  height: 3px;
  background: var(--grad-brand);
}
.topbar-inner { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 0; }

.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; margin-right: auto; }
.brand-mark { display: block; width: 40px; height: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.02rem; letter-spacing: -0.01em; color: var(--txt); }
.brand-text small { font-size: 0.67rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--txt-3); font-weight: 600; }

.topnav { display: flex; gap: 0.2rem; }
.topnav a {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  color: var(--txt-2);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.2s, background 0.2s;
}
.topnav a:hover { color: var(--blue); background: var(--surface-3); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--txt-2);
  white-space: nowrap;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(14, 159, 110, 0.5);
  animation: pulse 2.4s infinite;
  flex: none;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(14, 159, 110, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(14, 159, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(14, 159, 110, 0); }
}

/* ------------------------------------------------------------------ TAB */

.tabs {
  display: inline-flex;
  gap: 0.25rem;
  margin-top: 1.4rem;
  padding: 0.3rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: inset 0 1px 2px rgba(16, 30, 54, 0.04);
  max-width: 100%;
  flex-wrap: wrap;
}
.tab {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.5rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--txt-2);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.tab small { font-size: 0.68rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--txt-3); }
.tab:hover { color: var(--txt); }
.tab[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--line-2);
  color: var(--blue);
  box-shadow: 0 1px 2px rgba(16, 30, 54, 0.06), 0 8px 18px -14px rgba(16, 30, 54, 0.45);
}
.tab[aria-selected="true"] small { color: var(--blue); opacity: 0.75; }

/* ----------------------------------------------------------------- PANEL */

.panel {
  position: relative;
  margin-top: 1.5rem;
  padding: clamp(1.1rem, 2.4vw, 1.9rem);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.panel-head h2 { margin: 0; font-size: clamp(1rem, 1.6vw, 1.15rem); letter-spacing: -0.015em; }
.panel-head-text { max-width: 62ch; }
.panel-sub { margin: 0.35rem 0 0; font-size: 0.86rem; color: var(--txt-2); }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ HERO */

.hero { margin-top: 1.4rem; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(300px, 1fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
}

.gauge-col { display: grid; place-items: center; }
.gauge-wrap { position: relative; width: min(420px, 100%); }
.gauge { width: 100%; height: auto; display: block; overflow: visible; }
.gauge-track { stroke: #E9EDF6; }
.gauge-arc { transition: stroke-dasharray 0.12s linear; }
.tick { stroke: #DCE2EE; stroke-width: 1.4; stroke-linecap: round; }
.tick-major { stroke: #B9C4D8; stroke-width: 2; }
.gauge-label { fill: #8A97B0; font-family: var(--mono); font-size: 12px; }
.gauge-needle { transition: transform 0.12s linear; }

.gauge-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  /* l'ago e il perno stanno al centro esatto del quadrante: il blocco di
     lettura sale un po' per non finirci sopra */
  padding-bottom: 22%;
}
/* velo chiaro dietro la lettura: durante il test l'ago passa da qui e il
   numero deve restare leggibile */
.gauge-overlay::before {
  content: "";
  position: absolute;
  inset: 16% 8% 26%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0));
}
.gauge-overlay > * { position: relative; }
.readout { display: flex; align-items: baseline; gap: 0.4rem; }
.readout-value {
  font-family: var(--mono);
  font-size: clamp(2.4rem, 7vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--txt);
}
.readout-unit { font-size: clamp(0.8rem, 1.6vw, 1rem); color: var(--txt-2); font-weight: 600; }
.readout-label {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--txt-2);
  font-weight: 700;
}
.readout-sub { margin-top: 0.15rem; font-size: 0.74rem; color: var(--txt-3); font-family: var(--mono); }

/* ------------------------------------------------------------- CONTROLLI */

.ctrl-col { display: flex; flex-direction: column; gap: 1.1rem; }

.phase-chips { display: flex; gap: 0.5rem; list-style: none; margin: 0; padding: 0; }
.phase-chips li {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-align: center;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--txt-3);
  transition: all 0.25s var(--ease);
}
.phase-chips li[data-state="active"] {
  color: #fff;
  border-color: transparent;
  background: var(--grad-primary);
  box-shadow: 0 10px 22px -14px rgba(31, 95, 224, 0.9);
}
.phase-chips li[data-state="done"] { color: var(--green); border-color: rgba(14, 159, 110, 0.35); background: rgba(14, 159, 110, 0.07); }

.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1.05rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--grad-primary);
  color: #fff;
  font-family: inherit;
  font-size: clamp(1rem, 1.7vw, 1.1rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform 0.18s var(--ease), box-shadow 0.25s, filter 0.2s;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 20px 34px -18px rgba(31, 95, 224, 0.85); }
.start-btn:active { transform: translateY(0) scale(0.995); }
.start-btn[data-running="true"] {
  background: var(--surface-3);
  color: var(--txt-2);
  border: 1px solid var(--line-2);
  box-shadow: none;
  cursor: progress;
}
.start-icon { display: grid; place-items: center; }
.start-btn[data-running="true"] .start-icon { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.68rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--grad-primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform 0.18s var(--ease), box-shadow 0.25s;
  white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary[data-running="true"] { background: var(--surface-3); color: var(--txt-2); box-shadow: none; cursor: progress; }
.btn-primary[data-running="true"] .start-icon { animation: spin 1.6s linear infinite; }

.status { margin: 0; min-height: 1.4em; font-size: 0.87rem; color: var(--txt-2); font-family: var(--mono); }
.status[data-tone="error"] { color: var(--rose); }
.status[data-tone="ok"] { color: var(--green); }

.progress { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--grad-primary);
  /* scaleX invece di width: anima in compositing, senza layout a ogni frame
     mentre il test sta misurando. */
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s linear;
  will-change: transform;
}

.field-row { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 0.35rem; flex: 1 1 190px; min-width: 0; }
.field-label { font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--txt-3); font-weight: 700; }
.field-label b { color: var(--blue); font-family: var(--mono); }

select,
input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--txt);
  font-family: inherit;
  font-size: 0.9rem;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234C5A75' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
select:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

input[type="range"] {
  width: 100%;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(16, 30, 54, 0.4);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%;
  background: var(--blue);
}

.btn-ghost {
  padding: 0.6rem 0.95rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--txt-2);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--txt); border-color: var(--txt-3); }
.btn-ghost[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------------ IMPOSTAZIONI */

.settings {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  overflow: hidden;
}
.settings > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--txt-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.settings > summary::-webkit-details-marker { display: none; }
.settings > summary::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--txt-3);
  border-bottom: 2px solid var(--txt-3);
  transform: rotate(45deg);
  transition: transform 0.25s var(--ease);
}
.settings[open] > summary::after { transform: rotate(-135deg); }
.settings > summary:hover { color: var(--txt); }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem 1.1rem;
  padding: 0.2rem 0.9rem 0.6rem;
}
.toggles { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; padding: 0 0.9rem 0.6rem; }
.toggle { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--txt-2); cursor: pointer; }
.toggle input { accent-color: var(--blue); width: 16px; height: 16px; cursor: pointer; }
.settings-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0 0.9rem 0.9rem;
}
.hint { font-size: 0.76rem; color: var(--txt-3); }

/* -------------------------------------------------------------- BANNER */

.result-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 1.3rem;
  padding: 0.8rem 1rem;
  border-radius: var(--r-sm);
  border: 1px solid rgba(31, 95, 224, 0.28);
  background: rgba(31, 95, 224, 0.06);
  font-size: 0.88rem;
}
.result-banner span { color: var(--txt-2); font-family: var(--mono); font-size: 0.82rem; }
.result-banner #bannerClear { margin-left: auto; }

/* ----------------------------------------------------------------- CARDS */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: 1rem;
  margin-top: 1.3rem;
}
.card {
  position: relative;
  padding: 1.05rem 1.15rem 1.15rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent, var(--grad-primary));
}
.card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow-md); }
.card header { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.card-label {
  font-size: 0.71rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt-2);
  font-weight: 700;
}
.card-tag { font-size: 0.69rem; color: var(--txt-3); font-family: var(--mono); }
.card-value {
  margin: 0.5rem 0 0.15rem;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: clamp(1.7rem, 3.2vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--txt);
}
.card-value small { font-size: 0.72rem; font-weight: 600; color: var(--txt-3); letter-spacing: 0; }
.card-value-sm { font-size: clamp(1rem, 2vw, 1.2rem); font-family: var(--sans); letter-spacing: -0.01em; }
.card-meta { margin: 0; font-size: 0.75rem; color: var(--txt-3); font-family: var(--mono); }

.card-dl { --accent: linear-gradient(90deg, #1F5FE0, #0EA5E9); }
.card-ul { --accent: linear-gradient(90deg, #7C3AED, #A855F7); }
.card-ping { --accent: linear-gradient(90deg, #0E9F6E, #22C55E); }
.card-jitter { --accent: linear-gradient(90deg, #D97706, #F59E0B); }
.card-loaded { --accent: linear-gradient(90deg, #0891B2, #22D3EE); }
.card-grade { --accent: linear-gradient(90deg, #4F46E5, #7C3AED); }
.card-loss { --accent: linear-gradient(90deg, #DC2626, #F43F5E); }
.card-server { --accent: linear-gradient(90deg, #64748B, #94A3B8); }

.card-dl .card-value { color: #1852C4; }
.card-ul .card-value { color: #6D28D9; }
.card-ping .card-value { color: #0B7F58; }
.card-jitter .card-value { color: #B45309; }
.card-loaded .card-value { color: #0E7490; }
.card-grade .card-value { color: #4338CA; }
.card-loss .card-value { color: #B91C1C; }

.tone-great { color: var(--green); }
.tone-ok { color: var(--blue); }
.tone-warn { color: var(--amber); }
.tone-bad { color: var(--rose); }
.tone-neutral { color: var(--txt-2); }

/* ----------------------------------------------------------------- CHART */

.chart-panel { padding-bottom: 1rem; }
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--txt-2); }
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend-item i { width: 12px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; }

/* --------------------------------------------------------------- STORICO */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.history { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 700px; }
.history th, .history td { padding: 0.6rem 0.7rem; text-align: left; border-bottom: 1px solid var(--line); }
.history th {
  font-size: 0.67rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt-3);
  font-weight: 700;
  position: sticky;
  top: 0;
  background: var(--surface);
}
.history tbody tr { transition: background 0.18s; }
.history tbody tr:hover { background: var(--surface-2); }
.history td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.col-actions { text-align: right; }
.row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }
.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--txt-2);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.icon-btn:hover { color: var(--blue); border-color: var(--line-2); background: var(--surface-2); }
.empty { color: var(--txt-3); font-size: 0.85rem; margin: 1rem 0 0.2rem; }

/* ------------------------------------------------------------------ INFO */

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.info-item {
  padding: 0.95rem 1.05rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.info-item h3 { margin: 0 0 0.35rem; font-size: 0.95rem; letter-spacing: -0.01em; }
.info-item p { margin: 0; font-size: 0.85rem; color: var(--txt-2); }

/* --------------------------------------------------------- TRANSFER TEST */

.xfer .status { margin-top: 0.9rem; }
.xfer .progress { margin: 0.5rem 0 1.1rem; }

/* Selettore dei flussi: compatto, stessa altezza dei pulsanti accanto. */
.xfer-streams {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.55rem 0 0.75rem;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.xfer-streams > span {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--txt-3);
  font-weight: 700;
}
.xfer-streams select {
  width: auto;
  min-width: 3.4rem;
  padding: 0.55rem 1.5rem 0.55rem 0.3rem;
  border: 0;
  background-color: transparent;
  background-position: right 0.25rem center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
}
.xfer-streams select:disabled { color: var(--txt-3); cursor: not-allowed; }
.xfer-streams:focus-within { outline: 2px solid var(--blue); outline-offset: 1px; }
.xfer-streams select:focus-visible { outline: none; }

.xfer-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.mini {
  padding: 0.85rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.mini-label { font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--txt-3); font-weight: 700; }
.mini-value {
  margin: 0.35rem 0 0.1rem;
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--txt);
}
.mini-value small { font-size: 0.68rem; font-weight: 600; color: var(--txt-3); }
.mini-meta { margin: 0; font-size: 0.75rem; color: var(--txt-3); font-family: var(--mono); }

.xfer-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 640px; }
.xfer-table th, .xfer-table td { padding: 0.55rem 0.7rem; text-align: left; border-bottom: 1px solid var(--line); }
.xfer-table th {
  font-size: 0.67rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt-3);
  font-weight: 700;
  background: var(--surface);
}
.xfer-table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.xfer-table tbody tr[data-state="running"] { background: rgba(31, 95, 224, 0.05); }
.xfer-table tbody tr[data-state="running"] td.blk { color: var(--blue); font-weight: 700; }
.xfer-table tbody tr[data-state="done"] td.blk { font-weight: 700; color: var(--txt); }
.xfer-table tbody tr[data-state="skipped"] { color: var(--txt-3); }
.xfer-table tbody tr[data-state="skipped"] td.blk { text-decoration: line-through; text-decoration-color: var(--line-2); }
.xfer-table td.blk { white-space: nowrap; }
.xfer-table td .unit { color: var(--txt-3); font-size: 0.75rem; margin-left: 0.15rem; }
.xfer-table td.ratio-cell { color: var(--txt-2); }
.col-bar { width: 190px; }
.bar-stack { display: flex; flex-direction: column; gap: 3px; }
.bar-row { display: flex; align-items: center; gap: 0.4rem; }
.bar-row span { font-family: var(--mono); font-size: 0.68rem; color: var(--txt-3); width: 34px; flex: none; }
.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  flex: 1;
}
.bar > i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--blue);
  /* scaleX invece di width: la barra si aggiorna a ogni blocco misurato e
     animare la larghezza rifarebbe il layout della tabella ogni volta. */
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
  transition: transform 0.35s var(--ease);
  will-change: transform;
}
.bar > i.ul { background: var(--violet); }

.xfer-chart { height: 240px; margin-top: 1.3rem; }

/* ---------------------------------------------------------------- FOOTER */

.site-foot {
  margin-top: 3rem;
  padding-top: 2.6rem;
  background: var(--navy);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
}
.site-foot a { color: rgba(255, 255, 255, 0.72); text-decoration: none; transition: color 0.18s; }
.site-foot a:hover { color: #fff; }

.foot-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) repeat(2, minmax(150px, 1fr)) minmax(170px, 1fr);
  gap: 2rem;
  padding-bottom: 2.2rem;
}
.foot-brand { max-width: 34ch; }
.foot-logo { display: block; width: 220px; max-width: 100%; height: auto; }
.foot-tagline { margin: 0.9rem 0 1.1rem; font-size: 0.86rem; line-height: 1.6; color: rgba(255, 255, 255, 0.66); }
.foot-social { display: flex; gap: 0.55rem; }
.foot-social a {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.8);
}
.foot-social a:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.3); color: #fff; }

.foot-col h3 {
  margin: 0 0 0.8rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 700;
}
.foot-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }

.foot-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.8rem;
}
.foot-bottom p { margin: 0; }
.foot-links { display: flex; gap: 1rem; }

.foot-note {
  padding: 0.9rem 0 1.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.78rem;
}
.foot-note p { margin: 0 0 0.25rem; }
.foot-sub { font-family: var(--mono); font-size: 0.7rem; color: rgba(255, 255, 255, 0.38); overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- TOAST */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 80;
  transform: translateX(-50%) translateY(140%);
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--navy);
  color: #fff;
  font-size: 0.86rem;
  box-shadow: 0 22px 50px -22px rgba(11, 23, 41, 0.7);
  transition: transform 0.35s var(--ease), opacity 0.35s;
  opacity: 0;
  pointer-events: none;
  max-width: min(92vw, 480px);
  text-align: center;
}
.toast[data-show="true"] { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ------------------------------------------------------------- RESPONSIVE */

@media (max-width: 1000px) {
  .foot-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 1.8rem 2rem; }
  .foot-brand { grid-column: 1 / -1; max-width: none; }
}

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .gauge-wrap { width: min(380px, 92%); }
  .topnav { display: none; }
}

@media (max-width: 720px) {
  .wrap { width: min(1180px, 100% - 1.6rem); }
  .cards { grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 0.75rem; }
  .card { padding: 0.85rem 0.9rem 0.95rem; }
  .card-value { font-size: clamp(1.4rem, 6.5vw, 1.8rem); }
  .card-value-sm { font-size: 1rem; }
  .chart-box { height: 210px; }
  .panel { border-radius: 14px; }
  .readout-value { font-size: clamp(2.1rem, 11vw, 2.9rem); }
  .gauge-wrap { width: min(330px, 96%); }
  .settings-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; align-items: stretch; }
  .topbar-inner { gap: 0.5rem; }
  .pill { font-size: 0.64rem; max-width: 34vw; }
  .foot-grid { grid-template-columns: 1fr; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 0.5rem 0.7rem; }
  .xfer-chart { height: 190px; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .brand-text small { display: none; }
  .phase-chips li { font-size: 0.66rem; padding: 0.45rem 0.3rem; }
  .tab small { display: none; }
  .head-actions { width: 100%; }
}

/* --------------------------------------------------------- DIAGNOSTICA */

.diag .status { margin-top: 0.9rem; }
.diag .progress { margin: 0.5rem 0 1.1rem; }

/* Due righe, una per backend: la prima colonna è l'etichetta che si legge. */
.diag-table td.bk { font-weight: 700; }
.diag-table td.bk small { display: block; font-weight: 400; color: var(--txt-3); font-family: var(--mono); font-size: 0.7rem; }
.diag-table td.miss { color: var(--txt-3); }
.diag-table td.best { color: var(--green); font-weight: 700; }

.diag-verdict {
  margin-top: 1.1rem;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--blue);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.diag-verdict[data-level="code"] { border-left-color: var(--rose); }
.diag-verdict[data-level="path"] { border-left-color: var(--green); }
.diag-verdict[data-level="unknown"] { border-left-color: var(--txt-3); }
.diag-verdict p:first-child { margin: 0; font-size: 0.9rem; line-height: 1.55; }
.diag-verdict .hint { margin: 0.6rem 0 0; }

/* ------------------------------------------------------------- UTILITIES */

.hidden { display: none !important; }

/* L'attributo hidden deve vincere sui display: flex/grid dei componenti
   (.result-banner e' flex: senza questa riga resterebbe visibile da vuoto). */
[hidden] { display: none !important; }

:where(a, button, select, input, summary):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .topbar, .ctrl-col, .toast, .site-foot { display: none !important; }
  body { background: #fff; color: #000; }
}
