:root {
    /* Brand rosso */
    --primary-color: #C8102E;
    --primary-dark:  #8B0A20;
    --primary-light: #E63946;
    --primary-soft:  #fdecef;

    /* Neutri puri (nessun tono di blu) */
    --dark-surface: #222222;
    --anthracite:   #1a1a1a;
    --anthracite-2: #141414;
    --text-dark:    #1c1c1c;
    --text-muted:   #6b6b6b;
    --border-color: #e5e5e5;

    /* Sfondi pagine */
    --bg-page:   #f7f7f7;
    --bg-subtle: #f0f0f0;

    /* Override variabili Bootstrap */
    --bs-primary: #C8102E;
    --bs-primary-rgb: 200, 16, 46;
    --bs-dark: #1a1a1a;
    --bs-light: #f7f7f7;
}

html, body {
    min-height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Arial Narrow", Arial, sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-page);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(200, 16, 46, 0.04), transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(26, 26, 26, 0.05), transparent 45%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

body.bg-light,
.bg-light { background-color: var(--bg-page) !important; }

/* ============================================================
   OVERRIDE BOOTSTRAP — rimozione toni blu
   ============================================================ */
.bg-dark      { background-color: var(--anthracite) !important; }
.bg-secondary { background-color: #6b6b6b !important; }
.bg-info      { background-color: #d4d4d4 !important; }
.bg-primary   { background-color: var(--primary-color) !important; }
.text-primary { color: var(--primary-color) !important; }
.text-secondary { color: #6b6b6b !important; }

/* ============================================================
   CARD E CONTENITORI
   ============================================================ */
.card {
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    background-color: #ffffff;
}

.card-hover:hover,
.hover-shadow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ============================================================
   PULSANTI E FORM
   ============================================================ */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.btn-link { color: var(--primary-color); }

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #858686;
    padding: 0.6rem 0.85rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}

/* ============================================================
   BADGE
   ============================================================ */
.badge {
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.4em 0.7em;
}
.badge.bg-primary,
.badge.text-bg-primary { background-color: var(--primary-color) !important; }

/* ============================================================
   DASHBOARD — STATISTICHE
   ============================================================ */
.stat-card { border-left: 4px solid var(--primary-color); }
.stat-icon {
    width: 48px; height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

/* ============================================================
   TABELLE
   ============================================================ */
.table th {
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background-color: #f7f7f7;
    border-bottom: 2px solid #e5e5e5;
}
.table td { vertical-align: middle; }

/* ============================================================
   UPLOAD DRAG & DROP
   ============================================================ */
.upload-dropzone {
    border: 2px dashed #cfcfcf;
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}
.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--primary-color);
    background-color: var(--primary-soft);
}

/* ============================================================
   LIVE SERVER NOTICE
   ============================================================ */
.live-server-notice {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #f59e0b;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    color: #92400e;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.nav-item { font-family: Arial, sans-serif; }
.spaced-logo { letter-spacing: 0.1em; }
.nav-link.active,
.nav-link:hover { color: var(--primary-color) !important; }

/* ============================================================
   HERO — LANDING PAGE (full-screen + particelle)
   ============================================================ */
.hero {
    position: relative;
    margin-top: 0;
    padding-top: 0;
    /* Altezza = viewport meno navbar. Fallback 64px se JS non gira. */
    min-height: calc(100vh - var(--navbar-height, 64px));
    display: flex;
    align-items: center;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(120deg, #141414 0%, #222222 45%, #2b1a1f 100%);
}

#hero-particles {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    display: block;
    z-index: 1;
    pointer-events: none;
}

.hero-glow {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 45%, rgba(200, 16, 46, 0.28), transparent 55%),
        radial-gradient(circle at 85% 80%, rgba(200, 16, 46, 0.15), transparent 50%);
}

.hero-content { position: relative; z-index: 3; }

.hero-tag {
    display: inline-block;
    font-size: .8rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #fff;
    border-left: 3px solid var(--primary-color);
    padding-left: .75rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.hero h1 {
    font-weight: 800;
    font-size: clamp(2rem, 4.2vw, 3.5rem);
    line-height: 1.1;
    margin-bottom: 1.25rem;
}
.hero h1 .text-red { color: var(--primary-light); }

.hero p.lead {
    color: #d8d8d8;
    font-size: 1.125rem;
    max-width: 620px;
}

.btn-hero-primary {
    background-color: var(--primary-color);
    border: 2px solid var(--primary-color);
    color: #fff;
    font-weight: 600;
    padding: .8rem 1.75rem;
    border-radius: 8px;
    transition: all .25s ease;
}
.btn-hero-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    transform: translateY(-2px);
}

.btn-hero-outline {
    background: transparent;
    border: 2px solid #fff;
    color: #fff;
    font-weight: 600;
    padding: .8rem 1.75rem;
    border-radius: 8px;
    transition: all .25s ease;
}
.btn-hero-outline:hover {
    background: #fff;
    color: var(--anthracite);
}

/* ============================================================
   HERO-INNER — pagine interne (Acustica, Sicurezza, ecc.)
   Attaccata all'header, full-width, altezza contenuta
   ============================================================ */
.hero-inner {
    position: relative;
    margin-top: 0;
    padding: 3.5rem 0 3rem;
    color: #fff;
    overflow: hidden;
    background: linear-gradient(120deg, #141414 0%, #222222 55%, #2b1a1f 100%);
}

/* Bagliore rosso decorativo in basso a destra */
.hero-inner::after {
    content: "";
    position: absolute;
    right: -120px;
    bottom: -180px;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(200, 16, 46, 0.30) 0%, transparent 65%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Sottile riga diagonale in alto a sinistra, decorativa */
.hero-inner::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 140px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color) 0%, transparent 100%);
    z-index: 2;
}

.hero-inner .container {
    position: relative;
    z-index: 3;
}

.hero-inner h1 {
    font-weight: 800;
    font-size: clamp(1.8rem, 3.4vw, 2.75rem);
    line-height: 1.15;
    margin: 0 0 .75rem;
}

.hero-inner p.hero-inner-sub {
    color: #cfcfcf;
    font-size: 1.05rem;
    max-width: 720px;
    margin: 0;
}

/* Breadcrumb scuro integrato nella hero-inner */
.breadcrumb-dark {
    --bs-breadcrumb-divider-color: rgba(255, 255, 255, 0.45);
    margin-bottom: 1.25rem;
    font-size: .875rem;
}
.breadcrumb-dark .breadcrumb-item,
.breadcrumb-dark .breadcrumb-item a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: color .2s ease;
}
.breadcrumb-dark .breadcrumb-item a:hover {
    color: var(--primary-light);
}
.breadcrumb-dark .breadcrumb-item.active {
    color: #ffffff;
    font-weight: 600;
}
.breadcrumb-dark .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.45);
}

/* ============================================================
   SEZIONI STANDARD
   ============================================================ */
.section { padding: 5rem 0; }
.section-sm { padding: 3.5rem 0; }

.section-tag {
    font-size: .8rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--primary-color);
    font-weight: 700;
    display: inline-block;
    margin-bottom: .75rem;
}

.section-title {
    font-weight: 800;
    color: var(--text-dark);
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    margin-bottom: .75rem;
}

.section-subtitle {
    color: var(--text-muted);
    max-width: 720px;
    margin: 0 auto 3rem;
}

/* Titolo di gruppo servizi con linea rossa */
.group-title {
    font-weight: 700;
    color: var(--text-dark);
    font-size: clamp(1.35rem, 2.2vw, 1.75rem);
    margin-bottom: .5rem;
    position: relative;
    padding-left: 1rem;
}
.group-title::before {
    content: "";
    position: absolute;
    left: 0; top: .2em;
    width: 4px; height: 1em;
    background: var(--primary-color);
    border-radius: 2px;
}

.group-subtitle {
    color: var(--text-muted);
    font-size: .95rem;
    margin-left: 1rem;
    margin-bottom: 2.5rem;
}

/* ============================================================
   SERVICE CARD V2 — accordion in place (pagine interne)
   ============================================================ */
.service-card-v2 {
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all .25s ease;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.service-card-v2:hover {
    border-left-color: var(--primary-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.07);
    transform: translateY(-2px);
}

/* Card aperta (aria-expanded settato da Bootstrap sul toggler) */
.service-card-v2[aria-expanded="true"] {
    border-left-color: var(--primary-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.09);
    background: #ffffff;
}

.service-card-v2 .card-body {
    padding: 1.5rem 1.5rem 1.25rem;
}

.service-card-v2 .service-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}

.service-card-v2 h5 {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1.05rem;
    margin: 0 0 .5rem;
    line-height: 1.3;
}

.service-card-v2 .service-card-desc {
    color: var(--text-muted);
    font-size: .925rem;
    margin: 0;
}

/* Icona contenitore */
.service-card-v2 .service-icon-v2 {
    width: 52px; height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Varianti colore icona */
.service-icon-v2.icon-red {
    background: var(--primary-soft);
    color: var(--primary-color);
}
.service-icon-v2.icon-dark {
    background: #ededed;
    color: var(--anthracite);
}

/* Freccia indicator aperto/chiuso */
.service-card-arrow {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: #f0f0f0;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    flex-shrink: 0;
    transition: all .3s ease;
    margin-top: .25rem;
}
.service-card-v2[aria-expanded="true"] .service-card-arrow {
    background: var(--primary-color);
    color: #fff;
    transform: rotate(180deg);
}

/* Contenuto espanso */
.service-card-v2 .service-card-details {
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.6;
    border-top: 1px solid #f0f0f0;
    padding-top: 1rem;
}
.service-card-v2 .service-card-details p:last-child { margin-bottom: 0; }

/* ============================================================
   LOGIN AREA RISERVATA
   ============================================================ */
.login-section {
    background: var(--dark-surface);
    color: #fff;
    padding: 5rem 0;
    position: relative;
    overflow: hidden;
}
.login-section::after {
    content: "";
    position: absolute;
    right: -120px; top: -120px;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(200,16,46,.35) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    color: var(--text-dark);
    box-shadow: 0 20px 50px rgba(0,0,0,.4);
    position: relative;
    z-index: 2;
}
.login-lock-icon {
    width: 60px; height: 60px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 1rem;
}
.login-features li { margin-bottom: .75rem; color: #d4d4d4; }
.login-features i { color: var(--primary-light); margin-right: .5rem; }

/* ============================================================
   CTA BANNER
   ============================================================ */
.cta-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: 12px;
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
}
.cta-banner::after {
    content: "";
    position: absolute;
    right: -80px; bottom: -120px;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(255,255,255,.12) 0%, transparent 65%);
    border-radius: 50%;
    pointer-events: none;
}
.cta-banner h3 { font-weight: 800; position: relative; z-index: 1; }
.cta-banner p  { position: relative; z-index: 1; }

/* Variante scura del CTA (per fondo pagina servizi) */
.cta-banner-dark {
    background: linear-gradient(135deg, #1a1a1a 0%, #222222 100%);
    border-left: 4px solid var(--primary-color);
}
.cta-banner-dark::after {
    background: radial-gradient(circle, rgba(200,16,46,.25) 0%, transparent 65%);
}

/* ============================================================
   SEZIONE CONTATTI (landing) — form su sfondo chiaro
   ============================================================ */
.contact-form .form-control,
.contact-form .form-select {
    border-radius: 8px;
    padding: .75rem .9rem;
    border: 1px solid var(--border-color);
}
.contact-form .form-control:focus,
.contact-form .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}
.contact-form .form-label {
    font-weight: 600;
    font-size: .875rem;
}

/* ============================================================
   SEZIONE SERVIZI (landing) — card con barra rossa a sinistra
   ============================================================ */
.service-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem 1.75rem;
    height: 100%;
    transition: all .3s ease;
    background: #fff;
    position: relative;
    overflow: hidden;
}
.service-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 0;
    background: var(--primary-color);
    transition: height .3s ease;
}
.service-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 35px rgba(0,0,0,.08);
    border-color: transparent;
}
.service-card:hover::before { height: 100%; }

.service-icon {
    width: 56px; height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary-color);
    border-radius: 10px;
    font-size: 1.6rem;
    margin-bottom: 1.25rem;
}
.service-card h5 { color: var(--text-dark); font-weight: 700; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background-color: var(--anthracite);
    color: #b8b8b8;
    border-top: 1px solid #2a2a2a;
    margin-top: 0;
}
.site-footer strong { color: #e5e5e5; font-weight: 600; }
.footer-link {
    color: #b8b8b8;
    text-decoration: none;
    transition: color .2s ease;
}
.footer-link:hover { color: var(--primary-light); }
.footer-sep { color: #4a4a4a; margin: 0 .35rem; }

/* ============================================================
   UTILITY
   ============================================================ */
.no-scroll-x { overflow-x: hidden; }
.text-red { color: var(--primary-color) !important; }
.border-red { border-color: var(--primary-color) !important; }

/* ============================================================
   TOC — Indice di navigazione interno alle pagine
   ============================================================ */
.toc-nav {
    position: sticky;
    top: var(--navbar-height, 56px);
    z-index: 1020;
    background-color: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    padding: 0.75rem 0;
    margin-bottom: 0;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.toc-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background-color: #fff;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toc-list a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(200, 16, 46, 0.1);
}

.toc-list a i {
    font-size: 0.95rem;
}

/* Mobile: pills scrollabili orizzontalmente */
@media (max-width: 767.98px) {
    .toc-nav {
        padding: 0.5rem 0;
    }
    .toc-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 0.4rem;
        scrollbar-width: thin;
    }
    .toc-list::-webkit-scrollbar {
        height: 3px;
    }
    .toc-list::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    .toc-list a {
        font-size: 0.8rem;
        padding: 0.35rem 0.8rem;
    }
    .toc-list a i {
        font-size: 0.85rem;
    }
}

/* Smooth scroll per le ancore */
html {
    scroll-behavior: smooth;
}

/* Offset ancore: evita che le sezioni finiscano sotto navbar + pills */
section[id] {
    scroll-margin-top: calc(var(--navbar-height, 56px) + 70px);
}

/* ============================================================
   Navbar sopra le pills TOC
   Il dropdown della navbar deve stare sopra il .toc-nav (z-index 1020)
   ============================================================ */
.navbar.sticky-top {
    z-index: 1050;
}

.navbar .dropdown-menu {
    z-index: 1060;
}

/* Evidenziazione del testo cercato nei risultati */
mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 0 .2em;
    border-radius: 3px;
}

/* ============================================================
   Evidenziazione evento agenda dopo ricerca
   ============================================================ */
.evento-highlight {
    animation: evento-pulse 2.4s ease-out;
}

@keyframes evento-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.7);
        background-color: #fff3cd !important;
    }
    40% {
        box-shadow: 0 0 0 8px rgba(200, 16, 46, 0);
        background-color: #fff3cd !important;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(200, 16, 46, 0);
    }
}

/* ============================================================
   BREADCRUMB — stile brand (rosso)
   Esclude .breadcrumb-dark (usato nelle hero-inner, già bianco)
   ============================================================ */
.breadcrumb:not(.breadcrumb-dark) {
    --bs-breadcrumb-divider-color: #b0b0b0;
    margin-bottom: 0;
    padding: 0.5rem 0;
}

.breadcrumb:not(.breadcrumb-dark) .breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color .2s ease;
}

.breadcrumb:not(.breadcrumb-dark) .breadcrumb-item a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb:not(.breadcrumb-dark) .breadcrumb-item.active {
    color: var(--text-dark);
    font-weight: 600;
}

.breadcrumb:not(.breadcrumb-dark) .breadcrumb-item + .breadcrumb-item::before {
    color: #b0b0b0;
}

/* ============================================================
   AGENDA — COLORI EVENTI
   ============================================================
   Chiavi semantiche (migrazione 003, colonna eventi_agenda.colore).
   Ogni chiave ha:
     - .evento-colore-X : riquadro in agenda (sfondo tenue + bordo saturo)
     - .evento-bordo-X  : bordo sinistro per le dashboard ("Prossimi 7 giorni")
   Palette: sfondo chiaro, bordo scuro. Testo sempre scuro (leggibilità).
   ============================================================ */

.evento-colore-grigio   { background-color: #f0f0f0; border-color: #9a9a9a !important; }
.evento-colore-rosso    { background-color: #fdecef; border-color: #C8102E !important; }
.evento-colore-giallo   { background-color: #fff8e1; border-color: #d4a017 !important; }
.evento-colore-verde    { background-color: #e8f5e9; border-color: #2e7d32 !important; }
.evento-colore-blu      { background-color: #e3f2fd; border-color: #1565c0 !important; }
.evento-colore-viola    { background-color: #f3e5f5; border-color: #7b1fa2 !important; }
.evento-colore-arancio  { background-color: #fff3e0; border-color: #e65100 !important; }

.evento-bordo-grigio   { border-left: 4px solid #9a9a9a !important; }
.evento-bordo-rosso    { border-left: 4px solid #C8102E !important; }
.evento-bordo-giallo   { border-left: 4px solid #d4a017 !important; }
.evento-bordo-verde    { border-left: 4px solid #2e7d32 !important; }
.evento-bordo-blu      { border-left: 4px solid #1565c0 !important; }
.evento-bordo-viola    { border-left: 4px solid #7b1fa2 !important; }
.evento-bordo-arancio  { border-left: 4px solid #e65100 !important; }