/* ============================================================
    NEXUS DESIGN SYSTEM - EUROP SYS
    Console NOC/SOC chiara in stile mission-control: angoli quasi
    squadrati, indicatori di stato a "spia" (pallino colorato) invece
    di pillole decorative, letture numeriche in monospace tabulare,
    colore riservato esclusivamente agli stati (rosso/ambra/verde).
   ============================================================ */

/* 1. TOKEN ---------------------------------------------------- */
:root {
    --nexus-bg: #f8fafc;
    --nexus-surface: #ffffff;
    --nexus-surface-2: #f1f5f9;
    --nexus-surface-3: #e2e8f0;
    --nexus-border: #e2e8f0;
    --nexus-border-strong: #cbd5e1;

    --nexus-text: #1e293b;
    --nexus-text-secondary: #475569;
    --nexus-text-muted: #64748b;

    /* Palette istituzionale EuropSYS (blu/ardesia) */
    --nexus-blue: #2563eb;            /* Blu Azione — bottoni e link */
    --nexus-blue-strong: #1e40af;     /* Blu Istituzionale — hover / accento forte */
    --nexus-blue-tint: rgba(37, 99, 235, 0.08);
    --nexus-blue-corporate: #1e3a8a;  /* Blu Corporate — primario scuro */
    --nexus-blue-highlight: #3b82f6;  /* Azzurro Highlight */
    --nexus-green: #1a7f37;
    --nexus-green-tint: rgba(26, 127, 55, 0.10);
    --nexus-red: #c92a2a;
    --nexus-red-tint: rgba(201, 42, 42, 0.10);
    --nexus-amber: #9a6700;
    --nexus-amber-tint: rgba(154, 103, 0, 0.12);

    --nexus-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --nexus-font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;

    --nexus-radius-sm: 2px;
    --nexus-radius: 3px;
    --nexus-radius-lg: 4px;

    --nexus-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --nexus-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.10);
    --nexus-shadow-lg: 0 4px 6px rgba(16, 24, 40, 0.05), 0 12px 24px rgba(16, 24, 40, 0.12);

    --nexus-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 1b. COMPATIBILITÀ LAYOUT BOOTSTRAP -----------------------------------------
   Scoperta di sistema: nessuna pagina carica il CSS di Bootstrap (solo il
   bundle JS, per i componenti Modal). Ogni schermata dell'app però usa da
   sempre la nomenclatura di classe di Bootstrap per il layout (d-flex, row/
   col-md-*, align-items-*, justify-content-*, form-check/form-switch...),
   dando per scontato che facesse qualcosa. Non ha MAI funzionato: gli header
   "flex" sono sempre stati normali blocchi impilati verticalmente, e le
   griglie a due colonne nei modal di modifica sono sempre state impilate a
   piena larghezza. Definiamo qui il sottoinsieme di Bootstrap 5 realmente
   usato nel markup, invece di caricare l'intero framework (rischio di
   conflitto con .table/.modal/.btn già personalizzati). */
.d-flex        { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block       { display: block !important; }
.d-inline      { display: inline !important; }
.d-inline-block{ display: inline-block !important; }
.d-none        { display: none !important; }

.align-items-center { align-items: center !important; }
.align-items-start  { align-items: flex-start !important; }
.align-items-end    { align-items: flex-end !important; }

.justify-content-between { justify-content: space-between !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-start   { justify-content: flex-start !important; }
.justify-content-end     { justify-content: flex-end !important; }

.flex-column   { flex-direction: column !important; }
.flex-row      { flex-direction: row !important; }
.flex-fill     { flex: 1 1 auto !important; }
.flex-grow-0   { flex-grow: 0 !important; }
.flex-grow-1   { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-shrink-1 { flex-shrink: 1 !important; }

.fw-bold   { font-weight: 700 !important; }
.fw-normal { font-weight: 400 !important; }
.fw-light  { font-weight: 300 !important; }
.fst-italic { font-style: italic !important; }

/* Griglia 12 colonne (matematica identica a Bootstrap 5: gutter 24px,
   breakpoint md a 768px — sotto quella soglia ogni colonna impila a 100%). */
.row {
    display: flex !important;
    flex-wrap: wrap;
    margin-right: -12px;
    margin-left: -12px;
}
.row > [class*="col-"] {
    padding-right: 12px;
    padding-left: 12px;
    flex: 0 0 auto;
}
/* Larghezza base (mobile) su selettore semplice, cosi' l'override nella
   media query sotto (stessa specificity, ma dopo nel foglio) vince a >=768px. */
.col-12, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-12 {
    width: 100%;
}
@media (min-width: 768px) {
    .col-md-4  { width: 33.333333%; }
    .col-md-5  { width: 41.666667%; }
    .col-md-6  { width: 50%; }
    .col-md-7  { width: 58.333333%; }
    .col-md-8  { width: 66.666667%; }
    .col-md-12 { width: 100%; }
}

/* Toggle "form-switch": ovunque nel markup usato insieme a .custom-nexus-check,
   lo facciamo apparire identico allo switch iOS già definito altrove (§11)
   invece di replicare lo switch nativo di Bootstrap. */
.form-check.custom-nexus-check {
    display: flex;
    align-items: center;
    background: var(--nexus-surface-2);
    padding: 9px 12px;
    border: 1px solid var(--nexus-border);
    border-radius: var(--nexus-radius-sm);
    margin-top: 4px;
    min-height: 0;
    padding-left: 12px;
}
.form-check.custom-nexus-check label {
    cursor: pointer;
}
.form-check.custom-nexus-check .form-check-input {
    appearance: none;
    position: relative;
    width: 38px;
    height: 22px;
    margin: 0 10px 0 0;
    float: none;
    background: var(--nexus-surface-3);
    border: 1px solid var(--nexus-border);
    border-radius: 99px;
    cursor: pointer;
    transition: background-color 0.2s var(--nexus-ease);
}
.form-check.custom-nexus-check .form-check-input::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25);
    transition: transform 0.2s var(--nexus-ease);
}
.form-check.custom-nexus-check .form-check-input:checked {
    background: var(--nexus-green);
    border-color: var(--nexus-green);
}
.form-check.custom-nexus-check .form-check-input:checked::before {
    transform: translateX(16px);
}

/* 2. LAYOUT & SUPERFICI ----------------------------------------- */
.nexus-wrapper {
    background: transparent;
    width: 100%;
}

.nexus-card {
    background: var(--nexus-surface) !important;
    border: 1px solid var(--nexus-border) !important;
    border-radius: var(--nexus-radius-lg);
    box-shadow: var(--nexus-shadow-sm);
    overflow: hidden;
}

.nexus-hidden {
    display: none !important;
}

/* 3. HEADER & AZIONI ---------------------------------------------- */
.nexus-header-row {
    border-bottom: 1px solid var(--nexus-border) !important;
    padding-bottom: 16px !important;
}

.nexus-page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--nexus-text);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0 0 3px;
    white-space: nowrap;
}

/* Cornice quadrata attorno all'icona, stile pannello di controllo:
   nessuna modifica all'HTML richiesta, si applica a qualunque <i> dentro
   il titolo pagina. */
.nexus-page-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    background: var(--nexus-surface-2);
    border: 1px solid var(--nexus-border);
    border-radius: var(--nexus-radius-sm);
    font-size: 12px;
    color: var(--nexus-blue);
    margin: 0 !important;
}

.nexus-page-subtitle {
    display: block;
    color: var(--nexus-text-muted);
    font-size: 11.5px;
    letter-spacing: 0.2px;
    margin: 0;
}

.nexus-header-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
}

/* 4. INPUT & RICERCA ------------------------------------------------ */
.nexus-search, .nexus-search-lock {
    display: block !important;
    background: var(--nexus-surface) !important;
    border: 1px solid var(--nexus-border) !important;
    color: var(--nexus-text) !important;
    font-size: 13px !important;
    font-family: var(--nexus-font);
    border-radius: var(--nexus-radius-sm) !important;
    transition: border-color 0.15s var(--nexus-ease), box-shadow 0.15s var(--nexus-ease) !important;
}

.nexus-search {
    padding: 0 12px 0 34px !important;
    height: 34px !important;
    width: 100% !important;
}

.nexus-search-wrap {
    position: relative;
    width: 300px;
    display: flex;
    align-items: center;
    transition: width 0.25s var(--nexus-ease);
}

.nexus-search-wrap:focus-within {
    width: 420px;
}

.nexus-search-wrap .nexus-search-icon {
    position: absolute;
    left: 12px;
    font-size: 12px;
    color: var(--nexus-text-muted);
    z-index: 10;
    pointer-events: none;
    transition: color 0.2s var(--nexus-ease);
}

.nexus-search-wrap:focus-within .nexus-search-icon {
    color: var(--nexus-blue);
}

.nexus-search:focus, .nexus-search-lock:focus {
    outline: none;
    border-color: var(--nexus-blue) !important;
    box-shadow: 0 0 0 3px var(--nexus-blue-tint) !important;
}

.nexus-search:hover:not(:focus) {
    border-color: var(--nexus-border-strong) !important;
}

/* :not(textarea) invece di un semplice override: il ridimensionamento nativo
   funziona impostando un'altezza INLINE sull'elemento mentre lo trascini, e
   un height: ... !important nel foglio di stile la batte SEMPRE — comparirebbe
   la maniglia (perché resize:vertical è attivo) ma trascinarla non farebbe
   nulla, esattamente il sintomo segnalato. Le textarea vanno quindi escluse
   del tutto da questa regola, non solo sovrascritte. */
.nexus-search-lock:not(textarea) {
    width: 100% !important;
    height: 32px !important;
    padding: 0 11px !important;
}

textarea.nexus-search-lock {
    width: 100% !important;
    min-height: 76px;
    padding: 9px 11px !important;
    line-height: 1.5;
    resize: vertical;
}

/* Fix per Select (rimozione freccia di sistema, icona personalizzata) */
select.nexus-search-lock {
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238a94a0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.7rem center !important;
    background-size: 12px 9px !important;
    padding-right: 2.2rem !important;
}

.nexus-label-lock {
    display: block !important;
    width: 100% !important;
    color: var(--nexus-text-secondary);
    font-family: var(--nexus-font);
    font-size: 11.5px;
    font-weight: 600;
    margin-bottom: 5px !important;
    pointer-events: none;
}

/* 5. TABELLE ----------------------------------------------------------- */
.nexus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.nexus-table th {
    padding: 8px 14px;
    text-transform: uppercase;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--nexus-text-muted);
    border-bottom: 1px solid var(--nexus-border);
    background: var(--nexus-surface-2);
}

.nexus-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--nexus-border);
    color: var(--nexus-text);
    vertical-align: middle;
}

.nexus-table tbody tr:last-child td {
    border-bottom: none;
}

.nexus-table tbody tr:hover {
    background: var(--nexus-surface-2);
}

/* 5b. TIPOGRAFIA DI CELLA -------------------------------------------------
   Pattern ricorrente in ogni tabella: un valore primario in grassetto +
   una o più righe secondarie (meta) più piccole e attenuate sotto.
   Sostituisce i vari style="font-size: 10-13px" sparsi per-pagina. */
.nexus-cell-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--nexus-text);
}

.nexus-cell-title i {
    color: var(--nexus-text-muted);
    font-size: 11px;
}

.nexus-cell-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    font-size: 11px;
    color: var(--nexus-text-muted);
    font-family: var(--nexus-font-mono);
}

.nexus-cell-meta.truncate {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.nexus-cell-body {
    font-size: 13px;
    color: var(--nexus-text);
}

.nexus-cell-body + .nexus-cell-meta {
    margin-top: 2px;
}

/* 6. BOTTONI ------------------------------------------------------------- */
.btn-europsys {
    background: var(--nexus-blue) !important;
    color: #ffffff !important;
    border: 1px solid var(--nexus-blue) !important;
    font-family: var(--nexus-font);
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    padding: 0 14px !important;
    height: 32px !important;
    border-radius: var(--nexus-radius-sm) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
    transition: background-color 0.15s var(--nexus-ease), border-color 0.15s var(--nexus-ease) !important;
    white-space: nowrap;
}

.btn-europsys:hover {
    background: var(--nexus-blue-strong) !important;
    border-color: var(--nexus-blue-strong) !important;
    box-shadow: none !important;
}

/* Variante per azioni "positive" non distruttive (sync, esporta, ecc.),
   sostituisce lo style inline background/border-color ripetuto ad-hoc. */
.btn-europsys-success {
    background: var(--nexus-green) !important;
    border-color: var(--nexus-green) !important;
}
.btn-europsys-success:hover {
    filter: brightness(0.92);
}

/* Icona dentro un campo di input di un form (diverso da .nexus-search-wrap,
   pensato per la barra di ricerca in testata): stesso principio, contesto
   diverso. */
.nexus-input-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.nexus-input-icon-wrap .nexus-input-icon {
    position: absolute;
    left: 12px;
    font-size: 11px;
    color: var(--nexus-text-muted);
    z-index: 10;
    pointer-events: none;
}
.nexus-input-icon-wrap input {
    padding-left: 32px !important;
}

/* Blocco di codice/payload grezzo (JSON, hash, log): usato nei dettagli
   di sola lettura (audit trail, ecc.) al posto dello style inline ripetuto. */
.nexus-code-block {
    font-family: var(--nexus-font-mono);
    font-size: 11px;
    color: var(--nexus-text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--nexus-surface-2);
    border-radius: var(--nexus-radius-sm);
    max-height: 200px;
    overflow-y: auto;
}

.nexus-hash-text {
    font-family: var(--nexus-font-mono);
    font-size: 10px;
    color: var(--nexus-text-muted);
    word-break: break-all;
}

/* Riga "nessun dato" nelle tabelle (celle vuote/liste filtrate a zero
   risultati), sostituisce lo style inline font-size ripetuto ad-hoc. */
.nexus-empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--nexus-text-muted);
    font-family: var(--nexus-font-mono);
    text-transform: uppercase;
    font-size: 11px;
}
.nexus-empty-state i {
    font-size: 20px;
}

/* Select compatto inline in riga di tabella (es. revisione rapida esito),
   diverso dal campo form a piena larghezza .nexus-search-lock.w-100. */
.nexus-select-compact {
    width: auto !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
}

/* Callout tratteggiato per contesto/avvisi inline nei form (vault path,
   info SIEM/supply-chain, ecc.): sostituisce lo style inline
   background/border ripetuto identico in più schermate. */
.nexus-info-box {
    padding: 12px;
    border-radius: var(--nexus-radius);
    margin-bottom: 1rem;
    background: var(--nexus-blue-tint);
    border: 1px dashed var(--nexus-blue);
}

.nexus-info-box-danger {
    background: var(--nexus-red-tint);
    border: 1px dashed var(--nexus-red);
}

.nexus-btn-cancel {
    background: var(--nexus-surface) !important;
    border: 1px solid var(--nexus-border) !important;
    color: var(--nexus-text-secondary) !important;
    font-family: var(--nexus-font) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    padding: 0 14px !important;
    height: 32px !important;
    border-radius: var(--nexus-radius-sm) !important;
    transition: background-color 0.15s var(--nexus-ease), color 0.15s var(--nexus-ease) !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
}

.nexus-btn-cancel:hover {
    background: var(--nexus-red-tint) !important;
    border-color: transparent !important;
    color: var(--nexus-red) !important;
}

.nexus-btn-cancel:active, .btn-europsys:active {
    transform: scale(0.98);
}

.text-europsys {
    color: var(--nexus-blue) !important;
}

/* 7. AZIONI IN TABELLA ------------------------------------------------------ */
.nexus-action-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    gap: 4px !important;
}

.nexus-action-btn {
    width: 26px !important;
    height: 26px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: var(--nexus-radius-sm) !important;
    transition: background-color 0.15s var(--nexus-ease), border-color 0.15s var(--nexus-ease) !important;
    padding: 0 !important;
    font-size: 12.5px;
}

.nexus-action-btn:hover {
    background: var(--nexus-surface-2) !important;
    border-color: var(--nexus-border) !important;
}

/* 8. BADGE & STATI -----------------------------------------------------------
   Indicatori "a spia" stile pannello di controllo: pallino colorato (currentColor)
   + etichetta in monospace tabulare, non pillole decorative piene. */
.nexus-status-badge {
    font-family: var(--nexus-font-mono);
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px 2px 6px;
    border-radius: var(--nexus-radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
    background: var(--nexus-surface-2);
    color: var(--nexus-text-secondary);
}

.nexus-status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: currentColor;
}

.badge-status-enabled {
    background: var(--nexus-green-tint);
    color: var(--nexus-green);
    border-color: rgba(26, 127, 55, 0.25);
}

.badge-status-disabled {
    background: var(--nexus-red-tint);
    color: var(--nexus-red);
    border-color: rgba(201, 42, 42, 0.25);
}

.badge-status-warning {
    background: var(--nexus-amber-tint);
    color: var(--nexus-amber);
    border-color: rgba(154, 103, 0, 0.25);
}

.badge-status-neutral {
    color: var(--nexus-text-secondary);
    border-color: var(--nexus-border);
}

/* Pallino di stato isolato (es. indicatore JIT in tabella utenti), fuori
   dal componente badge completo: solo l'icona fa-circle colorata. */
.nexus-status-dot {
    font-size: 7px;
}

.security-badge {
    font-family: var(--nexus-font-mono);
    border: 1px solid rgba(26, 127, 55, 0.25);
    color: var(--nexus-green);
    background: var(--nexus-green-tint);
    padding: 2px 7px 2px 6px;
    border-radius: var(--nexus-radius-sm);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.security-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: currentColor;
}

.security-badge.is-unmanaged {
    color: var(--nexus-text-muted);
    background: var(--nexus-surface-3);
    border-color: var(--nexus-border-strong);
}

/* Modificatori sito: sostituiscono bg-primary/bg-warning, che non hanno mai
   funzionato in questa app (il CSS di Bootstrap non è caricato, solo il JS). */
.security-badge.site-milano {
    color: var(--nexus-blue);
    background: var(--nexus-blue-tint);
    border-color: rgba(31, 78, 121, 0.25);
}

.security-badge.site-calabria {
    color: var(--nexus-amber);
    background: var(--nexus-amber-tint);
    border-color: rgba(154, 103, 0, 0.25);
}

/* 8b. COMPATIBILITÀ CLASSI SEMANTICHE BOOTSTRAP ------------------------------
   Il markup di tutta l'app usa da tempo text-danger/bg-success/ecc. dando per
   scontato lo stile di Bootstrap, ma qui è caricato solo il bundle JS di
   Bootstrap (niente CSS): finora questi indicatori di stato non hanno MAI
   avuto colore. Le definiamo qui coi nostri token invece di riscrivere ogni
   occorrenza in 21 file. */
.text-primary   { color: var(--nexus-blue) !important; }
.text-secondary { color: var(--nexus-text-secondary) !important; }
.text-success   { color: var(--nexus-green) !important; }
.text-danger    { color: var(--nexus-red) !important; }
.text-warning   { color: var(--nexus-amber) !important; }
.text-info      { color: var(--nexus-blue) !important; }
.text-dark      { color: var(--nexus-text) !important; }
.text-light     { color: var(--nexus-text-muted) !important; }

.bg-primary   { background: var(--nexus-blue-tint) !important;   color: var(--nexus-blue) !important; }
.bg-secondary { background: var(--nexus-surface-3) !important;   color: var(--nexus-text-secondary) !important; }
.bg-success   { background: var(--nexus-green-tint) !important;  color: var(--nexus-green) !important; }
.bg-danger    { background: var(--nexus-red-tint) !important;    color: var(--nexus-red) !important; }
.bg-warning   { background: var(--nexus-amber-tint) !important;  color: var(--nexus-amber) !important; }
.bg-info      { background: var(--nexus-blue-tint) !important;   color: var(--nexus-blue) !important; }
.bg-dark      { background: var(--nexus-surface-3) !important;   color: var(--nexus-text) !important; }
.bg-light     { background: var(--nexus-surface-2) !important;   color: var(--nexus-text) !important; }

/* 9. PAGINAZIONE -------------------------------------------------------- */
.nexus-page-btn {
    background: var(--nexus-surface);
    border: 1px solid var(--nexus-border);
    color: var(--nexus-text-secondary);
    padding: 4px 10px;
    border-radius: var(--nexus-radius-sm);
    text-decoration: none !important;
    font-family: var(--nexus-font);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s var(--nexus-ease);
}

.nexus-page-btn:hover {
    background: var(--nexus-surface-2);
    border-color: var(--nexus-border-strong);
    color: var(--nexus-text);
}

.nexus-page-btn.active {
    background: var(--nexus-blue);
    border-color: var(--nexus-blue);
    color: #ffffff;
    font-weight: 600;
}

/* 10. ANIMAZIONI & MODALI -------------------------------------------------- */
.status-pulse {
    color: var(--nexus-blue);
    animation: nexus-pulse 2.4s ease-in-out infinite;
}

@keyframes nexus-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* Posizionamento base dei modal (.modal/.modal-dialog/.modal-backdrop): manca
   del tutto, perché qui non è mai stato caricato il CSS di Bootstrap (solo il
   suo bundle JS, per il componente Modal). Senza queste regole ogni modal
   dell'app è un normale elemento di blocco nel flusso della pagina, non un
   overlay fluttuante — visibile solo per caso se abbastanza in alto da non
   richiedere scroll, invisibile per qualunque contenuto più lungo (esattamente
   il sintomo della console SSH). Bootstrap crea .modal-backdrop via JS al volo:
   qui serve solo definirne l'aspetto. */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}
.modal:not(.show) {
    display: none !important;
}
.modal-dialog {
    position: relative;
    width: auto;
    max-width: 500px;
    margin: 1.75rem auto;
    pointer-events: auto;
}
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1140px; }
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    opacity: 0.5;
}

.modal-content {
    background: var(--nexus-surface) !important;
    border: 1px solid var(--nexus-border) !important;
    border-radius: var(--nexus-radius-lg) !important;
    box-shadow: var(--nexus-shadow-lg);
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    outline: 0;
}

@media (prefers-reduced-motion: reduce) {
    .status-pulse, .menu-content, .nexus-slider, .nexus-slider:before,
    .btn-europsys, .nexus-btn-cancel, .nexus-page-btn, .nexus-action-btn {
        transition: none !important;
        animation: none !important;
    }
}

/* FIX: supporto mobile e overflow */
@media (max-width: 768px) {
    .nexus-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px;
    }
    .nexus-header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .nexus-search {
        width: 100% !important;
    }
}

.nexus-modal-title {
    color: var(--nexus-text);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 14px;
}

/* 11. SWITCH (stile iOS) --------------------------------------------------- */
.nexus-switch-container {
    display: flex !important;
    align-items: center !important;
    background: var(--nexus-surface-2) !important;
    padding: 9px 12px !important;
    border: 1px solid var(--nexus-border) !important;
    border-radius: var(--nexus-radius-sm) !important;
    margin-top: 4px !important;
}

.nexus-switch {
    position: relative !important;
    display: inline-block !important;
    width: 38px !important;
    height: 22px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
}

.nexus-switch input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
}

.nexus-slider {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: var(--nexus-surface-3) !important;
    transition: background-color 0.2s var(--nexus-ease) !important;
    border-radius: 99px !important;
    border: 1px solid var(--nexus-border) !important;
}

.nexus-slider:before {
    position: absolute !important;
    content: "" !important;
    height: 16px !important;
    width: 16px !important;
    left: 2px !important;
    top: 2px !important;
    background-color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25) !important;
    transition: transform 0.2s var(--nexus-ease) !important;
    border-radius: 50% !important;
}

.nexus-switch input:checked + .nexus-slider {
    background-color: var(--nexus-green) !important;
    border-color: var(--nexus-green) !important;
}

.nexus-switch input:checked + .nexus-slider:before {
    transform: translateX(16px) !important;
    background-color: #ffffff !important;
}

.nexus-switch-label {
    margin-left: 10px;
    color: var(--nexus-text);
    font-family: var(--nexus-font-mono);
    font-size: 11px;
    letter-spacing: 0.2px;
}

/* 12. SERVICE DESK / TICKETING ---------------------------------------------
   Estensione del design system per il modulo ticket. Stessa grammatica:
   angoli squadrati, stati a spia, colore solo sullo stato, numeri monospace. */

/* Badge di stato BLU: mancava un colore "informativo/attivo" oltre a
   verde/rosso/ambra (per "aperto"/"in lavorazione"). Stessa struttura a spia. */
.badge-status-info {
    background: var(--nexus-blue-tint);
    color: var(--nexus-blue);
    border-color: rgba(37, 99, 235, 0.25);
}

/* Etichetta neutra compatta (tipo servizio), senza pallino di stato. */
.tk-tag {
    font-family: var(--nexus-font-mono);
    font-size: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--nexus-text-muted);
    border: 1px solid var(--nexus-border);
    border-radius: var(--nexus-radius-sm);
    padding: 1px 6px;
    white-space: nowrap;
}

/* Filtri a chip della coda. */
.tk-filter {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--nexus-text-secondary);
    background: var(--nexus-surface);
    border: 1px solid var(--nexus-border);
    border-radius: var(--nexus-radius-sm);
    text-decoration: none !important;
    transition: all 0.15s var(--nexus-ease);
}
.tk-filter:hover { border-color: var(--nexus-border-strong); color: var(--nexus-text); }
.tk-filter.active { background: var(--nexus-blue); border-color: var(--nexus-blue); color: #fff; }

/* Messaggi del thread: blocco squadrato con barra colore a sinistra che
   distingue cliente / staff / nota interna. */
.tk-msg {
    border: 1px solid var(--nexus-border);
    border-left: 3px solid var(--nexus-border-strong);
    border-radius: var(--nexus-radius-sm);
    background: var(--nexus-surface);
    padding: 10px 12px;
    margin-bottom: 10px;
}
.tk-msg:last-child { margin-bottom: 0; }
.tk-msg--pa       { border-left-color: var(--nexus-text-muted); background: var(--nexus-surface-2); }
.tk-msg--staff    { border-left-color: var(--nexus-blue); }
.tk-msg--system   { border-left-color: var(--nexus-border-strong); background: var(--nexus-surface-2); }
.tk-msg--internal { border-left-color: var(--nexus-amber); background: var(--nexus-amber-tint); }

.tk-msg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.tk-msg-who {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--nexus-text);
}
.tk-msg-who i { color: var(--nexus-text-muted); font-size: 11px; }
.tk-msg-role {
    font-family: var(--nexus-font-mono);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--nexus-text-muted);
}
.tk-msg-internal-tag {
    font-family: var(--nexus-font-mono);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--nexus-amber);
    background: var(--nexus-amber-tint);
    border: 1px solid rgba(154, 103, 0, 0.25);
    border-radius: var(--nexus-radius-sm);
    padding: 0 5px;
}
.tk-msg-time {
    font-family: var(--nexus-font-mono);
    font-size: 10px;
    color: var(--nexus-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tk-msg-body {
    font-size: 13px;
    color: var(--nexus-text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Definition list del pannello dettaglio (Ente, Asset, SLA...). */
.tk-meta { margin: 0; }
.tk-meta > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--nexus-border);
}
.tk-meta > div:last-child { border-bottom: none; }
.tk-meta dt {
    font-size: 11px;
    color: var(--nexus-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.tk-meta dd {
    margin: 0;
    font-size: 12px;
    color: var(--nexus-text-secondary);
    text-align: right;
}
.tk-meta dd.mono {
    font-family: var(--nexus-font-mono);
    font-variant-numeric: tabular-nums;
}
.tk-meta dd.breach { color: var(--nexus-red); }

/* Intestazione a etichetta di un pannello (Gestione, Storico). */
.tk-panel-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--nexus-text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--nexus-border);
}
.tk-panel-label i { color: var(--nexus-text-muted); }

/* Storico eventi. */
.tk-event { padding: 6px 0; border-bottom: 1px dashed var(--nexus-border); }
.tk-event:last-child { border-bottom: none; }
.tk-event-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tk-event-time {
    font-family: var(--nexus-font-mono);
    font-size: 10px;
    color: var(--nexus-text-muted);
    font-variant-numeric: tabular-nums;
}
.tk-event-type {
    font-family: var(--nexus-font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--nexus-blue);
    text-transform: uppercase;
}
.tk-event-detail { font-size: 11px; color: var(--nexus-text-secondary); }
.tk-event-actor { font-size: 10px; color: var(--nexus-text-muted); }

/* Banner esito operazione. */
.tk-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--nexus-radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.tk-banner.ok   { background: var(--nexus-green-tint); color: var(--nexus-green); border-color: rgba(26, 127, 55, 0.25); }
.tk-banner.warn { background: var(--nexus-amber-tint); color: var(--nexus-amber); border-color: rgba(154, 103, 0, 0.25); }

/* 13. CENTRO ALLARMI SOC/NOC (widget campanella fisso, audio+visivo) ------------- */
.soc-alert { position: fixed; top: 14px; right: 16px; z-index: 1200; }

.soc-alert-bell {
    position: relative;
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--nexus-border);
    background: var(--nexus-surface);
    color: var(--nexus-text-muted);
    box-shadow: var(--nexus-shadow);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    transition: color 0.15s var(--nexus-ease), border-color 0.15s var(--nexus-ease);
}
.soc-alert-bell:hover { border-color: var(--nexus-border-strong); color: var(--nexus-text); }

.soc-alert-count {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 4px;
    border-radius: 9px;
    background: var(--nexus-text-muted); color: #fff;
    font-size: 10px; font-weight: 700;
    font-family: var(--nexus-font-mono); font-variant-numeric: tabular-nums;
    display: flex; align-items: center; justify-content: center;
}

.soc-alert[data-level="warn"] .soc-alert-bell  { color: var(--nexus-amber); border-color: rgba(154, 103, 0, 0.4); }
.soc-alert[data-level="warn"] .soc-alert-count { background: var(--nexus-amber); }
.soc-alert[data-level="critical"] .soc-alert-bell {
    color: var(--nexus-red); border-color: rgba(201, 42, 42, 0.5);
    animation: soc-pulse 1.2s ease-in-out infinite;
}
.soc-alert[data-level="critical"] .soc-alert-count { background: var(--nexus-red); }

@keyframes soc-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 42, 42, 0.45); }
    50%      { box-shadow: 0 0 0 7px rgba(201, 42, 42, 0); }
}

.soc-alert-panel {
    position: absolute; top: 46px; right: 0;
    width: 244px;
    background: var(--nexus-surface);
    border: 1px solid var(--nexus-border);
    border-radius: var(--nexus-radius-lg);
    box-shadow: var(--nexus-shadow-lg);
    overflow: hidden;
}
.soc-alert-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-bottom: 1px solid var(--nexus-border);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--nexus-text-secondary);
}
.soc-alert-sound {
    font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px;
    color: var(--nexus-text-muted);
    display: flex; align-items: center; gap: 5px; cursor: pointer;
}
.soc-alert-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 12px; font-size: 12px;
    color: var(--nexus-text-secondary); text-decoration: none !important;
    border-bottom: 1px dashed var(--nexus-border);
}
.soc-alert-row:last-child { border-bottom: none; }
.soc-alert-row:hover { background: var(--nexus-surface-2); }
.soc-alert-row b { font-family: var(--nexus-font-mono); font-variant-numeric: tabular-nums; color: var(--nexus-text); }
.soc-alert-row.soc-crit b { color: var(--nexus-red); }

@media (prefers-reduced-motion: reduce) {
    .soc-alert[data-level="critical"] .soc-alert-bell { animation: none !important; }
}
