/* ===================================================
   VARIABILI GLOBALI
   =================================================== */

:root {
    --bg-page: #020617;
    --bg-shell: #020617;
    --bg-card: #0b1120;
    --bg-soft: #020617;

    --accent: #22d3ee;
    --accent-soft: rgba(34, 211, 238, 0.14);
    --accent-strong: rgba(34, 211, 238, 0.55);

    --text-main: #f9fafb;
    --text-muted: #9ca3af;

    --danger: #f97373;
    --success: #4ade80;

    --border-subtle: rgba(148, 163, 184, 0.3);
}

* {
    box-sizing: border-box;
}

/* ===================================================
   BASE LAYOUT / TIPOGRAFIA
   =================================================== */

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 24px;
    line-height: 1.45;
}

/* layout complessivo: colonne laterali + centro */
.page-layout {
    width: 100%;
    max-width: 1400px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
}

/* colonna centrale (contenuto del sito) */
.page-center {
    flex: 0 1 1180px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* wrapper centrale: app-shell + legenda + footer */
.page-wrap {
    width: 100%;
    max-width: 1180px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* colonne laterali per i banner (160px fissi) */
.side-ad-col {
    flex: 0 0 160px;
    display: flex;
    justify-content: center;
}

/* banner sotto il contenuto */
.bottom-ad {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

/* layout responsive: sotto i 1400px nascondo i laterali */
@media (max-width: 1400px) {
    .page-layout {
        flex-direction: column;
        align-items: center;
    }

    .side-ad-col {
        display: none;
    }

    .page-center {
        flex: 0 1 auto;
        width: 100%;
    }
}

/* onde in basso stile nPerf */
body::before {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100px;
    background:
        linear-gradient(to top, rgba(15, 118, 110, 0.5), transparent 65%),
        repeating-linear-gradient(-12deg,
            rgba(45, 212, 191, 0.7) 0 1px,
            transparent 1px 12px);
    opacity: 0.35;
    pointer-events: none;
    z-index: -1;
}

.app-shell {
    width: 100%;
    background: var(--bg-shell);
    border-radius: 20px;
    padding: 20px 20px 16px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow:
        0 22px 60px rgba(15, 23, 42, 0.9),
        0 0 0 1px rgba(15, 23, 42, 0.8);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===================================================
   SLOT BANNER / PLACEHOLDER ANNUNCI
   =================================================== */

/* wrapper che sovrappone placeholder e annuncio reale */
.ad-wrapper {
    position: relative;
}

/* colonne laterali: box 160x600 */
.ad-wrapper-side {
    position: relative;
    width: 160px;
    height: 600px;
}

/* banner sotto: 728x90 max */
.ad-wrapper-bottom {
    position: relative;
    width: 100%;
    max-width: 728px;
    height: 90px;
}

/* placeholder e iframe AdSense occupano lo stesso spazio */
.ad-wrapper-side .ad-slot,
.ad-wrapper-side .side-banner,
.ad-wrapper-bottom .ad-slot,
.ad-wrapper-bottom .bottom-banner {
    position: absolute;
    inset: 0;
}

/* placeholder generico */
.ad-slot {
    border-radius: 14px;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    background: #020617;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.04em;
    opacity: 0.9;
}

/* testo interno del placeholder */
.ad-slot span {
    font-weight: 600;
    opacity: 0.9;
}

/* titolo + sottotitolo */
.ad-slot-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-main);
    margin-bottom: 4px;
    opacity: 0.9;
}

.ad-slot-title::before {
    content: "💡";
    margin-right: 4px;
}

.ad-slot-subtitle {
    font-size: 11px;
    line-height: 1.4;
    max-width: 130px;
    /* laterali */
}

/* per il banner sotto, un po' più largo */
.ad-wrapper-bottom .ad-slot-subtitle {
    max-width: 100%;
    font-size: 11.5px;
}

/* placeholder laterale (160x600 minimi) */
.ad-slot-side {
    min-width: 160px;
    min-height: 600px;
}

/* placeholder bottom: riempie il wrapper */
.ad-slot-bottom {
    width: 100%;
    height: 100%;
}

/* banner bottom responsive */
.bottom-banner {
    width: 100%;
    height: 100%;
}

/* layout tablet per placeholder bottom */
@media (max-width: 900px) {
    .ad-wrapper-bottom {
        max-width: 100%;
        height: 90px;
    }
}

/* ===================================================
   HEADER / BRAND
   =================================================== */
header.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    padding-bottom: 10px;
}

header.app-header .brand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

header.app-header .header-right {
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-content: center;
    gap: 10px;
}

/* logo principale */
.brand-logo,
.brand-logo-full {
    display: block;
    width: auto;
    height: 90px;
    margin: 0;
}

.brand-text h1 {
    font-size: 18px;
    margin: 0 0 2px;
    letter-spacing: 0.02em;
}

.brand-text p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* chip di stato */

.chip {
    font-size: 11px;
    border-radius: 999px;
    padding: 3px 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.95);
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.chip.warn .chip-dot {
    background: #facc15;
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
}

/* ===================================================
   LAYOUT MAIN / PAGE TYPES
   =================================================== */

.page-main main {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* card test + colonna banner laterale (se servisse) */
.test-layout {
    display: grid;
    grid-template-columns: minmax(0, 3.3fr) minmax(260px, 1.2fr);
    gap: 14px;
    align-items: flex-start;
}

/* layout interno card test: gauge + metriche */
.test-layout-main {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 2.4fr);
    gap: 18px;
    align-items: center;
}

/* admin */
.page-admin main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr);
    gap: 14px;
}

/* layout tablet */
@media (max-width: 900px) {
    body {
        padding: 14px;
    }

    .app-shell {
        padding: 16px 12px 12px;
    }

    header.app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .test-layout,
    .test-layout-main,
    .page-admin main {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ===================================================
   CARD GENERICHE
   =================================================== */

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 14px 16px 12px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
    position: relative;
    overflow: hidden;
}

.card-test {
    padding-top: 18px;
}

.card.thin {
    padding: 12px 14px 10px;
}

.card.narrow {
    max-width: 420px;
    margin: 0 auto;
}

.card::before {
    content: "";
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(circle at 0 0, rgba(34, 211, 238, 0.12), transparent 60%),
        radial-gradient(circle at 100% 120%, rgba(59, 130, 246, 0.12), transparent 60%);
    opacity: 0.35;
    pointer-events: none;
}

.card-inner {
    position: relative;
    z-index: 1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.card-header h2 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #e5e7eb;
}

.card-header span.sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===================================================
   GAUGE CIRCOLARE
   =================================================== */

.dial-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    row-gap: 10px;
}

.dial-shell {
    position: relative;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 0, #0f172a, #020617 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 22px 40px rgba(15, 23, 42, 0.9),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

/* anello di base scuro */
.dial-ring {
    position: absolute;
    inset: 16px;
    border-radius: 50%;
    background:
        radial-gradient(circle,
            rgba(15, 23, 42, 1) 64%,
            rgba(15, 23, 42, 0.95) 66%,
            rgba(15, 23, 42, 0.9) 100%);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.8);
}

/* anello di avanzamento: la JS aggiorna --dial-progress (0–1) */
.dial-ring-fg {
    --dial-progress: 0;
    position: absolute;
    inset: 16px;
    border-radius: 50%;
    background:
        conic-gradient(from -90deg,
            #22d3ee 0deg,
            #22c55e calc(var(--dial-progress) * 360deg),
            rgba(15, 23, 42, 1) calc(var(--dial-progress) * 360deg),
            rgba(15, 23, 42, 1) 360deg);
    -webkit-mask: radial-gradient(farthest-side, transparent 70%, #000 71%);
    mask: radial-gradient(farthest-side, transparent 70%, #000 71%);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.55);
    pointer-events: none;
    transition: background 0.18s ease-out, box-shadow 0.18s ease-out;
}

/* bottone centrale GO */

.dial-button {
    position: relative;
    z-index: 2;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: none;
    background: radial-gradient(circle at 30% 0, #1f2937, #020617 70%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    font-family: inherit;
    box-shadow:
        0 0 0 2px rgba(15, 23, 42, 0.9),
        0 12px 26px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(34, 211, 238, 0.4);
    transition: transform 0.17s ease, box-shadow 0.17s ease;
}

.dial-button .dial-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.8;
}

.dial-button .dial-go {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.18em;
    margin-top: 4px;
}

.dial-button:hover {
    transform: translateY(-2px);
    box-shadow:
        0 0 0 2px rgba(34, 211, 238, 0.7),
        0 16px 32px rgba(0, 0, 0, 0.9),
        0 0 26px rgba(34, 211, 238, 0.7);
}

.dial-button:disabled {
    cursor: default;
    opacity: 0.7;
    transform: none;
}

/* testo sotto al gauge */

.dial-caption {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.dial-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
}

.status-text {
    font-size: 12px;
    color: var(--text-muted);
    min-height: 16px;
}

/* ===================================================
   METRICHE (PING / DOWN / UP / QUALITÀ)
   =================================================== */

.metrics-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 4px;
}

.results-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 800px) {
    .results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.metric-card {
    background: #0f172a;
    border-radius: 14px;
    padding: 9px 9px 8px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 10% 0, rgba(34, 211, 238, 0.1), transparent 55%);
    opacity: 0.7;
    pointer-events: none;
}

.metric-card-large {
    padding: 10px 11px 9px;
    background: linear-gradient(to bottom right,
            rgba(15, 23, 42, 0.98),
            rgba(15, 23, 42, 0.9));
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.8);
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-value {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.metric-unit {
    font-size: 13px;
    margin-left: 4px;
    color: var(--text-muted);
    font-weight: 400;
}

.metric-sub {
    font-size: 11.5px;
    color: rgba(209, 213, 219, 0.9);
}

.metric-highlight {
    color: var(--accent);
}

/* nota testuale accanto al ping */
.metric-note {
    margin-left: 6px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.9;
    display: inline-block;
}

/* card qualità + alone */

.metric-card-quality {
    position: relative;
}

.metric-card-quality::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 1px solid transparent;
    opacity: 0;
    transition: opacity 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.metric-card-quality.quality-excellent::before {
    border-color: rgba(34, 197, 94, 0.85);
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.6);
    opacity: 1;
}

.metric-card-quality.quality-good::before {
    border-color: rgba(34, 211, 238, 0.9);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.6);
    opacity: 1;
}

.metric-card-quality.quality-fair::before {
    border-color: rgba(234, 179, 8, 0.9);
    box-shadow: 0 0 16px rgba(234, 179, 8, 0.6);
    opacity: 1;
}

.metric-card-quality.quality-poor::before {
    border-color: rgba(248, 113, 113, 0.95);
    box-shadow: 0 0 16px rgba(248, 113, 113, 0.65);
    opacity: 1;
}

/* badge qualità */

.quality-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quality-badge {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-main);
    box-shadow: 0 0 8px rgba(15, 23, 42, 0.9);
}

.quality-badge-excellent {
    border-color: #22c55e;
    box-shadow:
        0 0 12px rgba(34, 197, 94, 0.7),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

.quality-badge-good {
    border-color: #22d3ee;
    box-shadow:
        0 0 12px rgba(34, 211, 238, 0.7),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

.quality-badge-fair {
    border-color: #eab308;
    box-shadow:
        0 0 12px rgba(234, 179, 8, 0.7),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

.quality-badge-poor {
    border-color: #f97373;
    box-shadow:
        0 0 12px rgba(248, 113, 113, 0.7),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

/* ===================================================
   BOTTONI
   =================================================== */

.btn-primary {
    border-radius: 999px;
    border: 0;
    padding: 9px 22px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    background: linear-gradient(90deg, #22d3ee, #22c55e);
    color: #0b1120;
    box-shadow:
        0 10px 24px rgba(34, 211, 238, 0.45),
        0 0 0 1px rgba(15, 23, 42, 0.9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease,
        filter 0.16s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow:
        0 14px 28px rgba(34, 211, 238, 0.65),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow:
        0 6px 16px rgba(34, 211, 238, 0.45),
        0 0 0 1px rgba(15, 23, 42, 0.9);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
    box-shadow: none;
}

.btn-support {
    min-width: 0;
}

.btn-secondary {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.95);
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* piccolo bottone vicino al badge connessione */
.btn-geo {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-geo:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(15, 23, 42, 1);
}

.btn-geo:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ===================================================
   STEP INDICATOR
   =================================================== */

.step-indicator {
    display: flex;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.step-pill {
    border-radius: 999px;
    padding: 3px 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.9);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.step-pill.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(34, 211, 238, 0.12);
}

.step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.9);
}

.step-pill.active .step-dot {
    background: var(--accent);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.8);
}

/* ===================================================
   FOOTER
   =================================================== */

.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    padding-top: 10px;
    margin-top: 4px;
    flex-wrap: wrap;
}

/* footer interno alla card test */
.footer-row-test {}

/* footer sito (fuori dalla card): niente bordo sopra */
.footer-row-site {
    border-top: none;
    padding-top: 0;
    margin-top: 10px;
}

.pill-small {
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.95);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pill-small strong {
    color: var(--text-main);
}

@media (max-width: 700px) {
    .footer-row {
        justify-content: center;
        text-align: center;
    }
}

/* ===================================================
   LINK
   =================================================== */

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===================================================
   TABELLE + FORM (ADMIN)
   =================================================== */

.table-wrapper {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(55, 65, 81, 0.8);
    background: rgba(15, 23, 42, 0.98);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.results-table thead {
    background: rgba(15, 23, 42, 1);
}

.results-table th,
.results-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.results-table th {
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.results-table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.96);
}

.results-table tbody tr:nth-child(odd) {
    background: rgba(15, 23, 42, 0.9);
}

.results-table tbody tr:hover {
    background: rgba(30, 64, 175, 0.4);
}

/* form / filtri */

.form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.form-row label {
    font-size: 12px;
    color: var(--text-muted);
}

.form-row input {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    padding: 7px 10px;
    font-size: 13px;
}

.form-row input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row.inline {
    flex: 1 1 120px;
    margin-bottom: 0;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
    align-items: flex-end;
}

.filters-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

@media (max-width: 700px) {
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-actions {
        justify-content: flex-end;
    }
}

/* pannello server */

.server-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.server-props {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    font-size: 12px;
}

@media (max-width: 700px) {
    .server-props {
        grid-template-columns: minmax(0, 1fr);
    }
}

.server-prop-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.server-prop-value {
    font-size: 13px;
}

.server-status {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
        Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 10px;
    padding: 8px 8px 7px;
    border: 1px solid rgba(30, 64, 175, 0.7);
    white-space: pre-line;
    max-height: 160px;
    overflow: auto;
}

/* ===================================================
   LEGENDA QUALITÀ
   =================================================== */

.legend-card {
    border-radius: 16px;
}

.legend-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 1040px;
    margin: 0 auto;
}

.legend-inner h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.legend-intro {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px;
    max-width: 72ch;
}

.legend-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.legend-list li {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 4px;
    align-items: flex-start;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: radial-gradient(circle at 0 0, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));
    overflow: hidden;
}

.legend-list li+li {
    margin-top: 4px;
}

.legend-tag {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    text-align: center;
    white-space: nowrap;
}

/* varianti colore */
.legend-tag-excellent {
    border-color: rgba(34, 197, 94, 0.7);
    background: linear-gradient(to right, rgba(34, 197, 94, 0.15), rgba(15, 23, 42, 0.95));
}

.legend-tag-good {
    border-color: rgba(34, 211, 238, 0.7);
    background: linear-gradient(to right, rgba(34, 211, 238, 0.15), rgba(15, 23, 42, 0.95));
}

.legend-tag-fair {
    border-color: rgba(234, 179, 8, 0.8);
    background: linear-gradient(to right, rgba(234, 179, 8, 0.18), rgba(15, 23, 42, 0.95));
}

.legend-tag-poor {
    border-color: rgba(248, 113, 113, 0.8);
    background: linear-gradient(to right, rgba(248, 113, 113, 0.18), rgba(15, 23, 42, 0.95));
}

.legend-item {
    border-left-width: 3px;
    border-left-style: solid;
    border-left-color: transparent;
}

.legend-item-excellent {
    border-left-color: #22c55e;
}

.legend-item-good {
    border-left-color: #22d3ee;
}

.legend-item-fair {
    border-left-color: #eab308;
}

.legend-item-poor {
    border-left-color: #f97373;
}

.legend-text {
    flex: 1 1 auto;
    line-height: 1.45;
    text-align: left;
}

@media (max-width: 700px) {
    .legend-inner {
        max-width: 100%;
        margin: 0;
        padding-inline: 6px;
    }

    .legend-list li {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        row-gap: 4px;
        padding: 10px 0;
    }

    .legend-tag {
        margin-bottom: 2px;
    }
}

/* =========================================
   BADGE CONNESSIONE / ISP
   ========================================= */

.conn-badge {
    margin-top: 12px;
    margin-bottom: 8px;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.96);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 640px;
    /* non si allarga a tutta la card su desktop */
    flex-wrap: nowrap;
    /* su desktop tiene tutto su una riga */
}

.conn-isp-logo-wrap {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.conn-isp-logo {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.conn-isp-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
    /* il testo occupa lo spazio centrale */
}

.conn-isp-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.conn-isp-meta {
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.3;
    word-break: break-word;
}

/* nota sotto al badge aggiornata dal browser */
#conn-geo-note {
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-muted);
}

/* quando non c'è logo */
.conn-badge-no-logo .conn-isp-logo-wrap {
    display: none;
}

/* pulsante “Migliora posizione” / “Riprova” dentro il badge */
#geo-improve-btn {
    margin-left: auto;
    white-space: nowrap;
}

/* =========================================
   MOBILE (badge connessione)
   ========================================= */

@media (max-width: 768px) {
    .conn-badge {
        width: 100%;
        max-width: none;
        border-radius: 18px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        flex-wrap: wrap;
        /* qui sì, può andare a capo */
    }

    .conn-isp-text {
        width: 100%;
    }

    #conn-geo-note {
        width: 100%;
    }

    #geo-improve-btn {
        margin-left: 0;
        align-self: stretch;
        text-align: center;
        padding-inline: 0;
        margin-top: 2px;
    }
}

/* nota connessione usata anche altrove */
.conn-isp-note {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ===================================================
   PAGINA SUPPORTO / FORM SEGNALAZIONE
   =================================================== */

.support-section {
    max-width: 920px;
    margin: 16px auto 4px;
    padding: 4px 4px 12px;
}

.support-header h1 {
    margin: 0 0 4px;
    font-size: 18px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.support-subtitle {
    margin: 0 0 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.support-intro {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.support-intro strong {
    color: var(--text-main);
}

.support-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.support-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

.support-alert {
    font-size: 13px;
    margin: 0 0 12px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.support-alert-success {
    border-color: rgba(34, 197, 94, 0.6);
    background: rgba(22, 163, 74, 0.12);
    color: #bbf7d0;
}

.support-alert-error {
    border-color: rgba(248, 113, 113, 0.8);
    background: rgba(127, 29, 29, 0.4);
    color: #fecaca;
}

.support-alert-error ul {
    margin: 4px 0 0 18px;
    padding: 0;
}

/* ===================================================
   UTILI
   =================================================== */

.text-danger {
    color: var(--danger);
}

.hidden {
    display: none !important;
}

/* ===================================================
   MOBILE (<= 768px)
   =================================================== */

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

    .page-wrap {
        gap: 10px;
    }

    .app-shell {
        padding: 14px 12px 14px;
        border-radius: 18px;
    }

    /* Header: logo centrato, chip sotto */
    .app-header {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding-bottom: 6px;
    }

    .brand {
        justify-content: center;
        width: 100%;
    }

    .brand-logo,
    .brand-logo-full {
        max-height: 36px;
    }

    .header-right {
        width: 100%;
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 6px;
    }

    .chip,
    .chip.warn {
        width: 100%;
        justify-content: flex-start;
        border-radius: 999px;
    }

    /* Card test */
    .card-test {
        padding-top: 14px;
        padding-bottom: 12px;
    }

    .card-header-tight {
        flex-direction: column;
        align-items: center;
        gap: 6px;
        text-align: center;
    }

    .card-header-tight>div {
        text-align: center;
    }

    .card-header-tight .chip {
        align-self: center;
        padding: 4px 14px;
        font-size: 11px;
        min-width: auto;
    }

    /* Gauge un filo più piccolo */
    .dial-area {
        margin-top: 4px;
    }

    .dial-shell {
        width: 210px;
        height: 210px;
    }

    .dial-button {
        width: 120px;
        height: 120px;
    }

    .dial-button .dial-label {
        font-size: 10px;
    }

    .dial-button .dial-go {
        font-size: 22px;
        letter-spacing: 0.16em;
    }

    .dial-caption {
        font-size: 11px;
        gap: 1px;
    }

    .dial-percent {
        font-size: 13px;
    }

    /* Metriche in colonna */
    .test-layout-main {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
        align-items: stretch;
    }

    .metrics-area {
        gap: 8px;
    }

    .results-grid-compact {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .metric-card-large {
        padding: 9px 10px 8px;
    }

    .metric-value {
        font-size: 20px;
    }

    /* Badge connessione: layout a colonna e bottone full width */
    .conn-badge {
        width: 100%;
        border-radius: 18px;
        align-self: flex-start;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .conn-isp-text {
        width: 100%;
    }

    #conn-geo-note {
        width: 100%;
    }

    #geo-improve-btn {
        margin-left: 0;
        align-self: stretch;
        text-align: center;
        padding-inline: 0;
        margin-top: 2px;
    }

    /* Footer card test in colonna */
    .footer-row-test {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-top: 10px;
    }

    .footer-row-test .pill-small {
        width: 100%;
        justify-content: flex-start;
    }

    /* Legenda + footer sito */
    .legend-card {
        border-radius: 16px;
        padding-inline: 10px;
    }

    .legend-inner {
        padding-inline: 0;
    }

    .footer-row-site {
        flex-direction: column;
        align-items: flex-start;
        border-top: none;
        padding-top: 0;
        margin-top: 6px;
        gap: 6px;
    }

    .footer-row-site .pill-small {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ===================================================
   EXTRA SMALL (<= 400px)
   =================================================== */

@media (max-width: 400px) {
    .dial-shell {
        width: 190px;
        height: 190px;
    }

    .dial-button {
        width: 110px;
        height: 110px;
    }

    .brand-logo,
    .brand-logo-full {
        max-height: 74px;
    }
}

/* ===================================================
   COOKIE BANNER
   =================================================== */

.cookie-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #7ed957;
    /* verde tipo nPerf */
    color: #022c22;
    font-size: 13px;
    display: none;
    /* mostrato via JS */
}

.cookie-banner-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cookie-banner-text {
    line-height: 1.4;
}

.cookie-banner-text a {
    color: #022c22;
    text-decoration: underline;
    font-weight: 600;
}

.cookie-banner-btn {
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.6);
    background: #f9fafb;
    color: #022c22;
    padding: 5px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.1s ease;
}

.cookie-banner-btn:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.cookie-banner-btn:active {
    transform: translateY(0);
}

/* stato visibile */
.cookie-banner.is-visible {
    display: block;
}

/* sposta il contenuto in basso quando il banner è visibile */
body.cookie-banner-visible {
    padding-top: 40px;
}

/* mobile */
@media (max-width: 700px) {
    .cookie-banner-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .cookie-banner-btn {
        align-self: flex-end;
    }
}