/* ==========================================
   Palette Colori
   ========================================== */
:root {
    --color-primary: #0077CC;
    --color-primary-dark: #005FA3;
    --color-sidebar: #004F8A;
    --color-accent: #7DD4FF;
    --color-bg: #F5F7FA;
    --color-row-alt: #F0F7FF;

    --color-view-bg: #E8F4FF;
    --color-view-text: #0055A0;
    --color-view-border: #B3D4F5;

    --color-edit-bg: #F0F8E8;
    --color-edit-text: #3A7D0A;
    --color-edit-border: #B8DCA0;

    --color-delete-bg: #FFF0F0;
    --color-delete-text: #C0392B;
    --color-delete-border: #F5B8B8;
    --color-delete-hover: #FFDDDD;

    --color-error: #e74c3c;
    --color-error-light: #fdf0ef;
    --color-error-border: #f5b8b3;

    --color-cancel: #fff;
    --color-cancel-text: #363636;
    --color-cancel-hover: #fff;
    --color-cancel-border: #dbdbdb;
}

/* ==========================================
   Scrollbar globale
   ========================================== */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 119, 204, 0.35) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: rgba(0, 119, 204, 0.35);
    border-radius: 6px;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 119, 204, 0.55);
}

/* ==========================================
   Validazione campi
   ========================================== */
.inp.campo-errore {
    border-color: var(--color-error) !important;
}

.campo-msg-errore {
    color: var(--color-error);
    font-style: italic;
    font-size: 12px;
    margin-top: 2px;
}

/* ==========================================
   Font Faces
   ========================================== */
@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/Inter-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/InterDisplay-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/Inter-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/jetbrainsmono/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0030-0039;
}


/* ==========================================
   Typography
   ========================================== */
body,
.button,
input,
select,
textarea,
.label,
.navbar,
.menu {
    font-family: 'JetBrains Mono', 'Inter', sans-serif;
}

body,
p {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.65;
}

body {
    background-color: var(--color-bg);
}

h1,
.title.is-1 {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.25;
}

h2,
.title.is-2 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
}

h3,
.title.is-3 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
}

h4,
.title.is-4 {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.subtitle {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    color: #6B7280;
}

.table td,
.table th {
    font-size: 13px;
}

.help {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
}

.is-numeric {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

/* ==========================================
   Bottoni CRUD
   ========================================== */
.button {
    font-size: 13px;
    padding: 0 14px;
    height: 34px;
}

.button.is-create {
    background: var(--color-sidebar);
    color: #fff;
    border: none;
}

.button.is-create:hover {
    background: var(--color-primary-dark);
}

.button.is-create img {
    filter: brightness(0) invert(1);
}

.button.is-view {
    background: var(--color-view-bg);
    color: var(--color-view-text);
    border: 1px solid var(--color-view-border);
}

.button.is-edit {
    background: var(--color-edit-bg);
    color: var(--color-edit-text);
    border: 1px solid var(--color-edit-border);
}

.button.is-edit:hover {
    background: var(--color-edit-border);
    color: var(--color-edit-text);
    border-color: var(--color-edit-border);
}

.button.is-delete {
    background: var(--color-delete-bg);
    color: var(--color-delete-text);
    border: 1px solid var(--color-delete-border);
}

.button.is-delete:hover {
    background: var(--color-delete-hover);
}

.button.is-cancel {
    background-color: var(--color-cancel);
    color: var(--color-cancel-text);
    border: 1px solid var(--color-cancel-border);
}

.button.is-cancel:hover {
    background-color: #f5f5f5;
    border-color: #b5b5b5;
}

.button.is-cancel img {
    filter: none;
}

/* ==========================================
   Badge
   ========================================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: var(--color-edit-bg);
    color: var(--color-edit-text);
    border: 1px solid var(--color-edit-border);
}

.badge-danger {
    background: var(--color-delete-bg);
    color: var(--color-delete-text);
    border: 1px solid var(--color-delete-border);
}

.badge-neutral {
    background: #F3F4F6;
    color: #6B7280;
    border: 1px solid #D1D5DB;
}

.badge-warning {
    background: #FFF7E6;
    color: #B7791F;
    border: 1px solid #F5D89E;
}

/* ==========================================
   Avatar persona (iniziali colorate o foto)
   ========================================== */
.cella-persona {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.avatar-persona {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.avatar-iniziali {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}


/* ==========================================
   Form — campo wrapper + label
   ========================================== */
.campo {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 0;
}

.campo-label {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    line-height: 1.4;
}

.req-star {
    color: var(--color-delete-text);
}

/* ==========================================
   Input — stile A (base): 32px · bordo 1px · radius 2
   ========================================== */
.inp {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 2px;
    background: #fff;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: #111827;
    width: 100%;
    box-shadow: none;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.inp::placeholder {
    color: #9CA3AF;
}

.inp:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
}

.inp:disabled {
    background: #f9fafb;
    color: #9CA3AF;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.inp.is-error {
    border-color: var(--color-delete-text);
}

.inp.is-error:focus {
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

.help.is-error {
    color: var(--color-delete-text);
}

/* Select — freccia custom */
select.inp {
    cursor: pointer;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* Textarea */
textarea.inp {
    height: auto;
    padding: 8px 10px;
    resize: vertical;
}

/* ── Varianti ── */

/* sm — E: 28px · ultra compatto */
.inp.is-sm {
    height: 28px;
    font-size: 12px;
    padding: 0 8px;
}

/* lg — D: 38px · SaaS moderno */
.inp.is-lg {
    height: 38px;
    font-size: 14px;
    padding: 0 12px;
    border-radius: 5px;
    border-width: 1.5px;
}

/* Campo con icona sinistra */
.campo-icona-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.campo-icona-wrapper .inp {
    padding-left: 34px;
}

.campo-icona-sx {
    position: absolute;
    left: 10px;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.campo-icona-sx img {
    filter: brightness(0) opacity(0.35);
}

/* ==========================================
   Spinner bottoni
   ========================================== */
.spinner {
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
    flex-shrink: 0;
}

.spinner.is-dark {
    border-color: rgba(0, 119, 204, 0.2);
    border-top-color: var(--color-primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   Layout generale
   ========================================== */
.app-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

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

.app-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* ==========================================
   Navbar
   ========================================== */
.app-navbar {
    height: 62px;
    background: var(--color-sidebar);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
}

.app-navbar-sinistra {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-burger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: 4px;
    transition: background 0.15s;
}

.sidebar-burger:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-burger img {
    filter: brightness(0) invert(1);
    display: block;
}

.sidebar-livello-1 {
    padding-left: 1rem !important;
}

.sidebar-livello-2 {
    padding-left: 2rem !important;
}

.sidebar-subgenitore {
    text-transform: none;
}

.app-navbar-destra {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.navbar-notifiche {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: 4px;
    margin-right: 4px;
    transition: background 0.15s;
}

.navbar-notifiche:hover {
    background: rgba(255, 255, 255, 0.15);
}

.navbar-notifiche img {
    filter: brightness(0) invert(1);
    display: block;
}

.navbar-notifiche-wrapper {
    position: relative;
}

.notifiche-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

.notifiche-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
    overflow: hidden;
}

.notifiche-dropdown.is-open {
    display: block;
}

.notifiche-dropdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #efefef;
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.notifiche-segna-lette {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11.5px;
    color: #3273dc;
    padding: 0;
}

.notifiche-segna-lette:hover {
    text-decoration: underline;
}

.notifiche-lista {
    max-height: 380px;
    overflow-y: auto;
}

.notifiche-vuoto {
    padding: 18px 14px;
    text-align: center;
    color: #999;
    font-size: 12.5px;
}

.notifiche-item {
    padding: 10px 14px 10px 11px;
    border-bottom: 1px solid #f3f3f3;
    border-left: 3px solid #3298dc;
}

.notifiche-item:last-child {
    border-bottom: none;
}

.notifiche-item.is-warning {
    border-left-color: #ffdd57;
}

.notifiche-item.is-danger {
    border-left-color: #e74c3c;
}

.notifiche-item.is-success {
    border-left-color: #27ae60;
}

.notifiche-item.is-letta {
    opacity: 0.55;
}

.notifiche-item.is-cliccabile {
    cursor: pointer;
}

.notifiche-item.is-cliccabile:hover {
    background: #fafafa;
}

.notifiche-item-titolo {
    font-size: 12.5px;
    font-weight: 600;
    color: #333;
    margin: 0 0 2px;
}

.notifiche-item-testo {
    font-size: 12px;
    color: #666;
    margin: 0;
    line-height: 1.45;
}

.navbar-utente {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.navbar-nome {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
    min-width: 80px;
}

.navbar-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.25);
    margin: 0 12px;
}

.navbar-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 4px;
    color: #fff;
    transition: background 0.15s;
    font-size: 13px;
    font-weight: 500;
}

.navbar-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.navbar-logout img {
    filter: brightness(0) invert(1);
    display: block;
}

/* ==========================================
   Sidebar
   ========================================== */
.sidebar {
    width: 210px;
    background: linear-gradient(180deg, var(--color-sidebar) 0%, #5a9fd4 100%);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.25);
    border-radius: 6px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.45);
}

.sidebar.is-collapsed {
    width: 52px;
}

.sidebar.is-collapsed .sidebar-label-testo,
.sidebar.is-collapsed .sidebar-freccia,
.sidebar.is-collapsed .sidebar-figli {
    display: none !important;
}

.sidebar.is-collapsed .sidebar-logo img {
    display: none;
}

.sidebar.is-collapsed .sidebar-logo {
    height: 62px;
    padding: 0;
    justify-content: center;
}

.sidebar.is-collapsed .sidebar-genitore {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.is-collapsed .sidebar-genitore-label {
    justify-content: center;
}

.sidebar-logo {
    padding: 16px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-logo img {
    max-height: 72px;
    width: auto;
}


.sidebar .menu {
    padding: 12px 0;
    flex: 1;
}

.sidebar .menu-list {
    margin: 0;
}

.sidebar .menu-list a.sidebar-genitore {
    border-left: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}

.sidebar .menu-list a.sidebar-genitore:hover {
    color: #000;
    background-color: rgba(255, 255, 255, 0.9);
}

.sidebar .menu-list a.sidebar-genitore:hover .sidebar-icona {
    filter: brightness(0) invert(0) opacity(0.8);
}

.sidebar-genitore-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-freccia {
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-right: 2px;
}

.sidebar-genitore.is-open .sidebar-freccia {
    transform: rotate(45deg);
}

.sidebar-item,
.sidebar-genitore {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.sidebar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-star {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
    /* bianco */
    transition: filter 0.2s ease;
}

.sidebar-item:hover .sidebar-star,
.sidebar-genitore:hover .sidebar-star {
    filter: brightness(0) invert(0);
    /* nero */
}

.sidebar-figli {
    display: none;
    margin: 0 !important;
    padding-bottom: 4px;
    padding-left: 5px;
    border-left: none !important;
}

.sidebar .menu-list .sidebar-figli a {
    color: #fff;
    padding: 8px 16px 8px 28px;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
    text-transform: none;
}

.sidebar .menu-list .sidebar-figli a:hover {
    background-color: rgba(255, 255, 255, 0.9);
    color: #000;
}

.sidebar .menu-list .sidebar-figli a:hover .sidebar-icona {
    filter: brightness(0) invert(0) opacity(0.8);
}

.sidebar .menu-list .sidebar-figli a.is-active {
    background-color: var(--color-primary);
    color: #fff;
    font-weight: 500;
}

.sidebar-icona {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    filter: brightness(0) invert(1) opacity(0.7);
}

.sidebar-figli a.is-active .sidebar-icona,
.sidebar-figli a:hover .sidebar-icona {
    filter: brightness(0) invert(1) opacity(1);
}

/* ==========================================
   Sidebar Footer
   ========================================== */
.sidebar-preferiti {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 0 4px;
}

/* LABEL */
.sidebar-preferiti-label {
    display: flex;
    align-items: center;
    gap: 6px;
    /* più compatto */

    padding: 6px 16px;

    color: #ffd86b;
    /* oro più acceso */
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;

    opacity: 0.95;
    user-select: none;
}

/* LISTA */
.sidebar-preferiti-lista {
    list-style: none;
    margin: 0;
    padding: 0;
    min-height: 28px;
}

/* ITEM */
.sidebar-preferiti-lista .sidebar-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    padding: 6px 16px;
    color: #ffd86b;
    font-size: 13px;
    border-radius: 6px;
}

/* LEFT: icona + testo più vicini */
.sidebar-preferiti-lista .sidebar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    /* ridotto */
}

/* HOVER */
.sidebar-preferiti-lista .sidebar-item:hover {
    background: rgba(255, 216, 107, 0.10);
    color: #ffe08a;
}

/* ICONA */
.sidebar-preferiti-lista .sidebar-icona {
    opacity: 1;
}

/* STAR */
.sidebar-preferiti-lista .sidebar-star {
    width: 16px;
    height: 16px;

    filter: none;
    opacity: 1;

    transition: transform 0.15s ease;
}

/* ACTIVE STAR */
.sidebar-preferiti-lista .sidebar-star.is-active {
    transform: scale(1.08);
    filter: drop-shadow(0 0 3px rgba(255, 216, 107, 0.9));
}

/* COLLAPSED */
.sidebar.is-collapsed .sidebar-preferiti {
    display: none;
}

.sidebar-preferiti-label .sidebar-icona,
.sidebar-preferiti-lista .sidebar-icona {
    filter: brightness(0) saturate(100%) invert(78%) sepia(45%) saturate(500%) hue-rotate(8deg) brightness(105%) contrast(95%);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 10px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.sidebar-footer-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    position: relative;
}

.sidebar-footer-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-footer-btn img {
    width: 18px;
    height: 18px;
    display: block;
    filter: brightness(0) invert(1) opacity(0.7);
    transition: opacity 0.15s;
}

.sidebar-footer-btn:hover img {
    opacity: 1;
    filter: brightness(0) invert(1) opacity(1);
}

.sidebar.is-collapsed .sidebar-footer {
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

/* ==========================================
   Modal Card — base globale
   ========================================== */
.modal-card {
    border-radius: 8px;
    overflow: hidden;
    width: 580px;
    max-width: calc(100vw - 40px);
}

.modal-card-head {
    background: #fff !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 16px 20px !important;
    display: flex;
    align-items: center;
}

.modal-card-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1f2937;
}

.modal-card-body {
    padding: 20px !important;
    overflow-y: auto;
}

.modal-card-foot {
    background: #f9fafb !important;
    border-top: 1px solid #e5e7eb !important;
    padding: 12px 20px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
}

/* ==========================================
   Modale Cerca
   ========================================== */
#modale-report-bug,
#modale-impostazioni-utente,
#modale-cerca {
    z-index: 200;
}

#modale-report-bug .modal-background,
#modale-impostazioni-utente .modal-background,
#modale-cerca .modal-background {
    z-index: 200;
}

#modale-report-bug .modal-card,
#modale-impostazioni-utente .modal-card,
.modale-cerca-card {
    z-index: 201;
}

.modale-cerca-card {
    position: fixed;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    max-width: 560px;
    z-index: 201;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

#modale-cerca .modal-card-head {
    gap: 10px;
}

.modale-cerca-icona {
    filter: brightness(0) opacity(0.35);
    flex-shrink: 0;
}

.modale-cerca-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: #111;
    background: transparent;
}

.modale-cerca-input::placeholder {
    color: #9ca3af;
}

.modale-cerca-body {
    padding: 0 !important;
}

.modale-cerca-lista {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: 360px;
    overflow-y: auto;
}

.cerca-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.12s;
}

.cerca-item:hover {
    background: var(--color-row-alt);
}

.cerca-genitore {
    color: #6b7280;
    font-size: 13px;
}

.cerca-separatore {
    color: #d1d5db;
    font-size: 13px;
}

.cerca-figlio {
    color: #111827;
    font-weight: 500;
}

.modale-cerca-vuoto {
    padding: 20px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
}

/* ==========================================
   Modale Elimina
   ========================================== */
#modale-elimina {
    z-index: 200;
}

#modale-elimina .modal-card,
#modale-anomalia-prezzo .modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    min-width: unset;
    max-width: unset;
    max-height: unset;
    height: auto;
}

#modale-elimina .modal-card {
    /* height fissa in % di viewport: su finestre basse tagliava testo/pulsanti.
       Il contenuto e' breve (conferma eliminazione): lascialo dimensionare da solo. */
    height: auto;
}

#modale-stampa-ubicazioni .modal-card {
    width: min(420px, 92vw);
    min-width: unset;
    max-width: unset;
    max-height: unset;
    height: auto;
    overflow: visible;
}

#modale-stampa-ubicazioni .modal-card-body {
    overflow: visible;
}


/* ==========================================
   Avatar Upload
   ========================================== */
.avatar-upload-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

.avatar-upload-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 2px solid #e5e7eb;
    flex-shrink: 0;
}

.avatar-upload-circle img:first-child {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.avatar-upload-overlay img {
    filter: brightness(0) invert(1);
}

.avatar-upload-circle:hover .avatar-upload-overlay {
    opacity: 1;
}

/* ==========================================
   Loader overlay
   ========================================== */
.loader-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.loader-overlay.is-active {
    display: flex;
}

.app-loader {
    --d: 90px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: var(--color-primary);
    box-shadow:
        calc(1*var(--d)) calc(0*var(--d)) 0 0,
        calc(0.707*var(--d)) calc(0.707*var(--d)) 0 1px,
        calc(0*var(--d)) calc(1*var(--d)) 0 2px,
        calc(-0.707*var(--d)) calc(0.707*var(--d)) 0 3px,
        calc(-1*var(--d)) calc(0*var(--d)) 0 4px,
        calc(-0.707*var(--d)) calc(-0.707*var(--d)) 0 5px,
        calc(0*var(--d)) calc(-1*var(--d)) 0 6px;
    animation: l27 1s infinite steps(8);
}

@keyframes l27 {
    100% {
        transform: rotate(1turn);
    }
}

/* ==========================================
   Dashboard — Home
   ========================================== */
.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.home-filtri {
    display: flex;
    align-items: center;
    gap: 10px;
}

.home-periodo {
    display: inline-flex;
    position: relative;
    padding: 4px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.home-periodo .chip-pill {
    position: absolute;
    top: 4px;
    height: calc(100% - 8px);
    border-radius: 16px;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    background: #0077CC;
    border: none;
    transition:
        left 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
        width 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
        opacity 0.18s ease;
}

.home-periodo-btn {
    font-size: 12px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: #4B5563;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    font-family: 'Inter', sans-serif;
    transition: color 0.2s ease;
}

.home-periodo-btn:hover {
    color: var(--color-primary);
}

.home-periodo-btn:active {
    transform: scale(0.96);
    transition-duration: 0.08s;
}

.home-periodo-btn.is-active {
    color: #fff;
    font-weight: 600;
}

.home-personalizza-wrapper {
    position: relative;
}

#btn-personalizza {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
}

#btn-personalizza img {
    filter: brightness(0) opacity(0.5);
}

#btn-personalizza:hover img {
    filter: brightness(0) opacity(0.8);
}

.home-personalizza-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 50;
    padding: 8px 0;
}

.home-personalizza-dropdown.is-open {
    display: block;
}

.home-personalizza-titolo {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9CA3AF;
    padding: 4px 14px 8px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
}

.home-personalizza-voce {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    transition: background 0.12s;
}

.home-personalizza-voce:hover {
    background: var(--color-row-alt);
}

.home-personalizza-voce input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--color-primary);
    flex-shrink: 0;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: box-shadow 0.15s;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.kpi-card.is-hidden {
    display: none;
}

.kpi-card.kpi-card-link {
    cursor: pointer;
}

.kpi-card.kpi-card-link:hover {
    box-shadow: 0 4px 12px rgba(0, 119, 204, 0.15);
    border-color: var(--color-primary);
}

.kpi-icona {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--color-row-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icona img {
    filter: invert(22%) sepia(90%) saturate(600%) hue-rotate(195deg) brightness(0.9);
}

.kpi-corpo {
    flex: 1;
    min-width: 0;
}

.kpi-titolo {
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-valore {
    font-size: 26px;
    font-weight: 400;
    color: #111827;
    line-height: 1.1;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 4px;
}

.kpi-sotto {
    font-size: 11px;
    color: #9CA3AF;
}

.home-sezioni {
    display: flex;
    gap: 16px;
}

.home-sezione {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.home-sezione-grande {
    flex: 3;
}

.home-sezione-piccola {
    flex: 2;
}

.home-sezione-meta {
    flex: 1;
}

.home-sezione-titolo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.home-sezione-titolo img {
    filter: brightness(0) opacity(0.4);
}

.home-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    color: #9CA3AF;
    font-size: 13px;
    font-style: italic;
    border: 2px dashed #e5e7eb;
    border-radius: 6px;
}

.home-placeholder-lg {
    min-height: 220px;
}

.home-placeholder-lista {
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.home-lista-vuota {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    font-size: 13px;
    font-style: italic;
    border: 2px dashed #e5e7eb;
    border-radius: 6px;
    min-height: 120px;
}

/* ==========================================
   Sidebar overlay (mobile)
   ========================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
    backdrop-filter: blur(1px);
}

.sidebar-overlay.is-active {
    display: block;
}

/* ==========================================
   ICONA ORDINAMENTO
   ========================================== */

.sort-icona {
    width: 10px;
    height: 10px;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
    filter: brightness(0) invert(1);

    opacity: 0.2;

    transition:
        transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease,
        filter 0.2s ease;
}

.col-header-top:hover .sort-icona {
    opacity: 0.5;
}

.sort-icona.active {
    opacity: 1 !important;
    filter: grayscale(0%) brightness(1.2) invert(1);
}

.sort-icona.desc {
    transform: rotate(180deg);
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #modale-elimina .modal-card {
        width: 50%;
        height: auto;
    }
}

@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -230px;
        z-index: 100;
        height: 100dvh;
        width: 220px;
        transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.is-open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.22);
    }

    /* disabilita il collasso desktop su mobile */
    .sidebar.is-collapsed {
        width: 220px;
        left: -230px;
    }

    .sidebar.is-collapsed.is-open {
        left: 0;
    }

    .sidebar.is-collapsed .sidebar-label-testo,
    .sidebar.is-collapsed .sidebar-freccia {
        display: unset !important;
    }

    .sidebar.is-collapsed .sidebar-figli {
        display: unset;
    }

    .sidebar.is-collapsed .sidebar-logo img {
        display: unset;
    }

    .sidebar.is-collapsed .sidebar-logo {
        height: auto;
        padding: 16px 8px;
        justify-content: center;
    }

    .sidebar.is-collapsed .sidebar-genitore {
        justify-content: space-between;
        padding: 9px 16px;
    }

    .sidebar.is-collapsed .sidebar-genitore-label {
        justify-content: flex-start;
    }

    .app-content {
        padding: 20px;
    }

    .navbar-nome {
        display: none;
    }
}

/* ─── Smart Search ─────────────────────────────────────────────────────────── */
.smart-search {
    position: relative;
}

.ss-dropdown {
    display: none;
    background: #fff;
    border: 1px solid #dce1e7;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 290px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.09);
    width: 100%;
}

.ss-item {
    padding: 7px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.1s;
}

.ss-item:last-child {
    border-bottom: none;
}

.ss-item:hover,
.ss-item.is-focused {
    background: #f0f6ff;
}

.ss-item.is-bloccato {
    cursor: not-allowed;
    background: #fafafa;
    opacity: 0.6;
}

.ss-r1 {
    font-size: 0.875rem;
    color: #1a1a1a;
    line-height: 1.35;
}

.ss-r2 {
    font-size: 0.72rem;
    color: #999;
    margin-top: 2px;
}

.ss-lock {
    font-size: 0.7rem;
}

.ss-empty {
    padding: 12px;
    text-align: center;
    font-size: 0.875rem;
    color: #888;
}

.ss-add-new {
    background: none;
    border: 1px dashed #0077CC;
    color: #0077CC;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}

.ss-add-new:hover {
    background: #f0f6ff;
}

.ss-more {
    display: block;
    width: 100%;
    padding: 7px;
    background: #f5f7fa;
    border: none;
    border-top: 1px solid #e8ecf0;
    color: #0077CC;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
}

.ss-more:hover {
    background: #e8f0fb;
}

@media (max-width: 767px) {
    .app-content {
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .home-sezioni {
        flex-direction: column;
    }

    .home-periodo-btn {
        padding: 6px 10px;
    }

    #modale-elimina .modal-card {
        width: 90%;
        height: auto;
    }
}

.export-dropdown-wrapper {
    position: relative;
}

.export-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
    z-index: 200;
    min-width: 120px;
    padding: 4px 0;
}

.export-dropdown-menu.is-open {
    display: block;
}

.export-dropdown-item {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 7px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
}

.export-dropdown-item:hover {
    background: #f3f4f6;
}

/* ── Pagina notifiche ─────────────────────────────────────────────────────── */
.notifiche-page-lista {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 780px;
}

.notif-riga {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    border-radius: 0;
    transition: background 0.15s;
}

.notif-riga:first-child {
    border-radius: 8px 8px 0 0;
    border-top: 1px solid #e5e7eb;
}

.notif-riga:last-child {
    border-radius: 0 0 8px 8px;
}

.notif-riga:first-child:last-child {
    border-radius: 8px;
}

.notif-riga.is-letta {
    background: #fafafa;
}

.notif-riga.is-letta .notif-titolo {
    font-weight: 500;
    color: #6b7280;
}

.notif-indicatore {
    flex-shrink: 0;
    width: 4px;
    align-self: stretch;
    border-radius: 2px;
    background: #d1d5db;
}

.notif-tipo-warning {
    background: #f59e0b;
}

.notif-tipo-danger {
    background: #e74c3c;
}

.notif-tipo-info {
    background: #3b82f6;
}

.notif-tipo-success {
    background: #10b981;
}

.notif-corpo {
    flex: 1;
    min-width: 0;
}

.notif-titolo {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 2px;
}

.notif-testo {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
}

.notif-data {
    flex-shrink: 0;
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    align-self: center;
}

/* ── Select Autocomplete ─────────────────────────────────────────────────────── */
.select-ac {
    position: relative;
    display: block;
}

.select-ac .sac-input {
    width: 100%;
    cursor: pointer;
    padding-right: 28px;
    color: #111827;
}

#sac-wrap-ddt_causale .sac-input {
    cursor: text;
    padding-right: 12px;
}

#sac-wrap-ddt_causale::after {
    display: none;
}

.select-ac::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #6b7280;
    pointer-events: none;
}

.sac-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #dce1e7;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.09);
    z-index: 9999;
}

.sac-lista {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sac-item {
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.1s;
    color: #374151;
}

.sac-item:last-child {
    border-bottom: none;
}

.sac-item:hover,
.sac-item.is-focused {
    background: #f0f6ff;
    color: var(--color-primary);
}

.sac-item.is-selected {
    background: var(--color-row-alt);
    color: var(--color-primary);
    font-weight: 500;
}

.sac-nessun-risultato {
    padding: 8px 12px;
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
}

.sc-add-btn,
.sc-rm-btn {
    min-width: 16px;
    height: 16px;
    padding: 0;
    font-size: 11px;
    line-height: 1;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    background: #f0f0f0;
    color: #666;
}

.sc-rm-btn {
    color: #bbb;
}

th[data-sc-col],
td[data-sc-col] {
    display: none;
}

table.sc-col-2-vis th[data-sc-col="2"],
table.sc-col-2-vis td[data-sc-col="2"] {
    display: table-cell;
}

table.sc-col-3-vis th[data-sc-col="3"],
table.sc-col-3-vis td[data-sc-col="3"] {
    display: table-cell;
}

table.sc-col-4-vis th[data-sc-col="4"],
table.sc-col-4-vis td[data-sc-col="4"] {
    display: table-cell;
}

table.sc-col-5-vis th[data-sc-col="5"],
table.sc-col-5-vis td[data-sc-col="5"] {
    display: table-cell;
}

.badge-stato {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: .75em;
    font-weight: 700;
    white-space: nowrap;
    color: #fff;
    line-height: 1.5;
    letter-spacing: .02em;
}
/* ==========================================
   Stato vuoto "ricco" (icona + messaggio), per le pagine con elenchi personalizzati
   ========================================== */
.stato-vuoto-ricco {
    text-align: center;
    color: #6B7280;
    padding: 48px 20px !important;
}

.stato-vuoto-ricco img {
    opacity: 0.35;
    margin-bottom: 12px;
}

.stato-vuoto-ricco p {
    margin: 0;
}

.stato-vuoto-ricco .stato-vuoto-titolo {
    font-size: 14px;
    font-weight: 600;
    color: #4B5563;
    margin-bottom: 4px;
}

.stato-vuoto-ricco .stato-vuoto-sotto {
    font-size: 12px;
    color: #9CA3AF;
}

#modale-impostazioni-utente .modal-card {
    width: 40vw;
    min-width: 520px;
    max-width: 95vw;
    height: 50vh;
    min-height: 420px;
    max-height: 95vh;
}

#modale-impostazioni-utente .modal-card-body {
    flex: 1;
}

.iu-tabs {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.iu-tabs ul {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.iu-tabs li a {
    display: block;
    padding: 8px 14px;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.iu-tabs li.is-active a {
    color: #004a80;
    border-bottom-color: #004a80;
    font-weight: 600;
}

.iu-tabs li a:hover {
    color: #004a80;
}

.iu-pane {
    display: none;
}

.iu-pane.is-active {
    display: block;
}

/* ==========================================
   Report: KPI e riga dei totali
   ========================================== */
.report-kpi-box {
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    color: #fff;
}

.report-kpi-label {
    font-size: 0.85rem;
    opacity: 0.85;
}

.report-kpi-valore {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 4px;
}

.report-tfoot td {
    background: #f0f0f0 !important;
    font-weight: 700;
}

.badge-colore {
    background: color-mix(in srgb, var(--bc, #9CA3AF) 14%, #fff);
    color: color-mix(in srgb, var(--bc, #9CA3AF) 70%, #000);
    border: 1px solid color-mix(in srgb, var(--bc, #9CA3AF) 35%, #fff);
}

.anagrafica-table tbody tr[data-kpi] {
    cursor: pointer;
}

.anagrafica-table tbody tr.is-selezionata,
.anagrafica-table tbody tr.is-selezionata:nth-child(even) {
    background: #ddeeff;
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Intestazioni allineate come le celle della colonna (numeri centrati o a destra) */
.anagrafica-table th.has-text-centered .col-header-top {
    justify-content: center;
}

.anagrafica-table th.has-text-right .col-header-top {
    justify-content: flex-end;
}
