/**
 * PAS - Stylesheet principale
 */

/* Accessibilità: miglior focus e skip link */
.skip-link {
    position: absolute !important;
    left: -9999px !important;
    top: 0;
    padding: .75rem 1rem;
    background: var(--bs-primary);
    color: #fff;
    border-radius: 0 0 .75rem .75rem;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-100%);
    transition: transform .2s ease, left .2s ease, opacity .2s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    left: .75rem !important;
    transform: translateY(0);
    outline: none;
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 0 0 4px rgba(42, 98, 255, 0.25);
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    font-family: var(--tf-font-sans, 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif);
    font-size: clamp(0.95rem, 0.2vw + 0.9rem, 1rem);
    line-height: 1.55;
    letter-spacing: -0.01em;
    background: radial-gradient(circle at top, rgba(13, 110, 253, 0.08), transparent 55%) fixed,
                linear-gradient(180deg, #f5f7fb, #eef2fa);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Theme tokens */
:root {
    color-scheme: light !important; /* Force light scheme for browser UI */
    --tf-font-sans: 'Inter', 'SF Pro Display', 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --tf-topbar-sticky-height: 68px;
    --tf-safe-bottom: 0px;
    /* FIXED: Calcolo più accurato dell'altezza bottom nav */
    --tf-bottom-nav-btn-height: 64px; /* min-height dei bottoni */
    --tf-bottom-nav-padding-top: 0.6rem; /* 9.6px */
    --tf-bottom-nav-padding-bottom: 0.75rem; /* 12px */
    /* Altezza totale = bottone + padding verticale + safe-area + margine sicurezza */
    --tf-bottom-nav-height: calc(var(--tf-bottom-nav-btn-height) + var(--tf-bottom-nav-padding-top) + var(--tf-bottom-nav-padding-bottom) + var(--tf-safe-bottom) + 8px);
    /* Extra padding per iOS Safari - valore fisso MOLTO generoso */
    --tf-mobile-content-padding-bottom: 400px;
}

/* Force Light Mode variables even if data-bs-theme is set to dark by accident */
:root,
:root[data-bs-theme='dark'],
:root[data-bs-theme='light'] {
    --bs-body-color: #212529;
    --bs-body-color-rgb: 33, 37, 41;
    --bs-body-bg: #fff;
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-tertiary-bg: #f8f9fa;
    --bs-tertiary-bg-rgb: 248, 249, 250;
}

@supports (padding: env(safe-area-inset-bottom)) {
    :root {
        --tf-safe-bottom: env(safe-area-inset-bottom);
    }
}

@supports (padding: constant(safe-area-inset-bottom)) {
    :root {
        --tf-safe-bottom: constant(safe-area-inset-bottom);
    }
}

img,
picture,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Bootstrap Icons spacing - icone PRIMA del testo */
.btn > i.bi:first-child,
.btn > .bi:first-child,
a > i.bi:first-child,
a > .bi:first-child,
.nav-link > i.bi:first-child,
.dropdown-item > i.bi:first-child,
.card-title > i.bi:first-child,
h1 > i.bi, h2 > i.bi, h3 > i.bi, h4 > i.bi, h5 > i.bi, h6 > i.bi,
p > i.bi:first-child,
span > i.bi:first-child,
label > i.bi:first-child {
    margin-right: 0.15rem; /* Desktop: ~2px */
}

/* Eccezione: icone DOPO il testo (es. freccia destra) */
.bi.bi-arrow-right,
.bi.bi-chevron-right,
.bi.bi-caret-right-fill,
.bi.bi-box-arrow-up-right {
    margin-right: 0 !important;
    margin-left: 0.15rem;
}

/* Mobile: spacing leggermente maggiore */
@media (max-width: 767.98px) {
    .btn > i.bi:first-child,
    .btn > .bi:first-child,
    a > i.bi:first-child,
    a > .bi:first-child,
    .nav-link > i.bi:first-child,
    .dropdown-item > i.bi:first-child,
    .card-title > i.bi:first-child,
    h1 > i.bi, h2 > i.bi, h3 > i.bi, h4 > i.bi, h5 > i.bi, h6 > i.bi,
    p > i.bi:first-child,
    span > i.bi:first-child,
    label > i.bi:first-child {
        margin-right: 0.35rem; /* Mobile: ~5-6px */
    }

    .bi.bi-arrow-right,
    .bi.bi-chevron-right,
    .bi.bi-caret-right-fill,
    .bi.bi-box-arrow-up-right {
        margin-left: 0.35rem;
    }
}

/* Layout shell */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: row;
    background: var(--bs-body-bg);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--bs-body-bg);
    background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.app-topbar::after {
    content: '';
    position: absolute;
    inset: auto 0 -1px 0;
    height: 1px;
    background: rgba(15, 23, 42, 0.05);
    pointer-events: none;
}

.app-sidebar {
    width: 280px;
    background: var(--bs-body-tertiary);
    border-right: 1px solid var(--bs-border-color);
    padding: 1rem 0.75rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-sidebar-brand {
    font-size: 1.05rem;
    font-weight: 600;
}

.app-brand-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(42, 98, 255, 0.1);
    color: var(--bs-primary);
    font-size: 1.3rem;
}

.app-sidebar .nav-link {
    border-radius: .75rem;
    padding: .55rem .85rem;
    transition: background-color .2s ease, color .2s ease;
}

.app-sidebar .nav-link:hover {
    background: rgba(42, 98, 255, 0.12);
    color: var(--bs-primary);
}

.app-sidebar .nav-link.active {
    background: var(--bs-primary);
    color: #fff;
    box-shadow: 0 8px 16px rgba(42, 98, 255, 0.16);
}

.app-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Permette al flex item di ridursi */
    background: var(--bs-body-bg);
}

.app-topbar {
    padding: .75rem clamp(1rem, 2vw, 1.75rem);
}

.app-topbar-inner {
    gap: clamp(.5rem, 1.5vw, 1rem);
    flex-wrap: wrap;
}

.app-topbar-title {
    font-weight: 600;
}

.app-topbar-actions {
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-topbar-actions > * {
    flex: 0 0 auto;
}

.app-topbar-actions .btn,
.app-topbar-actions .dropdown-toggle {
    min-height: 2.5rem;
}

.app-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
}

/* Default avatar style (senza bg-* class) */
.app-avatar:not([class*="bg-"]) {
    background: rgba(42, 98, 255, 0.12);
    color: var(--bs-primary);
}

/* Avatar con bg-primary esplicito - usa blu standard */
.app-avatar.bg-primary {
    background-color: #0d6efd !important; /* Bootstrap blue */
    color: #fff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.app-avatar.bg-primary i.bi-person-circle {
    margin: 0;
    padding: 0;
    line-height: 0;
    font-size: 1.1rem;
    position: relative;
    top: 0;
    left: 0;
}

.app-sidebar-offcanvas {
    width: 280px;
}

.app-sidebar-offcanvas .offcanvas-body {
    padding-bottom: 1rem;
}

/* Brand nel menu mobile - centrato con padding */
.app-sidebar-offcanvas .app-sidebar-brand {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    justify-content: center;
}

.app-sidebar-offcanvas .app-brand-link {
    justify-content: center;
    align-items: center !important;
    display: flex !important;
}

/* Forza allineamento verticale al centro del logo */
.app-sidebar-offcanvas .app-brand-link img {
    flex-shrink: 0;
}

.app-sidebar-offcanvas .app-brand-link span {
    margin: 0;
    padding: 0;
    line-height: 40px; /* Stessa altezza del logo */
    height: 40px;
    display: inline-flex;
    align-items: center;
}

.app-main {
    width: 100%;
    max-width: 1180px;
    flex: 1; /* Riempie lo spazio disponibile, spinge la navbar in fondo */
}

#main-content {
    scroll-margin-top: calc(var(--tf-topbar-sticky-height, 68px) + 20px);
}

.app-topbar-search .input-group-text {
    border-radius: 999px 0 0 999px;
    background: transparent;
    border-color: rgba(15, 23, 42, 0.08);
}

.app-topbar-search .form-control {
    border-radius: 0 999px 999px 0;
    background-color: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.08);
}

.mobile-fab {
    position: fixed;
    bottom: calc(5.5rem + var(--tf-safe-bottom));
    right: clamp(1rem, 5vw, 1.5rem);
    display: none;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    padding: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #5a8dff);
    color: #fff;
    font-weight: 700;
    font-size: 1.75rem;
    box-shadow: 0 12px 32px rgba(13, 110, 253, 0.45);
    z-index: 1045;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobile-fab:active {
    transform: scale(0.92);
}

.mobile-fab-icon {
    display: none;
}

.mobile-fab-label {
    display: none;
}

/*
 * Mobile Bottom Navigation - Sticky Layout
 * La navbar è parte del flusso del documento, si attacca al fondo della viewport
 * quando il contenuto è più alto dello schermo
 */
.mobile-bottom-nav {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: var(--tf-bottom-nav-height);
    padding: 0.6rem clamp(0.5rem, 5vw, 1rem);
    padding-bottom: calc(var(--tf-bottom-nav-padding-bottom) + env(safe-area-inset-bottom, 0px));
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    display: none;
    justify-content: space-between;
    gap: 0.5rem;
    z-index: 100;
    margin-top: auto; /* Spinge la navbar in fondo al flex container */
}

.mobile-bottom-nav-btn {
    flex: 1 1 0;
    border: none;
    background: transparent;
    color: var(--bs-body-color);
    border-radius: 1rem;
    padding: 0.65rem 0.35rem 0.55rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    min-height: 64px;
}

.mobile-bottom-nav-btn:active {
    transform: scale(0.92);
}

.mobile-bottom-nav-btn i {
    font-size: 1.5rem;
    line-height: 1;
}

.mobile-bottom-nav-btn.is-active {
    color: var(--bs-primary);
    background: rgba(13, 110, 253, 0.15);
    border-radius: 1.2rem;
}

.mobile-bottom-nav-btn:focus-visible,
.mobile-bottom-nav-btn:hover {
    color: var(--bs-primary);
    background: rgba(13, 110, 253, 0.12);
}

/* Nascondi il bottone X duplicato nel brand della sidebar */
.app-sidebar-brand .btn[data-bs-dismiss="offcanvas"] {
    display: none !important;
}

/* Nascondi bottoni export per utenti senza permessi */
[data-permission="visite.export"].disabled,
[data-permission="report.export"].disabled {
    display: none !important;
}

@media (max-width: 991.98px) {
    :root {
        --tf-topbar-sticky-height: 86px;
    }

    .mobile-fab {
        display: inline-flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }
}

.timeline-card {
    border: 1px solid rgba(15, 23, 42, 0.05);
    border-radius: 1rem;
    transition: transform .2s ease, box-shadow .2s ease;
}

.timeline-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(15, 23, 42, 0.08);
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid rgba(42, 98, 255, 0.6);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(42, 98, 255, 0.15);
}

/* Theme tokens */
:root[data-bs-theme='dark'] {
    color-scheme: dark;
}

:root[data-bs-theme='dark'] body {
    background-color: #0f172a;
    color: #e2e8f0;
}

:root[data-bs-theme='dark'] .card,
:root[data-bs-theme='dark'] .table {
    background-color: rgba(15, 23, 42, 0.55);
    color: #e2e8f0;
}

:root[data-bs-theme='dark'] .modal-content {
    background-color: #1e293b;
    color: #e2e8f0;
}

:root[data-bs-theme='dark'] .login-box {
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 0.25rem 1rem rgba(15, 23, 42, 0.7);
}

:root[data-bs-theme='dark'] .table-fixed thead th {
    background: rgba(15, 23, 42, 0.85);
}

body.theme-transition {
    transition: background-color .35s ease, color .35s ease;
}

/* Utility classes */
.visit-row {
    cursor: pointer;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
}

.sortable-header:hover i {
    color: var(--bs-primary);
}

/* KPI cards */
.kpi .card {
    min-height: 110px;
}

/* Table fixed header */
.table-fixed thead th {
    position: sticky;
    top: 0;
    background: var(--bs-body-bg);
    z-index: 1;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.2);
    border-radius: 999px;
}

/* ============================================
   Enhanced Global Theme (applies to all pages)
   - Softer cards, reusable hero, progress bars
   - Dark mode aware (reuses existing data-bs-theme)
   ============================================ */

/* Theme tokens for enhanced components */
:root {
    --tf-hero-border: rgba(13, 110, 253, 0.18);
    --tf-hero-shadow: 0 25px 65px rgba(15, 23, 42, 0.15);
    --tf-card-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

/* Global card refinements */
.card {
    border-radius: 1.25rem;
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.03);
    overflow: hidden;
}

:root[data-bs-theme='dark'] .card {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Reusable page hero */
.page-hero {
    border-radius: 1.8rem;
    border: 1px solid var(--tf-hero-border);
    background: radial-gradient(circle at 10% 20%, rgba(13, 202, 240, 0.18), transparent 55%),
                linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(116, 69, 255, 0.08));
    box-shadow: var(--tf-hero-shadow);
    padding: clamp(1.75rem, 3vw, 2.75rem);
    overflow: hidden;
    position: relative;
}

.page-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 85% 0%, rgba(255, 255, 255, 0.35), transparent 45%);
    pointer-events: none;
}

:root[data-bs-theme='dark'] {
    --tf-hero-border: rgba(255, 255, 255, 0.1);
    --tf-hero-shadow: 0 30px 70px rgba(0, 0, 0, 0.65);
}

:root[data-bs-theme='dark'] .page-hero {
    background: radial-gradient(circle at 15% 20%, rgba(13, 110, 253, 0.35), transparent 45%),
                linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(13, 110, 253, 0.2));
}

.hero-eyebrow {
    font-weight: 600;
    letter-spacing: 0.08em;
    color: rgba(15, 23, 42, 0.55);
}

:root[data-bs-theme='dark'] .hero-eyebrow {
    color: rgba(255, 255, 255, 0.7);
}

.hero-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
}

.hero-subtitle {
    font-size: 0.95rem;
    max-width: 540px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.hero-actions .btn {
    border-radius: 999px;
    padding-inline: 1rem;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

/* Metric cards (used in heros) */
.hero-metrics {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.hero-metric-card {
    border-radius: 1.2rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.12);
    min-height: 120px;
    overflow: hidden;
}

:root[data-bs-theme='dark'] .hero-metric-card {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.hero-metric-label {
    font-size: .7rem;
    letter-spacing: .08em;
    font-weight: 600;
}

.hero-metric-value {
    font-size: clamp(1.35rem, 3vw, 1.9rem);
    font-weight: 700;
    margin-top: .2rem;
}

.hero-metric-caption {
    font-size: .8rem;
    margin-top: .25rem;
}

/* Agent summary look (generic gradient card) */
.agent-summary-card {
    border: none;
    border-radius: 1.25rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.12), rgba(13, 110, 253, 0.02));
    box-shadow: var(--tf-card-shadow);
    overflow: hidden;
}
.agent-summary-card.academy {
    background: linear-gradient(135deg, rgba(131,56,236,0.16), rgba(131,56,236,0.04));
}
.agent-summary-card .value-amount {
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    font-weight: 700;
    display: flex;
    gap: .35rem;
    align-items: baseline;
}
.agent-summary-card .value-amount span { font-size: 1rem; }
.agent-summary-card .metric-label {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: rgba(15,23,42,.6);
}
:root[data-bs-theme='dark'] .agent-summary-card .metric-label { color: rgba(255,255,255,.65); }

/* Accordion refinements */
.accordion-item {
    border-radius: 1.25rem;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.08);
    margin-bottom: .75rem;
}
.accordion-button { font-weight: 600; gap: .75rem; }
.accordion-button:not(.collapsed) { box-shadow: inset 0 -1px 0 rgba(0,0,0,.05); }
.accordion-body { background: color-mix(in srgb, var(--bs-body-bg) 92%, white); }
@supports not (color-mix(in srgb, black 50%, white 50%)) {
    .accordion-body { background: rgba(0,0,0,.01); }
}

/* Tables tweaks */
.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.table tbody tr:hover { background: color-mix(in srgb, var(--bs-primary) 3%, transparent); }

/* Target progress bars */
.target-progress {
    height: 8px;
    border-radius: 999px;
    background: rgba(13, 110, 253, 0.15);
    position: relative;
    overflow: hidden;
}
.target-progress-bar {
    position: absolute;
    inset: 0;
    width: min(130%, var(--progress-width, 0%));
    background: linear-gradient(90deg, var(--bs-primary), var(--bs-info));
    border-radius: inherit;
    transition: width .45s ease;
}
.target-progress-bar.is-complete {
    background: linear-gradient(90deg, var(--bs-success), var(--bs-primary));
    box-shadow: 0 0 12px rgba(25,135,84,.4);
}
.target-progress-meta {
    font-size: .8rem;
    display: flex;
    justify-content: space-between;
    gap: .35rem;
    color: var(--bs-secondary-color);
    flex-wrap: wrap;
}
.target-note { font-size: .8rem; color: var(--bs-secondary-color); display: flex; align-items: center; gap: .25rem; }
.badge.text-bg-primary-subtle { border-radius: 999px; padding-inline: .75rem; }

@media (max-width: 991.98px) {
    .hero-actions { width: 100%; }
}

/* Login box */
.login-box {
    max-width: 400px;
    margin: 8vh auto;
    background: #fff;
    padding: 2rem;
    border-radius: .75rem;
    box-shadow: 0 0.25rem 1rem rgba(0,0,0,0.1);
}

.login-box h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Badge colors */
.badge-tipo-visita {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

/* Forms */
.form-group-inline {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.filter-action-group {
    display: flex;
    gap: 0.65rem;
    width: 100%;
    align-items: stretch;
}

.filter-action-group .btn {
    flex: 1 1 0;
    min-height: 52px;
    border-radius: 1rem;
    padding: 0.65rem 0.85rem;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.25;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.filter-action-group .btn i {
    font-size: 1rem;
    margin-right: 0.4rem;
}

.filter-action-group .btn-outline-secondary {
    background: #fff;
    border-width: 1.5px;
    border-color: rgba(15, 23, 42, 0.15);
}

.filter-action-group .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 20px rgba(15, 23, 42, 0.12);
}

.filter-action-group .btn.btn-primary {
    border: none;
    box-shadow: 0 14px 30px rgba(13, 110, 253, 0.35);
}

@media (max-width: 575.98px) {
    .filter-action-group {
        flex-direction: column;
    }

    .filter-action-group .btn {
        width: 100%;
        min-height: 50px;
    }
}

/* Responsive tables */
@media (max-width: 768px) {
.table-responsive {
    font-size: 0.875rem;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        display: none;
    }
    .app-main {
        max-width: 100%;
    }

    .app-shell {
        flex-direction: column;
    }

    .app-topbar-inner {
        align-items: flex-start;
        gap: 0.75rem;
    }

    .app-topbar-actions {
        width: 100%;
        justify-content: flex-start;
        padding-bottom: 0.25rem;
        overflow-x: auto;
        flex-wrap: wrap;
    }

    .app-topbar-actions::-webkit-scrollbar {
        height: 0;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    .navbar,
    .btn,
    .alert {
        display: none !important;
    }
}

/* ============================================
   DASHBOARD GAUGE CARDS
   ============================================ */
.kpi-card .display-6 {
    line-height: 1;
}

.table-sm td, .table-sm th {
    padding: .35rem .5rem;
}

/* Gauge Cards */
.gauge-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    position: relative;
    min-height: 220px;
    background-clip: padding-box;
}

.gauge-card.sinergy {
    background-image: linear-gradient(145deg, rgba(13,110,253,0.20), rgba(13,110,253,0.04));
}

.gauge-card.academy {
    background-image: linear-gradient(145deg, rgba(102,16,242,0.18), rgba(102,16,242,0.05));
}

.gauge-card.total {
    background-image: linear-gradient(145deg, rgba(25,135,84,0.16), rgba(25,135,84,0.04));
}

.gauge-card.sinergy .gauge-header,
.gauge-card.academy .gauge-header {
    color: rgba(15,23,42,.85);
    font-weight: 700;
}

.gauge-card.total .gauge-header {
    color: rgba(25,135,84,.82);
    font-weight: 700;
}

.gauge-card .gauge-header {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .7rem;
    color: rgba(15,23,42,.6);
}

.gauge-meter {
    --gauge-size: 140px;
    width: var(--gauge-size);
    height: var(--gauge-size);
    border-radius: 50%;
    background: conic-gradient(var(--gauge-color, #0d6efd) calc(var(--gauge-value, 0) * 1%), rgba(13,110,253,0.12) 0);
    display: grid;
    place-items: center;
    margin: 0 auto;
    position: relative;
    transition: background 0.6s ease;
}

.gauge-meter::after {
    content: '';
    position: absolute;
    width: calc(var(--gauge-size) - 34px);
    height: calc(var(--gauge-size) - 34px);
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.08);
}

.gauge-value {
    position: relative;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0;
    z-index: 1;
}

.gauge-value span {
    display: block;
    font-size: .75rem;
    text-transform: uppercase;
    color: rgba(15,23,42,.55);
    margin-bottom: .25rem;
    font-weight: 600;
    letter-spacing: .05em;
}

.gauge-meta {
    font-size: .85rem;
    color: rgba(15,23,42,.64);
}

.gauge-amount {
    display: inline-flex;
    align-items: baseline;
    gap: 0.15rem;
    line-height: 1;
}

.gauge-currency {
    font-size: 0.85em;
    opacity: 0.75;
}

.gauge-number {
    font-size: 1em;
}

.gauge-layout {
    flex-wrap: wrap;
    gap: clamp(1rem, 2vw, 2.5rem);
}

.gauge-layout .gauge-meter {
    margin-inline: auto;
}

.gauge-info {
    min-width: 140px;
}

.gauge-info-label {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .68rem;
    font-weight: 600;
    color: rgba(15, 23, 42, 0.55);
    margin-bottom: .35rem;
}

:root[data-bs-theme='dark'] .gauge-info-label {
    color: rgba(226, 232, 240, 0.7);
}

@media (max-width: 767.98px) {
    .gauge-layout {
        flex-direction: column !important;
        align-items: center !important;
    }

    .gauge-info {
        width: 100%;
    }

    .gauge-info .percent-display {
        text-align: center;
    }
}

.metric-chip {
    border-radius: 999px;
    padding: .35rem .75rem;
    background: rgba(15, 23, 42, 0.05);
    display: inline-flex;
    align-items: baseline;
    gap: .4rem;
    font-size: .8rem;
    font-weight: 600;
}

.metric-chip.text-success {
    background: rgba(25, 135, 84, 0.1);
    color: #198754 !important;
}

/* Command palette */
.command-palette {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    z-index: 1080;
}

.command-palette.is-open {
    display: flex;
}

.command-palette-dialog {
    width: min(720px, 92vw);
    background: var(--bs-body-bg);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.08);
    animation: cp-fade-in 0.18s ease-out;
}

.command-palette-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.command-palette-header .form-control {
    border: none;
    box-shadow: none;
    font-size: 1rem;
}

.command-palette-header .form-control:focus {
    box-shadow: none;
}

.command-palette-body {
    max-height: 60vh;
    overflow: auto;
}

.command-palette-item {
    border: none;
    text-align: left;
    padding: 0.85rem 1.25rem;
}

.command-palette-item.is-active,
.command-palette-item:hover {
    background: rgba(42, 98, 255, 0.09);
}

.command-palette-item mark {
    background: rgba(42, 98, 255, 0.18);
    color: inherit;
    padding: 0 .2em;
    border-radius: 4px;
}

.command-palette-desc {
    margin-top: .25rem;
}

.command-palette-empty {
    border-top: 1px solid rgba(15, 23, 42, 0.05);
}

.command-palette-hint {
    padding: .5rem 1.25rem;
}

@keyframes cp-fade-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.maintenance-wrapper {
    background: linear-gradient(135deg, rgba(42, 98, 255, 0.08), rgba(26, 174, 111, 0.08));
}

.ui-kpi-card {
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(42, 98, 255, 0.04), rgba(26, 174, 111, 0.02));
}

.ui-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(42, 98, 255, 0.12);
    display: grid;
    place-items: center;
    color: var(--bs-primary);
    font-size: 1.5rem;
}

.ui-kpi-trend {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

.ui-gauge {
    border-radius: 18px;
    background: var(--bs-body-bg);
}

.ui-gauge-meter {
    --ui-gauge-value: 0;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin: 0 auto;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--ui-gauge-color, #2A62FF) calc(var(--ui-gauge-value) * 1%), rgba(42, 98, 255, 0.12) 0);
    position: relative;
    transition: background 0.4s ease;
}

.ui-gauge-meter::after {
    content: '';
    position: absolute;
    width: calc(100% - 32px);
    height: calc(100% - 32px);
    border-radius: 50%;
    background: var(--bs-body-bg);
    box-shadow: inset 0 6px 20px rgba(15, 23, 42, 0.08);
}

.ui-gauge-meter.is-warning {
    --ui-gauge-color: #FFB020;
}

.ui-gauge-meter.is-danger {
    --ui-gauge-color: #FF6B6B;
}

.ui-gauge-meter.is-success {
    --ui-gauge-color: #1AAE6F;
}

.ui-gauge-value {
    position: relative;
    font-size: 1.5rem;
    font-weight: 700;
}

.ui-gauge-target {
    font-size: .75rem;
}

.ui-filter-chip {
    padding: .4rem .9rem;
    font-weight: 600;
    background: rgba(42, 98, 255, 0.1);
    color: var(--bs-primary);
    border: 1px solid rgba(42, 98, 255, 0.25);
}

.ui-filter-chip.active {
    background: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}

.ui-filter-chip .btn-close {
    filter: invert(1) grayscale(100%);
}

.ui-table-toolbar .form-control {
    border-radius: 999px;
}

.ui-table-toolbar-actions .btn {
    border-radius: 999px;
}

.ui-stepper {
    border-radius: 18px;
    background: var(--bs-body-bg);
}

.ui-stepper-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1rem;
}

.ui-stepper-item {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 1rem;
    align-items: center;
    position: relative;
}

.ui-stepper-item::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 48px;
    width: 2px;
    height: calc(100% - 48px);
    background: rgba(42, 98, 255, 0.2);
}

.ui-stepper-item:last-child::before {
    display: none;
}

.ui-stepper-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(42, 98, 255, 0.1);
    display: grid;
    place-items: center;
    font-weight: 600;
    color: var(--bs-primary);
}

.ui-stepper-item.is-active .ui-stepper-circle {
    background: var(--bs-primary);
    color: #fff;
}

.ui-stepper-item.is-completed .ui-stepper-circle {
    background: rgba(26, 174, 111, 0.2);
    color: #1AAE6F;
}

.ui-stepper-description {
    max-width: 420px;
}

.ui-empty-state {
    border-style: dashed;
}

.ui-empty-icon {
    font-size: 2.25rem;
}

.ui-pagination .page-link {
    border-radius: 999px !important;
    margin: 0 .125rem;
}
.percent-display {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.1;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .gauge-meter {
        --gauge-size: 120px;
    }
}

/* ============================================
   MAINTENANCE PAGE
   ============================================ */
.box {
    max-width: 560px;
    margin: 12vh auto;
}

/* ============================================
   RESPONSIVE MOBILE ENHANCEMENTS
   Modifiche per ottimizzare la visualizzazione
   su dispositivi mobili e tablet
   ============================================ */

/* ===== TABLET (768px - 991px) ===== */
@media (max-width: 991.98px) and (min-width: 768px) {
    /* Riduzione padding hero su tablet */
    .page-hero {
        padding: 2rem 1.5rem;
    }

    /* Grid metrics più strette */
    .hero-metrics {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    /* Gauge più piccoli */
    .gauge-meter {
        --gauge-size: 110px;
    }

    /* Topbar più compatta */
    .app-topbar {
        padding: 0.5rem 1rem;
    }
}

/* ===== GAUGE CIRCLE → PROGRESS BAR (TUTTI I DISPOSITIVI) ===== */

/* Nascondi il cerchio gauge */
.gauge-meter {
    display: none !important;
}

/* Mostra barra orizzontale al posto del gauge */
.gauge-layout {
    flex-direction: column !important;
    width: 100%;
}

/* ===== BARRA SEGMENTATA PROMOZIONI ===== */

/* Contenitore barra segmentata */
.promo-segmented-bar {
    width: 100%;
    order: -1;
    margin-bottom: 1rem;
}

/* Track della barra (sfondo grigio) */
.promo-bar-track {
    display: flex;
    width: 100%;
    height: 24px;
    background: rgba(13, 110, 253, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

/* Segmenti della barra */
.promo-bar-segment {
    height: 100%;
    transition: width 0.6s ease;
}

.promo-bar-segment.promo-segment {
    background: #198754;
    border-radius: 999px 0 0 999px;
}

.promo-bar-segment.other-segment {
    border-radius: 0 999px 999px 0;
}

/* Quando c'è solo promo, arrotonda entrambi i lati */
.promo-bar-segment.promo-segment:last-child {
    border-radius: 999px;
}

/* Etichette sotto la barra */
.promo-bar-labels {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    color: #6c757d;
}

.promo-bar-labels span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Pallini indicatori */
.promo-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.promo-dot.promo {
    background: #198754;
}

.promo-dot.other {
    background: #0d6efd;
}

/* Posizionamento relativo per ::after */
.gauge-card .card-body {
    position: relative;
    border-radius: inherit;
    overflow: hidden;
}

/* Info gauge allineate al centro */
.gauge-info {
    width: 100%;
    text-align: center;
}

/* Font ingranditi per desktop */
.gauge-header {
    font-size: 1rem !important;
    font-weight: 700 !important;
}

.gauge-amount {
    font-size: 1.75rem !important;
}

.gauge-currency {
    font-size: 1.2rem !important;
}

.gauge-number {
    font-size: 1.75rem !important;
}

.gauge-info-label {
    font-size: 1rem !important;
    font-weight: 600 !important;
}

.percent-display {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
}

.metric-chip {
    font-size: 0.95rem !important;
    padding: 0.55rem 0.95rem !important;
}

/* ===== MOBILE (max 767px) ===== */
@media (max-width: 767.98px) {
    /* ----- LAYOUT GENERALE ----- */

    /* Background più interessante */
    body {
        background: linear-gradient(180deg, #f8f9fc 0%, #f0f3f8 100%);
    }

    /* Main content compatto su mobile */
    :is(.app-main, #main-content) {
        padding-top: 1rem !important;
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
        padding-bottom: 1rem !important;
    }

    /* Container compatti */
    .container,
    .container-fluid {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    /* Riduzione spacing verticale globale */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    .py-3 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    /* Topbar compatta */
    .app-topbar {
        position: relative;
        padding: 0.45rem 0.85rem !important;
        min-height: auto;
        border-bottom: none;
        background: transparent;
        box-shadow: none;
    }

    /* .app-shell ereditera flex: 1 dal parent body */

    .app-topbar-inner {
        width: 100%;
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.5rem;
        background: rgba(255, 255, 255, 0.95);
        border: 1.5px solid rgba(13, 110, 253, 0.15);
        border-radius: 1.35rem;
        padding: 0.35rem 0.75rem;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    }

    .app-topbar .btn-outline-primary.d-lg-none {
        padding: 0;
        width: 44px;
        height: 44px;
        border-radius: 999px;
        border-width: 1.5px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.15rem;
        background: rgba(13, 110, 253, 0.08);
        color: var(--bs-primary);
        box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.12);
    }

    .app-topbar-title {
        font-size: 1rem;
        font-weight: 700;
        margin: 0;
        flex-grow: 1;
        text-align: left;
        padding-left: 0.25rem;
    }

    .app-topbar-actions {
        display: none !important;
    }

    /* Nascondi visivamente la ricerca ma mantienila accessibile per JS */
    .app-topbar-search {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        padding: 0.75rem 1rem;
        background: var(--bs-body-bg);
        border-bottom: 1px solid rgba(15, 23, 42, 0.1);
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
        z-index: 1050;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-10px);
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    /* Mostra ricerca quando ha focus */
    .app-topbar-search:focus-within {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    /* ----- CARDS E HERO - SPAZIOSO E LEGGIBILE ----- */

    /* Hero più compatto e moderno */
    .page-hero {
        padding: 1.25rem 1rem;
        border-radius: 1rem;
        margin-bottom: 1rem;
        background: linear-gradient(135deg, rgba(13, 110, 253, 0.06), rgba(116, 69, 255, 0.04));
        border: 1px solid rgba(13, 110, 253, 0.12);
    }

    .hero-title {
        font-size: 1.5rem;
        line-height: 1.3;
        font-weight: 700;
        margin-bottom: 0.5rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
        color: rgba(15, 23, 42, 0.7);
    }

    .hero-eyebrow {
        font-size: 0.85rem;
        margin-bottom: 0.35rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--bs-primary);
        font-weight: 600;
    }

    /* Hero metrics stack verticalmente */
    .hero-metrics {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .hero-metric-card {
        min-height: auto;
        padding: 1rem;
        border-radius: 0.85rem;
        background: rgba(255, 255, 255, 0.7);
        backdrop-filter: blur(8px);
    }

    .hero-metric-label {
        font-size: 0.85rem;
    }

    .hero-metric-value {
        font-size: 1.75rem;
        margin-top: 0.5rem;
    }

    /* Actions compatti e proporzionati */
    .hero-actions {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 0.4rem;
        margin-top: 0.85rem;
    }

    .hero-actions .btn {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
        padding: 0.6rem 0.65rem;
        font-size: 0.82rem;
        min-height: 44px;
        white-space: normal;
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ----- GAUGE CARDS E TARGET ----- */

    /* Target mensili - INGRANDITI */
    h2:has(.bi-bullseye) {
        font-size: 1.5rem !important;
        font-weight: 700;
        margin-top: 1.25rem;
        margin-bottom: 1rem;
    }

    /* Gauge cards target */
    .gauge-card {
        min-height: auto;
        margin-bottom: 1.25rem;
    }

    .gauge-header {
        font-size: 1.1rem !important;
        font-weight: 700;
        margin-bottom: 0.5rem;
        color: var(--bs-body-color);
    }

    .gauge-meter {
        --gauge-size: 120px;
    }

    .gauge-value {
        font-size: 1.25rem !important;
    }

    .gauge-amount {
        font-size: 1.75rem !important;
        color: var(--bs-body-color);
    }

    .gauge-currency {
        font-size: 1.1rem !important;
    }

    .gauge-number {
        font-size: 1.5rem !important;
    }

    .gauge-meta {
        font-size: 1rem !important;
    }

    .gauge-info-label {
        font-size: 1rem !important;
        font-weight: 600;
    }

    .percent-display {
        font-size: 2.75rem !important;
        font-weight: 700;
        margin: 0.75rem 0;
    }

    /* Metric chips più grandi */
    .metric-chip {
        font-size: 1rem !important;
        padding: 0.75rem 1rem !important;
    }

    /* Target progress bar più visibile */
    .target-progress {
        height: 12px !important;
        margin-top: 0.75rem;
    }

    .target-progress-meta {
        font-size: 0.95rem !important;
        margin-top: 0.5rem;
    }

    /* Card più compatte e moderne */
    .card {
        border-radius: 1rem;
        margin-bottom: 1rem;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.85rem 1rem;
        font-size: 1rem;
        font-weight: 600;
        background: rgba(13, 110, 253, 0.03);
        border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    }

    /* KPI Cards compatte */
    .kpi-card .col-6,
    .kpi-card .col-md-3 {
        min-width: 100%;
        flex: 0 0 100%;
        margin-bottom: 0.65rem;
    }

    .kpi-card .display-6 {
        font-size: 1.75rem;
        font-weight: 700;
    }

    .kpi {
        row-gap: 0.85rem;
    }

    .kpi .card {
        margin-bottom: 0.65rem;
    }

    /* Riduci padding interno KPI card */
    .kpi .card-body {
        padding: 0.85rem;
    }

    /* ----- TABELLE - Più leggibili ----- */

    /* Tabelle responsive con scroll orizzontale */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem 1.5rem;
        padding: 0 1rem;
    }

    .table-responsive table {
        min-width: 540px;
    }

    .table {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .table thead th {
        font-size: 0.875rem;
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
        font-weight: 700;
    }

    .table tbody td {
        padding: 0.75rem 0.5rem;
        vertical-align: middle;
        font-size: 0.95rem;
    }

    .table tbody tr {
        border-bottom-width: 1px;
    }

    /* Table fixed header più leggibile */
    .table-fixed thead th {
        font-size: 0.9rem;
        padding: 0.75rem 0.5rem;
    }

    /* ----- FORM E INPUT ----- */

    /* Form inline diventano stack */
    .form-group-inline {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    /* Input compatti e leggibili */
    .form-control,
    .form-select {
        font-size: 0.95rem;
        padding: 0.65rem 0.85rem;
        min-height: 48px;
        border-radius: 0.65rem;
        border: 1.5px solid rgba(15, 23, 42, 0.12);
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .form-control:focus,
    .form-select:focus {
        border-color: var(--bs-primary);
        box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
    }

    /* Label compatte */
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.35rem;
        font-weight: 600;
        color: rgba(15, 23, 42, 0.8);
    }

    /* Form group spacing ridotto */
    .mb-3 {
        margin-bottom: 0.85rem !important;
    }

    .mb-2 {
        margin-bottom: 0.5rem !important;
    }

    /* Bottoni più compatti e ordinati */
    .btn {
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
        min-height: 48px;
        font-weight: 600;
        border-radius: 0.75rem;
        transition: transform 0.1s ease, box-shadow 0.2s ease;
    }

    .btn:active {
        transform: scale(0.98);
    }

    .btn-primary {
        background: linear-gradient(135deg, #0d6efd 0%, #5a8dff 100%);
        border: none;
        box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
    }

    .btn-primary:hover {
        background: linear-gradient(135deg, #0b5ed7 0%, #4a7ee8 100%);
        box-shadow: 0 6px 18px rgba(13, 110, 253, 0.4);
        transform: translateY(-1px);
    }

    .btn-primary:active {
        transform: translateY(0) scale(0.98);
        box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
    }

    .btn-sm {
        padding: 0.5rem 0.85rem;
        font-size: 0.9rem;
        min-height: 40px;
    }

    /* Bottoni outline più leggeri */
    .btn-outline-secondary,
    .btn-outline-primary {
        border-width: 1.5px;
        font-weight: 500;
    }

    /* Bottoni filtro matteo-nav compatti */
    .matteo-nav .btn {
        padding: 0.65rem 0.9rem;
        font-size: 0.88rem;
        min-height: 44px;
        white-space: nowrap;
    }

    /* Riduzione spacing tra bottoni affiancati */
    .d-flex.gap-2 {
        gap: 0.5rem !important;
    }

    .d-flex.gap-3 {
        gap: 0.75rem !important;
    }

    /* ----- GRID FILTRI ----- */

    /* Filtri dashboard stack verticalmente */
    .row.g-2 > [class*="col-"] {
        margin-bottom: 0.5rem;
    }

    /* Filter grid più stretta */
    body.app-theme .filter-grid > div {
        min-width: 100%;
        flex: 0 0 100%;
    }

    /* ----- TOOLBAR LISTE ----- */

    .ui-table-toolbar {
        width: 100%;
        align-items: stretch !important;
    }

    .ui-table-toolbar-search {
        width: 100%;
    }

    .ui-table-toolbar-actions,
    .ui-table-toolbar-filters {
        width: 100%;
        gap: 0.5rem;
    }

    .ui-table-toolbar-actions .btn,
    .ui-table-toolbar-filters .ui-filter-chip {
        flex: 1 1 calc(50% - 0.5rem);
    }

    /* ----- COMMAND PALETTE ----- */

    /* Palette compatta */
    .command-palette {
        padding-top: 5vh;
    }

    .command-palette-dialog {
        width: 95vw;
        margin: 0 auto;
        border-radius: 12px;
    }

    .command-palette-header {
        padding: 0.75rem 1rem;
    }

    .command-palette-header .form-control {
        font-size: 0.9rem;
    }

    .command-palette-item {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .command-palette-body {
        max-height: 50vh;
    }

    /* ----- ALERT E BADGE ----- */

    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* ----- NAVIGATION ----- */

    /* Breadcrumb più compatte */
    .breadcrumb {
        font-size: 0.8rem;
        padding: 0.5rem 0;
    }

    /* Pagination più piccola */
    .pagination {
        font-size: 0.85rem;
    }

    .page-link {
        padding: 0.375rem 0.65rem;
    }

    /* ----- DROPDOWN E MODAL ----- */

    .dropdown-menu {
        font-size: 0.875rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
    }

    /* ----- ACCORDION - Più leggibile ----- */

    .accordion-item {
        margin-bottom: 1rem;
        border-radius: 1.25rem;
    }

    .accordion-button {
        padding: 1rem 1.25rem;
        font-size: 1rem;
        font-weight: 600;
    }

    .accordion-body {
        padding: 1.25rem;
        font-size: 0.95rem;
        line-height: 1.6;
    }

    /* ----- TOPBAR SEARCH MOBILE ----- */

    .app-topbar-search {
        display: flex !important;
        width: 100%;
        order: 3;
        margin-top: 0.25rem;
    }

    .app-topbar-search .input-group {
        width: 100%;
    }

    /* ----- SPACING UTILITIES OVERRIDE ----- */

    /* Riduci spacing verticali su mobile */
    .mt-4, .my-4 {
        margin-top: 1.5rem !important;
    }

    .mb-4, .my-4 {
        margin-bottom: 1.5rem !important;
    }

    .mt-5, .my-5 {
        margin-top: 2rem !important;
    }

    .mb-5, .my-5 {
        margin-bottom: 2rem !important;
    }

    .pt-4, .py-4 {
        padding-top: 1.5rem !important;
    }

    .pb-4, .py-4 {
        padding-bottom: 1.5rem !important;
    }

    /* ----- UTILITY CLASSES - Testo GRANDE e leggibile ----- */

    body {
        font-size: 1rem;
        line-height: 1.6;
    }

/* Custom styles for iscrizione_corso.php headers */
.header-step-font {
    font-family: var(--tf-font-sans, 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif);
    font-weight: 700; /* Make it explicitly bold */
    /* Il colore viene ereditato da .card-header-corsi */
}

.bg-primary-custom {
    background-color: var(--bs-primary) !important;
}

/* Ensure text on custom primary background is the new specific dark color in light mode, or white in dark mode */
.bg-primary-custom.text-dark {
    color: #151213 !important; /* New specific dark color for text on primary background */
}

:root[data-bs-theme='dark'] .bg-primary-custom.text-dark {
    color: var(--bs-white) !important; /* Keep white for dark mode */
}


    /* Text compatti e leggibili */
    .h1, h1 { font-size: 1.65rem; font-weight: 700; margin-bottom: 0.65rem; }
    .h2, h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.5rem; }
    .h3, h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.5rem; }
    .h4, h4 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
    .h5, h5 { font-size: 1rem; font-weight: 600; margin-bottom: 0.35rem; }
    .h6, h6 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.35rem; }

    small,
    .small {
        font-size: 0.9rem;
    }

    /* Display responsive - GRANDE */
    .display-1 { font-size: 3.5rem; }
    .display-2 { font-size: 3rem; }
    .display-3 { font-size: 2.5rem; }
    .display-4 { font-size: 2rem; }
    .display-5 { font-size: 1.75rem; }
    .display-6 { font-size: 1.5rem; }
}

/* ===== DESKTOP (min 768px) - Mostra menu topbar ===== */
@media (min-width: 768px) {
    .app-topbar-actions {
        display: flex !important;
    }
}


/* ===== MOBILE SMALL (max 575px) ===== */
@media (max-width: 575.98px) {
    /* Ancora più compatto per schermi molto piccoli */

    .app-topbar {
        padding: 0.5rem;
    }

    .app-topbar-title {
        font-size: 0.95rem;
    }

    .app-topbar-actions {
        gap: 0.4rem;
    }

    .app-topbar-search {
        margin-top: 0.5rem;
    }

    .app-main {
        padding-top: 0.75rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        padding-bottom: 0.75rem !important;
    }

    .container,
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .page-hero {
        padding: 1rem 0.75rem;
    }

    .card {
        border-radius: 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        margin: 0 -0.5rem 1rem;
        padding: 0 0.5rem;
    }

    .gauge-meter {
        --gauge-size: 90px;
    }

    .table {
        font-size: 0.75rem;
    }

    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    /* Stack tutti i bottoni */
    .d-flex.gap-2 .btn,
    .d-flex.gap-3 .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }


    .ui-table-toolbar-actions .btn,
    .ui-table-toolbar-filters .ui-filter-chip {
        flex: 1 1 100%;
    }

    /* Hero actions full width */
    .matteo-nav .btn,
    body.app-theme .matteo-nav .btn {
        flex: 1 1 100%;
    }
}

/* ===== OTTIMIZZAZIONI LANDSCAPE MOBILE ===== */
@media (max-height: 600px) and (orientation: landscape) {
    /* Riduci padding verticali in landscape */
    .app-main {
        padding-top: 0.75rem !important;
        /* padding-bottom remains as calculated for bottom nav - do NOT override */
    }

    .page-hero {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .modal-dialog {
        margin: 0.5rem auto;
    }

    .command-palette {
        padding-top: 2vh;
    }

    .command-palette-body {
        max-height: 40vh;
    }
}

/* ===== iPHONE SMALL (max 390px) - ANCORA GRANDE E LEGGIBILE ===== */
@media (max-width: 390px) {
    /* Topbar ultra compatta */
    .app-topbar {
        padding: 0.35rem 0.5rem !important;
    }

    .app-topbar-title {
        font-size: 1rem;
    }

    .app-topbar-inner {
        gap: 0.25rem;
    }

    .app-topbar-actions .btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
        min-height: 32px;
    }

    /* Ricerca dropdown anche su iPhone piccoli */
    .app-topbar-search {
        padding: 0.65rem 0.85rem;
        font-size: 0.9rem;
    }

    /* Padding ancora generoso */
    .app-main {
        padding-top: 1rem !important;
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
        /* padding-bottom is inherited from @media (max-width: 767.98px) */
    }

    .container,
    .container-fluid {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    /* Hero grande e leggibile */
    .page-hero {
        padding: 1.5rem 1rem;
        border-radius: 1.1rem;
        margin-bottom: 1.25rem;
    }

    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
        font-weight: 700;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .hero-eyebrow {
        font-size: 0.6rem;
        letter-spacing: 0.05em;
    }

    /* Hero metrics ridotti */
    .hero-metrics {
        gap: 0.5rem;
    }

    .hero-metric-card {
        padding: 0.65rem 0.75rem;
        border-radius: 0.75rem;
    }

    .hero-metric-label {
        font-size: 0.6rem;
    }

    .hero-metric-value {
        font-size: 1.1rem;
    }

    .hero-metric-caption {
        font-size: 0.7rem;
    }

    /* Card ridotte */
    .card {
        border-radius: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Gauge Ultra piccoli */
    .gauge-meter {
        --gauge-size: 80px;
    }

    .gauge-value {
        font-size: 0.9rem;
    }

    .gauge-value span {
        font-size: 0.6rem;
    }

    .gauge-meta {
        font-size: 0.75rem;
    }

    .gauge-card {
        padding: 0.75rem;
    }

    /* KPI cards */
    .kpi-card .display-6 {
        font-size: 1.5rem;
    }

    /* Topbar minimo */
    .app-topbar {
        padding: 0.375rem 0.5rem;
    }

    .app-topbar-title {
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Bottoni GRANDI e full-width */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        width: 100%;
        margin-bottom: 0.75rem;
        font-weight: 600;
        min-height: 52px;
    }

    .btn-outline-primary,
    .btn-primary,
    .btn-outline-secondary {
        width: 100%;
    }

    .btn-primary {
        box-shadow: 0 8px 20px rgba(13, 110, 253, 0.3);
    }

    /* Input form GRANDI e leggibili */
    .form-control,
    .form-select {
        font-size: 0.95rem;
        padding: 0.65rem 0.85rem;
        margin-bottom: 0.75rem;
        min-height: 48px;
        border-radius: 0.75rem;
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
        font-weight: 600;
    }

    /* Nascondere elementi ingombranti */
    .d-none.d-sm-inline,
    .d-none.d-md-inline,
    .d-none.d-lg-inline,
    .d-none.d-xl-inline {
        display: none !important;
    }

    /* Tabelle ultra compatte */
    .table {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }

    .table thead th {
        font-size: 0.6rem;
        padding: 0.35rem 0.25rem;
        line-height: 1.2;
    }

    .table tbody td {
        padding: 0.35rem 0.25rem;
        line-height: 1.2;
    }

    .table-responsive {
        margin-bottom: 0.5rem;
    }

    .table-responsive table {
        min-width: 500px;
    }

    /* Breadcrumb ridotto */
    .breadcrumb {
        font-size: 0.75rem;
        padding: 0.25rem 0;
        margin-bottom: 0.5rem;
    }

    /* Pagination piccola */
    .pagination {
        font-size: 0.8rem;
        gap: 0.25rem;
    }

    .page-link {
        padding: 0.3rem 0.5rem;
        min-height: auto;
    }

    /* Badge compatti */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    /* Alert ridotto */
    .alert {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }

    /* Accordion super compatto */
    .accordion-item {
        margin-bottom: 0.35rem;
        border-radius: 0.75rem;
    }

    .accordion-button {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.4rem;
    }

    .accordion-body {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    /* Gauge card spacing */
    .gauge-card {
        margin-bottom: 0.75rem;
    }

    .gauge-card .card-body {
        gap: 1.5rem;
    }

    /* Percent display */
    .percent-display {
        font-size: 1.25rem;
    }

    /* Metric chips */
    .metric-chip {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    /* Text utilities */
    .h1, h1 { font-size: 1.4rem; }
    .h2, h2 { font-size: 1.2rem; }
    .h3, h3 { font-size: 1.05rem; }
    .h4, h4 { font-size: 0.95rem; }
    .h5, h5 { font-size: 0.9rem; }
    .small, .text-muted { font-size: 0.75rem; }

    /* Spacing ridotto */
    .mt-1, .my-1 { margin-top: 0.25rem !important; }
    .mb-1, .my-1 { margin-bottom: 0.25rem !important; }
    .mt-2, .my-2 { margin-top: 0.5rem !important; }
    .mb-2, .my-2 { margin-bottom: 0.5rem !important; }
    .mt-3, .my-3 { margin-top: 0.75rem !important; }
    .mb-3, .my-3 { margin-bottom: 0.75rem !important; }
    .mt-4, .my-4 { margin-top: 1rem !important; }
    .mb-4, .my-4 { margin-bottom: 1rem !important; }

    .pt-2, .py-2 { padding-top: 0.5rem !important; }
    .pb-2, .py-2 { padding-bottom: 0.5rem !important; }
    .pt-3, .py-3 { padding-top: 0.75rem !important; }
    .pb-3, .py-3 { padding-bottom: 0.75rem !important; }

    /* Row/col spacing */
    .row.g-2 > [class*="col-"] {
        margin-bottom: 0.25rem;
    }

    .row.g-3 > [class*="col-"] {
        margin-bottom: 0.5rem;
    }

    /* Dropdown menu compatto */
    .dropdown-menu {
        font-size: 0.8rem;
        padding: 0.35rem 0;
    }

    .dropdown-item {
        padding: 0.4rem 0.75rem;
    }

    /* Modal compatto */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-header {
        padding: 0.75rem;
    }

    .modal-body {
        padding: 0.75rem;
    }

    .modal-footer {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .modal-title {
        font-size: 0.95rem;
    }

    /* Command palette super compatta */
    .command-palette {
        padding-top: 3vh;
    }

    .command-palette-dialog {
        width: 98vw;
        border-radius: 10px;
    }

    .command-palette-header {
        padding: 0.6rem 0.75rem;
    }

    .command-palette-header .form-control {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    .command-palette-item {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    .command-palette-body {
        max-height: 45vh;
    }

    /* Form group inline - full stack */
    .form-group-inline {
        gap: 0.5rem;
    }

    /* Agent summary card */
    .agent-summary-card {
        padding: 0.75rem;
    }

    .agent-summary-card .value-amount {
        font-size: 1.25rem;
    }

    .agent-summary-card .metric-label {
        font-size: 0.7rem;
    }

    /* Filter grid */
    body.app-theme .filter-grid > div {
        margin-bottom: 0.5rem;
    }

    /* Matteo agent block */
    .matteo-agent-block {
        padding: 0.65rem 0.75rem;
        margin-bottom: 0.5rem;
    }

    .agent-title {
        font-size: 0.85rem;
    }

    .agent-subtitle {
        font-size: 0.75rem;
    }

    /* Hero actions buttons */
    .hero-actions {
        gap: 0.35rem;
    }

    .hero-actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
}

/* ===== iPHONE SE (max-width: 375px) - ANCORA PIÙ STRETTO ===== */
@media (max-width: 375px) {
    .app-main {
        padding-top: 0.375rem !important;
        padding-left: 0.375rem !important;
        padding-right: 0.375rem !important;
        padding-bottom: 0.5rem !important;
    }

    .container,
    .container-fluid {
        padding-left: 0.375rem;
        padding-right: 0.375rem;
    }

    .page-hero {
        padding: 0.75rem 0.6rem;
        margin-bottom: 0.75rem;
    }

    .hero-title {
        font-size: 1rem;
    }

    .hero-metric-card {
        padding: 0.55rem 0.65rem;
    }

    .gauge-meter {
        --gauge-size: 75px;
    }

    .card-body {
        padding: 0.65rem;
    }

    .btn {
        padding: 0.4rem 0.65rem;
        font-size: 0.75rem;
    }

    .table {
        font-size: 0.65rem;
    }

    .table thead th {
        font-size: 0.55rem;
        padding: 0.25rem 0.2rem;
    }

    .table tbody td {
        padding: 0.25rem 0.2rem;
    }

    .form-control,
    .form-select {
        font-size: 0.75rem;
        padding: 0.35rem 0.5rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 0.65rem;
    }

    .command-palette-dialog {
        width: 99vw;
    }

    .command-palette-item {
        padding: 0.5rem 0.65rem;
        font-size: 0.75rem;
    }

    .h1, h1 { font-size: 1.2rem; }
    .h2, h2 { font-size: 1rem; }
    .h3, h3 { font-size: 0.95rem; }
}

/* ===== TOUCH OPTIMIZATION ===== */
@media (hover: none) and (pointer: coarse) {
    /* Aumenta area touch per dispositivi touch */

    .btn,
    .nav-link,
    .dropdown-item,
    .page-link {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Link in tabelle più facili da cliccare */
    .table td a,
    .table th a {
        padding: 0.5rem;
        margin: -0.5rem;
    }

    /* Checkbox e radio più grandi */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* ============================================
   DEBUG & FIX per Bottom Nav Overlap
   ============================================ */

/* Debug visivo (rimuovi in produzione o commenta) */
.mobile-bottom-nav.debug {
    background: rgba(255, 0, 0, 0.3) !important;
    border-top: 3px solid red !important;
}

.app-main.debug,
#main-content.debug {
    outline: 2px dashed blue;
    outline-offset: -2px;
}

/* Pagine legacy che NON usano layout_start() - solo padding minimo */
@media (max-width: 991.98px) {
    body:not(.app-shell) > main,
    body:not(.app-shell) > .container,
    body:not(.app-shell) > .container-fluid {
        padding-bottom: 1rem;
    }
}

/* Safe area inset indicator per debug iOS */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 165, 0, 0.3);
        pointer-events: none;
        display: none; /* Abilita per debug: display: block; */
    }
}

/* ============================================
   NOTIFICATION SYSTEM STYLES
   ============================================ */

.notification-dropdown {
    position: relative;
    display: inline-block;
    isolation: isolate;
}

.notification-toggle {
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notification-toggle:hover {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
}

.notification-toggle:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.notification-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem !important;
    min-width: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background: #ffffff;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    min-width: 320px;
    max-width: 380px;
    width: 360px;
    visibility: hidden;
    opacity: 0;
    -webkit-transform: translateY(-10px);
    -moz-transform: translateY(-10px);
    -ms-transform: translateY(-10px);
    transform: translateY(-10px);
    -webkit-transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
    -moz-transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
    pointer-events: none;
    /* Override glassmorphism della topbar */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    isolation: isolate;
}

.notification-menu.show {
    visibility: visible;
    opacity: 1;
    -webkit-transform: translateY(0);
    -moz-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-transition-delay: 0s;
    -moz-transition-delay: 0s;
    transition-delay: 0s;
    pointer-events: auto;
}

.notification-header {
    background-color: #f8f9fa;
    background-image: none;
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 14px 16px !important;
    border-bottom: 1px solid #e9ecef !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.notification-header span {
    color: #212529;
    font-size: 15px;
}

.notification-mark-all-read {
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.notification-mark-all-read:hover {
    color: #0a58ca !important;
    text-decoration: underline !important;
}

.notification-list {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -moz-flex-direction: column;
    -ms-flex-direction: column;
    -webkit-flex-direction: column;
    flex-direction: column;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling */
.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 0.5rem 0;
}

.notification-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.notification-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.notification-item {
    padding: 14px 20px 14px 28px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #ffffff;
    cursor: pointer;
    -webkit-transition: background-color 0.2s ease;
    -moz-transition: background-color 0.2s ease;
    transition: background-color 0.2s ease;
    position: relative;
    -webkit-box-flex: 0;
    -moz-box-flex: 0;
    -ms-flex: 0 0 auto;
    -webkit-flex: 0 0 auto;
    flex: 0 0 auto;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

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

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item.unread {
    background-color: #e7f3ff;
    font-weight: 500;
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 20px;
    width: 8px;
    height: 8px;
    background: #0d6efd;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

.notification-title {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 2px;
    color: #212529;
    font-weight: 600;
    word-break: break-word;
}

.notification-message {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 4px;
    line-height: 1.4;
    word-break: break-word;
}

.notification-time {
    font-size: 12px;
    color: #999;
    margin-top: auto;
}

.notification-empty {
    padding: 50px 30px;
    text-align: center;
    color: #999;
    background-color: #ffffff;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -moz-flex-direction: column;
    -ms-flex-direction: column;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -moz-align-items: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
}

/* Fallback for browsers that don't support gap */
.notification-empty > * + * {
    margin-top: 12px;
}

.notification-empty i {
    font-size: 3rem;
    opacity: 0.4;
}

.notification-empty p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.notification-delete {
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.notification-item:hover .notification-delete {
    opacity: 1;
}

.notification-link {
    position: absolute;
    inset: 0;
}

/* Dark mode support - DISABILITATA (solo light mode) */


/* Tablet responsiveness */
@media (max-width: 768px) {
    .notification-menu {
        width: 340px;
        max-width: calc(100vw - 40px);
        right: -10px;
    }
}

/* Tablet responsiveness */
@media (max-width: 768px) {
    .notification-menu {
        width: 340px;
        max-width: calc(100vw - 40px);
        right: -10px;
    }
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    .notification-menu {
        position: fixed;
        top: 60px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 80px) !important;
        background: #ffffff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .notification-list {
        max-height: calc(100vh - 180px) !important;
    }

    .notification-item {
        padding: 14px 18px;
    }

    .notification-title {
        font-size: 14px;
    }

    .notification-message {
        font-size: 13px;
    }

    .notification-delete {
        opacity: 1;
    }
}

/* ===== PDF Export Mobile Modal ===== */
.pdf-export-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
    padding: env(safe-area-inset-bottom, 20px) 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pdf-export-modal {
    background: var(--bs-body-bg, #fff);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 20px;
    animation: slideUp 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.pdf-export-modal.pdf-loading {
    border-radius: 16px;
    max-width: 280px;
    margin-bottom: 40px;
    text-align: center;
    padding: 30px;
}

.pdf-export-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

.pdf-export-header i {
    font-size: 1.5rem;
}

.pdf-export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.pdf-export-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 12px;
    background: var(--bs-body-bg, #fff);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 72px;
    text-align: left;
}

.pdf-export-option:hover,
.pdf-export-option:focus {
    border-color: var(--bs-primary, #0d6efd);
    background: rgba(13, 110, 253, 0.05);
    outline: none;
}

.pdf-export-option:active {
    transform: scale(0.98);
}

.pdf-export-option i {
    font-size: 1.3rem;
    color: var(--bs-primary, #0d6efd);
    margin-bottom: 4px;
}

.pdf-export-option span {
    font-weight: 600;
    font-size: 1rem;
    color: var(--bs-body-color, #212529);
}

.pdf-export-option small {
    font-size: 0.85rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-top: 2px;
}

.pdf-export-cancel {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: var(--bs-light, #f8f9fa);
    color: var(--bs-body-color, #212529);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pdf-export-cancel:hover,
.pdf-export-cancel:focus {
    background: var(--bs-gray-300, #dee2e6);
    outline: none;
}

/* Desktop: modal centrato */
@media (min-width: 576px) {
    .pdf-export-overlay {
        align-items: center;
        padding: 20px;
    }

    .pdf-export-modal {
        border-radius: 16px;
        margin-bottom: 0;
    }
}

/* ============================================================
   DUPLICATE WARNING - Anti-duplicati clienti real-time
   ============================================================ */
.duplicate-warning-container {
    transition: all 0.3s ease;
}

.dup-candidate-card {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    border-left-width: 4px !important;
    border-left-style: solid !important;
}

.dup-candidate-card.dup-risk-high {
    border-left-color: var(--bs-danger, #dc3545) !important;
}

.dup-candidate-card.dup-risk-medium {
    border-left-color: var(--bs-warning, #ffc107) !important;
}

.dup-candidate-card.dup-risk-low {
    border-left-color: var(--bs-secondary, #6c757d) !important;
}

/* Touch target minimo 56px per bottoni azione */
.dup-action-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
}

/* Mobile: stack verticale */
@media (max-width: 575.98px) {
    .dup-candidate-card .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .dup-candidate-card .d-flex.gap-2 {
        width: 100%;
        margin-top: 0.5rem;
    }

    .dup-action-btn {
        min-height: 56px;
        flex: 1;
        justify-content: center;
    }

    .duplicate-warning-container .d-flex.gap-2.flex-wrap {
        flex-direction: column;
    }

    .duplicate-warning-container .d-flex.gap-2.flex-wrap .btn {
        min-height: 56px;
        width: 100%;
    }
}

/* Dark mode support */
[data-bs-theme="dark"] .dup-candidate-card {
    background: var(--bs-dark-bg-subtle, #1a1d21);
    border-color: var(--bs-border-color-translucent, rgba(255,255,255,0.1));
}
