/* ST SAFE TRAVEL — Travel-risk atlas
 *
 * Concept "Atlante": una carta nautica chiara. Carta grigio-nebbia con graticola
 * (reticolo di meridiani/paralleli a filo), accento blu oceano e un solo segnale
 * arancio-bussola per minaccia e allerta. Le schede minaccia sono fascicoli
 * (dossier) con segni di registro agli angoli e un timbro tratteggiato per il
 * livello Basso/Medio/Alto. Header chiaro con scala metrica in basso.
 * Nessun gradiente decorativo, nessun glow, nessuna nuvola, nessuna emoji.
 *
 * Font (solo self-hosted, /css/fonts.css): Instrument Serif (display), DM Sans (testo),
 * IBM Plex Mono (etichette, punteggi, numeri).
 *
 * Contrasti (WCAG): ink su carta 14.2:1, muted su carta 5.6:1, oceano #0b6e99 su carta 4.9:1
 * e su card 5.4:1, bianco su oceano-scuro #085a7e 7.6:1, segnale #b93a0a su card 5.9:1,
 * "Model" ink su header 15:1, "Vault" #0b6e99 su header 5.4:1.
 */

:root {
    --paper: #eceff3;
    --card: #fbfcfd;
    --recess: #e1e7ed;
    --rule: #cbd3dc;
    --rule-2: #8f9cab;
    --ink: #11202c;
    --ink-2: #2f414e;
    --muted: #4c5b69;
    --faint: #586775;

    --accent: #0b6e99;
    --accent-d: #085a7e;
    --accent-hi: #0a7db0;
    --accent-l: rgba(11, 110, 153, .08);
    --signal: #b93a0a;
    --signal-l: rgba(185, 58, 10, .09);
    --green: #2c6a2a;
    --green-l: rgba(44, 106, 42, .10);
    --amber: #84560a;
    --amber-l: rgba(132, 86, 10, .11);
    --red: #b93a0a;
    --red-l: rgba(185, 58, 10, .09);
    --slate: #4c5b69;

    --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
    --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

    --radius: 4px;
    --radius-sm: 3px;
    --shadow: 0 1px 0 rgba(17, 32, 44, .04), 0 6px 18px -12px rgba(17, 32, 44, .25);
    --shadow-hover: 0 10px 28px -14px rgba(17, 32, 44, .35);

    --hdr-h: 60px;

    /* Alias storici (markup/inline legacy) */
    --text: var(--ink);
    --text-secondary: var(--ink-2);
    --line: var(--rule);
    --line-strong: var(--rule-2);
    --border: var(--rule);
    --border2: var(--rule-2);
    --panel: var(--recess);
    --surface: var(--card);
    --white: #fff;
    --headings: var(--serif);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Utility locali (ex-Bootstrap): uniche due classi usate in interact.php. */
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }

html { -webkit-text-size-adjust: 100%; }

body {
    background-color: var(--paper);
    /* Graticola: meridiani/paralleli sottili, maglia fine + maglia maggiore. Statica. */
    background-image:
        linear-gradient(rgba(17, 32, 44, .055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(17, 32, 44, .055) 1px, transparent 1px),
        linear-gradient(rgba(11, 110, 153, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(11, 110, 153, .06) 1px, transparent 1px);
    background-size: 192px 192px, 192px 192px, 32px 32px, 32px 32px;
    background-position: -1px -1px;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { font-family: var(--serif); font-weight: 400; letter-spacing: 0; color: var(--ink); }

::selection { background: var(--accent); color: #fff; }

:focus-visible { outline: 2px solid var(--accent-d); outline-offset: 2px; }

/* === HEADER === */
header {
    background: var(--card);
    border-bottom: 1px solid var(--rule-2);
    padding: 0 max(clamp(1rem, 3vw, 2.5rem), calc((100% - 1040px) / 2));
    height: var(--hdr-h);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
/* Scala metrica: tacche ogni 8px, maggiori ogni 40px, lungo il bordo inferiore */
header::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
    pointer-events: none;
    background:
        repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 40px) bottom / 100% 6px no-repeat,
        repeating-linear-gradient(90deg, var(--rule-2) 0 1px, transparent 1px 8px) bottom / 100% 3px no-repeat;
}
.hdr-left { display: flex; align-items: center; gap: .7rem; }

.logo {
    font-family: 'DM Serif Display', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: 1.5rem;
    letter-spacing: .005em;
    line-height: 1;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex; align-items: center; min-height: 44px;
    transition: color .18s ease;
}
.logo span { color: var(--accent); transition: color .18s ease; }
.logo:hover, .logo:focus-visible, .logo:active { color: var(--accent); }

.back-arrow {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; flex-shrink: 0;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--rule-2);
    border-radius: 50%;
    background: transparent;
    transition: color .15s, border-color .15s, background .15s;
}
.back-arrow svg { display: block; }
.back-arrow::after { content: ""; position: absolute; inset: -9px; }
.back-arrow:hover { color: #fff; border-color: var(--accent-d); background: var(--accent-d); }

.hdr-right { margin-left: auto; display: flex; align-items: center; gap: .85rem; min-width: 0; }
.badge-st {
    background: var(--signal-l); color: var(--signal);
    border: 1px dashed var(--signal);
    border-radius: 2px; padding: 2px 9px;
    font-family: var(--mono);
    font-size: .66rem; font-weight: 600; letter-spacing: .12em;
    white-space: nowrap;
}
.hdr-title {
    color: var(--muted); font-family: var(--mono);
    font-size: .72rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: .14em;
    white-space: nowrap;
}

/* === TABS === */
.tabs-bar {
    background: var(--paper);
    border-bottom: 1px solid var(--rule-2);
    padding: 0 clamp(1rem, 3vw, 2.5rem);
    display: flex;
    justify-content: center;
    position: sticky;
    top: var(--hdr-h);
    z-index: 90;
}
.tab-link {
    position: relative;
    padding: .8rem 1.25rem;
    display: inline-flex; align-items: center; gap: .45rem; min-height: 44px;
    font-family: var(--mono);
    font-size: .74rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--muted); text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.tab-link:hover { color: var(--ink); border-bottom-color: var(--rule-2); }
.tab-link.active { color: var(--accent-d); border-bottom-color: var(--accent); font-weight: 600; }
/* Segnaposto a losanga arancio sul tab attivo */
.tab-link.active::before {
    content: ""; width: 6px; height: 6px; flex-shrink: 0;
    background: var(--signal); transform: rotate(45deg);
}

/* === CONTENT === */
.content {
    flex: 1; display: flex; flex-direction: column;
    max-width: 1040px; width: 100%;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem) 3rem;
    position: relative; z-index: 1;
}
.sec-title {
    font-family: var(--mono);
    font-size: .72rem; font-weight: 600;
    letter-spacing: .16em; text-transform: uppercase;
    color: var(--ink);
    border-bottom: 1px solid var(--ink);
    padding-bottom: .5rem;
    margin: 2.5rem 0 1.25rem;
}

/* === HERO === */
.st-hero {
    position: relative;
    text-align: center;
    margin: 2.25rem 0 0;
    padding: 1.5rem 0 .5rem;
    animation: heroFadeIn .7s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes heroFadeIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.st-hero-inner { position: relative; z-index: 1; padding: 0 1rem; }
/* Filetto con losanga-segnale al centro */
.st-hero-inner::before {
    content: "";
    display: block; width: 72px; height: 9px; margin: 0 auto .9rem;
    background:
        linear-gradient(var(--ink), var(--ink)) left center / 28px 1px no-repeat,
        linear-gradient(var(--ink), var(--ink)) right center / 28px 1px no-repeat,
        linear-gradient(var(--signal), var(--signal)) center / 7px 7px no-repeat;
}
.st-hero h1 {
    color: var(--ink);
    font-size: clamp(2rem, 1.35rem + 2.2vw, 3rem);
    line-height: 1.06;
    letter-spacing: -.005em;
    margin-bottom: .75rem;
}
.st-hero .lead {
    color: var(--ink-2);
    font-size: clamp(.9rem, 1.4vw, 1.05rem);
    max-width: 36rem;
    margin: 0 auto;
    line-height: 1.6;
}

/* === CARD BASE (fascicolo): registro angolare === */
.st-search, .form-card, .threat, .stat-card, .chart-box, .info-card, .ticket-bar, .no-ep {
    background: var(--card);
    border: 1px solid var(--rule-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* === SEARCH FORM === */
.st-search, .form-card {
    position: relative;
    border-top: 3px solid var(--accent);
    padding: clamp(1.4rem, 3vw, 2rem);
    margin-bottom: 1.75rem;
}
.st-search { margin-top: 1.75rem; animation: searchFadeIn .6s .12s cubic-bezier(.16, 1, .3, 1) both; }
.form-card { margin-bottom: 1.5rem; }
@keyframes searchFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* Segni di registro agli angoli bassi */
.st-search::before, .st-search::after, .form-card::before, .form-card::after {
    content: ""; position: absolute; width: 11px; height: 11px; pointer-events: none;
    border: 0 solid var(--signal);
}
.st-search::before, .form-card::before { left: -6px; bottom: -6px; border-width: 0 0 2px 2px; }
.st-search::after, .form-card::after { right: -6px; bottom: -6px; border-width: 0 2px 2px 0; }

.st-search h2, .form-card h2 {
    font-size: 1.55rem; line-height: 1.15;
    color: var(--ink); margin-bottom: .2rem;
    display: flex; align-items: center; gap: .5rem;
}
.st-search h2 .ico, .form-card h2 .ico { color: var(--signal) !important; font-size: .9em; }
.st-search > p, .form-card > p {
    color: var(--muted); font-size: .86rem;
    margin-bottom: 1.35rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.form-row--2 { grid-template-columns: repeat(2, 1fr); }
.form-row > * { min-width: 0; }
.form-row-full { margin-bottom: 1.25rem; }

.field { min-width: 0; }
.field label {
    display: block;
    font-family: var(--mono);
    font-size: .68rem; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted); margin-bottom: .35rem;
}
.field input,
.field select,
.field textarea {
    width: 100%; min-width: 0; max-width: 100%;
    background: #fff;
    border: 1px solid var(--rule-2);
    border-radius: var(--radius-sm);
    color: var(--ink); font-family: inherit;
    font-weight: 400; font-size: .92rem;
    padding: .65rem .85rem;
    min-height: 44px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field textarea {
    resize: vertical; min-height: 110px;
    font-family: var(--mono); font-size: .8rem;
}
.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2311202c' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .9rem center;
    padding-right: 2.2rem;
}
.field input::placeholder,
.field textarea::placeholder { color: #8d99a5; font-style: italic; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-2); }
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(11, 110, 153, .18);
}
.field select option { background: #fff; color: var(--ink); }

.btn-go {
    width: 100%; min-height: 48px; padding: .8rem;
    background: var(--accent-d); color: #fff;
    border: 1px solid var(--accent-d);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: .78rem; font-weight: 600;
    letter-spacing: .16em; text-transform: uppercase;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
}
.btn-go:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); }
.btn-go:active:not(:disabled) { transform: translateY(1px); }
.btn-go:disabled { opacity: .55; cursor: not-allowed; }

/* === THREAT CARDS (dossier) === */
.threats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.1rem;
    margin-bottom: 1.5rem;
}
.threat {
    position: relative;
    overflow: hidden;
    transition: box-shadow .2s, border-color .2s;
}
.threat:hover { box-shadow: var(--shadow-hover); border-color: var(--ink-2); }
/* Segni di registro: angolo alto-sinistra oceano, basso-destra segnale */
.threat::before, .threat::after {
    content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
}
.threat::before { left: 5px; top: 5px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.threat::after { right: 5px; bottom: 5px; border-right: 2px solid var(--signal); border-bottom: 2px solid var(--signal); }

.threat.entering { animation: threatIn .45s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes threatIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.threat-head {
    display: flex; align-items: center; gap: .75rem;
    padding: 1rem 1.15rem .85rem 1.3rem;
    border-bottom: 1px dashed var(--rule-2);
}
.threat-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-l);
    border: 1px solid rgba(11, 110, 153, .35);
    color: var(--accent-d);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.15rem;
}
.threat-icon .ico { width: 1.15em; height: 1.15em; }
.threat-title {
    font-family: var(--serif);
    font-size: 1.35rem; line-height: 1.1;
    color: var(--ink); flex: 1; min-width: 0;
}

/* Timbro di livello: bordo tratteggiato, mono, leggermente inclinato */
.threat-badge {
    display: inline-block;
    padding: 3px 9px; border-radius: 2px;
    font-family: var(--mono);
    font-size: .66rem; font-weight: 700;
    letter-spacing: .14em; text-transform: uppercase;
    white-space: nowrap;
    border: 2px dashed currentColor;
    transform: rotate(-3deg);
    flex-shrink: 0;
}
.threat.done .threat-badge { animation: stampIn .28s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes stampIn {
    from { opacity: 0; transform: rotate(-3deg) scale(1.35); }
    to   { opacity: 1; transform: rotate(-3deg) scale(1); }
}
/* Punteggio: cifra mono dentro quadro a filo (colore da classe lvl-*, o inline) */
.threat-score {
    min-width: 38px; height: 38px; padding: 0 6px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono);
    font-size: 1.05rem; font-weight: 700; color: #fff;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.threat-score.lvl-LOW { background: var(--green); }
.threat-score.lvl-MEDIUM { background: var(--amber); }
.threat-score.lvl-HIGH { background: var(--signal); }
.badge-LOW { background: var(--green-l); color: var(--green); }
.badge-MEDIUM { background: var(--amber-l); color: var(--amber); }
.badge-HIGH { background: var(--red-l); color: var(--red); }
.badge-CRITICAL { background: var(--red-l); color: var(--red); }
.badge-ERROR { background: rgba(76, 91, 105, .1); color: var(--slate); }

.threat-body { padding: 1rem 1.3rem 1.3rem; }

.score-row { margin-bottom: .9rem; }
.score-summary {
    font-size: .88rem;
    line-height: 1.65; color: var(--ink-2);
    padding-top: .1rem;
}

/* Articles */
.articles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: .6rem;
}
.articles--orphan > :last-child { grid-column: 1 / -1; }
.article {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--rule-2);
    border-radius: var(--radius-sm);
    padding: .75rem .85rem;
    transition: border-color .15s, background .15s;
}
.article:hover { border-color: var(--accent); border-left-color: var(--accent); background: #fff; }
.article-title {
    font-size: .82rem; font-weight: 600;
    color: var(--ink); margin-bottom: .25rem;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.article-snippet {
    font-size: .76rem;
    color: var(--muted); line-height: 1.5;
    margin-bottom: .3rem;
    display: -webkit-box; -webkit-line-clamp: 3;
    -webkit-box-orient: vertical; overflow: hidden;
}
.article-src {
    position: relative;
    font-family: var(--mono);
    font-size: .66rem; color: var(--accent-d);
    font-weight: 500; word-break: break-all; text-decoration: none;
}
.article-src:hover { text-decoration: underline; }
.article-src::after, .article-toggle::after { content: ""; position: absolute; inset: -14px -6px; }
.article-expand {
    display: none; font-size: .76rem;
    color: var(--muted); line-height: 1.55;
    margin-top: .3rem; padding-top: .3rem;
    border-top: 1px dashed var(--rule-2);
}
.article-expand.open { display: block; }
.article-toggle {
    font-family: var(--mono);
    font-size: .66rem; color: var(--accent-d); font-weight: 600;
    letter-spacing: .04em;
    cursor: pointer; border: none; background: none; padding: 0;
    position: relative;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.article-toggle:hover { color: var(--ink); }

.threat-loading {
    display: flex; align-items: center; justify-content: center;
    gap: .6rem; padding: 1.75rem;
    font-family: var(--mono); letter-spacing: .06em;
    color: var(--muted); font-size: .8rem;
}
.tl-spin {
    width: 18px; height: 18px;
    border: 2px dashed var(--rule-2); border-top: 2px solid var(--signal);
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Actions */
.action-bar {
    display: none; gap: .5rem; flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--rule-2);
}
.action-bar.show { display: flex; }
.abtn, .btn-reset {
    padding: .5rem 1.1rem;
    border: 1px solid var(--ink);
    background: var(--card);
    color: var(--ink); border-radius: var(--radius-sm);
    font-family: var(--mono); font-size: .72rem; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    min-height: 44px;
    cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.abtn:hover, .btn-reset:hover { background: var(--ink); color: #fff; }
.abtn-red { color: var(--signal); border-color: var(--signal); }
.abtn-red:hover { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn-reset--sm { font-size: .68rem; padding: .3rem .85rem; }

.error-box {
    background: var(--signal-l); border: 1px dashed var(--signal);
    border-radius: var(--radius-sm); padding: .9rem;
    color: var(--signal); font-size: .86rem; font-weight: 500; margin-bottom: 1rem;
    display: none;
}

.no-ep {
    padding: 3rem 2rem; text-align: center;
    color: var(--muted); margin-top: 2rem;
    border-style: dashed;
}
.no-ep .ico { color: var(--accent); }

/* === STATS === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .9rem; margin-bottom: 2rem;
}
.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 {
    position: relative;
    padding: 1.2rem .9rem 1.05rem; text-align: left;
    min-width: 0;
    border-top: 3px solid var(--accent);
}
.stat-card:nth-child(3n + 2) { border-top-color: var(--signal); }
.stat-card .ico { color: var(--accent); margin-bottom: .45rem; display: block; width: 1.25rem; height: 1.25rem; }
.stat-val {
    display: block;
    font-family: var(--serif);
    font-size: 2.1rem; line-height: 1.05; font-weight: 400; color: var(--ink);
    white-space: nowrap; font-variant-numeric: tabular-nums;
    overflow: hidden; text-overflow: ellipsis;
}
.stat-label {
    display: block;
    font-family: var(--mono);
    font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted); margin-top: .35rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-label .lbl-short { display: none; }
@media (max-width: 600px) {
    .stat-label .lbl-full { display: none; }
    .stat-label .lbl-short { display: inline; }
}

.chart-box {
    padding: clamp(.75rem, 2vw, 1.15rem) clamp(1rem, 2.5vw, 1.4rem);
    margin-bottom: 1.15rem; overflow: hidden;
}
.chart-box canvas { display: block; max-width: 100%; margin: 0 auto; }
.chart-box--hist { margin-bottom: 1.15rem; }
.chart-box--exec { margin-top: 1.15rem; }
.chart-head {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem;
    padding-bottom: .5rem; border-bottom: 1px solid var(--ink);
}
.chart-head h3 {
    margin: 0; font-family: var(--mono); font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .14em; color: var(--ink);
}
.chart-head > div { display: flex; align-items: center; gap: .5rem; }
#sync-status { color: var(--muted); font-family: var(--mono); font-size: .68rem; }
.tbl-wrap { overflow-x: auto; }
.chart-box h3 { font-size: 1.1rem; margin: 0 0 .6rem; color: var(--ink); }

.stats-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.stats-table th {
    text-align: left;
    font-family: var(--mono); font-size: .64rem; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted); padding: .5rem .65rem;
    border-bottom: 1px solid var(--rule-2);
}
.stats-table td {
    padding: .55rem .65rem;
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
    vertical-align: middle;
}
.stats-table .c-text { text-align: left; }
.stats-table th.c-num, .stats-table td.c-num {
    text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
    font-family: var(--mono); font-size: .76rem;
}
.stats-table .c-nowrap { white-space: nowrap; }
.stats-table .c-strong { font-weight: 600; }
.stats-table .c-small { font-size: .74rem; }
.stats-table--hist th:first-child, .stats-table--hist td:first-child { width: 34%; }
.stats-table--exec th:first-child, .stats-table--exec td:first-child { width: 42%; }
.stats-table--exec th:last-child, .stats-table--exec td:last-child { width: 22%; min-width: 4.5rem; }
.stats-table tr:last-child td { border: none; }
.stats-table tbody tr:hover td { background: var(--accent-l); }

.dl-btn {
    background: var(--card); border: 1px solid var(--ink);
    color: var(--ink); border-radius: var(--radius-sm);
    padding: 2px 8px; font-family: var(--mono); font-size: .68rem; font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s; white-space: nowrap;
}
.dl-btn:hover { color: #fff; background: var(--ink); }

/* === INFO === */
.info-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; margin-bottom: 1.15rem; }
@media (min-width: 900px) {
    .info-grid { grid-template-columns: 1fr 1fr; }
    .info-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.info-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--accent-l); color: var(--accent-d);
    border: 1px dashed var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.info-card {
    padding: 1.3rem 1.35rem 1.15rem;
    position: relative; overflow: hidden;
}
.info-grid .info-card { margin-bottom: 0; }
.info-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .55rem; }
.info-head h3 { margin: 0; }
/* Linguetta del fascicolo */
.info-card::before {
    content: ''; position: absolute;
    left: 1.35rem; top: 0; width: 38px; height: 4px;
    background: var(--signal);
}
.info-card h3 { font-size: 1.35rem; line-height: 1.15; margin-bottom: .5rem; color: var(--ink); }
.info-grid .info-card h3 { font-size: 1.3rem; }
.info-card p { font-size: .88rem; color: var(--ink-2); line-height: 1.65; }
.info-card p + p { margin-top: .4rem; }

.res-links {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: .45rem; margin-top: .8rem;
}
.res-links > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.res-links > a,
.res-links > span {
    display: flex !important; align-items: center; justify-content: center;
    text-align: center; padding: .45rem .9rem; min-height: 44px;
    font-family: var(--mono); font-size: .72rem; border-radius: var(--radius-sm);
    font-weight: 600; letter-spacing: .06em; text-decoration: none;
}
.res-links > a {
    background: var(--card); color: var(--accent-d);
    border: 1px solid var(--accent);
    transition: background .15s, color .15s;
}
.res-links > a:hover { background: var(--accent-d); color: #fff; }
.res-links > span {
    background: var(--recess); color: var(--muted);
    border: 1px dashed var(--rule-2); cursor: not-allowed;
}

/* === AI transparency (banner a una riga: non ingrandire) === */
.ai-notice {
    margin: 1.5rem 0 0;
    border: 1px solid var(--rule-2);
    background: var(--recess); color: var(--ink-2);
    font-weight: 500;
}
.ai-notice .ai-ico { color: var(--signal); }
.ai-notice .ai-notice-link { color: var(--accent-d); }
.ai-notice .ai-notice-link:hover { color: var(--ink); }
.ai-info-card {
    border: 1px solid var(--rule-2); background: var(--card);
    box-shadow: var(--shadow-hover);
}
.ai-info-card h3 { color: var(--ink); }
.ai-info-card > p { color: var(--ink-2); }
.ai-info-card .ai-field { background: #fff; border-color: var(--rule); }
.ai-info-card .ai-field-label { color: var(--muted); }
.ai-info-card .ai-field-value { color: var(--ink); }
.ai-info-card .ai-limits {
    background: var(--accent-l);
    border-color: rgba(11, 110, 153, .3);
    color: var(--ink-2);
}
.ai-info-card .ai-ref-line { color: var(--muted); }
.ai-info-card .ai-limits strong { color: var(--accent-d); }

/* === TESTING CHAT === */
.chat-container { display: none; flex-direction: column; }
.chat-container.show { display: flex; }
#testing-chat { display: none; }
#testing-chat.show { display: flex; }

.ticket-bar {
    padding: .9rem 1.15rem; margin-bottom: .9rem;
    display: flex; align-items: center;
    gap: .9rem; flex-wrap: wrap;
    border-left: 3px solid var(--signal);
}
.ticket-bar .tb-label {
    font-family: var(--mono);
    font-size: .64rem; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted);
}
.ticket-bar .tb-val { font-size: .84rem; color: var(--ink); font-weight: 500; }
.ticket-bar .tb-item { display: flex; flex-direction: column; gap: .1rem; }
.tb-divider { width: 1px; height: 26px; background: var(--rule-2); }

.chat-messages {
    display: flex; flex-direction: column; gap: .7rem;
    padding: .9rem 0; min-height: 110px;
    max-height: 60vh; overflow-y: auto;
}
.msg { display: flex; gap: .55rem; max-width: 90%; }
.msg-agent { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; flex-shrink: 0;
    background: var(--accent-l); color: var(--accent-d);
    border: 1px solid rgba(11, 110, 153, .35);
}
.msg-user .msg-avatar { background: var(--ink); color: #fff; border-color: var(--ink); }
.msg-bubble {
    padding: .65rem 1rem; border-radius: var(--radius-sm);
    font-size: .84rem; line-height: 1.6;
    background: var(--card); border: 1px solid var(--rule-2);
    color: var(--ink); box-shadow: var(--shadow);
}
.msg-user .msg-bubble { background: var(--accent-d); border-color: var(--accent-d); color: #fff; }
.msg-bubble pre {
    margin: 0; white-space: pre-wrap; word-break: break-all;
    font-size: .75rem; font-family: var(--mono);
}
.msg-meta { font-family: var(--mono); font-size: .64rem; color: var(--ink); margin-top: .2rem; padding: 0 .35rem; }
.msg-phase {
    display: inline-block;
    font-family: var(--mono); font-size: .62rem; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 2px;
    margin-bottom: .4rem;
    background: var(--accent-l); color: var(--accent-d);
    border: 1px dashed currentColor;
}
.phase-retrieve { background: var(--green-l); color: var(--green); }
.phase-escalated { background: var(--red-l); color: var(--red); }
.phase-done { background: var(--green-l); color: var(--green); }

.radio-lbl {
    display: inline-flex; align-items: center; gap: .5rem;
    min-height: 44px; padding-right: .5rem;
    color: var(--ink); font-size: .84rem; cursor: pointer;
}
.radio-lbl input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--accent-d); }

/* === REVEAL === */
.reveal {
    opacity: 0; transform: translateY(20px);
    transition: opacity .55s cubic-bezier(.16, 1, .3, 1), transform .55s cubic-bezier(.16, 1, .3, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-stagger > *:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > *:nth-child(2) { transition-delay: .06s; }
.reveal-stagger > *:nth-child(3) { transition-delay: .12s; }
.reveal-stagger > *:nth-child(4) { transition-delay: .18s; }
.reveal-stagger > *:nth-child(5) { transition-delay: .24s; }

/* === Torna in alto (iniettato da animations.js) === */
#to-top {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 300;
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--card); border: 1px solid var(--ink); color: var(--ink);
    cursor: pointer; box-shadow: var(--shadow-hover);
    opacity: 0; transform: translateY(10px); pointer-events: none;
    transition: opacity .2s, transform .2s, color .15s, background .15s;
}
#to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
#to-top:hover { background: var(--ink); color: #fff; }

/* Icone SVG inline (sostituiscono Font Awesome, bloccato dal CSP) */
.ico { width: 1em; height: 1em; vertical-align: -0.125em; flex-shrink: 0; }
.ico-2x { width: 2em; height: 2em; }
.ico-3x { width: 3em; height: 3em; }

/* === FOCUS === */
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.tab-link:focus-visible, .btn-go:focus-visible, .abtn:focus-visible, .btn-reset:focus-visible,
.dl-btn:focus-visible, .res-links a:focus-visible, .article-src:focus-visible,
.article-toggle:focus-visible, .back-arrow:focus-visible, .logo:focus-visible,
.radio-lbl:focus-within, #to-top:focus-visible {
    outline: 2px solid var(--accent-d); outline-offset: 2px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    :root { --hdr-h: 56px; }
    .form-card, .st-search { padding: 1.15rem; }

    .st-hero { margin-top: 1.5rem; }
    .st-hero .lead { font-size: .88rem; }
    .st-search { margin-top: 1.25rem; margin-bottom: 1.25rem; }

    .form-row { grid-template-columns: repeat(2, 1fr); }
    .form-row .field:nth-child(3) { grid-column: 1 / -1; }
    .form-row--2 { grid-template-columns: 1fr; }

    .threats { grid-template-columns: 1fr; }
    .articles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid.stat-grid--reduced { grid-template-columns: 1fr 1fr; }
    .info-grid { grid-template-columns: 1fr; }

    .hdr-title { display: none; }
    .logo { font-size: 1.45rem; }

    .tabs-bar {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs-bar::-webkit-scrollbar { display: none; }

    .content { padding: 0 1rem 2rem; }

    .ticket-bar { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .tb-divider { display: none; }
    .msg { max-width: 95%; }
}

@media (max-width: 480px) {
    :root { --hdr-h: 52px; }
    header { padding: 0 .75rem; }
    .logo { font-size: 1.3rem; }
    .badge-st { font-size: .58rem; padding: 2px 6px; letter-spacing: .08em; }

    .tabs-bar { padding: 0 .5rem; }
    .tab-link { padding: .65rem .8rem; font-size: .68rem; letter-spacing: .06em; }

    .content { padding: 0 .75rem 1.5rem; }

    .st-hero { margin-top: 1rem; padding-top: 1rem; }
    .st-hero h1 { font-size: 2rem; }
    .st-hero .lead { font-size: .84rem; }

    .st-search { padding: 1rem; margin-top: 1rem; margin-bottom: 1rem; }
    .st-search h2 { font-size: 1.35rem; }
    .form-card { padding: 1rem; }

    .form-row { grid-template-columns: 1fr; }
    .form-row .field:nth-child(3) { grid-column: auto; }

    .threat-head { padding: .85rem .9rem .75rem 1.1rem; gap: .55rem; }
    .threat-icon { width: 36px; height: 36px; }
    .threat-title { font-size: 1.15rem; }
    .threat-body { padding: .8rem .9rem 1rem 1.1rem; }
    .score-summary { font-size: .84rem; }

    .articles { grid-template-columns: 1fr; }

    .stat-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
    .stat-card { padding: .9rem .7rem; }
    .stat-val { font-size: 1.7rem; }

    .abtn { font-size: .68rem; }
    .stats-table td, .stats-table th { padding-left: .45rem; padding-right: .45rem; }
    .chart-box { padding: .7rem .75rem; }

    .res-links { grid-template-columns: 1fr; }
    .res-links > :last-child:nth-child(odd) { grid-column: auto; }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .st-hero, .st-search, .threat.entering, .threat.done .threat-badge { animation: none; }
    .tl-spin { animation: none; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .logo, .logo span, .tab-link, .btn-go, .abtn, .btn-reset, .field input, .field select,
    .field textarea, .back-arrow, .article, #to-top, .res-links > a, .dl-btn, .threat { transition: none; }
}
