/* CRM Totem PA — stile aree Console e Manager */

:root {
    --blu: #0b3d91;
    --blu-scuro: #082b66;
    --blu-chiaro: #eaf0fb;
    --grigio-bg: #f3f5f9;
    --grigio-bordo: #dde3ec;
    --testo: #1d2433;
    --testo-soft: #5b6577;
    --bianco: #ffffff;
    --verde: #0f9d58;
    --verde-bg: #e6f6ee;
    --rosso: #d93025;
    --rosso-bg: #fdecea;
    --giallo: #b06000;
    --giallo-bg: #fef3e0;
    --raggio: 10px;
    --ombra: 0 1px 3px rgba(16, 30, 54, .08), 0 4px 14px rgba(16, 30, 54, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--grigio-bg);
    color: var(--testo);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--blu); text-decoration: none; }
a:hover { text-decoration: underline; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: -3px; }
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 26px; height: 26px; }

/* ---------- Layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--bianco);
    border-right: 1px solid var(--grigio-bordo);
    color: var(--testo-soft);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 17px 18px 15px; border-bottom: 1px solid var(--grigio-bordo); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: linear-gradient(150deg, #2f80ed, #0b3d91); color: #fff; border-radius: 11px; box-shadow: 0 4px 12px rgba(11, 61, 145, .3); flex-shrink: 0; }
.brand-mark .ico { width: 20px; height: 20px; }
.brand-testo { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 17px; color: var(--testo); }
.brand-sub { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; color: var(--testo-soft); }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; flex: 1; overflow-y: auto; }
.nav-gruppo { font-size: 11px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; color: #9aa4b5; padding: 15px 12px 6px; }
.nav-gruppo:first-child { padding-top: 5px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--testo-soft);
    padding: 9px 12px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 14.5px;
    transition: background .12s ease, color .12s ease;
}
.nav-link .ico { color: #9aa4b5; }
.nav-link:hover { background: var(--grigio-bg); color: var(--testo); text-decoration: none; }
.nav-link:hover .ico { color: var(--testo-soft); }
.nav-link.attivo { background: var(--blu-chiaro); color: var(--blu); font-weight: 700; }
.nav-link.attivo .ico { color: var(--blu); }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--grigio-bordo); }
.sidebar-user .avatar { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(150deg, #2f80ed, #0b3d91); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.su-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.su-nome { font-weight: 700; font-size: 14px; color: var(--testo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-ruolo { font-size: 11px; color: var(--testo-soft); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bianco);
    border-bottom: 1px solid var(--grigio-bordo);
    box-shadow: 0 2px 10px rgba(16, 30, 54, .05);
    padding: 0 22px;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title { font-size: 18px; margin: 0; flex: 1; font-weight: 700; letter-spacing: -.2px; }
.topbar-title::before {
    content: ""; display: inline-block; width: 4px; height: 20px; vertical-align: -3px;
    margin-right: 11px; border-radius: 3px; background: linear-gradient(180deg, #17499f, var(--blu));
}
.topbar-orologio { text-align: right; line-height: 1.2; }
.tb-data { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--testo-soft); }
.tb-ora { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--testo); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.tb-avatar { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(150deg, #2f80ed, #0b3d91); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.tb-user-info { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.tb-user-name { font-weight: 700; font-size: 14px; }
.tb-user-ente { font-size: 11px; color: var(--testo-soft); text-transform: uppercase; letter-spacing: .3px; font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: inline-flex; }

/* Campanella notifiche */
.topbar-bell { position: relative; }
.bell-badge { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: var(--rosso); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px var(--bianco); }
.bell-badge[hidden] { display: none; }
.bell-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 350px; max-width: calc(100vw - 24px); background: var(--bianco); border: 1px solid var(--grigio-bordo); border-radius: 14px; box-shadow: 0 16px 44px rgba(16, 30, 54, .2); z-index: 60; overflow: hidden; animation: modal-in .15s ease; }
.bell-menu[hidden] { display: none; }
.bell-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-weight: 800; border-bottom: 1px solid var(--grigio-bordo); }
.bell-head .ico { width: 17px; height: 17px; color: var(--blu); }
.bell-lista { max-height: 400px; overflow-y: auto; }
.bell-vuoto { padding: 30px 16px; text-align: center; color: var(--testo-soft); }
.bell-item { display: flex; gap: 11px; padding: 12px 15px; border-bottom: 1px solid var(--grigio-bg); }
.bell-item:hover { background: var(--grigio-bg); text-decoration: none; }
.bell-item:last-child { border-bottom: none; }
.bell-item.nuova { background: #f2f7ff; }
.bell-item.nuova:hover { background: #e9f1ff; }
.bell-ico { flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; background: var(--blu-chiaro); color: var(--blu); display: grid; place-items: center; }
.bell-ico .ico { width: 17px; height: 17px; }
.bell-corpo { display: flex; flex-direction: column; min-width: 0; }
.bell-titolo { font-weight: 700; font-size: 13.5px; color: var(--testo); }
.bell-sub { font-size: 12.5px; color: var(--testo-soft); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bell-data { font-size: 11px; color: #9aa4b5; margin-top: 2px; }
/* Hamburger: su desktop comprime/mostra la sidebar */
@media (min-width: 861px) {
    body.nav-aperta .sidebar { display: none; }
}

.content { padding: 24px; max-width: 1440px; width: 100%; }

/* ---------- Card, griglie ---------- */

.card {
    background: var(--bianco);
    border: 1px solid var(--grigio-bordo);
    border-radius: var(--raggio);
    box-shadow: var(--ombra);
    padding: 20px 22px;
    margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--testo-soft); font-size: 13px; margin: 2px 0 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
    background: var(--bianco);
    border: 1px solid var(--grigio-bordo);
    border-radius: var(--raggio);
    box-shadow: var(--ombra);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--blu-chiaro); color: var(--blu); }
.stat-ico .ico { width: 22px; height: 22px; }
.stat-ico.verde { background: var(--verde-bg); color: var(--verde); }
.stat-ico.rosso { background: var(--rosso-bg); color: var(--rosso); }
.stat-ico.giallo { background: var(--giallo-bg); color: var(--giallo); }
.stat-num { font-size: 24px; font-weight: 750; line-height: 1.1; }
.stat-label { color: var(--testo-soft); font-size: 13px; }

/* ---------- Tabelle ---------- */

.table-wrap { overflow-x: auto; }
table.tab { width: 100%; border-collapse: collapse; }
.tab th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--testo-soft);
    padding: 8px 10px;
    border-bottom: 2px solid var(--grigio-bordo);
    white-space: nowrap;
}
.tab td { padding: 11px 10px; border-bottom: 1px solid var(--grigio-bordo); vertical-align: middle; }
.tab tr:last-child td { border-bottom: 0; }
.tab tr:hover td { background: #f8fafd; }
.td-azioni { text-align: right; white-space: nowrap; }
.vuoto { text-align: center; color: var(--testo-soft); padding: 28px 10px !important; }

/* Riordino per trascinamento */
.drag-cell { width: 30px; text-align: center; padding-left: 4px !important; padding-right: 0 !important; }
.drag-handle {
    display: inline-flex; padding: 6px; border-radius: 6px;
    color: var(--testo-soft); cursor: grab; touch-action: none; user-select: none;
}
.drag-handle:hover { background: #eef2f8; }
.drag-handle:active { cursor: grabbing; }
tr.trascinando { background: #eef3fb !important; box-shadow: 0 8px 22px rgba(0, 0, 0, .14); }
tr.trascinando td { background: transparent !important; }

/* ---------- Badge ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 650;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-verde { background: var(--verde-bg); color: var(--verde); }
.badge-rosso { background: var(--rosso-bg); color: var(--rosso); }
.badge-giallo { background: var(--giallo-bg); color: var(--giallo); }
.badge-blu { background: var(--blu-chiaro); color: var(--blu); }
.badge-grigio { background: #eceff4; color: var(--testo-soft); }

.pallino { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pallino.on { background: var(--verde); box-shadow: 0 0 0 3px var(--verde-bg); }
.pallino.off { background: #b9c1cf; }

/* ---------- Form ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 16px; }
.form-grid .campo-full { grid-column: 1 / -1; }
.campo label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 5px; color: var(--testo); }
.campo .hint { font-size: 12px; color: var(--testo-soft); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=date], input[type=datetime-local], input[type=color], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--grigio-bordo);
    border-radius: 8px;
    font: inherit;
    background: var(--bianco);
    color: var(--testo);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blu);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, .12);
}
textarea { min-height: 100px; resize: vertical; }
input[type=color] { padding: 3px; height: 40px; }
input[type=file] { font-size: 14px; }

/* Area di caricamento file (migliora l'input file nativo) — contenuto centrato */
label.filedrop {
    position: relative;
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 9px;
    border: 2px dashed var(--grigio-bordo); border-radius: 12px;
    padding: 22px 18px; background: #fafbff; cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.filedrop:hover, .filedrop.dragover { border-color: var(--blu); background: var(--blu-chiaro); }
.filedrop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.filedrop-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--blu-chiaro); color: var(--blu); display: grid; place-items: center; flex-shrink: 0; }
.filedrop-ico svg { width: 26px; height: 26px; }
.filedrop-testo { min-width: 0; max-width: 100%; display: flex; flex-direction: column; align-items: center; }
.filedrop-titolo { display: block; max-width: 100%; font-weight: 700; font-size: 15px; color: var(--testo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filedrop-titolo b { color: var(--blu); font-weight: 700; }
.filedrop-hint { display: block; font-size: 12.5px; color: var(--testo-soft); margin-top: 3px; }
.filedrop-anteprima { order: -1; width: 62px; height: 62px; border-radius: 12px; object-fit: cover; display: none; box-shadow: 0 2px 8px rgba(16, 30, 54, .22); }
.filedrop.pieno { border-style: solid; border-color: var(--verde); background: var(--verde-bg); }
.filedrop.pieno .filedrop-ico { display: none; }
.form-upload .form-azioni { justify-content: center; }

/* Spinner di caricamento (nei pulsanti) */
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.caricando { pointer-events: none; opacity: .92; }

.check-inline { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; padding-top: 8px; }
.check-inline input { width: 17px; height: 17px; }

/* Checkbox come chip selezionabili (es. tipi di una voce Numeri Utili) */
.check-tipi { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 2px; }
.check-tipi .check-inline {
    padding: 9px 13px; border: 1px solid var(--grigio-bordo); border-radius: 9px;
    background: var(--bianco); cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.check-tipi .check-inline .ico { width: 16px; height: 16px; }
.check-tipi .check-inline:hover { border-color: #b9c6de; }
.check-tipi .check-inline:has(input:checked) { border-color: var(--blu); background: var(--blu-chiaro); color: var(--blu); }

.form-azioni { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.app-footer {
    margin-top: auto;
    padding: 15px 24px;
    border-top: 1px solid var(--grigio-bordo);
    background: var(--bianco);
    color: var(--testo-soft);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    flex-wrap: wrap;
}
.app-footer .footer-right a { font-weight: 700; color: var(--blu); }
.app-footer a:hover { text-decoration: underline; }

/* ---------- Bottoni ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #17499f, var(--blu));
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 9px;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(11, 61, 145, .28);
    transition: transform .12s ease, box-shadow .12s ease, filter .15s ease, background .15s ease;
}
.btn:hover { color: #fff; text-decoration: none; filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 5px 16px rgba(11, 61, 145, .34); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(11, 61, 145, .3); }
.btn-secondario { background: var(--bianco); color: var(--testo); border: 1px solid var(--grigio-bordo); box-shadow: 0 1px 2px rgba(16, 30, 54, .06); }
.btn-secondario:hover { background: var(--grigio-bg); color: var(--testo); filter: none; }
.btn-pericolo { background: linear-gradient(180deg, #e2483d, var(--rosso)); box-shadow: 0 2px 6px rgba(217, 48, 37, .28); }
.btn-pericolo:hover { filter: brightness(1.05); }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--testo-soft);
    cursor: pointer;
    font: inherit;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-icon:hover { background: var(--blu-chiaro); color: var(--blu); border-color: var(--grigio-bordo); }

.azioni-riga { display: inline-flex; gap: 4px; }
.azioni-riga form { display: inline; margin: 0; }

/* ---------- Flash ---------- */

/* Toast (notifiche): in alto a destra, si chiudono da sole */
.flash-wrap { position: fixed; top: 76px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 44px)); pointer-events: none; }
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 13px 14px 13px 15px;
    border-radius: 12px;
    font-weight: 600;
    background: var(--bianco);
    color: var(--testo);
    border: 1px solid var(--grigio-bordo);
    border-left: 4px solid var(--testo-soft);
    box-shadow: 0 12px 30px rgba(16, 30, 54, .16);
    pointer-events: auto;
    animation: toast-in .28s cubic-bezier(.2, .8, .2, 1);
}
.flash::before { content: ""; flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; background: currentColor; -webkit-mask: center/contain no-repeat; mask: center/contain no-repeat; }
.flash-testo { flex: 1; min-width: 0; color: var(--testo); font-weight: 600; }
.flash-chiudi { flex: 0 0 auto; border: none; background: none; color: var(--testo-soft); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.flash-ok { border-left-color: var(--verde); color: var(--verde); }
.flash-ok::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.flash-errore { border-left-color: var(--rosso); color: var(--rosso); }
.flash-errore::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v5M12 16h.01'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v5M12 16h.01'/%3E%3C/svg%3E"); }
.flash-info { border-left-color: var(--blu); color: var(--blu); }
.flash-info::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E"); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.flash.uscita { animation: toast-out .3s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* Modal di conferma (popup) */
.modal-overlay { position: fixed; inset: 0; z-index: 400; background: rgba(16, 30, 54, .5); display: grid; place-items: center; padding: 20px; }
.modal-overlay[hidden] { display: none; }
.modal-box { background: var(--bianco); border-radius: 16px; padding: 26px 26px 22px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); animation: modal-in .2s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-ico { width: 56px; height: 56px; border-radius: 16px; background: var(--rosso-bg); color: var(--rosso); display: grid; place-items: center; margin: 0 auto 14px; }
.modal-ico svg { width: 28px; height: 28px; }
.modal-titolo { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.modal-msg { color: var(--testo-soft); margin: 0 0 20px; }
.modal-azioni { display: flex; gap: 10px; justify-content: center; }

/* Interruttore visibile / non visibile (liste) */
.switch-form { margin: 0; display: inline-flex; }
.switch { width: 44px; height: 25px; border-radius: 20px; border: none; background: #cbd3e0; cursor: pointer; padding: 0; position: relative; transition: background .18s ease; flex: 0 0 auto; }
.switch .switch-dot { position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .18s ease; }
.switch.on { background: var(--verde); }
.switch.on .switch-dot { left: 22px; }

/* Statistiche */
.seg-azioni { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stat-ente-form { margin: 0; }
.stat-ente-form select { min-width: 200px; }

/* Stampa (per salvare le statistiche come PDF dal browser) */
@media print {
    .sidebar, .topbar, .app-footer, .nav-toggle, .seg-azioni, .seg-pills, .modal-overlay, .flash-wrap { display: none !important; }
    .content { max-width: none; padding: 0; }
    .card, .seg-stat, .stat-grafico, .stat-barre { box-shadow: none !important; break-inside: avoid; }
    body { background: #fff; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.stat-grafico { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 10px; }
.stat-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.stat-col-bar { width: 100%; max-width: 24px; background: linear-gradient(180deg, #2f80ed, #0b3d91); border-radius: 5px 5px 0 0; }
.stat-col-lbl { font-size: 10px; color: var(--testo-soft); margin-top: 6px; }
.stat-barre { display: flex; flex-direction: column; gap: 15px; }
.stat-barra-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.stat-barra-nome { font-weight: 600; color: var(--testo); }
.stat-barra-val { font-weight: 800; color: var(--blu); }
.stat-barra-track { height: 10px; background: var(--grigio-bg); border-radius: 6px; overflow: hidden; }
.stat-barra-fill { height: 100%; background: linear-gradient(90deg, #2f80ed, #0b3d91); border-radius: 6px; }
.stat-grafico-ore .stat-col-lbl { font-size: 9px; }
.stat-col.punta .stat-col-bar { background: linear-gradient(180deg, #f2a516, #d97706); }
.stat-col.punta .stat-col-lbl { color: #d97706; font-weight: 800; }

/* ---------- Login ---------- */

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--blu-scuro), var(--blu) 60%, #1a56c4);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bianco);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(4, 16, 45, .4);
    padding: 34px 32px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .brand-mark { background: var(--blu-chiaro); color: var(--blu); width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; }
.login-brand h1 { font-size: 21px; margin: 0; }
.login-sub { color: var(--testo-soft); font-size: 14px; margin: 0 0 22px; }
.login-card .campo { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }

/* ---------- Varie ---------- */

.code-box {
    background: #0f172a;
    color: #d8e3f8;
    font-family: Consolas, monospace;
    font-size: 12.5px;
    border-radius: 8px;
    padding: 14px;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}
.token-mono { font-family: Consolas, monospace; font-size: 12px; color: var(--testo-soft); word-break: break-all; }

/* Tab della scheda ente (Dati / Integrazioni / Raccolta / Totem) */
.tabbar { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--grigio-bordo); margin-bottom: 18px; }
.tabbar button {
    display: inline-flex; align-items: center; gap: 7px;
    border: none; background: none; cursor: pointer;
    padding: 10px 16px; margin-bottom: -2px;
    font: inherit; font-weight: 600; font-size: 14px; color: var(--testo-soft);
    border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0;
}
.tabbar button:hover { color: var(--blu); background: var(--blu-chiaro); }
.tabbar button.attivo { color: var(--blu); border-bottom-color: var(--blu); }
.tabbar button .ico { width: 16px; height: 16px; }

/* PIN del bot: cifre grandi in stile OTP, con i pulsanti a fianco.
   Dimensioni fluide (clamp): identiche sul desktop, si riducono dolcemente se lo
   spazio è poco. Le cifre non vanno MAI a capo: un PIN spezzato è illeggibile. */
.pin-riga { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.pin-cifre { display: flex; gap: clamp(4px, 1.2vw, 8px); flex-wrap: nowrap; }
.pin-cifra {
    flex: 0 0 auto;
    width: clamp(34px, 8vw, 46px);
    height: clamp(44px, 10vw, 58px);
    display: grid;
    place-items: center;
    font-family: Consolas, ui-monospace, monospace;
    font-size: clamp(20px, 4.6vw, 27px);
    font-weight: 700;
    color: var(--blu);
    background: var(--bianco);
    border: 2px solid var(--grigio-bordo);
    border-radius: 10px;
    box-shadow: var(--ombra);
}
.pin-azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.pin-vuoto { display: inline-flex; align-items: center; gap: 8px; color: var(--giallo); background: var(--giallo-bg); border-radius: 8px; padding: 12px 14px; font-weight: 600; font-size: 14px; }

.thumb { width: 52px; height: 38px; object-fit: cover; border-radius: 6px; border: 1px solid var(--grigio-bordo); }
.logo-anteprima { max-height: 46px; max-width: 130px; }

.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.15); vertical-align: -4px; }

.griglia-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .griglia-2 { grid-template-columns: 1fr; } }

/* Galleria evento */
.galleria-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.galleria-item { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--grigio-bordo); aspect-ratio: 3/4; }
.galleria-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galleria-item form { position: absolute; top: 5px; right: 5px; margin: 0; }
.galleria-del { background: rgba(217, 48, 37, .92); color: #fff; width: 30px; height: 30px; }
.galleria-del:hover { background: var(--rosso); color: #fff; }

/* Pulsanti totem (pagina configurazione) */
.slot-pulsante {
    border: 1px solid var(--grigio-bordo);
    border-radius: var(--raggio);
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fafbfe;
}
.slot-testata { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 12px; }
.slot-num {
    width: 26px; height: 26px;
    background: var(--blu);
    color: #fff;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: -270px;
        transition: left .25s ease;
        z-index: 50;
        box-shadow: 0 0 40px rgba(16, 30, 54, .22);
    }
    body.nav-aperta .sidebar { left: 0; }
    .nav-toggle { display: inline-flex; font-size: 19px; }
    .content { padding: 16px; }
}
@media (max-width: 620px) {
    .topbar-orologio, .tb-user-info { display: none; }
    .topbar { gap: 10px; padding: 0 14px; }
}

/* Tabelle: su tablet e smartphone si impilano in verticale (niente scroll orizzontale) */
@media (max-width: 900px) {
    .table-wrap { overflow-x: visible; }
    .tab thead { display: none; }
    .tab, .tab tbody { display: block; width: 100%; }
    .tab tr {
        display: block;
        background: #fff;
        border: 1px solid var(--grigio-bordo);
        border-radius: 12px;
        padding: 4px 14px;
        margin-bottom: 12px;
    }
    .tab tr:hover td { background: transparent; }
    .tab td {
        display: block;
        padding: 9px 0;
        border-bottom: 1px solid var(--grigio-bordo);
        text-align: left;
        white-space: normal;
    }
    .tab tr td:last-child { border-bottom: 0; }
    .tab td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .4px;
        color: var(--testo-soft);
        margin-bottom: 4px;
    }
    .td-azioni { text-align: left; }
    .td-azioni .azioni-riga { justify-content: flex-start; }
    .tab td.vuoto { text-align: center; }
    .tab td.drag-cell { display: none; } /* su mobile l'ordine si imposta dal campo "Ordine" */
}

/* ============ Anteprima totem (riquadro con chiusura) ============ */

body.no-scroll { overflow: hidden; }

.preview-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(15, 23, 42, .86);
    display: flex; flex-direction: column;
    backdrop-filter: blur(2px);
}
.preview-overlay[hidden] { display: none; }

.preview-barra {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; background: #0f172a; color: #fff; flex-wrap: wrap; flex-shrink: 0;
}
.preview-tit { font-weight: 700; font-size: 15px; }
.preview-azioni { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.preview-orient { display: inline-flex; background: rgba(255, 255, 255, .12); border-radius: 8px; padding: 3px; gap: 3px; }
.preview-orient button {
    background: transparent; border: none; color: #cbd5e1; font: inherit; font-weight: 700;
    padding: 6px 13px; border-radius: 6px; cursor: pointer;
}
.preview-orient button.attivo { background: #fff; color: #0f172a; }
.preview-chiudi { background: #ef4444; }

.preview-palco { flex: 1; display: flex; align-items: center; justify-content: center; padding: 18px; min-height: 0; }
.preview-telaio {
    background: #000; border-radius: 18px; overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55); border: 6px solid #0f172a;
}
.preview-telaio.verticale { width: min(100%, calc(84vh * 9 / 16)); aspect-ratio: 9 / 16; }
.preview-telaio.orizzontale { width: min(100%, calc(80vh * 16 / 9)); aspect-ratio: 16 / 9; }
.preview-frame { width: 100%; height: 100%; border: 0; display: block; background: #000; }

@media (max-width: 620px) {
    .preview-tit { display: none; }
    .preview-telaio { border-width: 4px; border-radius: 14px; }
}

/* ============ Bot Telegram ============ */

.tg-box {
    margin: 4px 0 4px; padding: 16px; border: 1px solid var(--grigio-bordo);
    border-radius: 12px; background: #f2f9fd;
}
.tg-box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tg-box-tit { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; color: #0f6ca8; }
.tg-box-tit .ico { color: #229ed9; }
.tg-pin-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tg-pin-box { display: flex; flex-direction: column; gap: 2px; }
.tg-pin {
    font-family: ui-monospace, monospace; font-size: 26px; font-weight: 800; letter-spacing: 4px;
    color: var(--blu); background: #fff; border: 1px solid var(--grigio-bordo);
    border-radius: 10px; padding: 6px 16px;
}
.tg-flag { color: #229ed9; vertical-align: middle; margin-left: 4px; }
.tg-flag .ico { width: 16px; height: 16px; }
.tg-log-tit { font-weight: 800; color: var(--testo-soft); margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tg-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tg-log li { font-size: 13.5px; color: var(--testo); border-left: 3px solid #cfe4f2; padding: 2px 0 2px 10px; line-height: 1.4; }
.tg-log-quando { color: var(--testo-soft); font-variant-numeric: tabular-nums; }
.ticket-foto { display: inline-block; margin-top: 8px; }
.ticket-foto img { max-height: 130px; max-width: 220px; border-radius: 10px; border: 1px solid var(--grigio-bordo); object-fit: cover; display: block; }

/* ============ Segnalazioni & Tickets ============ */

.seg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.seg-title { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -.5px; }
.seg-title span { color: var(--blu); }
.seg-sub { color: var(--testo-soft); margin: 3px 0 0; font-size: 14px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 12px; }

.seg-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.seg-stat { border-radius: 16px; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; min-height: 118px; }
a.seg-stat { text-decoration: none; transition: transform .12s ease, box-shadow .12s ease; }
a.seg-stat:hover { text-decoration: none; transform: translateY(-2px); filter: brightness(1.02); }
.seg-stat-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.seg-stat-ico .ico { width: 18px; height: 18px; }
.seg-stat-num { font-size: 40px; font-weight: 800; line-height: 1; margin-top: auto; }
.seg-stat-lbl { text-transform: uppercase; font-size: 12px; letter-spacing: .8px; font-weight: 700; }
.seg-stat-totale { background: linear-gradient(150deg, #2f80ed, #0b3d91); color: #fff; box-shadow: 0 12px 26px rgba(11, 61, 145, .28); }
.seg-stat-totale .seg-stat-ico { background: rgba(255, 255, 255, .2); color: #fff; }
.seg-stat-totale .seg-stat-lbl { color: rgba(255, 255, 255, .85); }
.seg-stat-nuovi { background: linear-gradient(150deg, #eaf3ff, #d6e8ff); color: #14549f; }
.seg-stat-nuovi .seg-stat-ico { background: rgba(20, 84, 159, .14); color: #14549f; }
.seg-stat-nuovi .seg-stat-lbl { color: #4a6b96; }
.seg-stat-revisione { background: linear-gradient(150deg, #fff6e0, #ffeec2); color: #9a6a00; }
.seg-stat-revisione .seg-stat-ico { background: rgba(154, 106, 0, .14); color: #9a6a00; }
.seg-stat-revisione .seg-stat-lbl { color: #a9803a; }
.seg-stat-risolti { background: linear-gradient(150deg, #e3f7ec, #ccf0da); color: #0f7a45; }
.seg-stat-risolti .seg-stat-ico { background: rgba(15, 122, 69, .14); color: #0f7a45; }
.seg-stat-risolti .seg-stat-lbl { color: #3f8a63; }

.seg-toolbar { display: flex; flex-direction: column; gap: 14px; }
.seg-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.seg-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--grigio-bordo); background: var(--bianco); color: var(--testo-soft); padding: 8px 14px; border-radius: 22px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; transition: all .15s ease; }
.seg-pill:hover { border-color: #b9c6de; }
.seg-pill-n { background: var(--grigio-bg); color: var(--testo-soft); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.seg-pill.p-viola { color: #6d4bd8; } .seg-pill.p-viola .seg-pill-n { background: #efeafb; color: #6d4bd8; }
.seg-pill.p-blu { color: #2f80ed; } .seg-pill.p-blu .seg-pill-n { background: #e7f0ff; color: #2f80ed; }
.seg-pill.p-giallo { color: #b8860b; } .seg-pill.p-giallo .seg-pill-n { background: #fdf1d6; color: #b8860b; }
.seg-pill.p-verde { color: #0f9d58; } .seg-pill.p-verde .seg-pill-n { background: #e2f6ea; color: #0f9d58; }
.seg-pill.p-rosso { color: #e5533c; } .seg-pill.p-rosso .seg-pill-n { background: #fdece8; color: #e5533c; }
.seg-pill.attivo { background: var(--blu); color: #fff; border-color: var(--blu); box-shadow: 0 3px 10px rgba(11, 61, 145, .25); }
.seg-pill.p-viola.attivo { background: #6d4bd8; border-color: #6d4bd8; color: #fff; }
.seg-pill.p-blu.attivo { background: #2f80ed; border-color: #2f80ed; color: #fff; }
.seg-pill.p-giallo.attivo { background: #e0a100; border-color: #e0a100; color: #fff; }
.seg-pill.p-verde.attivo { background: #0f9d58; border-color: #0f9d58; color: #fff; }
.seg-pill.p-rosso.attivo { background: #e5533c; border-color: #e5533c; color: #fff; }
.seg-pill.attivo .seg-pill-n { background: rgba(255, 255, 255, .28); color: #fff; }

.seg-cerca { position: relative; display: flex; gap: 12px; }
.seg-cerca-ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--testo-soft); pointer-events: none; display: flex; }
.seg-cerca-ico .ico { width: 18px; height: 18px; }
.seg-cerca input { flex: 1; padding-left: 42px; }
.seg-cerca select { flex: 0 0 auto; width: auto; min-width: 190px; }

.seg-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.ticket-card { background: var(--bianco); border: 1px solid var(--grigio-bordo); border-left: 4px solid var(--grigio-bordo); border-radius: 14px; box-shadow: var(--ombra); padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ticket-card.stato-nuovo { border-left-color: #2f80ed; }
.ticket-card.stato-in_revisione { border-left-color: #e0a100; }
.ticket-card.stato-risolto { border-left-color: #0f9d58; }
.ticket-card.stato-non_risolto { border-left-color: #e5533c; }
.ticket-body { min-width: 0; flex: 1; }
.ticket-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 7px; }
.badge-stato { font-size: 12px; font-weight: 700; padding: 3px 11px; border-radius: 20px; }
.s-nuovo { background: #e7f0ff; color: #2f80ed; }
.s-in_revisione { background: #fdf1d6; color: #b8860b; }
.s-risolto { background: #e2f6ea; color: #0f9d58; }
.s-non_risolto { background: #fdece8; color: #e5533c; }
.chip-cat { font-size: 12px; font-weight: 600; color: var(--testo-soft); background: var(--grigio-bg); padding: 3px 10px; border-radius: 20px; }
.chip-prio { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 2px 8px; border-radius: 6px; }
.prio-bassa { background: #eef1f6; color: #6b7280; }
.prio-media { background: #e7f0ff; color: #2f6fd0; }
.prio-alta { background: #fdece8; color: #e5533c; }
.ticket-ente { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--testo-soft); }
.ticket-ente .ico { width: 14px; height: 14px; }
.ticket-data { font-size: 12px; color: var(--testo-soft); margin-left: auto; }
.ticket-titolo { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.ticket-desc { color: var(--testo-soft); font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ticket-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.ticket-stato-form { margin: 0; }
.ticket-actions .js-stato { padding: 8px 10px; border-radius: 8px; font-size: 13px; width: 138px; }

.seg-empty { text-align: center; padding: 50px 20px; color: var(--testo-soft); }
.seg-empty-ico { display: inline-grid; place-items: center; width: 70px; height: 70px; border-radius: 18px; background: linear-gradient(150deg, #2f80ed, #0b3d91); color: #fff; margin-bottom: 14px; box-shadow: 0 10px 22px rgba(11, 61, 145, .28); }
.seg-empty-ico .ico { width: 32px; height: 32px; }
.seg-empty h3 { font-size: 20px; font-weight: 800; color: var(--testo); margin: 0 0 6px; }
.seg-empty p { margin: 0 0 16px; }

@media (max-width: 900px) { .seg-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) {
    .ticket-card { flex-direction: column; align-items: stretch; }
    .ticket-actions { justify-content: flex-end; }
    .ticket-data { margin-left: 0; }
    .seg-cerca { flex-direction: column; }
    .seg-cerca-ico { top: 11px; transform: none; }
    .seg-cerca select { min-width: 0; }
}
