/* NHP NETWORK HARDENING — refined console theme
   Flat neutrals, hairline borders, single restrained emerald accent.
   Type: DM Sans (UI) / Space Grotesk (display) / IBM Plex Mono (data). */

:root {
    --bg: #0b0d11;
    --surface: #101319;
    --surface-2: #151a22;
    --inset: #0c0f14;
    --border: rgba(255, 255, 255, 0.08);
    --border-2: rgba(255, 255, 255, 0.15);
    --accent: #34d399;
    --accent-soft: rgba(52, 211, 153, 0.10);
    --accent-ink: #05281b;
    --ok: #34d399;
    --warn: #d9a441;
    --danger: #e5484d;
    --steel: #9aa3b2;
    --text: #edeff3;
    --muted: #9aa3b2;
    --faint: #646c7a;
    --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
    --disp: 'Space Grotesk', 'DM Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', 'JetBrains Mono', 'Menlo', monospace;
    --r-s: 8px;
    --r-m: 12px;
    --r-l: 16px;
    --wrap: 1120px;
    --hdr-h: 60px;
    --pad-x: clamp(0.75rem, 3vw, 1.25rem);
    /* alias legacy per gli stili inline in interact.php */
    --white: #fff;
    --border2: rgba(255, 255, 255, 0.15);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: 32px 32px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 90% 42% at 50% -6%, rgba(52, 211, 153, 0.055), transparent 70%);
    z-index: 0;
    pointer-events: none;
}

::selection {
    background: rgba(52, 211, 153, 0.28);
    color: #fff;
}

a { color: var(--accent); }

code {
    font-family: var(--mono);
    font-size: 0.84em;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Header ─────────────────────────────── */
header {
    background: rgba(11, 13, 17, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    /* Pinned alla colonna contenuto: su schermi larghi i bordi seguono
       .content (max --wrap, centrato), su mobile resta 2rem (override sotto). */
    padding: 0 max(2rem, calc((100% - var(--wrap)) / 2));
    height: var(--hdr-h);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.hdr-left { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }

.logo {
    font-family: var(--disp);
    font-weight: 600;
    font-size: 1.12rem;
    letter-spacing: 0.01em;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.logo span { color: var(--accent); }

.back-arrow {
    color: rgba(255,255,255,.5);
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 50%;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: color .15s, border-color .15s, background .15s;
}
.back-arrow svg { display: block; }
.back-arrow:hover { color: var(--text); border-color: var(--accent); background: rgba(52,211,153,.08); }

.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; min-width: 0; }

.badge-app {
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 3px 10px;
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    color: var(--muted);
    white-space: nowrap;
}

.hdr-title {
    color: var(--faint);
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Tabs ───────────────────────────────── */
.tabs-bar {
    background: rgba(11, 13, 17, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    /* Tab allineati al bordo sinistro di .content su schermi larghi. */
    padding: 0 max(2rem, calc((100% - var(--wrap)) / 2));
    display: flex;
    gap: 0.25rem;
    position: sticky;
    top: var(--hdr-h);
    z-index: 90;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }

.tab-link {
    padding: 0.8rem 1.1rem;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color 0.15s;
}
.tab-link:hover { color: var(--text); }
.tab-link.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Content ────────────────────────────── */
.content {
    flex: 1;
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: clamp(1.25rem, 3vw, 2rem) var(--pad-x) 3.5rem;
    position: relative;
    z-index: 1;
}

.sec-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--faint);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.65rem;
    margin-bottom: 1.25rem;
}

/* ── Form card ──────────────────────────── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: clamp(1.25rem, 3vw, 1.75rem);
    margin-bottom: 1.25rem;
}
.form-card h2 {
    font-family: var(--disp);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.3rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.form-card > p { color: var(--muted); font-size: 0.88rem; margin-bottom: 1rem; max-width: 62ch; }

/* Key points strip — concise, scannable */
.nhp-points {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background: var(--inset);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.nhp-points > div { padding: 0.7rem 0.9rem; min-width: 0; }
.nhp-points > div + div { border-left: 1px solid var(--border); }
.nhp-points b { display: block; font-family: var(--disp); font-size: 0.82rem; font-weight: 600; color: var(--text); }
.nhp-points span { display: block; font-size: 0.74rem; color: var(--faint); margin-top: 0.1rem; }

.h-ico { width: 20px; height: 20px; flex-shrink: 0; color: var(--accent); }

/* Segmented control */
.seg-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background: var(--inset);
    margin-bottom: 1.25rem;
}
.seg-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: var(--r-s);
    padding: 0.6rem 0.75rem;
    min-height: 44px;
    font-size: 0.83rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: rgba(255, 255, 255, 0.08); color: var(--text); }

/* Upload */
.upload-zone {
    border: 1px dashed rgba(255, 255, 255, 0.22);
    border-radius: var(--r-m);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--inset);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(52, 211, 153, 0.04);
}
.upload-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.8rem;
    color: var(--muted);
}
.upload-icon svg { width: 20px; height: 20px; }
.upload-zone h3 { font-family: var(--disp); font-size: 0.98rem; font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.upload-hint { font-size: 0.82rem; color: var(--faint); }
.file-chip {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.9rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
}
.file-chip.show { display: flex; }

/* Editor */
#json-editor {
    width: 100%;
    height: 300px;
    background: var(--inset);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    padding: 1rem 1.1rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.7;
    color: #dbe1ea;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
#json-editor:focus { border-color: var(--accent); }
#json-editor::placeholder { color: var(--faint); }

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.8rem;
}
.json-pill {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-2);
    color: var(--muted);
}
.json-pill.ok { background: var(--accent-soft); border-color: rgba(52, 211, 153, 0.35); color: var(--accent); }
.json-pill.bad { background: rgba(229, 72, 77, 0.08); border-color: rgba(229, 72, 77, 0.35); color: #f08a8e; }
.editor-error { margin-top: 0.5rem; color: #f08a8e; font-size: 0.82rem; display: none; }
.editor-examples { display: flex; gap: 0.5rem; margin-left: auto; flex-wrap: wrap; }

/* Buttons */
.btn-go {
    padding: 0.8rem 1.5rem;
    min-height: 48px;
    background: var(--text);
    color: #0b0d11;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-go:hover:not(:disabled) { background: #ffffff; }
.btn-go:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-go.block { width: 100%; margin-top: 1rem; }

.btn-ghost {
    padding: 0.55rem 1.1rem;
    min-height: 40px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.28); }

.btn-reset {
    padding: 0.55rem 1.2rem;
    min-height: 40px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.btn-reset:hover { border-color: rgba(229, 72, 77, 0.5); color: #f08a8e; }

/* ── Loader ─────────────────────────────── */
.nhp-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 1rem;
}
.nhp-radar { position: relative; width: 148px; height: 148px; margin-bottom: 1.1rem; }
.nhp-ring { position: absolute; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 50%; }
.nhp-ring.r1 { inset: 0; }
.nhp-ring.r2 { inset: 22px; }
.nhp-ring.r3 { inset: 44px; }
.nhp-sweep {
    position: absolute; inset: 4px; border-radius: 50%;
    background: conic-gradient(from 0deg,
        rgba(52, 211, 153, 0.55) 0deg,
        rgba(52, 211, 153, 0.12) 40deg,
        transparent 90deg);
    animation: nhpSpin 2.4s linear infinite;
}
.nhp-node {
    position: absolute; width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent);
    animation: nhpBlip 2.6s ease-in-out infinite;
}
.nhp-node.n1 { top: 14%; left: 62%; }
.nhp-node.n2 { top: 52%; left: 82%; animation-delay: 0.5s; }
.nhp-node.n3 { top: 76%; left: 38%; animation-delay: 1s; }
.nhp-node.n4.vuln { top: 32%; left: 18%; background: var(--danger); animation-delay: 0.7s; }
.nhp-node.n5.crit { top: 60%; left: 52%; width: 6px; height: 6px; background: var(--warn); animation-delay: 1.3s; }
.nhp-core {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--inset);
    border: 1px solid var(--border-2);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}
.nhp-core svg { width: 20px; height: 20px; }
.nhp-time {
    font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
    color: var(--text); margin-bottom: 0.7rem;
    font-variant-numeric: tabular-nums;
}
.pl-status-wrap {
    height: 1.4em; overflow: hidden; position: relative;
    width: 100%; max-width: 320px; margin-bottom: 0.9rem;
}
.pl-status {
    font-size: 0.85rem; color: var(--muted);
    text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    position: absolute; left: 0; right: 0; top: 0;
}
.pl-dots { display: flex; gap: 6px; }
.pl-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--faint);
    animation: plDotPulse 1.4s ease-in-out infinite;
}
.pl-dots span:nth-child(2) { animation-delay: 0.2s; }
.pl-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── Result dashboard ───────────────────── */
.result-dashboard { display: none; }
.result-dashboard.show { display: block; }

.dash-head {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.dash-status {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; font-weight: 600; flex-shrink: 0;
    border: 1px solid;
}
.dash-status.ok { background: var(--accent-soft); color: var(--accent); border-color: rgba(52, 211, 153, 0.3); }
.dash-status.fail { background: rgba(229, 72, 77, 0.08); color: #f08a8e; border-color: rgba(229, 72, 77, 0.3); }
.dash-head h3 { font-family: var(--disp); font-size: 1.05rem; font-weight: 600; color: var(--text); }
.dash-head .dash-reply { font-size: 0.83rem; color: var(--muted); margin-top: 0.15rem; max-width: 70ch; }
.dash-head .dash-badges { margin-left: auto; display: flex; gap: 0.45rem; flex-wrap: wrap; }

.nhp-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    border: 1px solid;
    white-space: nowrap;
}
.nhp-badge.green { background: var(--accent-soft); color: var(--accent); border-color: rgba(52, 211, 153, 0.3); }
.nhp-badge.red { background: rgba(229, 72, 77, 0.08); color: #f08a8e; border-color: rgba(229, 72, 77, 0.3); }
.nhp-badge.blue { background: rgba(154, 163, 178, 0.10); color: #c3c9d4; border-color: rgba(154, 163, 178, 0.3); }
.nhp-badge.yellow { background: rgba(217, 164, 65, 0.09); color: #e3b869; border-color: rgba(217, 164, 65, 0.32); }
.nhp-badge.slate { background: rgba(154, 163, 178, 0.10); color: #c3c9d4; border-color: rgba(154, 163, 178, 0.3); }
.nhp-badge.purple { background: rgba(154, 163, 178, 0.10); color: #c3c9d4; border-color: rgba(154, 163, 178, 0.3); }

.dash-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    padding: 1rem 1.1rem;
    min-width: 0;
}
.kpi-label {
    font-size: 0.68rem; font-weight: 500;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--faint);
}
.kpi-val {
    font-family: var(--disp);
    font-size: 1.75rem; font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text); margin-top: 0.3rem; line-height: 1.1;
    font-variant-numeric: tabular-nums;
    overflow-wrap: break-word;
}
.kpi-val.accent, .kpi-val.good { color: var(--accent); }
.kpi-sub { font-size: 0.75rem; color: var(--faint); margin-top: 0.25rem; }

.dash-main {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}
.dash-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: 1.15rem 1.2rem;
    min-width: 0;
}
.panel h3 { font-family: var(--disp); font-size: 0.95rem; font-weight: 600; color: var(--text); }
.panel .panel-sub {
    font-size: 0.72rem; font-weight: 500;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--faint); margin: 0.3rem 0 1rem;
}

.act-tbl { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.act-tbl th {
    text-align: left; font-size: 0.66rem; font-weight: 500;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--faint); padding: 0.5rem 0.55rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.act-tbl td {
    padding: 0.5rem 0.55rem;
    border-bottom: 1px solid var(--border);
    color: var(--text); vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.act-tbl tr:last-child td { border-bottom: none; }
.act-port { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); white-space: nowrap; }
.act-arrow { color: var(--faint); margin: 0 0.25rem; }
.total-row td { font-weight: 600; border-top: 1px solid var(--border-2); }
.total-row .total-val { color: var(--accent); font-family: var(--mono); }

.bar-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.55rem; font-size: 0.8rem; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label {
    flex: 0 0 clamp(92px, 24vw, 118px);
    text-align: right; color: var(--muted);
    font-size: 0.76rem; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-track { flex: 1; background: rgba(255, 255, 255, 0.06); border-radius: 5px; overflow: hidden; min-width: 0; }
.bar-fill {
    height: 20px; border-radius: 5px;
    display: flex; align-items: center; padding: 0 0.55rem;
    font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
    color: #0b0d11;
    white-space: nowrap;
}

.topo-host {
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background: var(--inset);
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.55rem;
}
.topo-host:last-child { margin-bottom: 0; }
.topo-host-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.topo-host-name { font-weight: 500; font-size: 0.82rem; color: var(--text); font-family: var(--mono); overflow-wrap: anywhere; }
.svc-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.svc-chip {
    font-size: 0.72rem; font-family: var(--mono);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: #c3c9d4;
    padding: 2px 9px; border-radius: 6px;
    display: inline-flex; align-items: center; gap: 0.35rem;
}
.svc-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; flex-shrink: 0; }
.svc-chip.vuln { border-color: rgba(229, 72, 77, 0.4); color: #f3b8bb; }
.svc-chip.vuln .dot { background: var(--danger); }
.svc-chip.crit { border-color: rgba(217, 164, 65, 0.4); }

.run-rows { font-size: 0.83rem; }
.run-row {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.run-row:last-child { border-bottom: none; }
.run-row .k { color: var(--muted); flex-shrink: 0; }
.run-row .v {
    color: var(--text); font-weight: 500; text-align: right;
    font-family: var(--mono); font-size: 0.76rem;
    overflow-wrap: anywhere; max-width: 62%;
}

.dash-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

/* ── Stats ──────────────────────────────── */
/* ── Stats: colonne fisse e bilanciate (come F1): 6 card → 3×2, 4 card → 4 in riga ── */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; margin-bottom: 1.25rem; }
.stat-grid.stat-grid--reduced { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
    .stat-grid, .stat-grid.stat-grid--reduced { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    padding: 1.15rem 1rem;
    text-align: left;
}
.stat-val {
    display: block;
    font-family: var(--disp);
    font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat-label { display: block; font-size: 0.72rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-top: 0.3rem; }

.chart-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.chart-box h3 { font-family: var(--disp); font-size: 0.92rem; font-weight: 600; margin-bottom: 1rem; color: var(--text); }
.chart-box canvas { max-width: 100%; display: block; }

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.stats-table th {
    text-align: left; font-size: 0.66rem; font-weight: 500;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--faint); padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border);
}
.stats-table td {
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stats-table tr:last-child td { border: none; }

/* ── Info ───────────────────────────────── */
.info-grid { display: grid; grid-template-columns: 1fr; gap: 0.8rem; margin-bottom: 1.25rem; }
/* Desktop: 2 colonne bilanciate (4 card → 2×2); l'eventuale orfana va a tutta riga. */
@media (min-width: 900px) {
    .info-grid { grid-template-columns: 1fr 1fr; }
    .info-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    padding: 1.3rem 1.35rem;
}
.info-card h3 {
    font-family: var(--disp);
    font-size: 0.98rem; font-weight: 600;
    margin-bottom: 0.6rem; color: var(--text);
    display: flex; align-items: baseline; gap: 0.65rem;
}
.info-idx { font-family: var(--mono); font-size: 0.72rem; font-weight: 500; color: var(--accent); }
.info-card p { font-size: 0.88rem; color: var(--muted); line-height: 1.7; }
.info-card p + p { margin-top: 0.5rem; }
.info-card ol { margin: 0.5rem 0 0 1.2rem; color: var(--muted); line-height: 1.75; font-size: 0.87rem; }

.res-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.9rem; }
.res-links > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.res-links > a, .res-links > span {
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 0.6rem 1rem; min-height: 44px;
    font-size: 0.82rem; font-weight: 500;
    border-radius: 10px;
}
.res-links > a {
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border-2);
    transition: background 0.15s, border-color 0.15s;
}
.res-links > a:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.28); }
.res-links > span {
    color: var(--faint);
    border: 1px solid var(--border);
    cursor: not-allowed;
}

/* ── Testing ────────────────────────────── */
.test-result {
    background: var(--inset);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    padding: 1rem;
    font-family: var(--mono);
    font-size: 0.76rem;
    line-height: 1.65;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #dbe1ea;
}
.field label {
    display: block; font-size: 0.68rem; font-weight: 500;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--faint); margin-bottom: 0.45rem;
}
.field select, .field input[type="text"] {
    width: 100%; background: var(--inset);
    border: 1px solid var(--border-2); border-radius: 10px;
    color: var(--text); font-family: var(--mono); font-size: 0.82rem;
    padding: 0.7rem 0.9rem; min-height: 46px; outline: none;
    transition: border-color 0.15s;
}
.field select:focus, .field input[type="text"]:focus { border-color: var(--accent); }
.field select option { background: #151a22; color: var(--text); }
#testing-base-url-display { overflow-wrap: anywhere; }
#testing-payload { transition: border-color 0.15s; }
#testing-payload:focus { border-color: var(--accent); }

.no-ep {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: 3.5rem 2rem;
    text-align: center;
    color: var(--muted);
}

/* ── Form guidato / topologia / recap ───── */
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 0.9rem; }
.f-host {
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background: var(--inset);
    padding: 1rem;
    margin-bottom: 0.8rem;
}
.f-host-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; }
.f-host-title { font-family: var(--mono); font-weight: 500; font-size: 0.8rem; color: var(--text); letter-spacing: 0.02em; }
.f-host input[type="text"], .f-host input[type="number"] {
    width: 100%; background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-2); border-radius: 10px;
    color: var(--text); font-family: var(--mono); font-size: 0.8rem;
    padding: 0.6rem 0.75rem; min-height: 44px; outline: none;
    transition: border-color 0.15s;
}
.f-host input:focus { border-color: var(--accent); }
.f-host .f-id { margin-bottom: 0.4rem; }
.f-feat { padding: 0.7rem 0; border-top: 1px solid var(--border); }
.f-feat:first-of-type { border-top: none; padding-top: 0.3rem; }
.f-feat-main { display: grid; grid-template-columns: minmax(0, 1.4fr) 104px auto auto 30px; gap: 0.55rem; align-items: center; }
.f-dep { margin-top: 0.5rem; }
.f-check { display: flex; align-items: center; gap: 0.35rem; font-size: 0.74rem; color: var(--muted); white-space: nowrap; cursor: pointer; min-height: 44px; }
.f-check input[type="checkbox"] { width: 17px; height: 17px; accent-color: #34d399; cursor: pointer; }
.f-x {
    background: none; border: 1px solid transparent; color: var(--faint);
    border-radius: var(--r-s); width: 32px; height: 32px; font-size: 0.8rem;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.f-x:hover { color: #f08a8e; border-color: rgba(229, 72, 77, 0.4); }
.f-invalid { border-color: var(--danger) !important; }
.f-add { margin-top: 0.5rem; font-size: 0.8rem; }
.form-run-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }

.topo-preview {
    margin-top: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background: var(--inset);
    padding: 1rem 1.1rem;
}
.topo-preview h3 { font-family: var(--disp); font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.topo-empty { color: var(--faint); font-size: 0.83rem; padding: 0.7rem 0; }
.topo-svg { width: 100%; height: auto; display: block; }

.recap { margin-bottom: 1rem; }
.recap-toggle {
    width: 100%; background: none; border: none; padding: 0;
    color: var(--text); font-family: var(--disp); font-size: 0.92rem; font-weight: 600;
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    cursor: pointer; text-align: left;
}
.recap-chev { color: var(--faint); font-size: 0.75rem; transition: transform 0.2s; }
.recap-body { margin-top: 0.9rem; }
.recap-json summary { cursor: pointer; font-size: 0.8rem; color: var(--muted); margin: 0.8rem 0 0.5rem; }
.recap-json pre {
    background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-m);
    padding: 0.9rem; font-family: var(--mono); font-size: 0.74rem; line-height: 1.6;
    color: #dbe1ea; max-height: 280px; overflow: auto;
    white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
}

.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.dash-main > .panel { display: flex; flex-direction: column; min-width: 0; }
.dash-main > .panel .tbl-scroll { flex: 1 1 auto; }

/* Injected by /js/animations.js */
#scroll-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent); transform-origin: left; transform: scaleX(0); z-index: 200;
}
#to-top {
    position: fixed; right: 1rem; bottom: 1rem; width: 42px; height: 42px;
    border-radius: 50%; background: rgba(16, 19, 25, 0.92);
    border: 1px solid var(--border-2); color: var(--muted);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    opacity: 0; pointer-events: none; transition: opacity 0.2s, color 0.15s;
    z-index: 200;
}
#to-top.is-visible { opacity: 1; pointer-events: auto; }
#to-top:hover { color: var(--text); }
.code-copy {
    display: inline-block; margin-top: 0.6rem; padding: 0.35rem 0.85rem; min-height: 32px;
    font-size: 0.74rem; font-family: inherit; border-radius: var(--r-s);
    background: transparent; border: 1px solid var(--border-2);
    color: var(--muted); cursor: pointer;
}
.code-copy.is-copied { color: var(--accent); border-color: rgba(52, 211, 153, 0.4); }

/* AI transparency — flat tints */
.ai-notice { border-color: rgba(52, 211, 153, 0.25); background: rgba(52, 211, 153, 0.05); }
.ai-notice .ai-notice-link { color: rgba(52, 211, 153, 0.85); }
.ai-notice .ai-notice-link:hover { color: var(--accent); }
.ai-info-card { border-color: rgba(52, 211, 153, 0.2); background: rgba(52, 211, 153, 0.04); }
.ai-info-card .ai-limits { background: rgba(52, 211, 153, 0.05); border-color: rgba(52, 211, 153, 0.14); }
.ai-info-card .ai-limits strong { color: var(--accent); }

/* Hints, legend, validation */
.form-hint { font-size: 0.79rem; color: var(--muted); line-height: 1.65; margin: 0.1rem 0 0.9rem; }
.form-hint strong { color: var(--text); font-weight: 600; }
.topo-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.74rem; color: var(--muted); margin-bottom: 0.7rem; font-family: var(--mono); }
.topo-legend .lg-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 0.35rem; }

.iss { border-radius: var(--r-m); padding: 0.7rem 0.9rem; font-size: 0.8rem; margin-top: 0.6rem; line-height: 1.6; }
.iss b { display: block; margin-bottom: 0.3rem; font-size: 0.76rem; font-weight: 600; }
.iss ul { margin: 0 0 0 1.1rem; }
.iss-err { background: rgba(229, 72, 77, 0.07); border: 1px solid rgba(229, 72, 77, 0.3); color: #f3b8bb; }
.iss-warn { background: rgba(217, 164, 65, 0.07); border: 1px solid rgba(217, 164, 65, 0.3); color: #e8c98a; }
.form-warn { display: none; margin-top: 0.5rem; font-size: 0.8rem; line-height: 1.6; color: #e8c98a; background: rgba(217, 164, 65, 0.07); border: 1px solid rgba(217, 164, 65, 0.3); border-radius: var(--r-m); padding: 0.6rem 0.9rem; }
.form-warn strong { display: block; margin-bottom: 0.2rem; }

/* Reveal — only when JS is present (html.js), so no-JS never hides content */
html.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.45s ease, transform 0.45s ease; }
html.js .reveal.visible { opacity: 1; transform: translateY(0); }

/* ── Large screens ──────────────────────── */
@media (min-width: 1500px) {
    :root { --wrap: 1280px; }
    .dash-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; }
    .dash-kpis { gap: 1rem; }
}

/* ── Tablet ─────────────────────────────── */
@media (max-width: 1024px) {
    .dash-main { grid-template-columns: minmax(0, 1fr); }
    .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Medium: side panels in two columns ─── */
@media (min-width: 641px) and (max-width: 1024px) {
    .dash-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .dash-side .panel:last-child { grid-column: 1 / -1; }
}

/* ── Small ──────────────────────────────── */
@media (max-width: 760px) {
    .frow { grid-template-columns: 1fr; }
    .f-feat-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; row-gap: 0.35rem; }
    .f-feat-main .f-svc { grid-column: 1 / -1; }
    .f-feat-main .f-port { grid-column: 1 / -1; }
    .f-feat-main .f-x { grid-row: 3; grid-column: 3; }
    .f-check { min-height: 40px; }
    .act-tbl { min-width: 600px; }
    .stats-table { min-width: 0; }
    .dash-head .dash-badges { margin-left: 0; width: 100%; }
    .run-row .v { max-width: 58%; }
}

@media (max-width: 700px) {
    :root { --hdr-h: 56px; }
    header { padding: 0 1rem; }
    .hdr-title { display: none; }
    .tabs-bar { padding: 0 1rem; }
    .tab-link { padding: 0.75rem 0.9rem; font-size: 0.84rem; }
    .stat-val { font-size: 1.45rem; }
    .chart-box { padding: 1rem; }
    .res-links { grid-template-columns: 1fr 1fr; }
    .editor-examples { margin-left: 0; width: 100%; }
    .editor-examples .btn-ghost { flex: 1 1 auto; text-align: center; }
    .bar-label { flex-basis: 92px; }
}

/* Very small: stack segmented control + actions, compact KPIs */
@media (max-width: 560px) {
    body { font-size: 14.5px; }
    .seg-control { grid-template-columns: 1fr; }
    .seg-btn { min-height: 46px; }
    .nhp-points { grid-template-columns: 1fr; }
    .nhp-points > div + div { border-left: none; border-top: 1px solid var(--border); }
    .form-card h2 { font-size: 1.08rem; }
    .kpi-card { padding: 0.8rem 0.85rem; }
    .kpi-val { font-size: 1.35rem; }
    .kpi-sub { font-size: 0.7rem; }
    .dash-actions > * { flex: 1 1 calc(50% - 0.6rem); text-align: center; }
    .res-links { grid-template-columns: 1fr; }
    .res-links > :last-child:nth-child(odd) { grid-column: auto; }
    .upload-zone { padding: 2rem 1rem; }
    .topo-host-head { align-items: flex-start; }
}

@media (max-width: 380px) {
    .dash-kpis { gap: 0.6rem; }
    .kpi-val { font-size: 1.2rem; }
    .bar-label { flex-basis: 84px; font-size: 0.7rem; }
}

/* ── Motion ─────────────────────────────── */
@keyframes nhpSpin { from { transform: rotate(0); } to { transform: rotate(1turn); } }
@keyframes nhpBlip { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes plDotPulse { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    html.js .reveal { opacity: 1; transform: none; transition: none; }
    .nhp-sweep, .nhp-node, .pl-dots span { animation: none; }
    * { transition-duration: 0.01ms !important; }
}

/* ── Print ──────────────────────────────── */
@media print {
    body { background: #fff !important; color: #000 !important; display: block; }
    body::before { display: none !important; }
    header, .tabs-bar, #form-card, #nhp-actions, .no-ep, .ai-notice { display: none !important; }
    .content { max-width: 100% !important; padding: 0 !important; }
    .result-dashboard { display: block !important; }
    .dash-head, .kpi-card, .panel { background: #fff !important; border: 1px solid #999 !important; }
    .dash-head h3, .panel h3, .kpi-val, .act-tbl td, .act-tbl th, .run-row .v, .topo-host-name { color: #000 !important; }
    .dash-reply, .kpi-label, .kpi-sub, .panel-sub, .run-row .k, .svc-chip { color: #333 !important; }
    .nhp-badge { background: #fff !important; }
    .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { color: #000 !important; text-decoration: none !important; }
}
