/* ============================================================
   NEXENTRYNODE — Foglio di stile principale
   Algor S.r.l. | v1.0
   Font: Roboto (Google Fonts)
   Framework: Bootstrap 5.3.3 + Bootstrap Icons 1.11.3
   ============================================================ */

/* --- VARIABILI TEMA SCURO ---------------------------------- */
:root {
    --nx-green:         #2AB358;
    --nx-green-dark:    #1e8741;
    --nx-green-hover:   #3FBB69;  /* hover bottoni: si schiarisce, il testo scuro resta leggibile */
    --nx-btn-text:      #111111;  /* leggibilita 08/2026: testo scuro su verde (6,9:1; bianco era 2,7:1) */
    --nx-link:          #55C279;  /* link su sfondo pagina: 4,6:1 (il verde base era 3,8:1) */
    --nx-link-hover:    #75CE92;
    --nx-main-bg:       #404040;
    --nx-sidebar-bg:    #333333;
    --nx-card-bg:       #2c2c2c;
    --nx-input-bg:      #555555;
    --nx-input-border:  #666666;
    --nx-text:          #e0e0e0;
    --nx-text-muted:    #b3b3b3;  /* leggibilita 08/2026: 4,95:1 anche su sfondo pagina */
    --nx-text-subtle:   #9e9e9e;  /* solo su card/superfici scure, mai su sfondo pagina */
    --nx-placeholder:   #cccccc;  /* 4,6:1 sugli input #555 */
    --nx-border:        #444444;
    --nx-sidebar-w:     260px;
    --nx-navbar-h:      56px;
    --nx-radius:        8px;
    --nx-shadow:        0 4px 6px rgba(0,0,0,0.3);
}

/* --- RESET / BASE ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Roboto', 'Segoe UI', sans-serif;
    font-size: 0.93rem;
    background-color: var(--nx-main-bg);
    color: var(--nx-text);
    overflow-x: hidden;
    padding-top: var(--nx-navbar-h);
}

a { text-decoration: none; color: var(--nx-link); }
a:hover { color: var(--nx-link-hover); }

/* Testo secondario Bootstrap -> tavolozza NX (leggibilita 08/2026) */
.text-muted { color: var(--nx-text-muted) !important; }
.form-text  { color: var(--nx-text-subtle); }

/* --- NAVBAR ------------------------------------------------- */
.navbar-custom {
    background-color: var(--nx-green);
    height: var(--nx-navbar-h);
    z-index: 1030;
    border-bottom: 1px solid rgba(0,0,0,0.2);
}

.navbar-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background-color: var(--nx-card-bg);
    border-radius: 6px;
    padding: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.navbar-brand-text { letter-spacing: 0.08em; }

/* Navbar a norma (opzione A committente, 08/2026): i testi seguono il testo
   adattivo dell'accento (--nx-btn-text), come i bottoni. Il verde del marchio
   resta intatto; i veli traslucidi diventano CHIARI perche' il testo e' scuro. */
.navbar-custom .text-white { color: var(--nx-btn-text) !important; }

/* Logo tenant in navbar */
.navbar-tenant-sep {
    width: 1px; height: 28px;
    background: rgba(255,255,255,0.3);
    margin: 0 4px;
}
.navbar-tenant-logo {
    height: 34px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 4px;
    background: rgba(255,255,255,0.9);
    padding: 3px 6px;
}

/* Avatar navbar */
.avatar-sm {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    color: var(--nx-btn-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700;
    flex-shrink: 0;
}

/* --- SIDEBAR ------------------------------------------------ */
#sidebar-wrapper {
    width: var(--nx-sidebar-w);
    height: calc(100vh - var(--nx-navbar-h));
    position: fixed;
    top: var(--nx-navbar-h);
    left: 0;
    background-color: var(--nx-sidebar-bg);
    border-right: 1px solid var(--nx-border);
    overflow-y: auto;
    padding-bottom: 40px;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-profile {
    background: linear-gradient(160deg, #3a3f45 0%, #222527 100%);
    padding: 18px 20px;
    color: white;
}

.avatar-lg {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
    border: 2px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}

.sidebar-group-label {
    padding: 14px 20px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--nx-text-subtle);
    user-select: none;
}

.list-group-item-action {
    background-color: transparent !important;
    border: none !important;
    color: var(--nx-text);
    font-weight: 500;
    padding: 11px 20px;
    border-left: 4px solid transparent !important;
    transition: background-color 0.15s, color 0.15s;
}

.list-group-item-action:hover,
.list-group-item-action.active {
    background-color: rgba(255,255,255,0.05) !important;
    color: var(--nx-link) !important;
    border-left-color: var(--nx-green) !important;
}

.sidebar-icon {
    width: 22px;
    display: inline-block;
    text-align: center;
    margin-right: 9px;
    opacity: 0.65;
}
.list-group-item-action:hover .sidebar-icon,
.list-group-item-action.active .sidebar-icon { opacity: 1; }

/* Badge accessi temporanei in attesa */
.badge-pending-at {
    display: inline-flex; align-items: center; justify-content: center;
    background: #ffc857; color: #1a1000;
    border-radius: 20px; font-size: 0.75rem; font-weight: 700;
    padding: 1px 7px; margin-left: 5px;
}

/* Sidebar nascosta (desktop toggle) */
#wrapper.sidebar-hidden #sidebar-wrapper { transform: translateX(calc(-1 * var(--nx-sidebar-w))); }
#wrapper.sidebar-hidden #page-content-wrapper { margin-left: 0; }

/* Floating reopen tab */
#sidebar-reopen {
    display: none;
    position: fixed;
    top: calc(var(--nx-navbar-h) + 12px);
    left: 0;
    z-index: 1100;
    background: var(--nx-sidebar-bg);
    border: 1px solid var(--nx-border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--nx-text-muted);
}
#sidebar-reopen:hover { color: var(--nx-green); }
#wrapper.sidebar-hidden #sidebar-reopen { display: block; }

/* --- LAYOUT CONTENT ---------------------------------------- */
#wrapper { display: flex; width: 100%; }

#page-content-wrapper {
    flex: 1;
    padding: 28px;
    margin-left: var(--nx-sidebar-w);
    min-height: calc(100vh - var(--nx-navbar-h));
    transition: margin-left 0.3s ease;
    /* Senza questo, un elemento flessibile non si restringe mai sotto la
       larghezza del proprio contenuto: una tabella larga allargava l'intera
       pagina invece di scorrere dentro il suo riquadro, e i bottoni a fine
       riga finivano fuori dallo schermo. Con min-width:0 il riquadro
       .table-responsive torna a fare il suo mestiere.
       (segnalazione del committente, 27/07/2026) */
    min-width: 0;
}

/* Mobile */
@media (max-width: 768px) {
    #sidebar-wrapper { transform: translateX(calc(-1 * var(--nx-sidebar-w))); }
    #page-content-wrapper { margin-left: 0; }
    #wrapper.sidebar-open #sidebar-wrapper { transform: translateX(0); }
}

/* --- CARDS -------------------------------------------------- */
.card-dark {
    background-color: var(--nx-card-bg);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    box-shadow: var(--nx-shadow);
}

.card-dark .card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--nx-border);
    font-weight: 600;
}

/* KPI cards (dashboard) */
.kpi-card {
    background-color: var(--nx-card-bg);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    padding: 20px;
    text-align: center;
}
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--nx-green); }
.kpi-label { font-size: 0.78rem; color: var(--nx-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* --- FORM --------------------------------------------------- */
.form-label { color: #ccc; font-weight: 500; font-size: 0.88rem; }

.form-control, .form-select {
    background-color: var(--nx-input-bg) !important;
    border-color: var(--nx-input-border) !important;
    color: var(--nx-text) !important;
    border-radius: 6px;
}
.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(42,179,88,0.25) !important;
    border-color: var(--nx-green) !important;
}
.form-control::placeholder { color: var(--nx-placeholder); }
.form-select option { background-color: var(--nx-card-bg); }

/* --- BUTTONS ----------------------------------------------- */
.btn-nx {
    background-color: var(--nx-green);
    color: var(--nx-btn-text);
    border: none;
    border-radius: 6px;
    font-weight: 500;
}
.btn-nx:hover { background-color: var(--nx-green-hover); color: var(--nx-btn-text); }

.btn-nx-outline {
    border: 1px solid var(--nx-green);
    color: var(--nx-link);
    background: transparent;
    border-radius: 6px;
}
.btn-nx-outline:hover { background-color: var(--nx-green); color: var(--nx-btn-text); }

/* Override Bootstrap sotto soglia sul tema scuro (leggibilita 08/2026) */
.btn-outline-secondary {
    --bs-btn-color: var(--nx-text-muted);
    --bs-btn-border-color: #8a8a8a;
}
.text-danger  { color: #ff8a97 !important; }   /* #dc3545 era 3,0:1 su card */
.text-success { color: #55C279 !important; }   /* #198754 era sotto soglia */
.btn-outline-danger {
    --bs-btn-color: #ff8a97;                   /* testo; il bordo #dc3545 resta (3:1 ok) */
}
.btn-outline-success {
    --bs-btn-color: #55C279;
    --bs-btn-border-color: #2AB358;            /* #198754 come bordo era 2,3:1 */
}

/* --- TABLES ------------------------------------------------ */
.table-nx {
    color: var(--nx-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--nx-border);
}
.table-nx th {
    border-bottom: 2px solid #555;
    color: white;
    font-weight: 600;
    padding: 12px 8px;
    font-size: 0.83rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    /* Le intestazioni vanno a capo invece di allargare la tabella: senza
       questo, su uno schermo da portatile le tabelle con molte colonne
       sforano in orizzontale e i bottoni a fine riga restano irraggiungibili
       (segnalazione del committente, 27/07/2026 — misurato fino a 180px di
       sfondamento sulla pagina Utenti a 1280px).
       Allineate in basso, così restano su una linea comune anche quando una
       occupa due righe e le altre una sola. */
    white-space: normal;
    vertical-align: bottom;
}
.table-nx td {
    border-bottom: 1px solid var(--nx-border);
    padding: 11px 8px;
    vertical-align: middle;
}
.table-nx tbody tr:hover { background-color: rgba(255,255,255,0.04); }

/* --- BREADCRUMB -------------------------------------------- */
.breadcrumb-nx {
    background: transparent;
    padding: 0;
    margin-bottom: 1.2rem;
}
.breadcrumb-nx .breadcrumb-item a { color: var(--nx-link); font-weight: 600; }
.breadcrumb-nx .breadcrumb-item.active { color: var(--nx-text-muted); }
.breadcrumb-nx .breadcrumb-item + .breadcrumb-item::before { color: var(--nx-text-subtle); }

/* --- TABS -------------------------------------------------- */
.nav-tab-nx {
    color: var(--nx-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.87rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.nav-tab-nx.active { color: var(--nx-text); border-bottom-color: var(--nx-green); }
.nav-tab-nx:hover  { color: var(--nx-text); }

/* --- BADGES ----------------------------------------------- */
.badge-status-active     { background: #1a3a1a; color: #2AB358; }
.badge-status-inactive   { background: #2a2a2a; color: var(--nx-text-subtle); }
.badge-status-warning    { background: #4a3a00; color: #ffc857; }
.badge-status-danger     { background: #3a1a1a; color: #ff6b6b; }
.badge-status-info       { background: #1a2a3a; color: #5b9bd5; }
.badge-status-orange     { background: #3a2a10; color: #fd7e14; }
.badge-status-secondary  { background: #28292a; color: #fcfcfc; }
.badge-status-cyan       { background: #0a2a30; color: #0dcaf0 !important; }
.badge-status-blue       { background: #0a1530; color: #4d94ff !important; }

/* --- ACCESSI TEMPORANEI ------------------------------------ */
.richiesta-card {
    background-color: var(--nx-card-bg);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.richiesta-card.pending   { border-left: 4px solid #ffc857; }
.richiesta-card.r-success { border-left: 4px solid #2AB358; }
.richiesta-card.r-danger  { border-left: 4px solid #e05252; }

.richiesta-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.875rem 1.1rem; flex-wrap: wrap; gap: 8px;
    cursor: pointer; user-select: none;
}
.richiesta-header:hover { background: rgba(255,255,255,0.025); }

.richiesta-expandable {
    padding: 0.75rem 1.1rem 0.875rem;
    border-top: 1px solid #2e2e2e;
}
.richiesta-action-strip {
    padding: 0.75rem 1.1rem;
    border-top: 1px solid #2e2e2e;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.meta-grid { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }
.meta-item { display: flex; flex-direction: column; gap: 5px; }
.meta-label { font-size: 0.72rem; color: var(--nx-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.meta-value { font-size: 0.88rem; color: var(--nx-text); font-weight: 500; }

.avatar-circle {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78rem; font-weight: 600; flex-shrink: 0;
}
.av-green { background: #1a3a1a; color: #2AB358; }
.av-blue  { background: #1a2a3a; color: #5b9bd5; }
.av-red   { background: #3a1a1a; color: #ff6b6b; }

.ai-panel {
    background: #242424; border: 1px solid #3a3a3a;
    border-radius: 6px; padding: 1rem; margin-bottom: 1rem;
}
.ai-panel.danger-panel { background: #2a1a1a; border-color: #5a2a2a; }

.strato-tag {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.72rem; font-weight: 600; padding: 2px 8px;
    border-radius: 20px; margin-right: 4px;
}
.strato-algo { background: #1a2a3a; color: #5b9bd5; border: 1px solid #2a4a6a; }
.strato-ai   { background: #1a1a3a; color: #9b7fd4; border: 1px solid #3a3a6a; }

/* Barra escalation (sostituisce countdown-box) */
.escalation-wrap  { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.escalation-bar   { height: 5px; background: #2e2e2e; border-radius: 3px; overflow: hidden; }
.escalation-fill  { height: 100%; border-radius: 3px; transition: width 1s linear, background-color 0.8s; }
.escalation-label { font-size: 0.75rem; color: var(--nx-text-muted); text-align: right; line-height: 1; }

/* Badges adeguatezza AI */
.badge-alta  { background: #1a3a1a; color: #2AB358; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; display: inline-block; }
.badge-media { background: #3a2a00; color: #ffc857; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; display: inline-block; }
.badge-bassa { background: #3a1a1a; color: #ff6b6b; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; display: inline-block; }

/* AI panel header e dot */
.at-ai-header { display: flex; align-items: center; gap: 6px; margin-bottom: 0.5rem; }
.at-ai-dot    { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.at-ai-dot-green  { background: #2AB358; }
.at-ai-dot-yellow { background: #ffc857; }
.at-ai-dot-red    { background: #e05252; animation: atPulse 1s infinite; }
.at-ai-dot-grey   { background: #888; }
.at-ai-label { font-size: 0.75rem; color: var(--nx-text-subtle); font-weight: 500; }
@keyframes atPulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* AI attributi determinanti tags */
.at-ai-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 0.375rem; }
.at-ai-tag  { font-size: 0.75rem; padding: 2px 8px; border-radius: 20px; background: #333; border: 1px solid #555; color: var(--nx-text-muted); }

/* Segnali attenzione */
.at-attenzione        { background: #2e2000; border: 1px solid #5a4000; border-radius: 5px; padding: 0.375rem 0.625rem; font-size: 0.78rem; color: #ffc857; margin-top: 0.375rem; display: flex; gap: 6px; align-items: flex-start; }
.at-attenzione.danger { background: #2a1010; border-color: #5a1a1a; color: #ff6b6b; }

/* Disclaimer architettura ibrida */
.at-disclaimer { background: #1e1e2e; border: 1px solid #3a3a5a; border-radius: 5px; padding: 0.5rem 0.75rem; font-size: 0.76rem; color: #9b7fd4; display: flex; gap: 8px; align-items: flex-start; margin-bottom: 1rem; }

/* Azione inline nella card */
.at-action-row   { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.at-action-label { font-size: 0.82rem; color: var(--nx-text-muted); }
.at-input-ore    { width: 70px; background: #1e1e1e; border: 1px solid #444; color: #e0e0e0; border-radius: 4px; padding: 4px 8px; font-size: 0.84rem; }
.at-input-note   { flex: 1; min-width: 140px; max-width: 300px; background: #1e1e1e; border: 1px solid #444; color: #e0e0e0; border-radius: 4px; padding: 4px 8px; font-size: 0.84rem; }
.at-btn-approva  { background: #1a3a1a; color: #2AB358; border: 1px solid #2AB358; border-radius: 4px; padding: 5px 14px; font-size: 0.84rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.at-btn-approva:hover { background: var(--nx-green); color: var(--nx-btn-text); }
.at-btn-nega     { background: transparent; color: var(--nx-text-muted); border: 1px solid #555; border-radius: 4px; padding: 5px 14px; font-size: 0.84rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.at-btn-nega:hover { background: #3a1a1a; color: #ff6b6b; border-color: #e05252; }
.at-btn-nega.danger       { color: #ff6b6b; border-color: #e05252; }
.at-btn-nega.danger:hover { background: #3a1a1a; }

/* Pill filtri storico */
.st-pill        { background: transparent; border: 1px solid #555; color: var(--nx-text-subtle); border-radius: 20px; padding: 3px 12px; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.st-pill:hover  { border-color: var(--nx-text-subtle); color: #ccc; }
.st-pill.active { background: var(--nx-accent, #5b9bd5); border-color: var(--nx-accent, #5b9bd5); color: #111111; }

/* Admin badge (dropdown) */
.admin-badge-inline {
    font-size: 0.72rem; font-weight: 700;
    background: #1a2a3a; color: #5b9bd5;
    border: 1px solid #2a4a6a;
    border-radius: 20px; padding: 1px 6px;
}
.dropdown-item-admin {
    color: var(--nx-text); font-size: 0.88rem;
    display: flex; align-items: center; gap: 6px;
}
.dropdown-item-admin:hover { background-color: var(--nx-green); color: var(--nx-btn-text); }

/* Demo console — voce dropdown in viola */
.dropdown-item-demo {
    color: #c9b3ff; font-size: 0.88rem;
    display: flex; align-items: center; gap: 6px;
}
.dropdown-item-demo:hover { background-color: rgba(167,139,250,.15); color: #d4c4ff; }
.demo-badge-inline {
    background: rgba(167,139,250,.25) !important;
    color: #c9b3ff !important;
    border-color: rgba(167,139,250,.45) !important;
}

/* --- DROPDOWN THEME ---------------------------------------- */
.dropdown-menu-dark {
    background-color: var(--nx-card-bg) !important;
    border-color: #555 !important;
}
.dropdown-item { color: var(--nx-text) !important; font-size: 0.88rem; }
.dropdown-item:hover { background-color: var(--nx-green) !important; color: var(--nx-btn-text) !important; }
.dropdown-divider { border-top-color: #555 !important; }

/* --- LOGIN ------------------------------------------------- */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background-color: var(--nx-main-bg);
    padding: 5vh 20px;
}
.login-card {
    width: 440px; max-width: 100%;
    background-color: var(--nx-card-bg);
    border-radius: var(--nx-radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
}
.login-header {
    background-color: var(--nx-card-bg);
    padding: 28px 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wordmark {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    justify-content: center;
}
.login-logo {
    width: 140px;
    height: 140px;
    object-fit: contain;
}
.login-wordmark-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.login-brand-name {
    font-size: 3.5rem;
    font-weight: 400;
    color: #fff;
    letter-spacing: 0.3px;
}
.login-brand-tagline {
    font-size: 1.45rem;
    font-weight: 300;
    color: var(--nx-text-muted);
    letter-spacing: 0.5px;
    margin-top: 2px;
}
.login-body { padding: 38px 48px 44px; }

.login-input-group { margin-bottom: 32px; }
.login-label { color: #ff6b6b; font-size: 0.87rem; margin-bottom: 5px; display: block; }
.login-input {
    width: 100%; border: none;
    border-bottom: 2px solid #e05252;
    background: transparent; color: var(--nx-text);
    padding: 8px 0; font-size: 1rem; font-family: 'Roboto', sans-serif;
}
.login-input:focus { outline: none; border-bottom-color: #ff5252; }
.btn-login {
    background-color: var(--nx-green); color: var(--nx-btn-text);
    border: none; border-radius: 6px;
    padding: 10px 40px; font-weight: 700; font-size: 1rem;
    display: block; margin: 0 auto;
    transition: background-color 0.2s;
    font-family: 'Roboto', sans-serif;
}
.btn-login:hover { background-color: var(--nx-green-hover); color: var(--nx-btn-text); }

.login-lang {
    text-align: right;
    margin-bottom: 8px;
}
.login-lang a {
    color: var(--nx-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: color 0.15s;
}
.login-lang a:hover { color: #ccc; }
.login-lang a.active { color: var(--nx-green); }
.login-lang-sep {
    color: #555;
    margin: 0 5px;
    font-size: 0.8rem;
}

/* --- PORTA MASTER (login co-branded, gestione SA) ---------- */
.porta-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 6px 0 2px;
}
.porta-logo {
    max-width: 300px;
    max-height: 110px;
    object-fit: contain;
}
.porta-master-name {
    font-size: 1.9rem;
    font-weight: 500;
    color: var(--nx-text);
    text-align: center;
    line-height: 1.25;
    text-wrap: balance;
}
.porta-powered {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--nx-text-muted);
    letter-spacing: 0.4px;
}
.porta-powered img { width: 16px; height: 16px; }
.porta-benvenuto {
    text-align: center;
    color: var(--nx-text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* Stile VETRINA (Fase 1b): pannello del Master + card affiancati.
   Le parti dinamiche (sfumatura/foto del pannello) arrivano da nxPortaHeadStyle. */
.porta-shell {
    display: flex;
    width: 960px;
    max-width: 100%;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 14px 44px rgba(0,0,0,0.6);
}
.porta-shell .login-card {
    width: 430px;
    max-width: 100%;
    flex-shrink: 0;
    border-radius: 0;
    box-shadow: none;
}
.porta-panel {
    flex: 1 1 55%;
    padding: 52px 46px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.porta-panel-logo {
    width: 120px;
    max-height: 120px;
    object-fit: contain;
    border-radius: 10px;
}
.porta-panel-title {
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--nx-text);
    line-height: 1.25;
    text-wrap: balance;
}
.porta-panel-sub {
    color: var(--nx-text-muted);
    font-size: 1rem;
    line-height: 1.5;
}
.porta-panel .porta-powered { margin-top: 22px; }
@media (max-width: 860px) {
    .porta-shell { flex-direction: column; width: 440px; }
    .porta-panel {
        padding: 26px 28px;
        gap: 10px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .porta-panel-title { font-size: 1.35rem; }
    .porta-panel-logo { width: 84px; }
    .porta-panel .porta-powered { margin-top: 8px; }
    .porta-shell .login-card { width: 100%; }
}

.login-footer {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 16px 48px 20px;
    text-align: center;
}
.login-footer-copy {
    color: var(--nx-text-muted);
    font-size: 0.82rem;
    line-height: 1.6;
    letter-spacing: 0.02em;
}

/* --- AUDIT TRAIL SIDEBAR ----------------------------------- */
.sidebar-audit-label { color: #C8962E; }
.sidebar-audit-link .sidebar-icon { color: #C8962E; opacity: 0.8; }
.sidebar-audit-link:hover,
.sidebar-audit-link.active {
    background-color: rgba(200,150,46,0.08) !important;
    color: #C8962E !important;
    border-left-color: #C8962E !important;
}
.sidebar-audit-link:hover .sidebar-icon,
.sidebar-audit-link.active .sidebar-icon { opacity: 1; color: #C8962E; }

/* --- BRANDING: Color set picker ----------------------------- */
.color-set-card {
    width: 130px;
    padding: 8px;
    border-radius: 6px;
    border: 2px solid var(--nx-border);
    background: var(--nx-card-bg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}
.color-set-card:hover {
    border-color: var(--nx-green);
}
.color-set-card.selected {
    border-color: var(--nx-green);
    box-shadow: 0 0 0 2px var(--nx-green), var(--nx-shadow);
}
.color-set-swatches {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 5px;
}
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-block;
}
.color-set-name {
    font-size: 0.72rem;
    color: var(--nx-text-muted);
    display: block;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.color-set-card.selected .color-set-name {
    color: var(--nx-green);
    font-weight: 600;
}

/* --- PRINT ------------------------------------------------- */
@media print {
    #sidebar-wrapper, .navbar-custom, #sidebar-reopen,
    .breadcrumb-nx, .btn, button { display: none !important; }
    body { background: #fff !important; color: #111 !important; }
    #page-content-wrapper { margin-left: 0 !important; padding: 0 !important; }
}

/* --- SCROLLBAR (webkit) ------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* ============================================================
   GLOBAL SEARCH (Ctrl+K)
   ============================================================ */

/* Trigger nella navbar */
.nx-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(0,0,0,0.20);
    color: var(--nx-btn-text);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    line-height: 1;
}
.nx-search-trigger:hover {
    background: rgba(255,255,255,0.35);
    border-color: rgba(0,0,0,0.30);
    color: var(--nx-btn-text);
}
.nx-search-trigger .bi-search { font-size: 0.95rem; }
.nx-search-trigger-label { opacity: 0.7; min-width: 120px; text-align: left; }
.nx-search-kbd {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    margin-left: 4px;
}
.nx-search-kbd kbd,
.nx-search-footer kbd,
.nx-search-hint kbd {
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.72rem;
    font-family: inherit;
    color: #ddd;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
    line-height: 1.3;
}

/* Overlay */
.nx-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}
.nx-search-overlay.show {
    display: flex;
    animation: nxFadeIn .12s ease-out;
}
@keyframes nxFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Pannello */
.nx-search-panel {
    width: 100%;
    max-width: 640px;
    background: var(--nx-card-bg);
    border: 1px solid var(--nx-border);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 72vh;
}

/* Input */
.nx-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--nx-border);
    background: var(--nx-input-bg);
}
.nx-search-icon {
    color: var(--nx-text-muted);
    font-size: 1.05rem;
}
.nx-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--nx-text);
    font-size: 1rem;
    padding: 0;
}
.nx-search-input::placeholder { color: var(--nx-text-muted); }
.nx-search-hint { flex: 0 0 auto; }

/* Risultati */
.nx-search-results {
    overflow-y: auto;
    padding: 6px 0;
    flex: 1;
}
.nx-search-empty,
.nx-search-loading,
.nx-search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: var(--nx-text-muted);
    font-size: 0.88rem;
}
.nx-search-loading .spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.nx-search-group {
    padding: 6px 0;
}
.nx-search-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--nx-text-muted);
    font-weight: 600;
}
.nx-search-group-label .nx-search-see-all {
    font-size: 0.72rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--nx-green);
    text-decoration: none;
}
.nx-search-group-label .nx-search-see-all:hover { text-decoration: underline; }

.nx-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--nx-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .1s;
}
.nx-search-item:hover,
.nx-search-item.is-active {
    background: rgba(255,255,255,0.06);
    color: var(--nx-text);
    border-left-color: var(--nx-green);
}
.nx-search-item-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(42,179,88,0.15);
    color: var(--nx-green);
    border-radius: 6px;
    font-size: 0.95rem;
}
.nx-search-item-body {
    flex: 1;
    min-width: 0;
}
.nx-search-item-label {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--nx-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nx-search-item-sub {
    font-size: 0.78rem;
    color: var(--nx-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.nx-search-item-label mark,
.nx-search-item-sub mark {
    background: rgba(42,179,88,0.25);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* Footer */
.nx-search-footer {
    display: flex;
    gap: 14px;
    padding: 8px 16px;
    border-top: 1px solid var(--nx-border);
    font-size: 0.72rem;
    color: var(--nx-text-muted);
    background: rgba(0,0,0,0.15);
    flex-wrap: wrap;
}
.nx-search-footer kbd { margin-right: 4px; }

/* Responsive */
@media (max-width: 576px) {
    .nx-search-overlay { padding-top: 5vh; padding-left: 12px; padding-right: 12px; }
    .nx-search-trigger-label, .nx-search-kbd { display: none !important; }
    .nx-search-trigger { padding: 5px 8px; }
}

/* ─── NX Help alert (glosse didattiche) ────────────────────────────────── */
.nx-help-alert {
    background: #162a3a;
    border: 1px solid #2a6bb0;
    color: #d9e6f2;
    padding: .65rem .9rem;
    border-radius: .375rem;
    margin-bottom: 1rem;
    font-size: .9rem;
    line-height: 1.4;
}
.nx-help-alert i.bi-info-circle-fill { color: #5b9bd5; font-size: 1.05rem; }
.nx-help-alert strong { color: #e8f0fa; }
.nx-help-alert code { color: #ffc857; background: transparent; }
.nx-help-alert .btn-close { padding: .25rem; font-size: .75rem; opacity: .6; }
.nx-help-alert .btn-close:hover { opacity: 1; }
.nx-help-icon {
    cursor: pointer;
    color: #5b9bd5;
    opacity: .65;
    transition: opacity .15s;
    font-size: .9em;
}
.nx-help-icon:hover,
.nx-help-icon:focus-visible { opacity: 1; }
.nx-help-icon:focus-visible {
    outline: 2px solid var(--nx-green);
    outline-offset: 2px;
    border-radius: 50%;
}
/* Wizard step tabs — focus a11y */
.wiz-step-tab:focus-visible {
    outline: 2px solid var(--nx-green);
    outline-offset: -2px;
}

/* ── Colonna azioni uniforme (20/07/2026) ─────────────────────────────────
   Bottoni-icona Modifica/Elimina impilati in VERTICALE, stessa taglia,
   ben distanziati: colonna azioni più stretta e righe compatte. Usata da
   Notifiche, Clienti, Utenti, Luoghi, Nodi. */
.nx-actions {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}
.nx-actions .btn {
    width: 38px;
    height: 31px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── Interruttore vista DEMO/UFFICIALI del superadmin (topbar) ────────────
   Badge a larghezza FISSA (misurata su "UFFICIALI"): commutando lo switch
   non si sposta nulla nella navbar. Contrasto pensato per la barra verde. */
.nx-demo-switch .form-check-input {
    width: 3em;
    height: 1.5em;
    cursor: pointer;
    margin-top: 0;
    background-color: rgba(255, 255, 255, .28);
    border-color: rgba(255, 255, 255, .65);
}
.nx-demo-switch .form-check-input:focus {
    border-color: rgba(255, 255, 255, .85);
    box-shadow: 0 0 0 .15rem rgba(255, 255, 255, .25);
}
.nx-demo-switch .form-check-input:checked {
    background-color: #ffc107;
    border-color: #ffc107;
}
.nx-demo-switch .form-check-label { cursor: pointer; }
.nx-demo-switch .badge {
    display: inline-block;
    min-width: 92px;
    text-align: center;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .6px;
    padding: .48em .55em;
}
.nx-demo-switch .badge.nx-demo-view-on  { background: #ffc107; color: #1a1d21; }
.nx-demo-switch .badge.nx-demo-view-off { background: rgba(255, 255, 255, .28); color: var(--nx-btn-text); border: 1px solid rgba(0, 0, 0, .35); }

/* ── Ricerca globale ancorata al CENTRO della navbar (≥1200px) ────────────
   Non si sposta mai, qualunque cosa cambi ai lati (switch, lingua, logo
   tenant). Sotto i 1200px resta nel flusso a destra: al centro assoluto
   colliderebbe con logo e menu. L'etichetta si tronca con ellissi se serve. */
@media (min-width: 1200px) {
    .nx-search-trigger {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }
    .nx-search-trigger-label {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ─── Sola lettura abbonamento: bottoni di scrittura spenti ─────────────────
   La classe nx-write-locked sul body arriva dal server (header.php) quando
   l'abbonamento non consente scritture. Niente pointer-events:none: il click
   resta possibile così nexentrynode.js mostra il toast con il messaggio. */
body.nx-write-locked .nx-write-btn,
body.nx-write-locked .nx-actions .btn,
body.nx-write-locked .btn-disattiva,
body.nx-write-locked .btn-rimuovi,
body.nx-write-locked .btn-associa,
body.nx-write-locked .at-btn-approva,
body.nx-write-locked .at-btn-nega {
    opacity: .45;
    cursor: not-allowed;
    filter: grayscale(35%);
}

/* ─── Caselle di spunta più visibili sulle pagine pubbliche ─────────────────
   (registrazione/attivazione: su monitor a basso contrasto il bordo di default
   di Bootstrap in tema scuro quasi scompare) */
.login-card .form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: .15em;
    background-color: #2a2e33;
    border: 2px solid #98a6b5;
}
.login-card .form-check-input:checked {
    background-color: #2AB358;
    border-color: #2AB358;
}
.login-card .form-check-input:focus {
    border-color: #5b9bd5;
    box-shadow: 0 0 0 .2rem rgba(91, 155, 213, .25);
}
