/* 1. DEFINIZIONE VARIABILI */
:root {
    --accent-color: #b98a2f;
    --accent-light: #dfc27a;
    --accent-soft: rgba(185, 138, 47, 0.1);
    --accent-border: rgba(185, 138, 47, 0.2);

    --sidebar-width-open: 250px;
    --sidebar-width-closed: 70px;
    --transition-speed: 0.3s;

    /* LIGHT MODE - Colori neutri puliti, niente giallo */
    --bg-principale: #f8f9fa;
    --bg-content: #ffffff;
    --bg-card: #ffffff;
    --bg-soft: #f1f3f5;

    --navbar-bg: #ffffff;
    --navbar-text: #171717;

    --sidebar-bg: #ffffff;
    --sidebar-text: #221f18;
    --sidebar-muted: #746a58;
    --sidebar-icon-bg: #f1f3f5;
    --sidebar-link-hover: rgba(185, 138, 47, 0.1);

    --testo-principale: #181818;
    --text-muted: #746d60;
    --text-inverted: #ffffff;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(185, 138, 47, 0.2);

    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);

    --page-bg: var(--bg-principale);
    --content-bg: transparent;
    --card-gradient: transparent;
    --panel-border-top: transparent;
    
    --btn-success: #18c964;
    --btn-error: #e5484d;
}

/* 2. DARK MODE */
html.dark-mode,
body.dark-mode {
    --bg-principale: #0b0b0d;
    --bg-content: transparent;
    --bg-card: #17171a;
    --bg-soft: #222226;

    --navbar-bg: rgba(18, 18, 21, 0.92);
    --navbar-text: #f7f2e8;

    --sidebar-bg: linear-gradient(180deg, #17171a 0%, #111114 100%);
    --sidebar-text: rgba(255,255,255,0.88);
    --sidebar-muted: rgba(255,255,255,0.58);
    --sidebar-icon-bg: rgba(255,255,255,0.07);
    --sidebar-link-hover: rgba(185, 138, 47, 0.18);

    --testo-principale: #f7f2e8;
    --text-muted: #c3b8a3;
    --text-inverted: #050505;

    --border-color: rgba(255,255,255,0.08);
    --border-strong: rgba(185, 138, 47, 0.32);

    --shadow-soft: 0 8px 24px rgba(0,0,0,0.28);
    --shadow-card: 0 20px 50px rgba(0,0,0,0.42);

    --page-bg: #0b0b0d;
    --content-bg: transparent;
    --card-gradient: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
    --panel-border-top: rgba(185, 138, 47, 0.55);
}

/* 3. APPLICAZIONE AI TAG */
body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at top left, rgba(185, 138, 47, 0.10), transparent 32%),
        radial-gradient(circle at 90% 10%, rgba(223, 194, 122, 0.05), transparent 28%),
        var(--bg-principale);
    color: var(--testo-principale);
    transition:
        background-color var(--transition-speed),
        color var(--transition-speed);
}




/* NAVBAR */
.navbar {
    height: 65px;
    background: var(--navbar-bg);
    display: flex;
    align-items: center;
    padding: 0;
    color: var(--navbar-text);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 10px 28px rgba(0,0,0,0.12);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: relative;
    z-index: 50;
}

html.dark-mode .navbar,
body.dark-mode .navbar {
    box-shadow:
        0 10px 30px rgba(0,0,0,0.34),
        inset 0 -1px 0 rgba(185, 138, 47, 0.08);
}

html.dark-mode .navbar,
body.dark-mode .navbar {
    box-shadow:
        0 10px 30px rgba(0,0,0,0.34),
        inset 0 -1px 0 rgba(185, 138, 47, 0.08);
}

/* Parte sinistra larga quanto la sidebar aperta */
.nav-left {
    width: var(--sidebar-width-open);
    min-width: var(--sidebar-width-open);
    height: 65px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    overflow: hidden;
    transition:
        width 0.38s cubic-bezier(.22, 1, .36, 1),
        min-width 0.38s cubic-bezier(.22, 1, .36, 1),
        padding 0.38s cubic-bezier(.22, 1, .36, 1);
}


/* =========================================================
   LOGO NAVBAR MIDICA
   ========================================================= */

.nav-left {
    width: var(--sidebar-width-open);
    min-width: var(--sidebar-width-open);
    height: 65px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    overflow: hidden;
    transition:
        width 0.38s cubic-bezier(.22, 1, .36, 1),
        min-width 0.38s cubic-bezier(.22, 1, .36, 1),
        padding 0.38s cubic-bezier(.22, 1, .36, 1);
}

.nav-logo {
    height: 65px;
    width: 100%;
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: flex-start;

    overflow: hidden;
    text-decoration: none;
}

.nav-logo img {
    display: block;
    object-fit: contain;
    object-position: left center;
    flex-shrink: 0;
}

/* Nascondo tutto di base */
.nav-logo .logo-full,
.nav-logo .logo-compact {
    display: none;
}

/* Logo esteso */
.nav-logo .logo-full {
    width: 178px;
    height: auto;
    max-height: 48px;
}

/* Logo compatto */
.nav-logo .logo-compact {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

/* LIGHT MODE + sidebar aperta */
.nav-logo .logo-full.logo-light {
    display: block;
}

.nav-logo .logo-full.logo-dark {
    display: none;
}

/* DARK MODE + sidebar aperta */
html.dark-mode .nav-logo .logo-full.logo-light,
body.dark-mode .nav-logo .logo-full.logo-light {
    display: none;
}

html.dark-mode .nav-logo .logo-full.logo-dark,
body.dark-mode .nav-logo .logo-full.logo-dark {
    display: block;
}

/* Sidebar chiusa */
body.sidebar-collapsed .nav-left,
html.sidebar-collapsed .nav-left {
    width: var(--sidebar-width-closed);
    min-width: var(--sidebar-width-closed);
    padding: 0;
    justify-content: center;
}

body.sidebar-collapsed .nav-logo,
html.sidebar-collapsed .nav-logo {
    justify-content: center;
}

/* Sidebar chiusa: nascondo logo esteso */
body.sidebar-collapsed .nav-logo .logo-full.logo-light,
body.sidebar-collapsed .nav-logo .logo-full.logo-dark,
html.sidebar-collapsed .nav-logo .logo-full.logo-light,
html.sidebar-collapsed .nav-logo .logo-full.logo-dark {
    display: none;
}

/* Sidebar chiusa + LIGHT MODE */
body.sidebar-collapsed .nav-logo .logo-compact.logo-light,
html.sidebar-collapsed .nav-logo .logo-compact.logo-light {
    display: block;
}

body.sidebar-collapsed .nav-logo .logo-compact.logo-dark,
html.sidebar-collapsed .nav-logo .logo-compact.logo-dark {
    display: none;
}

/* Sidebar chiusa + DARK MODE */
html.dark-mode body.sidebar-collapsed .nav-logo .logo-compact.logo-light,
body.dark-mode.sidebar-collapsed .nav-logo .logo-compact.logo-light,
html.dark-mode.sidebar-collapsed .nav-logo .logo-compact.logo-light {
    display: none;
}

html.dark-mode body.sidebar-collapsed .nav-logo .logo-compact.logo-dark,
body.dark-mode.sidebar-collapsed .nav-logo .logo-compact.logo-dark,
html.dark-mode.sidebar-collapsed .nav-logo .logo-compact.logo-dark {
    display: block;
}
body.sidebar-collapsed .nav-left {
    width: var(--sidebar-width-closed);
    min-width: var(--sidebar-width-closed);
    padding: 0;
    justify-content: center;
}

body.sidebar-collapsed .nav-logo {
    justify-content: center;
}

/* Quando la sidebar è chiusa, nascondo sempre il logo esteso */
body.sidebar-collapsed .nav-logo .logo-full.logo-light,
body.sidebar-collapsed .nav-logo .logo-full.logo-dark {
    display: none;
}

/* Sidebar chiusa + LIGHT MODE: icona nera */
body.sidebar-collapsed .nav-logo .logo-compact.logo-light {
    display: block;
}

body.sidebar-collapsed .nav-logo .logo-compact.logo-dark {
    display: none;
}

/* Sidebar chiusa + DARK MODE: icona bianca */
body.sidebar-collapsed.dark-mode .nav-logo .logo-compact.logo-light {
    display: none;
}

body.sidebar-collapsed.dark-mode .nav-logo .logo-compact.logo-dark {
    display: block;
}

/* Hamburger parallelo al bordo destro della sidebar */
.menu-hamburger {
    position: static;
    margin-left: 14px;
    width: 42px;
    height: 42px;
    min-width: 42px;

    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent-color);
    cursor: pointer;

    /* Dispone le 3 linee in verticale */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px; 

    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    transition:
        background 0.25s ease,
        color 0.25s ease,
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

.menu-hamburger:hover {
    background: var(--accent-color);
    color: #050505;
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(200, 155, 44, 0.24);
}

/* === STILE DELLE 3 LINEE === */
.menu-hamburger .bar {
    width: 20px;
    height: 2px;
    background-color: currentColor;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-origin: center;
}

/* === ANIMAZIONE X QUANDO E' APERTO === */
.menu-hamburger.is-active .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-hamburger.is-active .bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.menu-hamburger.is-active .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Parte destra navbar */
.nav-right {
    height: 65px;
    flex: 1;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
    gap: 15px;
}



.profile-img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-strong);
    cursor: pointer;
    background: var(--bg-card);
    box-shadow: 0 8px 20px rgba(0,0,0,0.20);
    transition:
        transform 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

.profile-img:hover {
    transform: translateY(-1px) scale(1.03);
    border-color: var(--accent-color);
    box-shadow: 0 14px 32px rgba(200, 155, 44, 0.20);
}


    .theme-toggle {
        width: 40px;
        height: 40px;
        border: 1px solid var(--border-strong);
        border-radius: 14px;
        background: var(--accent-soft);
        color: var(--accent-color);
        cursor: pointer;
        font-size: 1.05rem;

        display: inline-flex;
        align-items: center;
        justify-content: center;

        box-shadow: 0 8px 20px rgba(0,0,0,0.10);
        transition:
            background 0.25s ease,
            color 0.25s ease,
            transform 0.25s ease,
            box-shadow 0.25s ease,
            border-color 0.25s ease;
    }

    .theme-toggle:hover {
        background: var(--accent-color);
        color: #050505;
        transform: translateY(-1px);
        box-shadow: 0 14px 32px rgba(200, 155, 44, 0.24);
    }

/* Layout Principale */

/* =========================================================
   LAYOUT + SIDEBAR PROFESSIONALE MIDICA
   ========================================================= */

.wrapper {
    display: flex;
    height: calc(100vh - 65px);
    background: var(--page-bg);
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width-open);
    flex: 0 0 var(--sidebar-width-open);
    height: 100%;
    background: var(--sidebar-bg);
    box-shadow:
        18px 0 45px rgba(0, 0, 0, 0.24),
        inset -1px 0 0 rgba(185, 138, 47, 0.10);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition:
        width 0.38s cubic-bezier(.22, 1, .36, 1),
        flex-basis 0.38s cubic-bezier(.22, 1, .36, 1),
        box-shadow 0.38s ease;
    z-index: 20;
}

html.dark-mode .sidebar::after,
body.dark-mode .sidebar::after {
    content: "";
    position: absolute;
    top: 18px;
    right: 0;
    width: 1px;
    height: calc(100% - 36px);
    background: linear-gradient(
        180deg,
        transparent,
        rgba(185, 138, 47, 0.42),
        transparent
    );
    pointer-events: none;
}


.sidebar.closed {
    width: var(--sidebar-width-closed);
    flex-basis: var(--sidebar-width-closed);
}

.sidebar-brand {
    height: 82px;
    padding: 18px 16px;
    display: flex;
    align-items: center;
    gap: 13px;
    position: relative;
    z-index: 1;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-icon {
    min-width: 42px;
    width: 42px;
    height: 42px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: #050505;
    background: linear-gradient(135deg, #fff2a0, var(--accent-color));
    box-shadow: 0 10px 24px rgba(205, 194, 32, 0.28);
}

.sidebar-brand-icon i {
    color: #050505;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
    min-width: 0;
    transition: opacity 0.22s ease, transform 0.28s ease;
}

.sidebar-brand-text strong {
    color: #ffffff;
    font-size: 1rem;
    letter-spacing: 0.4px;
}

.sidebar-brand-text small {
    margin-top: 5px;
    color: rgba(255,255,255,0.55);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.4px;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    z-index: 1;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(205, 194, 32, 0.35);
    border-radius: 999px;
}

.sidebar-link {
    min-height: 48px;
    margin: 5px 0;
    padding: 0 13px;
    border-radius: 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 13px;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    transition:
        background 0.25s ease,
        color 0.25s ease,
        transform 0.25s ease,
        box-shadow 0.25s ease;
}


.sidebar-link:hover {
    color: #171717;
    background: var(--sidebar-link-hover);
    transform: translateX(4px);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

html.dark-mode .sidebar-link:hover,
body.dark-mode .sidebar-link:hover {
    color: #ffffff;
}

.sidebar-link:hover::before {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-icon {
    min-width: 34px;
    width: 34px;
    height: 34px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--sidebar-icon-bg);
    transition: background 0.25s ease, transform 0.25s ease;
    position: relative;
    z-index: 1;
}

.sidebar-icon i {
    color: var(--sidebar-text);
    font-size: 1rem;
    transition: color 0.25s ease, transform 0.25s ease;
}

.sidebar-link:hover .sidebar-icon {
    background: rgba(205, 194, 32, 0.16);
    transform: scale(1.04);
}

.sidebar-link:hover .sidebar-icon i {
    color: var(--accent-color);
}

.sidebar-text {
    color: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.15px;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.22s ease, transform 0.28s ease;
    position: relative;
    z-index: 1;
}

.sidebar-indicator {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent-color);
    margin-left: auto;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.25s ease, transform 0.25s ease;
    position: relative;
    z-index: 1;
}

.sidebar-link:hover .sidebar-indicator {
    opacity: 1;
    transform: scale(1);
}

.sidebar-footer {
    min-height: 62px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border-strong);
    position: relative;
    z-index: 1;
}

.sidebar-footer-icon {
    min-width: 38px;
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(205, 194, 32, 0.12);
}

.sidebar-footer-icon i {
    color: var(--accent-color);
}

.sidebar-footer-text {
    color: var(--sidebar-muted);;
    font-size: 0.82rem;
    font-weight: 600;
    transition: opacity 0.22s ease, transform 0.28s ease;
}

/* Stato chiuso */
.sidebar.closed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.closed .sidebar-brand-text,
.sidebar.closed .sidebar-text,
.sidebar.closed .sidebar-footer-text,
.sidebar.closed .sidebar-indicator {
    display: none;
}

.sidebar.closed .sidebar-link {
    width: 100%;
    justify-content: center;
    padding: 0;
    gap: 0;
    box-sizing: border-box;
}

.sidebar.closed .sidebar-icon {
    margin: 0 auto;
}

.sidebar.closed .sidebar-link:hover {
    transform: translateX(0);
}

.sidebar.closed .sidebar-footer {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.closed .sidebar-footer-icon {
    margin: 0 auto;
}
/* Tooltip elegante quando la sidebar è chiusa */
.sidebar.closed .sidebar-link:hover::after {
    content: attr(data-title);
    position: fixed;
    left: calc(var(--sidebar-width-closed) + 14px);
    padding: 9px 12px;
    border-radius: 12px;
    background: #111111;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid rgba(205, 194, 32, 0.25);
    box-shadow: 0 12px 30px rgba(0,0,0,0.28);
    z-index: 999;
    pointer-events: none;
}

/* =========================================================
   SIDEBAR - VOCE ATTIVA
   ========================================================= */

.sidebar-link.active {
    color: #171717;
    background:
        linear-gradient(135deg, rgba(185, 138, 47, 0.28), rgba(185, 138, 47, 0.12));
    box-shadow:
        inset 0 0 0 1px var(--border-strong),
        0 10px 24px rgba(185, 138, 47, 0.12);
}

html.dark-mode .sidebar-link.active,
body.dark-mode .sidebar-link.active {
    color: #ffffff;
}

.sidebar-link.active .sidebar-icon {
    background: rgba(205, 194, 32, 0.16);
    transform: scale(1.04);
}

.sidebar-link.active .sidebar-icon i {
    color: var(--accent-color);
}

.sidebar-link.active .sidebar-indicator {
    opacity: 1;
    transform: scale(1);
}

/* Area contenuto */
.main-content {
    flex-grow: 1;
    padding: 34px 34px 42px;
    overflow-y: auto;
    background:
        radial-gradient(circle at top left, rgba(185, 138, 47, 0.055), transparent 34%),
        linear-gradient(180deg, rgba(255,255,255,0.018), transparent 220px),
        var(--content-bg);
    color: var(--testo-principale);
    transition:
        background-color var(--transition-speed),
        color var(--transition-speed);
}

html.dark-mode .main-content,
body.dark-mode .main-content {
    box-shadow: inset 18px 0 48px rgba(0, 0, 0, 0.18);
}



.btn-edit {
    background: linear-gradient(135deg, var(--accent-light), var(--accent-color));
    color: #050505;
    padding: 9px 16px;
    border-radius: 13px;
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 900;
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow:
        0 14px 32px rgba(185, 138, 47, 0.22),
        inset 0 1px 0 rgba(255,255,255,0.30);
    transition:
        transform 0.22s ease,
        box-shadow 0.22s ease,
        filter 0.22s ease;
}

.btn-edit:hover {
    transform: translateY(-2px);
    filter: brightness(1.04);
    box-shadow:
        0 20px 46px rgba(185, 138, 47, 0.32),
        inset 0 1px 0 rgba(255,255,255,0.34);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 65px;
        left: 0;
        bottom: 0;
        transform: translateX(0);
    }

    .sidebar.closed {
        transform: translateX(-100%);
        width: var(--sidebar-width-open);
        flex-basis: var(--sidebar-width-open);
    }

    .sidebar.closed .sidebar-brand-text,
    .sidebar.closed .sidebar-text,
    .sidebar.closed .sidebar-footer-text {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

    .sidebar.closed .sidebar-link {
        justify-content: flex-start;
        padding: 0 13px;
        gap: 13px;
    }

    /* .main-content {
        padding: 18px;
    } */
}

.btn-action {
    padding: 8px 13px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    transition:
        background 0.22s ease,
        color 0.22s ease,
        border-color 0.22s ease,
        transform 0.22s ease;
    color: var(--testo-principale);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.btn-action:hover {
    background: var(--accent-color);
    color: #050505;
    border-color: var(--accent-color);
    transform: translateY(-1px);
}


/*dropdown e raggruppamento delle voci di menu*/

/* Rimuovi stili di default dal bottone per farlo sembrare un link */
.sidebar-dropdown-btn {
    width: 100%;
    border: none;
    cursor: pointer;
    background: transparent;
    font-family: inherit;
}

/* Freccia a destra */
.sidebar-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.5;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar-link:hover .sidebar-arrow {
    opacity: 1;
    color: var(--accent-color);
}

.sidebar-arrow.rotate {
    transform: rotate(180deg);
}

/* Sottomenu e Indentazione */
.sidebar-submenu {
    margin-left: 10px; /* Sposta le voci a destra rispetto al gruppo */
    padding-left: 10px;
    border-left: 1px solid rgba(185, 138, 47, 0.15); /* Linea guida verticale */
    margin-bottom: 10px;
}

.sidebar-icon.sub-icon {
    transform: scale(0.8); /* Icone sottomenu leggermente più piccole */
    background: transparent;
}

/* Nascondi la freccia quando la sidebar è chiusa */
.sidebar.closed .sidebar-arrow {
    display: none;
}




/* TABELLA E CARD */
.table-card {
    background:
        var(--card-gradient),
        var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.main-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--testo-principale);
}

.main-table th {
    background: var(--bg-soft);
    color: var(--text-muted);
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.8px;
}

.main-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.main-table tr:hover td {
    background: var(--accent-soft);
}




/*========================================================= v DASHBOARD v =============================================================================================*/

/* DASHBOARD GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* STAT CARDS */
.stat-card {
    background:
        var(--card-gradient),
        var(--bg-card);
    padding: 22px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 16px;
    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease,
        border-color 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-light);
    box-shadow: 0 10px 25px rgba(185, 138, 47, 0.15); /* Ombra dorata soffusa */
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

/* Colori icone basati sull'accento o logica */
.icon-blue { background: rgba(52, 152, 219, 0.14); color: #3498db; }
.icon-green { background: rgba(46, 204, 113, 0.14); color: #2ecc71; }
.icon-yellow { background: var(--accent-soft); color: var(--accent-color); }
.icon-red { background: rgba(231, 76, 60, 0.14); color: #e74c3c; }

.stat-details h3 {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-details .stat-number {
    margin: 5px 0 0;
    font-size: 1.4rem;
    font-weight: 800;
}

/* CHART CONTAINER */
.chart-container {
    background:
        var(--card-gradient),
        var(--bg-card);
    padding: 26px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    box-shadow: var(--shadow-card);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-legend {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
}

.legend-item { display: flex; align-items: center; gap: 8px; }
.dot-entrate { width: 12px; height: 12px; border-radius: 3px; background: #2ecc71; }
.dot-uscite { width: 12px; height: 12px; border-radius: 3px; background: #e74c3c; }

/* Stile per i pallini della legenda del grafico */
.dot-entrate { 
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
    background: var(--accent-color); 
    box-shadow: 0 0 8px var(--accent-color); /* Effetto luminoso sul giallo */
}
.dot-uscite { 
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
    background: var(--text-muted); 
}

/* =========================================================
   2. LOGIN MIDICA
   ========================================================= */

.login-body *,
.login-body *::before,
.login-body *::after {
    box-sizing: border-box;
}

.login-body {
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
    color: #ffffff;
    background: #0f0f11;
}

.login-page {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.login-bg {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: #0f0f11;
    pointer-events: none;
}

.login-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.login-bg-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        radial-gradient(circle at 18% 22%, rgba(185, 138, 47, 0.28), transparent 32%),
        linear-gradient(135deg, rgba(15, 15, 17, 0.76) 0%, rgba(15, 15, 17, 0.58) 45%, rgba(15, 15, 17, 0.9) 100%);
}

.login-content {
    position: fixed;
    inset: 0;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    width: 100%;
}

.login-hero {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 70px 70px 70px 90px;
}

.login-hero-inner {
    max-width: 760px;
}

.login-kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    margin-bottom: 22px;
    border-radius: 999px;
    border: 1px solid rgba(223, 194, 122, 0.28);
    background: rgba(185, 138, 47, 0.14);
    color: var(--accent-light);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.login-kicker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-light);
    box-shadow: 0 0 14px rgba(223, 194, 122, 0.85);
}

.login-hero-title {
    margin: 0 0 22px;
    color: #ffffff;
    font-size: clamp(2.2rem, 4vw, 4.6rem);
    line-height: 1.04;
    font-weight: 900;
    letter-spacing: -0.055em;
    text-shadow: 0 16px 48px rgba(0, 0, 0, 0.42);
}

.login-hero-title span {
    color: var(--accent-light);
}

.login-hero-text {
    max-width: 620px;
    margin: 0;
    color: rgba(255, 255, 255, 0.74);
    font-size: 1.06rem;
    line-height: 1.75;
}

.login-panel-wrap {
    width: 480px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px 48px 42px 24px;
}

.login-panel-stack {
    width: 100%;
    max-width: 400px;
}

.login-brand {
    margin-bottom: 22px;
    text-align: center;
}

.login-brand-logo {
    max-width: 190px;
    max-height: 92px;
    object-fit: contain;
    filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.34));
}

.login-brand-logo[src=""],
.login-brand-logo:not([src]) {
    display: none;
}

.login-brand-fallback {
    display: none;
    margin: 0;
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -0.05em;
}

.login-brand-fallback span {
    color: var(--accent-light);
}

.login-panel {
    width: 100%;
    padding: 34px 30px 30px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
}

.login-form-title {
    margin: 0 0 8px;
    color: #ffffff;
    font-size: 1.55rem;
    font-weight: 850;
    text-align: center;
}

.login-form-subtitle {
    margin: 0 0 26px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.92rem;
    text-align: center;
}

.login-error {
    display: none;
    margin-bottom: 18px;
    padding: 12px 13px;
    border-radius: 14px;
    background: rgba(255, 107, 107, 0.13);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
    font-size: 0.9rem;
    text-align: center;
}

.login-error.is-visible {
    display: block;
}

.login-field {
    margin-bottom: 18px;
}

.login-label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-input {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.94);
    color: #171717;
    font-size: 0.98rem;
    outline: none;
    box-sizing: border-box;
    transition:
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        background 0.22s ease;
}

.login-input:focus {
    border-color: var(--accent-light);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(185, 138, 47, 0.22);
}

.login-password-wrap {
    position: relative;
    width: 100%;
}

.login-password-input {
    padding-right: 88px;
}

.login-password-toggle {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #5f5f5f;
    font-size: 0.72rem;
    font-weight: 900;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}

.login-session-note {
    margin: 2px 0 22px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.78rem;
}

.login-submit {
    width: 100%;
    height: 50px;
    border: 0;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-color));
    color: #050505;
    font-size: 0.96rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    cursor: pointer;
    box-shadow: 0 16px 34px rgba(185, 138, 47, 0.28);
    transition:
        transform 0.22s ease,
        box-shadow 0.22s ease,
        filter 0.22s ease;
}

.login-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 46px rgba(185, 138, 47, 0.34);
    filter: brightness(1.04);
}

.login-footer {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.44);
    text-align: center;
    font-size: 0.78rem;
}

@media (max-width: 980px) {
    .login-body {
        overflow: auto;
    }

    .login-content {
        display: block;
        min-height: 100vh;
        padding: 34px 18px;
    }

    .login-hero {
        display: none;
    }

    .login-panel-wrap {
        width: 100%;
        min-height: calc(100vh - 68px);
        padding: 0;
    }

    .login-panel-stack {
        max-width: 420px;
    }
}

@media (max-width: 480px) {
    .login-panel {
        padding: 28px 22px 24px;
        border-radius: 20px;
    }

    .login-brand-logo {
        max-width: 160px;
    }
}

.login-brand-title {
    margin: 0;
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    text-align: center;
}

.login-brand-title span {
    color: var(--accent-light);
}

/* =========================================================
   MENU PROFILO NAVBAR
   ========================================================= */

.profile-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-menu-trigger {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-menu-trigger:focus {
    outline: none;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 220px;
    padding: 10px;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-card);
    z-index: 9999;
    display: none;
}

.profile-menu-wrapper:focus-within .profile-dropdown {
    display: block;
}

.profile-dropdown::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 18px;
    width: 14px;
    height: 14px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-strong);
    border-top: 1px solid var(--border-strong);
    transform: rotate(45deg);
}

.profile-dropdown-header {
    padding: 12px 12px 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.profile-dropdown-header strong {
    display: block;
    color: var(--testo-principale);
    font-size: 0.9rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.profile-dropdown-header span {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.profile-dropdown-link {
    display: block;
    padding: 11px 12px;
    border-radius: 11px;
    color: var(--testo-principale);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
}

.profile-dropdown-link:hover {
    background: var(--accent-soft);
    color: var(--accent-color);
}

.profile-dropdown-logout {
    color: var(--btn-error);
}

.profile-dropdown-logout:hover {
    background: rgba(229, 72, 77, 0.12);
    color: var(--btn-error);
}

/* =========================================================
   PROFILO UTENTE
   ========================================================= */

.profile-page {
    width: 100%;
    padding: 28px 24px 34px;
    box-sizing: border-box;
}

.profile-shell {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
}

.profile-hero-card {
    background:
        radial-gradient(circle at top center, rgba(185, 138, 47, 0.12), transparent 42%),
        var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 24px;
    padding: 34px 24px 28px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.profile-avatar-frame {
    position: relative;
    width: 112px;
    height: 112px;
    margin: 0 auto 18px;
    border-radius: 50%;
    padding: 4px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-color));
    box-shadow: 0 16px 34px rgba(185, 138, 47, 0.20);
    display: grid;
    place-items: center;
    box-sizing: border-box;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    background: var(--bg-soft);
    border: 4px solid var(--bg-card);
    box-sizing: border-box;
}

.profile-avatar-badge {
    display: none;
}

.profile-name {
    margin: 0;
    color: var(--testo-principale);
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    text-transform: uppercase;
}

.profile-subtitle {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
}

.profile-hero-meta {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    color: var(--testo-principale);
    font-size: 0.85rem;
    font-weight: 800;
}

.profile-meta-pill i {
    color: var(--accent-color);
}

.profile-tabs {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 18px 0 20px;
    padding: 0 4px 12px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.profile-tabs::-webkit-scrollbar {
    height: 4px;
}

.profile-tabs::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}

.profile-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 2px;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 800;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    opacity: 0.82;
    cursor: pointer;
    user-select: none;
}

.profile-tab i {
    font-size: 0.82rem;
}

.profile-tab.is-active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    opacity: 1;
}

.profile-panel[hidden] {
    display: none !important;
}

.profile-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.profile-info-item {
    padding: 18px;
    border-radius: 18px;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
}

.profile-info-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.profile-info-value {
    display: block;
    color: var(--testo-principale);
    font-size: 1rem;
    font-weight: 800;
    word-break: break-word;
}

.profile-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.profile-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-form-group-full {
    grid-column: 1 / -1;
}

.profile-form-label {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.profile-form-input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-soft);
    color: var(--testo-principale);
    font-size: 0.95rem;
    font-weight: 700;
    outline: none;
}

.profile-form-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(185, 138, 47, 0.15);
}

.profile-alert {
    position: relative;
    margin: 0 0 22px;
    padding: 15px 18px 15px 48px;

    border-radius: 16px;
    border: 1px solid var(--border-color);

    color: var(--testo-principale);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
        var(--bg-soft);

    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.35;

    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.profile-alert::before {
    position: absolute;
    top: 50%;
    left: 16px;

    width: 22px;
    height: 22px;

    border-radius: 50%;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    transform: translateY(-50%);

    font-size: 0.76rem;
    font-weight: 900;
}

.profile-alert-successo {
    border-color: rgba(24, 201, 100, 0.30);
    background:
        linear-gradient(135deg, rgba(24, 201, 100, 0.14), rgba(24, 201, 100, 0.055)),
        var(--bg-card);
    color: var(--testo-principale);
}

.profile-alert-successo::before {
    content: "✓";
    color: #ffffff;
    background: var(--btn-success);
    box-shadow: 0 0 0 4px rgba(24, 201, 100, 0.14);
}

.profile-alert-errore {
    border-color: rgba(229, 72, 77, 0.34);
    background:
        linear-gradient(135deg, rgba(229, 72, 77, 0.14), rgba(229, 72, 77, 0.055)),
        var(--bg-card);
    color: var(--testo-principale);
}

.profile-alert-errore::before {
    content: "!";
    color: #ffffff;
    background: var(--btn-error);
    box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.14);
}

@media (max-width: 760px) {
    .profile-form-grid {
        grid-template-columns: 1fr;
    }
}

.profile-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 13px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 900;
    transition:
        transform 0.22s ease,
        background 0.22s ease,
        color 0.22s ease,
        box-shadow 0.22s ease;
}

.profile-btn-secondary {
    color: var(--testo-principale);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.profile-btn-secondary:hover {
    background: var(--accent-soft);
    color: var(--accent-color);
    transform: translateY(-1px);
}

.profile-btn-primary {
    color: #050505;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-color));
    box-shadow: 0 12px 28px rgba(185, 138, 47, 0.24);
}

.profile-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(185, 138, 47, 0.30);
}

@media (max-width: 760px) {
    .profile-page {
        padding: 22px 16px 28px;
    }

    .profile-hero-card,
    .profile-panel {
        padding: 20px;
        border-radius: 20px;
    }

    .profile-name {
        font-size: 1.45rem;
    }

    .profile-tabs {
        gap: 14px;
    }

    .profile-info-grid {
        grid-template-columns: 1fr;
    }

    .profile-actions {
        flex-direction: column;
    }

    .profile-btn {
        width: 100%;
    }
}

/* =========================================================
   MODALE LATERALE MIDICA
   Basata su modal_old.php, stile modernizzato
   ========================================================= */

body.modal-open {
    overflow: hidden;
}

/* Overlay oscurato */
.modal-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9990;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Stato aperto gestito da JS */
.modal-sidebar.is-open {
    display: block;
}

/* Pannello laterale destro */
.modal-content-sidebar {
    background: var(--bg-card);
    color: var(--testo-principale);

    margin-left: auto;
    width: min(620px, 100%);
    height: 100%;

    display: flex;
    flex-direction: column;

    border-left: 2px solid var(--accent-color);
    box-shadow: -28px 0 80px rgba(0, 0, 0, 0.42);

    position: relative;
    overflow: hidden;

    animation: slideInRight 0.30s cubic-bezier(.22, 1, .36, 1);
}

/* Animazione ingresso da destra verso sinistra */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0.92;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0.92;
    }
}

.modal-sidebar.is-closing .modal-content-sidebar {
    animation: slideOutRight 0.24s cubic-bezier(.22, 1, .36, 1) forwards;
}

/* Header modale */
.modal-header {
    min-height: 78px;
    padding: 22px 24px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;

    border-bottom: 1px solid var(--border-color);
    background:
        radial-gradient(circle at top left, rgba(185, 138, 47, 0.10), transparent 42%),
        var(--bg-card);

    flex-shrink: 0;
}

.modal-title-sidebar {
    margin: 0;
    color: var(--testo-principale);
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.025em;
}

.modal-subtitle-sidebar {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

/* Bottone chiusura */
.close-sidebar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;

    border: 1px solid var(--border-color);
    border-radius: 50%;

    background: var(--bg-soft);
    color: var(--text-muted);

    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    aspect-ratio: 1 / 1;

    font-size: 1.1rem;
    line-height: 1;

    transition:
        background 0.22s ease,
        color 0.22s ease,
        border-color 0.22s ease,
        transform 0.22s ease,
        box-shadow 0.22s ease;
}

.close-sidebar:hover {
    background: rgba(229, 72, 77, 0.14);
    color: var(--btn-error);
    border-color: rgba(229, 72, 77, 0.36);
    transform: rotate(90deg);
    box-shadow: 0 10px 24px rgba(229, 72, 77, 0.14);
}

/* Corpo modale */
.modal-body-sidebar {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-body-sidebar::-webkit-scrollbar {
    width: 7px;
}

.modal-body-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}

.modal-loading {
    margin: 0;
    padding: 16px;
    border-radius: 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 700;
}

/* Form dentro la modale */
.modal-body-sidebar form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 26px 22px;
    align-items: start;
}

/* Ogni blocco campo */
.modal-body-sidebar .form-group,
.modal-body-sidebar .form-field {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

/* Campi a larghezza piena quando necessario */
.modal-body-sidebar .form-group.full,
.modal-body-sidebar .form-field.full {
    grid-column: 1 / -1;
}

/* Label */
.modal-body-sidebar label {
    color: var(--testo-principale);
    font-size: 0.84rem;
    font-weight: 900;
    letter-spacing: 0.01em;
}

/* Input, select e textarea */
.modal-body-sidebar input,
.modal-body-sidebar select,
.modal-body-sidebar textarea {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;

    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.16);

    background: rgba(255, 255, 255, 0.055);
    color: var(--testo-principale);

    font-size: 0.95rem;
    font-weight: 700;
    outline: none;
    box-sizing: border-box;

    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.025),
        0 8px 18px rgba(0, 0, 0, 0.10);

    transition:
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        background 0.22s ease,
        transform 0.22s ease;
}

body:not(.dark-mode) .modal-body-sidebar input,
body:not(.dark-mode) .modal-body-sidebar select,
body:not(.dark-mode) .modal-body-sidebar textarea {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.14);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.015),
        0 8px 18px rgba(0, 0, 0, 0.04);
}

.modal-body-sidebar input:hover,
.modal-body-sidebar select:hover,
.modal-body-sidebar textarea:hover {
    border-color: rgba(185, 138, 47, 0.45);
    background: rgba(255, 255, 255, 0.075);
}

body:not(.dark-mode) .modal-body-sidebar input:hover,
body:not(.dark-mode) .modal-body-sidebar select:hover,
body:not(.dark-mode) .modal-body-sidebar textarea:hover {
    background: #ffffff;
    border-color: rgba(185, 138, 47, 0.45);
}

.modal-body-sidebar input:focus,
.modal-body-sidebar select:focus,
.modal-body-sidebar textarea:focus {
    border-color: var(--accent-color);
    background: rgba(185, 138, 47, 0.08);
    box-shadow:
        0 0 0 4px rgba(185, 138, 47, 0.18),
        0 12px 26px rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
}

body:not(.dark-mode) .modal-body-sidebar input:focus,
body:not(.dark-mode) .modal-body-sidebar select:focus,
body:not(.dark-mode) .modal-body-sidebar textarea:focus {
    background: #ffffff;
}

.modal-body-sidebar select {
    cursor: pointer;
    appearance: auto;
}

.modal-body-sidebar select option {
    background: var(--bg-card);
    color: var(--testo-principale);
}

/* Textarea */
.modal-body-sidebar textarea {
    min-height: 105px;
    padding-top: 13px;
    resize: vertical;
}

/* Focus campi */
.modal-body-sidebar input:focus,
.modal-body-sidebar select:focus,
.modal-body-sidebar textarea:focus {
    border-color: var(--accent-color);
    background: rgba(185, 138, 47, 0.06);
    box-shadow: 0 0 0 4px rgba(185, 138, 47, 0.15);
    transform: translateY(-1px);
}

/* Select più pulite */
.modal-body-sidebar select {
    cursor: pointer;
}

/* Checkbox / switch */
.modal-body-sidebar input[type="checkbox"] {
    min-height: auto;
    width: auto;
}

/* Footer eventuale se viene generato dall'AJAX */
.modal-body-sidebar .modal-footer,
.modal-body-sidebar .form-actions {
    grid-column: 1 / -1;

    margin-top: 18px;
    padding-top: 22px;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;

    border-top: 1px solid var(--border-color);
}

/* Bottoni dentro modale */
.modal-body-sidebar button,
.modal-body-sidebar .btn,
.modal-body-sidebar .btn-save {
    min-height: 46px;
    padding: 0 24px;

    border-radius: 14px;
    border: 1px solid transparent;

    cursor: pointer;

    font-size: 0.9rem;
    font-weight: 900;
    text-decoration: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    transition:
        background 0.22s ease,
        color 0.22s ease,
        border-color 0.22s ease,
        transform 0.22s ease,
        box-shadow 0.22s ease;
}

/* Se il bottone Salva è figlio diretto del form, lo centro */
.modal-body-sidebar form > button[type="submit"],
.modal-body-sidebar form > .btn-save,
.modal-body-sidebar form > .btn-primary {
    grid-column: 1 / -1;
    justify-self: center;
    min-width: 280px;
    margin-top: 28px;
}

/* Bottone principale */
.modal-body-sidebar button[type="submit"],
.modal-body-sidebar .btn-primary,
.modal-body-sidebar .btn-save {
    background: linear-gradient(135deg, var(--accent-light), var(--accent-color));
    color: #050505;
    box-shadow: 0 16px 34px rgba(185, 138, 47, 0.26);
}

.modal-body-sidebar button[type="submit"]:hover,
.modal-body-sidebar .btn-primary:hover,
.modal-body-sidebar .btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 46px rgba(185, 138, 47, 0.34);
}

/* Bottone secondario */
.modal-body-sidebar button[type="button"],
.modal-body-sidebar .btn-secondary {
    background: var(--bg-soft);
    color: var(--testo-principale);
    border-color: var(--border-color);
}

.modal-body-sidebar button[type="button"]:hover,
.modal-body-sidebar .btn-secondary:hover {
    color: var(--accent-color);
    border-color: var(--border-strong);
    background: var(--accent-soft);
}

.modal-body-sidebar {
    flex: 1;
    padding: 28px 26px 34px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* =========================================================
   SWITCH / TOGGLE GLOBALE
   ========================================================= */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--btn-success);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 760px) {
    .modal-content-sidebar {
        width: 100%;
        border-left: 0;
        border-top: 2px solid var(--accent-color);
    }

    .modal-header {
        padding: 20px;
    }

    .modal-body-sidebar {
        padding: 20px;
    }

    .modal-body-sidebar form {
        grid-template-columns: 1fr;
    }

    .modal-body-sidebar .modal-footer,
    .modal-body-sidebar .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-body-sidebar button,
    .modal-body-sidebar .btn,
    .modal-body-sidebar .btn-save {
        width: 100%;
    }
}

/* =========================================================
   PRELOAD - EVITA SCATTI CAMBIO PAGINA
   ========================================================= */

html.app-preload .navbar,
html.app-preload .nav-left,
html.app-preload .sidebar,
html.app-preload .sidebar *,
html.app-preload .main-content {
    transition: none !important;
    animation: none !important;
}

/* Stato sidebar letto subito da <html>, prima che parta script.php */
html.sidebar-collapsed .nav-left {
    width: var(--sidebar-width-closed);
    min-width: var(--sidebar-width-closed);
    padding: 0;
    justify-content: center;
}

html.sidebar-open .nav-left {
    width: var(--sidebar-width-open);
    min-width: var(--sidebar-width-open);
}

/* Sidebar chiusa da stato iniziale */
html.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-closed);
    flex-basis: var(--sidebar-width-closed);
}

html.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

html.sidebar-collapsed .sidebar-brand-text,
html.sidebar-collapsed .sidebar-text,
html.sidebar-collapsed .sidebar-footer-text,
html.sidebar-collapsed .sidebar-indicator {
    display: none;
}

html.sidebar-collapsed .sidebar-link {
    width: 100%;
    justify-content: center;
    padding: 0;
    gap: 0;
    box-sizing: border-box;
}

html.sidebar-collapsed .sidebar-icon {
    margin: 0 auto;
}

html.sidebar-collapsed .sidebar-footer {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

/* Sidebar aperta: forza apertura anche se l'HTML ha ancora class="closed" */
html.sidebar-open .sidebar.closed {
    width: var(--sidebar-width-open);
    flex-basis: var(--sidebar-width-open);
}

html.sidebar-open .sidebar.closed .sidebar-brand {
    justify-content: flex-start;
    padding-left: 16px;
    padding-right: 16px;
}

html.sidebar-open .sidebar.closed .sidebar-brand-text {
    display: flex;
}

html.sidebar-open .sidebar.closed .sidebar-text {
    display: inline;
}

html.sidebar-open .sidebar.closed .sidebar-footer-text {
    display: block;
}

html.sidebar-open .sidebar.closed .sidebar-indicator {
    display: block;
}

html.sidebar-open .sidebar.closed .sidebar-link {
    justify-content: flex-start;
    padding: 0 13px;
    gap: 13px;
}

html.sidebar-open .sidebar.closed .sidebar-icon {
    margin: 0;
}


/*LOGO PER PAGINA LOGIN*/
.midica-logo-text {
    display: inline-flex;
    align-items: baseline;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
}

.midica-logo-text .midica-dark {
    color: #ffffff;
}

.midica-logo-text .midica-gold {
    color: #c78f2f;
}

/* =========================================================
   LOGOUT POS / TABLET
   ========================================================= */

.pos-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pos-summary-header h3 {
    margin: 0;
}

.pos-logout {
    min-height: 34px;
    padding: 0 12px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);

    background: rgba(229, 72, 77, 0.88);
    color: #ffffff;

    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;

    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);

    transition:
        background 0.2s ease,
        transform 0.2s ease,
        border-color 0.2s ease;
}

.pos-logout:hover {
    background: #e5484d;
    border-color: #e5484d;
    transform: translateY(-1px);
}

.pos-logout i {
    font-size: 13px;
}

/*==================================================================================== SELECT 2 ===================================================================================================*/
/* --- RESET TOTALE SELECT2 PER DARK/LIGHT MODE --- */

/* 1. Contenitore Principale (Barra chiusa) */
.select2-container--default .select2-selection--single {
    background-color: var(--bg-principale) !important;
    border: 1px solid var(--border-color) !important;
    height: 40px !important;
}

/* Fix per evitare che il background "sfugga" sui lati */
.select2-selection__rendered {
    background-color: transparent !important;
    color: var(--testo-principale) !important;
    line-height: 38px !important;
}

/* 2. Menu a tendina (Lista aperta) */
.select2-dropdown {
    background-color: var(--bg-principale) !important;
    border-color: var(--border-color) !important;
}

/* 3. Risultati e singole Opzioni */
.select2-results__option .select2-selection .select2-selection--multiple .select2-selection--clearable{
    background-color: var(--bg-principale) !important; /* Forza lo sfondo delle righe */
    color: var(--testo-principale) !important;
}

/* 4. Opzione selezionata o sotto il mouse (Hover) */
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option[aria-selected="true"] .select2-selection__choice{
    background-color: var(--accent-color) !important;
    color: #ffffff !important; /* Di solito qui il bianco serve per contrasto */
}

/* 5. Campo di ricerca dentro la tendina */
.select2-search--dropdown {
    background-color: var(--bg-principale) !important;
}

.select2-search--dropdown .select2-search__field {
    background-color: var(--bg-card) !important; /* Leggermente diverso se vuoi stacco */
    color: var(--testo-principale) !important;
    border: 1px solid var(--border-color) !important;
}

/* 6. La freccetta */
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--testo-principale) transparent transparent transparent !important;
}

/* 1. Sfondo per la selezione multipla */
.select2-container--default .select2-selection--multiple {
    background-color: var(--bg-principale) !important;
    border: 1px solid var(--border-color) !important;
    min-height: 40px !important;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 2px !important;
}

/* 2. I "Tag" delle scelte effettuate (li.select2-selection__choice) */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--accent-color) !important; /* Colore di risalto per i tag */
    border: 1px solid var(--accent-color) !important;
    color: #ffffff !important; /* Testo dei tag solitamente bianco per contrasto */
    border-radius: 4px;
    padding: 2px 8px !important;
    margin: 2px !important;
    font-size: 0.9em;
}

/* 3. La "X" per rimuovere la scelta dal tag */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #ffffff !important;
    margin-right: 5px !important;
    border: none !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: rgba(0,0,0,0.2) !important;
    color: #ff4d4d !important; /* X rossa al passaggio del mouse */
}

/* 4. Il campo di testo dove scrivi dentro la multipla */
.select2-container--default .select2-selection--multiple .select2-search__field {
    background-color: transparent !important;
    color: var(--testo-principale) !important;
    margin-top: 0 !important;
    padding-left: 10px !important;
}

/* Fix per evitare aloni bianchi quando la multipla è vuota */
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--accent-color) !important;
}


/* =========================================================
   RESPONSIVE ASSISTENZA / AMMINISTRATORE
   Deve stare ALLA FINE del file
   ========================================================= */

html,
body {
    width: 100%;
    max-width: 100%;
}

* {
    box-sizing: border-box;
}

.wrapper,
.navbar,
.main-content,
.table-card,
.profile-page,
.profile-shell,
.modal-content-sidebar {
    min-width: 0;
}

/* Tabelle: non schiacciarle, falle scrollare */
.table-card {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.main-table {
    min-width: 760px;
}

/* Select2 sempre dentro il contenitore */
.select2-container {
    max-width: 100% !important;
}

/* =========================================================
   TABLET ORIZZONTALE / SCHERMI MEDI
   ========================================================= */
@media (max-width: 1180px) {
    .main-content {
        padding: 26px 24px 34px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
        gap: 16px;
    }

    .stat-card {
        padding: 18px;
    }

    .chart-container {
        padding: 22px;
    }

    .table-card {
        border-radius: 18px;
    }

    .main-table th,
    .main-table td {
        padding: 12px;
    }

    .modal-content-sidebar {
        width: min(560px, 100%);
    }
}

/* =========================================================
   TABLET VERTICALE / MOBILE GRANDE
   Sidebar laterale off-canvas, contenuto pieno
   ========================================================= */
@media (max-width: 900px) {
    body {
        overflow: hidden;
    }

    .navbar {
        height: 62px;
    }

    html.sidebar-open .nav-left,
    body.sidebar-open .nav-left {
        width: var(--sidebar-width-open);
        min-width: var(--sidebar-width-open);
        padding: 0 20px;
        justify-content: flex-start;
    }

    html.sidebar-collapsed .nav-left,
    body.sidebar-collapsed .nav-left {
        width: var(--sidebar-width-closed);
        min-width: var(--sidebar-width-closed);
        padding: 0;
        justify-content: center;
    }



    .menu-hamburger {
        margin-left: 8px;
        width: 40px;
        height: 40px;
        min-width: 40px;
        border-radius: 13px;
    }

    .nav-right {
        height: 62px;
        padding: 0 12px;
        gap: 10px;
    }

    .theme-toggle,
    .profile-img {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }

    .wrapper {
        height: calc(100vh - 62px);
        width: 100%;
        overflow: hidden;
    }

    @supports (height: 100dvh) {
        .wrapper {
            height: calc(100dvh - 62px);
        }
    }

    .sidebar {
        position: fixed;
        top: 62px;
        left: 0;
        bottom: 0;

        width: min(280px, 86vw);
        flex-basis: auto;

        transform: translateX(0);
        z-index: 1000;

        box-shadow: 24px 0 60px rgba(0, 0, 0, 0.42);
    }

    .sidebar.closed {
        width: min(280px, 86vw);
        flex-basis: auto;
        transform: translateX(-110%);
    }

    .sidebar.closed .sidebar-brand-text,
    .sidebar.closed .sidebar-text,
    .sidebar.closed .sidebar-footer-text,
    .sidebar.closed .sidebar-indicator {
        display: flex;
    }

    .sidebar.closed .sidebar-text {
        display: inline;
    }

    .sidebar.closed .sidebar-link {
        justify-content: flex-start;
        padding: 0 13px;
        gap: 13px;
    }

    .sidebar.closed .sidebar-icon {
        margin: 0;
    }

    .main-content {
        width: 100%;
        flex: 1 1 auto;
        padding: 22px 18px 30px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .stat-card {
        min-width: 0;
        padding: 16px;
        border-radius: 18px;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        min-width: 46px;
        border-radius: 14px;
        font-size: 1.25rem;
    }

    .stat-details h3 {
        font-size: 0.75rem;
    }

    .stat-details .stat-number {
        font-size: 1.2rem;
    }

    .chart-container {
        padding: 18px;
        border-radius: 20px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-legend {
        flex-wrap: wrap;
        gap: 12px;
        font-size: 0.82rem;
    }

    .table-card {
        border-radius: 18px;
    }

    .main-table {
        min-width: 720px;
    }

    .main-table th,
    .main-table td {
        padding: 11px;
        font-size: 0.85rem;
    }

    .btn-action,
    .btn-edit {
        padding: 8px 11px;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .profile-page {
        padding: 20px 14px 28px;
    }

    .profile-hero-card,
    .profile-panel {
        padding: 20px;
        border-radius: 20px;
    }

    .profile-info-grid {
        grid-template-columns: 1fr;
    }

    .profile-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content-sidebar {
        width: 100%;
        border-left: 0;
        border-top: 2px solid var(--accent-color);
    }

    .modal-header {
        min-height: 66px;
        padding: 16px 18px;
    }

    .modal-title-sidebar {
        font-size: 1.1rem;
    }

    .modal-subtitle-sidebar {
        font-size: 0.8rem;
    }

    .modal-body-sidebar {
        padding: 18px;
    }

    .modal-body-sidebar form {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .modal-body-sidebar form > button[type="submit"],
    .modal-body-sidebar form > .btn-save,
    .modal-body-sidebar form > .btn-primary {
        min-width: 0;
        width: 100%;
    }
}

/* =========================================================
   TELEFONI
   ========================================================= */
@media (max-width: 600px) {
    .navbar {
        height: 58px;
    }

    .nav-left {
        width: 64px;
        min-width: 64px;
    }

    .menu-hamburger {
        width: 38px;
        height: 38px;
        min-width: 38px;
        border-radius: 12px;
    }

    .menu-hamburger .bar {
        width: 18px;
    }

    .nav-right {
        height: 58px;
        padding: 0 10px;
        gap: 8px;
    }

    .theme-toggle,
    .profile-img {
        width: 36px;
        height: 36px;
        min-width: 36px;
        border-radius: 12px;
    }

    .wrapper {
        height: calc(100vh - 58px);
    }

    @supports (height: 100dvh) {
        .wrapper {
            height: calc(100dvh - 58px);
        }
    }

    .sidebar {
        top: 58px;
        width: min(270px, 88vw);
    }

    .sidebar.closed {
        width: min(270px, 88vw);
    }

    .main-content {
        padding: 16px 12px 24px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 15px;
        gap: 12px;
    }

    .chart-container {
        padding: 16px;
        border-radius: 18px;
    }

    .table-card {
        border-radius: 16px;
    }

    .main-table {
        min-width: 680px;
    }

    .main-table th,
    .main-table td {
        padding: 10px;
        font-size: 0.8rem;
    }

    .btn-action,
    .btn-edit {
        padding: 7px 10px;
        font-size: 0.74rem;
    }

    .profile-page {
        padding: 16px 10px 24px;
    }

    .profile-hero-card,
    .profile-panel {
        padding: 16px;
        border-radius: 18px;
    }

    .profile-avatar-frame {
        width: 92px;
        height: 92px;
    }

    .profile-name {
        font-size: 1.25rem;
    }

    .profile-subtitle {
        font-size: 0.9rem;
    }

    .profile-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-btn {
        width: 100%;
    }

    .modal-header {
        padding: 14px;
    }

    .close-sidebar {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }

    .modal-body-sidebar {
        padding: 14px;
    }

    .modal-body-sidebar input,
    .modal-body-sidebar select,
    .modal-body-sidebar textarea {
        min-height: 44px;
        font-size: 0.9rem;
    }

    .modal-body-sidebar .modal-footer,
    .modal-body-sidebar .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 10px;
    }

    .modal-body-sidebar button,
    .modal-body-sidebar .btn,
    .modal-body-sidebar .btn-save {
        width: 100%;
        min-height: 44px;
    }
}

/* =========================================================
   TELEFONI MOLTO STRETTI
   ========================================================= */
@media (max-width: 380px) {
    .main-content {
        padding: 14px 10px 22px;
    }

    .stat-card {
        padding: 13px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        min-width: 42px;
    }

    .main-table {
        min-width: 640px;
    }

    .modal-body-sidebar {
        padding: 12px;
    }
}

/* =========================================================
   TABLET / MOBILE IN ORIZZONTALE
   Navbar compatta, contenuto scrollabile
   ========================================================= */
@media (orientation: landscape) and (max-height: 620px) and (max-width: 1180px) {
    .navbar {
        height: 54px;
    }

    .nav-left {
        height: 54px;
        width: 64px;
        min-width: 64px;
    }

    .menu-hamburger {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .nav-right {
        height: 54px;
    }

    .theme-toggle,
    .profile-img {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }

    .wrapper {
        height: calc(100vh - 54px);
    }

    @supports (height: 100dvh) {
        .wrapper {
            height: calc(100dvh - 54px);
        }
    }

    .sidebar {
        top: 54px;
    }

    .main-content {
        padding: 14px 16px 22px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 13px;
        gap: 10px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 1.05rem;
    }

    .stat-details h3 {
        font-size: 0.68rem;
    }

    .stat-details .stat-number {
        font-size: 1.05rem;
    }

    .chart-container {
        padding: 14px;
    }

    .modal-header {
        min-height: 56px;
        padding: 12px 14px;
    }

    .modal-body-sidebar {
        padding: 14px;
    }
}


/* =========================================================
   DETAIL / FORM ACTIONS
   ========================================================= */

.btn-back {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--testo-principale);
    padding: 8px 15px;
    border-radius: 10px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-back:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #050505;
}

.btn-action-success {
    background-color: var(--btn-success);
    color: #ffffff;
    border-color: var(--btn-success);
}

.btn-action-error {
    background-color: var(--btn-error);
    color: #ffffff;
    border-color: var(--btn-error);
}

.is-hidden {
    display: none !important;
}


.page-title {
    margin: 0;
    font-weight: 800;
}

.page-subtitle {
    margin: 8px 0 0;
    color: var(--text-muted);
}

.calendar-box {
    background: var(--bg-principale);
    padding: 20px;
    border-radius: 8px;
}

.calendar-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.calendar-actions .btn-salva {
    flex: 2;
}

.calendar-actions .btn-elimina {
    flex: 1;
}

.is-hidden {
    display: none !important;
}

.input-color {
    height: 40px;
}

/* =========================================================
   MODALI - FORM DINAMICI
   ========================================================= */

.modal-body-sidebar .form-group {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 15px;
}

.modal-body-sidebar .btn-save {
    width: 100%;
    margin-top: 20px;
}

.btn-add-composition {
    margin-top: 10px;
}

.composition-row select,
.composition-row input {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-principale);
    color: var(--testo-principale);
}

/* =========================================================
   LIST / DETAIL HEADER
   ========================================================= */

.list-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.list-page-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.detail-title {
    margin: 0;
    color: var(--testo-principale);
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.list-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}


