:root {
    --wp-navy: #142238;
    --wp-navy-light: #1e3252;
    --wp-gold: #f59e0b;
    --wp-yellow-input: #fef9c3;
    --wp-yellow-border: #eab308;
    --wp-blue-auto: #e0f2fe;
    --wp-blue-border: #0284c7;
    --wp-bg: #f4f6f9;
}

body.bg-app {
    background-color: var(--wp-bg);
    color: #1e293b;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.bg-wp-navy {
    background-color: var(--wp-navy) !important;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 1.1rem;
}

/* Logo & Brand Lockup — Login & Navbar */
.wp-logo-login {
    width: 88px;
    height: 88px;
    max-width: 88px;
    max-height: 88px;
    object-fit: cover;
    border-radius: 50%;
    border: 2.5px solid var(--wp-gold);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18), 0 6px 16px rgba(0, 0, 0, 0.4);
    background-color: #38bdf8;
}

.wp-motto-login {
    font-size: 0.86rem;
    font-weight: 600;
    font-style: italic;
    color: #fde047;
    letter-spacing: 0.015em;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.wp-navbar-brand {
    max-width: calc(100% - 54px);
    min-width: 0;
}

.wp-logo-nav {
    width: 42px;
    height: 42px;
    max-width: 42px;
    max-height: 42px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--wp-gold);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.16), 0 2px 6px rgba(0, 0, 0, 0.3);
    background-color: #38bdf8;
}

.wp-brand-title {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: 0.025em;
    color: #ffffff;
}

.wp-role-badge {
    font-size: 0.65rem;
    padding: 0.22em 0.5em;
    max-width: 110px;
    letter-spacing: 0.02em;
}

.wp-motto-nav {
    font-size: 0.7rem;
    font-weight: 600;
    font-style: italic;
    color: #fde047;
    white-space: nowrap;
    margin-top: 3px;
    letter-spacing: 0.012em;
    line-height: 1.1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.min-w-0 {
    min-width: 0;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.82);
    border-radius: 6px;
    padding: 0.4rem 0.55rem;
    font-size: 0.84rem;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.navbar-dark .navbar-nav .nav-link.active {
    color: #fff;
    background-color: rgba(245, 158, 11, 0.22);
    border-bottom: 2px solid var(--wp-gold);
    font-weight: 600;
}

/* Ottimizzazione millimetrica Navbar su Laptop XL (1200px - 1399px: 1280px e 1366px) */
@media (min-width: 1200px) {
    .wp-navbar-brand {
        max-width: none;
    }
    .border-xl-0 {
        border-top: 0 !important;
    }
}

@media (min-width: 1200px) and (max-width: 1279.98px) {
    .wp-logo-nav {
        width: 36px;
        height: 36px;
        max-width: 36px;
        max-height: 36px;
    }
    .wp-brand-title {
        font-size: 0.9rem;
    }
    .wp-motto-nav {
        font-size: 0.62rem;
    }
    .wp-main-nav {
        gap: 0.12rem !important;
    }
    .navbar-dark .navbar-nav .nav-link {
        font-size: 0.74rem;
        padding: 0.35rem 0.36rem;
    }
}

@media (min-width: 1280px) and (max-width: 1399.98px) {
    .wp-logo-nav {
        width: 38px;
        height: 38px;
        max-width: 38px;
        max-height: 38px;
    }
    .wp-brand-title {
        font-size: 0.94rem;
    }
    .wp-motto-nav {
        font-size: 0.65rem;
    }
    .wp-main-nav {
        gap: 0.18rem !important;
    }
    .navbar-dark .navbar-nav .nav-link {
        font-size: 0.78rem;
        padding: 0.38rem 0.44rem;
    }
}

@media (min-width: 1400px) and (max-width: 1599.98px) {
    .navbar-dark .navbar-nav .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.48rem;
    }
}

@media (min-width: 1600px) {
    .wp-logo-nav {
        width: 44px;
        height: 44px;
        max-width: 44px;
        max-height: 44px;
    }
    .wp-brand-title {
        font-size: 1.04rem;
    }
    .wp-motto-nav {
        font-size: 0.72rem;
    }
    .navbar-dark .navbar-nav .nav-link {
        font-size: 0.86rem;
        padding: 0.42rem 0.65rem;
    }
}

@media (max-width: 575.98px) {
    .wp-logo-nav {
        width: 36px;
        height: 36px;
        max-width: 36px;
        max-height: 36px;
    }
    .wp-brand-title {
        font-size: 0.92rem;
    }
    .wp-role-badge {
        font-size: 0.6rem;
        max-width: 88px;
    }
    .wp-motto-nav {
        font-size: 0.63rem;
    }
    .wp-logo-login {
        width: 76px;
        height: 76px;
        max-width: 76px;
        max-height: 76px;
    }
    .wp-motto-login {
        font-size: 0.8rem;
    }
}

/* Stile Modulo Giornaliero fedele ai colori logici dell'Excel */
.wp-section-header {
    background-color: var(--wp-navy);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 0.88rem;
    text-transform: uppercase;
    padding: 0.6rem 1rem;
    border-radius: 6px 6px 0 0;
}

.wp-code-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 26px;
    border-radius: 5px;
    font-weight: 700;
    font-size: 0.78rem;
    background-color: #e2e8f0;
    color: #334155;
}

.wp-code-badge.auto {
    background-color: #0284c7;
    color: #fff;
}

.wp-input-yellow {
    background-color: #fefce8 !important;
    border: 1.5px solid #facc15 !important;
    font-weight: 600;
    text-align: right;
    color: #0f172a;
}

.wp-input-yellow:focus {
    background-color: #ffffff !important;
    border-color: #d97706 !important;
    box-shadow: 0 0 0 0.2rem rgba(245, 158, 11, 0.25) !important;
}

.wp-input-yellow:disabled,
.wp-input-yellow[readonly] {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #64748b;
}

.wp-auto-box {
    background-color: var(--wp-blue-auto);
    border: 1.5px solid #7dd3fc;
    border-radius: 6px;
    padding: 0.45rem 0.75rem;
    font-weight: 700;
    text-align: right;
    color: #0369a1;
}

/* Tabelle Riepilogo Direzione */
.table-wp-report {
    font-size: 0.785rem;
    margin-bottom: 0;
}

.table-wp-report thead th {
    background-color: #1e293b;
    color: #fff;
    font-weight: 600;
    vertical-align: middle;
    border-bottom: none;
    white-space: nowrap;
    padding: 0.48rem 0.42rem;
}

.table-wp-report tbody td,
.table-wp-report tfoot td {
    vertical-align: middle;
    padding: 0.44rem 0.42rem;
}

.table-wp-report tfoot tr.row-totale-rete td,
.table-wp-report tbody tr.row-totale-rete td {
    background-color: #dbeafe !important;
    color: #1e3a8a;
    font-weight: 700;
    border-top: 2px solid #1d4ed8;
}

.cell-auto-highlight {
    background-color: #f0f9ff !important;
    font-weight: 600;
    color: #0369a1;
}

/* KPI Cards */
.kpi-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    transition: transform 0.15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* Funnel Steps */
.funnel-step {
    position: relative;
    border-left: 4px solid #0284c7;
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 0.65rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Calendario Compilazioni */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    min-height: 92px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.15s ease;
}

.calendar-day:hover {
    border-color: #94a3b8;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.calendar-day.day-submitted {
    background-color: #f0fdf4;
    border-color: #86efac;
}

.calendar-day.day-missing {
    background-color: #fffbeb;
    border-color: #fde047;
}

.calendar-day.day-future {
    background-color: #f8fafc;
    opacity: 0.65;
}

@media (max-width: 991.98px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767.98px) {
    .calendar-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Prima colonna ("Centro") bloccata a sinistra durante lo scroll orizzontale su smartphone/tablet */
    .table-wp-report thead th:first-child,
    .table-wp-report tbody td:first-child,
    .table-wp-report tfoot td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
    }

    .table-wp-report tbody td:first-child {
        background-color: #ffffff;
        box-shadow: 2px 0 4px rgba(15, 23, 42, 0.08);
    }

    .table-wp-report tfoot tr.row-totale-rete td:first-child {
        background-color: #dbeafe !important;
        box-shadow: 2px 0 4px rgba(15, 23, 42, 0.12);
    }

    /* Scorrimento fluido per i tab delle sezioni su schermi stretti */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 575.98px) {
    .calendar-grid {
        grid-template-columns: 1fr;
    }

    /* Ottimizzazione Modulo Giornaliero su smartphone (evita zoom iOS e allarga i campi numerici) */
    #dailyReportForm table.table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 0.35rem 0;
        border-bottom: 1px solid #e2e8f0;
    }

    #dailyReportForm table.table tbody tr td {
        border-bottom: none;
        padding: 0.25rem 0.5rem;
    }

    #dailyReportForm table.table tbody tr td:nth-child(1) {
        width: 48px !important;
        flex: 0 0 48px;
    }

    #dailyReportForm table.table tbody tr td:nth-child(2) {
        width: calc(100% - 168px) !important;
        flex: 1 1 calc(100% - 168px);
        font-size: 0.9rem;
    }

    #dailyReportForm table.table tbody tr td:nth-child(3) {
        width: 120px !important;
        flex: 0 0 120px;
    }

    #dailyReportForm table.table tbody tr td:nth-child(4) {
        width: 100% !important;
        flex: 0 0 100%;
        padding-left: 52px;
        padding-top: 0;
        font-size: 0.76rem;
    }

    .wp-input-yellow,
    #dailyReportForm .form-control,
    #dailyReportForm .form-select {
        font-size: 16px; /* Previene l'auto-zoom su iPhone/iOS */
    }
}

@media print {
    body.bg-app {
        background-color: #fff !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #cbd5e1 !important;
    }
    .table-wp-report {
        font-size: 0.72rem;
    }
}

/* =========================================================================
   SMART FLOATING HELP PILL & HYBRID TICKET DRAWER (DESKTOP + MOBILE)
   ========================================================================= */
.btn-wp-navy {
    background-color: var(--wp-navy);
    color: #ffffff;
    border-color: var(--wp-navy);
}
.btn-wp-navy:hover,
.btn-wp-navy:focus {
    background-color: #163056;
    color: #ffffff;
    border-color: #163056;
}
.text-wp-navy {
    color: var(--wp-navy) !important;
}
.btn-xs {
    padding: 0.18rem 0.48rem;
    font-size: 0.74rem;
    border-radius: 0.25rem;
}

.wp-help-fab {
    position: fixed;
    z-index: 1038;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    right: calc(14px + env(safe-area-inset-right, 0px));
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #1b365d 0%, #0f172a 100%);
    color: #ffffff;
    border: 1.5px solid rgba(245, 158, 11, 0.72);
    border-radius: 999px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28);
    height: 42px;
    user-select: none;
    touch-action: none;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.2s ease,
                box-shadow 0.2s ease,
                border-radius 0.2s ease;
}

.wp-help-fab:hover {
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.38);
    border-color: #fbbf24;
}

.wp-help-fab[data-dock="left"] {
    left: calc(14px + env(safe-area-inset-left, 0px));
    right: auto;
    flex-direction: row-reverse;
}

.wp-help-fab[data-dragging="true"] {
    transition: none !important;
    transform: scale(1.05);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.45);
    cursor: grabbing;
}

.wp-help-fab__trigger {
    background: transparent;
    border: none;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    padding: 0 0.65rem 0 0.85rem;
    height: 100%;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: grab;
    white-space: nowrap;
}

.wp-help-fab[data-dock="left"] .wp-help-fab__trigger {
    padding: 0 0.85rem 0 0.65rem;
}

.wp-help-fab__icon {
    color: #fbbf24;
    font-size: 1rem;
}

.wp-help-fab__badge {
    font-size: 0.68rem;
    padding: 0.22em 0.5em;
}

.wp-help-fab__minimize {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.78);
    height: 100%;
    width: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-top-right-radius: 999px;
    border-bottom-right-radius: 999px;
    font-size: 0.76rem;
    padding: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.wp-help-fab[data-dock="left"] .wp-help-fab__minimize {
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px 0 0 999px;
}

.wp-help-fab__minimize:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Modalità Edge Peek (24px non ingombrante sul bordo schermo) */
.wp-help-fab[data-mode="peek"][data-dock="right"] {
    right: 0 !important;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    opacity: 0.88;
}

.wp-help-fab[data-mode="peek"][data-dock="left"] {
    left: 0 !important;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    opacity: 0.88;
}

.wp-help-fab[data-mode="peek"] .wp-help-fab__label {
    display: none !important;
}

.wp-help-fab[data-mode="peek"] .wp-help-fab__trigger {
    padding: 0 0.45rem;
}

/* Auto-hide quando la tastiera virtuale smartphone è attiva */
.wp-help-fab[data-kb-hidden="true"] {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(24px) scale(0.9);
}

/* Hybrid Drawer: Offcanvas laterale (450px) su Desktop/Tablet, Bottom Sheet (93dvh) su Mobile */
.wp-ticket-drawer {
    width: 455px !important;
    max-width: 100vw;
    border-left: 1px solid rgba(15, 23, 42, 0.15);
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.18);
}

.wp-drawer-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(251, 191, 36, 0.18);
    color: #fbbf24;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.wp-drawer-tabs .nav-link {
    color: #475569;
    border-radius: 0.4rem 0.4rem 0 0;
}

.wp-drawer-tabs .nav-link.active {
    color: var(--wp-navy);
    background-color: #ffffff;
    border-color: #dee2e6 #dee2e6 #ffffff;
}

.wp-context-banner {
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-left: 3.5px solid var(--wp-navy);
    border-radius: 0.375rem;
    padding: 0.45rem 0.65rem;
}

.wp-dropzone {
    border: 1.5px dashed #94a3b8;
    background-color: #f8fafc;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.wp-dropzone:hover,
.wp-dropzone--active {
    border-color: var(--wp-navy);
    background-color: #eff6ff;
}

.wp-screenshot-canvas-wrap canvas {
    max-height: 195px;
    width: auto;
    cursor: crosshair;
    touch-action: none;
}

.wp-ticket-card {
    transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.wp-ticket-card:hover {
    border-color: var(--wp-navy) !important;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.wp-super-actions-card {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fde68a !important;
}

.wp-chat-bubble {
    border: 1px solid #e2e8f0;
}

.wp-chat-bubble--center {
    background-color: #ffffff;
    border-left: 3.5px solid #0ea5e9;
}

.wp-chat-bubble--admin {
    background-color: #f8fafc;
    border-left: 3.5px solid var(--wp-navy);
}

.wp-chat-bubble--internal {
    background-color: #fefce8;
    border: 1px dashed #eab308;
    border-left: 3.5px solid #ca8a04;
}

@media (max-width: 575.98px) {
    .wp-ticket-drawer.offcanvas-end {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        height: 93dvh !important;
        max-height: 93dvh !important;
        border-left: none;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        transform: translateY(100%);
    }

    .wp-ticket-drawer.offcanvas-end.show,
    .wp-ticket-drawer.offcanvas-end.showing {
        transform: none;
    }

    .wp-ticket-drawer.offcanvas-end.hiding {
        transform: translateY(100%);
    }

    .wp-drawer-handle {
        background-color: var(--wp-navy);
        border-top-left-radius: 15px;
        border-top-right-radius: 15px;
        padding-top: 6px;
        text-align: center;
    }

    .wp-drawer-handle span {
        display: inline-block;
        width: 38px;
        height: 4px;
        border-radius: 99px;
        background: rgba(255, 255, 255, 0.35);
    }

    .wp-ticket-drawer .form-control,
    .wp-ticket-drawer .form-select {
        font-size: 16px; /* Previene auto-zoom iOS */
    }
}
