/* ==================================================================
   GDPR DPIA App — Design System "Blu Istituzionale"
   ==================================================================
   app.css è caricato DOPO Bootstrap 5.3.3 in ogni template, quindi
   qui sovrascriviamo i componenti Bootstrap per dare un look moderno
   e coerente a tutte le pagine da un unico file.
   Palette e font ripresi dal design system di riferimento (blu
   istituzionale #003882, Titillium Web): flat, bordi netti, alta
   leggibilità.
   ================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');

:root {
    /* Brand */
    --primary:        #003882;
    --primary-dark:   #00224f;
    --primary-darker: #00173a;
    --primary-light:  #e6ebf3;
    --primary-rgb:    0, 56, 130;

    /* Neutri */
    --ink:        #1a1a1a;
    --ink-soft:   #3a3f44;
    --muted:      #5d7083;
    --line:       #c5c7c9;
    --line-soft:  #f5f5f5;
    --surface:    #ffffff;
    --canvas:     #ffffff;

    /* Status */
    --success: #008055;
    --warning: #995c00;
    --danger:  #cc334d;
    --info:    #5d7083;

    /* Effetti */
    --radius:      8px;
    --radius-sm:   4px;
    --radius-pill: 999px;
    --shadow:    0 1px 2px rgba(0,34,79,.08), 0 1px 3px rgba(0,34,79,.05);
    --shadow-md: 0 4px 12px rgba(0,34,79,.12);

    /* Alias retro-compatibili con i template/classi esistenti */
    --dblue:      var(--primary);
    --dblue-dark: var(--primary-dark);
}

/* --- Base --- */
body {
    background: var(--canvas);
    min-height: 100vh;
    font-family: 'Titillium Web', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--muted) !important; }
hr { border-color: var(--line); opacity: 1; }

/* --- Bootstrap override: Buttons --- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 0.45rem 0.9rem;
    transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn-sm { padding: 0.3rem 0.65rem; }
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .25); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:active { background: var(--primary-darker) !important; border-color: var(--primary-darker) !important; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-outline-secondary { color: var(--ink-soft); border-color: var(--line); }
.btn-outline-secondary:hover { background: var(--ink-soft); border-color: var(--ink-soft); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger  { background: var(--danger);  border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-link { color: var(--primary); }

/* --- Bootstrap override: Cards --- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
    /* Senza questo, una tabella a bordo pieno (card-body p-0, comune per
       le liste) ha angoli squadrati che spuntano oltre l'arrotondamento
       della card. Non ritaglia i menu a discesa nelle Azioni: quelli usano
       già popperConfig strategy 'fixed' (main.js) apposta per non dipendere
       dall'overflow di un antenato, card compresa. */
    overflow: hidden;
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    padding: 0.8rem 1rem;
}
.card-body { padding: 1.25rem 1.5rem; }

/* --- Bootstrap override: Tables --- */
.table { color: var(--ink); margin-bottom: 0; }
.table > thead th {
    background: var(--line-soft);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table > tbody td { border-color: var(--line-soft); vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: var(--primary-light); }
.table-light th, .table-light td { background: var(--line-soft) !important; }

/* --- Bootstrap override: Forms --- */
.form-control, .form-select {
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    color: var(--ink);
    font-size: 0.92rem;
    padding: 0.65rem 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}
.form-label { font-weight: 600; color: var(--ink-soft); margin-bottom: 0.35rem; font-size: 0.85rem; }
.form-control::placeholder { color: #94a3b8; }
.input-group-text { background: var(--line-soft); border-color: #dbe3ee; color: var(--muted); }
/* Più respiro tra le righe di campi nei form: solo dentro <form>, per non
   allargare le griglie di card/statistiche che riusano .row.g-3 altrove. */
form .row.g-3 { row-gap: 1.1rem; }

/* --- Bootstrap override: Badges --- */
.badge { font-weight: 600; padding: 0.35em 0.6em; border-radius: 6px; letter-spacing: .01em; }
.bg-primary   { background: var(--primary) !important; }
.bg-success   { background: var(--success) !important; }
.bg-danger    { background: var(--danger)  !important; }
.bg-warning   { background: var(--warning) !important; }
.bg-info      { background: var(--info)    !important; }
.text-bg-light, .bg-light { background: var(--line-soft) !important; color: var(--ink-soft) !important; }

/* --- Bootstrap override: Nav / tabs / dropdown / alerts --- */
.navbar { background: var(--surface) !important; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.nav-tabs { border-bottom: 1px solid var(--line); }
.nav-tabs .nav-link { color: var(--muted); border: none; border-bottom: 2px solid transparent; border-radius: 0; }
.nav-tabs .nav-link.active { color: var(--primary); background: transparent; border-bottom-color: var(--primary); font-weight: 600; }
.dropdown-menu { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.dropdown-item.active, .dropdown-item:active { background: var(--primary); }
.alert { border-radius: var(--radius); border: 1px solid transparent; }
.list-group-item { border-color: var(--line); }
.modal-content { border: none; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(15,23,42,.25); }
.page-link { color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.progress { background: var(--line); border-radius: 999px; }
.progress-bar { background: var(--primary); }
.border { border-color: var(--line) !important; }

/* ==================================================================
   App shell — header / navigazione moderna (base.html)
   ================================================================== */
.app-header {
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.app-header-inner {
    max-width: 1500px; margin: 0 auto; padding: 0 1.25rem;
    height: 60px; display: flex; align-items: center; gap: 1.25rem;
}
.app-brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; flex-shrink: 0; }
.app-brand:hover { text-decoration: none; }
.app-brand-logo {
    width: 36px; height: 36px; border-radius: 10px; color: #fff; font-size: 1.05rem;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-darker));
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), .35);
}
.app-brand-name { font-size: 1.05rem; color: var(--ink); font-weight: 500; letter-spacing: -.01em; }
.app-brand-name strong { font-weight: 800; }

.app-nav { display: flex; align-items: center; gap: .15rem; flex: 1; overflow-x: auto; }
.app-nav a {
    display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
    padding: .5rem .75rem; border-radius: 8px; font-size: .85rem; font-weight: 500;
    color: var(--muted); text-decoration: none; transition: background .15s, color .15s;
}
.app-nav a i { font-size: .95rem; opacity: .85; }
.app-nav a:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.app-nav a.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

.app-header-right { display: flex; align-items: center; gap: .65rem; margin-left: auto; flex-shrink: 0; }
.app-ctrl-select { position: relative; display: flex; align-items: center; }
.app-ctrl-select i { position: absolute; left: .6rem; color: var(--muted); font-size: .85rem; pointer-events: none; }
.app-ctrl-select select { padding-left: 1.9rem !important; max-width: 190px; border-radius: 8px; }

.app-user { position: relative; }
.app-user-btn {
    display: flex; align-items: center; gap: .5rem; background: transparent; border: 1px solid var(--line);
    border-radius: 999px; padding: .25rem .6rem .25rem .3rem; cursor: pointer; transition: background .15s, border-color .15s;
}
.app-user-btn:hover { background: var(--line-soft); border-color: #cbd5e1; }
.app-user-avatar {
    width: 30px; height: 30px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .85rem;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-darker));
}
.app-user-name { font-size: .85rem; font-weight: 600; color: var(--ink); }
.app-user-btn .bi-chevron-down { font-size: .7rem; color: var(--muted); }

.app-main { max-width: 1500px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.app-main > .container-fluid { padding-left: 0 !important; padding-right: 0 !important; }

/* --- Stat cards (dashboard) --- */
.stat-card {
    position: relative; display: flex; flex-direction: column; height: 100%;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem 1.1rem; text-decoration: none; box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s; overflow: hidden;
}
/* La barra a sinistra seguiva sempre il blu di --primary, qualunque fosse
   il border-{colore} applicato alla card: su una card intenzionalmente
   grigia (conteggio neutro) restava comunque un'inspiegabile riga blu. */
.stat-card::before { content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--muted); opacity:.9; }
.stat-card.border-primary::before { background:var(--primary); }
.stat-card.border-success::before { background:var(--success); }
.stat-card.border-warning::before { background:var(--warning); }
.stat-card.border-danger::before { background:var(--danger); }
.stat-card.border-info::before { background:var(--info); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; border-color: #cbd5e1; }
.stat-ico {
    width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; margin-bottom: .65rem; background: var(--primary-light); color: var(--primary);
}
.stat-num { font-size: 1.85rem; font-weight: 800; line-height: 1; color: var(--ink); letter-spacing: -.02em; }
.stat-lbl { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.stat-primary::before{background:var(--primary)} .stat-primary .stat-ico{background:#eff6ff;color:#2563eb}
.stat-success::before{background:var(--success)} .stat-success .stat-ico{background:#f0fdf4;color:var(--success)}
.stat-danger::before{background:var(--danger)}   .stat-danger .stat-ico{background:#fef2f2;color:var(--danger)}
.stat-info::before{background:var(--info)}        .stat-info .stat-ico{background:#ecfeff;color:#0891b2}
.stat-warning::before{background:var(--warning)}  .stat-warning .stat-ico{background:#fffbeb;color:var(--warning)}
.stat-slate::before{background:var(--muted)}      .stat-slate .stat-ico{background:var(--line-soft);color:var(--ink-soft)}
.app-messages { margin-bottom: 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head .page-sub { color: var(--muted); font-size: .9rem; margin: .15rem 0 0; }

@media (max-width: 992px) {
    .app-nav { display: none; }
    .app-user-name { display: none; }
}


/* ==================================================================
   Classi custom dell'app (nomi invariati: usati nei 47 template)
   ================================================================== */

/* --- Hero Bar (controller info) --- */
.hero-bar { background: linear-gradient(135deg, var(--primary), var(--primary-darker)); color: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-md); }

/* --- Controller Bar (search + select) --- */
.controller-bar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.75rem 1rem; }
.search-select-wrapper { position: relative; flex: 1; min-width: 200px; }
.search-select-input { width: 100%; padding: 0.45rem 0.7rem; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); font-size: 0.85rem; }
.search-select-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.15); }
.search-select-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 1000; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto; box-shadow: var(--shadow-md); }
.search-select-dropdown .cs-item { padding: 0.45rem 0.7rem; cursor: pointer; font-size: 0.82rem; border-bottom: 1px solid var(--line-soft); }
.search-select-dropdown .cs-item:last-child { border-bottom: none; }
.search-select-dropdown .cs-item:hover, .search-select-dropdown .cs-item.highlight { background: var(--primary-light); }
.search-select-dropdown .cs-item.selected { background: var(--primary); color: #fff; }

/* --- Navigation Cards (Dashboard) --- */
.nav-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s, border-color .15s; min-height: 75px; }
.nav-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #c7d2fe; text-decoration: none; color: inherit; }
.nav-card .nc-count { font-size: 1.4rem; font-weight: 700; line-height: 1; color: var(--primary); }
.nav-card h6 { color: var(--ink); font-weight: 600; }
.nc-ico {
    flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; font-size: 1.25rem;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light); color: var(--primary);
}
.nc-ico-info    { background: #eff6ff; color: #2563eb; }
.nc-ico-warn    { background: #fffbeb; color: var(--warning); }
.nc-ico-success { background: #f0fdf4; color: var(--success); }
.nc-ico-danger  { background: #fef2f2; color: var(--danger); }

/* --- Tags / Labels --- */
.tag { display: inline-block; padding: 0.14rem 0.5rem; border-radius: 6px; font-size: 0.72rem; font-weight: 500; background: var(--primary-light); color: var(--primary-dark); margin-right: 0.2rem; white-space: nowrap; }
.tag-alt { background: #fff7ed; color: #c2410c; }
.tag-green { background: #f0fdf4; color: #15803d; }
.tag-controller { background: #eff6ff; color: #1d4ed8; }
.tag-employee { background: #fdf2f8; color: #be185d; }
.tag-admin { background: #faf5ff; color: #7e22ce; }
.tag-none { background: var(--line-soft); color: var(--muted); }
.tag-anonymous { background: #f0fdfa; color: #0f766e; }
.tag-identified { background: #eff6ff; color: #1d4ed8; }

/* --- Messages --- */
.message { padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: 0.4rem; font-size: 0.83rem; border-left: 4px solid; }
.msg-success { background: #f0fdf4; color: #15803d; border-color: var(--success); }
.msg-error { background: #fef2f2; color: #b91c1c; border-color: var(--danger); }
.msg-warning { background: #fffbeb; color: #b45309; border-color: var(--warning); }
.msg-info { background: var(--primary-light); color: var(--primary-dark); border-color: var(--info); }

/* --- Tooltip (custom) --- */
.tooltip-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--line); color: var(--muted); font-size: 0.6rem; cursor: help; vertical-align: middle; }
.tooltip-text { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 0.72rem; padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); max-width: 280px; white-space: normal; z-index: 10; box-shadow: var(--shadow-md); }
.tooltip-icon:hover .tooltip-text { display: block; }
.tooltip-text::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink); }

/* --- Profile (employee detail) --- */
.profile { display: flex; align-items: flex-start; gap: 1.25rem; }
@media (max-width: 500px) { .profile { flex-direction: column; align-items: center; text-align: center; } }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--primary); font-weight: 700; flex-shrink: 0; }

/* --- Org Tree --- */
.org-tree { display: flex; flex-direction: column; gap: 0.3rem; }
.dept-node { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 1rem; box-shadow: var(--shadow); }

/* --- Employee Cards --- */
.emp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.75rem 1rem; box-shadow: var(--shadow); margin-bottom: 0.5rem; }

/* --- Stepper moderno (Wizard DPIA/Audit) --- */
.stepper { display: flex; margin-bottom: 1.5rem; }
.stepper-item { flex: 1; text-align: center; position: relative; }
.stepper-item::before {
    content: ""; position: absolute; top: 19px; left: -50%; width: 100%; height: 2px;
    background: var(--line); z-index: 0;
}
.stepper-item:first-child::before { display: none; }
.stepper-item.done::before, .stepper-item.active::before { background: var(--primary); }
.stepper-dot {
    position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%;
    margin: 0 auto .45rem; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem; background: #fff; border: 2px solid var(--line);
    color: var(--muted); transition: all .15s;
}
.stepper-item.active .stepper-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .16); }
.stepper-item.done .stepper-dot { background: var(--success); border-color: var(--success); color: #fff; }
.stepper-label { font-size: .78rem; color: var(--muted); padding: 0 .25rem; }
.stepper-item.active .stepper-label { color: var(--ink); font-weight: 600; }
.stepper-item.done .stepper-label { color: var(--success); }
@media (max-width: 576px) { .stepper-label { font-size: .65rem; } .stepper-dot { width: 32px; height: 32px; } }

/* --- Wizard progress bar (sotto lo stepper) --- */
.wizard-progress-bar {
    position: relative; height: 10px; border-radius: 999px; background: var(--line-soft);
    box-shadow: inset 0 1px 2px rgba(15,23,42,.06); margin-top: 1.4rem;
}
.wizard-progress-fill {
    height: 100%; border-radius: 999px; overflow: hidden;
    background: linear-gradient(90deg, var(--primary), var(--primary-darker));
    transition: width .4s ease;
}
.wizard-progress-pct {
    position: absolute; top: -1.4rem; right: 0; font-size: .72rem; font-weight: 600; color: var(--muted);
}

/* --- Progress Steps (Wizard) --- */
.progress-step { flex: 1; text-align: center; padding: 0.35rem 0.2rem; font-size: 0.65rem; color: var(--muted); background: var(--line-soft); border-radius: var(--radius-sm); min-width: 40px; transition: all .15s; }
.progress-step.active { background: var(--primary); color: #fff; font-weight: 600; }
.progress-step.done { background: #f0fdf4; color: #15803d; }

/* --- Step Labels (Wizard) --- */
.step-labels span { padding: 0.25rem 0.6rem; border-radius: var(--radius-sm); font-size: 0.7rem; background: var(--line-soft); color: var(--muted); }
.step-labels span.active { background: var(--primary); color: #fff; font-weight: 600; }
.step-labels span.done { background: #f0fdf4; color: #15803d; }

/* --- Wizard Cards --- */
.fw-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.fw-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.65rem 1rem; box-shadow: var(--shadow); }

/* --- DPIA Scores --- */
.score-circle { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 700; color: #fff; }
.score-ring { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 700; color: #fff; background: var(--line); }

/* --- Risk Assessment --- */
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.suggestion-card { background: #fffbeb; border-radius: var(--radius-sm); padding: 0.75rem 1rem; border-left: 3px solid var(--warning); font-size: 0.82rem; }

/* --- Section Tabs (Risk Assessment) --- */
.section-tab { display: inline-block; padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.8rem; cursor: pointer; background: var(--line-soft); color: var(--ink-soft); }
.section-tab:hover { background: var(--line); }
.section-tab.active { background: var(--primary); color: #fff; }

/* --- Factor Tag --- */
.factor-tag { display: inline-block; padding: 0.1rem 0.4rem; border-radius: 6px; font-size: 0.7rem; background: #fef2f2; color: var(--danger); margin: 0.1rem; }

/* --- Custom Modal --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1040; align-items: center; justify-content: center; display: none; }
.modal-overlay.active { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; max-width: 640px; width: 95%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(15,23,42,.25); }

/* --- Chip Picker (M2M): sostituisce il vecchio widget a doppia colonna
   (due <select multiple> con frecce per spostare le opzioni) con una
   ricerca + chip a pillola, sullo stile del componente CategoryChip di
   riferimento. Un solo <select multiple> resta la fonte di verità (quello
   che il form invia); le chip ne sono solo la vista. --- */
.chip-picker-search { position: relative; margin-bottom: 0.6rem; }
.chip-picker-search i { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; }
.chip-picker-search input { padding-left: 2.1rem; }
.chip-picker-options { display: flex; flex-wrap: wrap; gap: 0.5rem; max-height: 220px; overflow-y: auto; padding: 0.15rem; }
.chip-option {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.85rem; border-radius: var(--radius-pill);
    border: 1px solid var(--line); background: var(--line-soft);
    color: var(--ink); font-size: 0.82rem; cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.chip-option:hover { border-color: var(--primary); }
.chip-option .chip-check { display: none; font-size: 0.8rem; }
.chip-option.selected { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.chip-option.selected .chip-check { display: inline; }
.chip-picker-empty { color: var(--muted); font-size: 0.82rem; padding: 0.4rem 0; }
.chip-picker-add { margin-top: 0.6rem; }

/* --- Searchable Select: select singola con molte opzioni (es. attività di
   trattamento). Il <select> resta nel DOM per l'invio del form e la
   validazione, ma invisibile: un campo di ricerca + menu filtrato è la sua
   vista. --- */
.searchable-select { position: relative; }
.searchable-select-native {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.searchable-select-input { cursor: pointer; background: var(--surface); width: 100%; }
/* Il <select> nativo era un figlio diretto di .input-group, e Bootstrap lo
   allarga con flex: 1 1 auto; il wrapper che lo sostituisce in vista non
   eredita quella regola (mirata su .form-control/.form-select), quindi il
   campo si restringeva al contenuto invece di occupare lo spazio libero. */
.input-group > .searchable-select { flex: 1 1 auto; width: 1%; min-width: 0; }
.searchable-select-menu {
    position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); max-height: 260px; overflow-y: auto; display: none;
}
.searchable-select-menu.open { display: block; }
.searchable-select-option { padding: 0.5rem 0.85rem; font-size: 0.85rem; cursor: pointer; }
.searchable-select-option:hover { background: var(--line-soft); }
.searchable-select-option.selected { color: var(--primary-dark); font-weight: 600; background: var(--primary-light); }
.searchable-select-empty { padding: 0.5rem 0.85rem; font-size: 0.82rem; color: var(--muted); }

/* --- Icon button discreto per rimuovere una riga in una tabella editabile
   (es. periodi di conservazione): un quadrato rosso pieno con "×" colpisce
   troppo l'occhio per un'azione così frequente. --- */
.btn-icon-danger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--muted); font-size: 0.85rem;
    transition: background .12s, color .12s;
}
.btn-icon-danger:hover { background: #fdecee; color: var(--danger); }

/* --- Existing List (Wizard) --- */
.existing-list { background: var(--line-soft); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; margin-top: 0.5rem; max-height: 280px; overflow-y: auto; }

/* --- Compliance Alerts --- */
.alerts-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.alerts-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.alert-badge { display: inline-block; padding: 0.14rem 0.55rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }

/* --- Audit Log --- */
.action { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 6px; font-size: 0.7rem; font-weight: 600; background: var(--line-soft); color: var(--ink-soft); }
.action-create { background: #f0fdf4; color: #15803d; }
.action-update { background: var(--primary-light); color: var(--primary-dark); }
.action-delete { background: #fef2f2; color: var(--danger); }

/* --- Organigramma Indicators --- */
.designated { border-left: 3px solid var(--primary); }
.dpo { border-left: 3px solid var(--warning); }
.manager { border-left: 3px solid var(--success); }

/* --- Score Colors --- */
.score-green { background: var(--success); }
.score-yellow { background: var(--warning); }
.score-red { background: var(--danger); }
.score-gray { background: var(--muted); }
.cell-alto, .cell-critico { background: #fef2f2; color: var(--danger); font-weight: 600; }
.cell-medio { background: #fffbeb; color: var(--warning); font-weight: 600; }
.cell-basso { background: #f0fdf4; color: #15803d; font-weight: 600; }

/* --- Help Icon (Guidance) --- */
.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 0.6rem; font-weight: 700; cursor: pointer; vertical-align: middle; margin-left: 0.4rem; transition: background .15s, color .15s, border-color .15s; }
.help-icon:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.popover { max-width: 400px; border-color: var(--line); }
.popover-body ul { padding-left: 1.2rem; margin-bottom: 0; }
.popover-body ul li { margin-bottom: 0.25rem; font-size: 0.82rem; }

/* --- Field Groups (Registro detail) --- */
.field-group { display: grid; grid-template-columns: 150px 1fr; gap: 0.3rem 0.75rem; font-size: 0.82rem; margin-bottom: 0.5rem; }
.field-group .label { color: var(--muted); font-weight: 600; }
@media (max-width: 576px) { .field-group { grid-template-columns: 1fr; } }

/* --- Configurazione Grid --- */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .config-grid { grid-template-columns: 1fr; } }
