:root {
    --sidebar-bg: #ffffff;
    --main-bg: #ffffff;
    --accent: #167D87;
    --border: #e0e6ed;
    --text-main: #2c3e50;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --b2b: #2980b9;
    --colonne-sale: 6;
    --slot-height: 55px;
    --panel-width: 400px;
}

/* --- UNIFORMITÀ TIPOGRAFICA ASSOLUTA --- */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Font unico Inter per TUTTA la piattaforma — lettere E numeri */
*, *::before, *::after,
body, input, button, select, textarea, label,
td, th, span, div, p, h1, h2, h3, h4, h5, h6,
.flatpickr-calendar, .flatpickr-calendar * {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

/* Numeri allineati e proporzionati senza ricorrere a monospace */
.font-num,
[class*="kpi-value"], [class*="-mono"], [class*="-importo"],
[class*="-totale"], [class*="-tot-"], [class*="-valore"],
td[style*="monospace"], span[style*="monospace"] {
    font-variant-numeric: tabular-nums !important;
    font-feature-settings: "tnum" 1 !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

body { margin: 0; display: flex; height: 100vh; overflow: hidden; background: var(--main-bg); color: var(--text-main); }
.left-sidebar { width: 260px; flex-shrink: 0; padding: 15px; display: flex; flex-direction: column; border-right: 1px solid var(--border); z-index: 200; background: var(--sidebar-bg); height: 100vh; overflow: hidden; }
.left-sidebar .mini-calendar-wrapper,
.left-sidebar .logo-container,
.left-sidebar .calendar-nav-buttons { flex-shrink: 0; }
.nav-sidebar { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; padding-bottom: 12px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; display: flex; flex-direction: column; gap: 8px; margin-top: 25px; }
.main-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #fafafa; position: relative; }

.logo-container { width: 100%; height: 80px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.logo-container img { max-width: 100%; max-height: 60px; object-fit: contain; }

header { background: white; padding: 15px 25px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 20px; }

.menu-icon { display: none !important; width: 0 !important; height: 0 !important; overflow: hidden !important; visibility: hidden !important; pointer-events: none !important; }
.menu-icon span { display: block; width: 26px; height: 3px; background-color: var(--text-main); border-radius: 2px; transition: all 0.2s; }
.nav-sidebar a { text-decoration: none; color: var(--text-main); font-size: 0.85em; font-weight: 600; padding: 10px 15px; border-radius: 6px; transition: all 0.2s; display: block; cursor: pointer; }
.nav-sidebar a:hover { background: #f4f7f6; color: var(--accent); padding-left: 20px; }
.nav-sidebar a.active { background: var(--accent); color: white; }

/* --- Gruppo menu con sottomenù --- */
.nav-group { display: flex; flex-direction: column; gap: 0; }
.nav-group-toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; border-radius: 6px; cursor: pointer; font-size: 0.85em; font-weight: 600; color: var(--text-main); transition: all 0.2s; user-select: none; }
.nav-group-toggle:hover { background: #f4f7f6; color: var(--accent); padding-left: 20px; }
.nav-group-open > .nav-group-toggle { color: var(--accent); background: rgba(22,125,135,0.06); }
.nav-group-arrow { transition: transform 0.22s ease; flex-shrink: 0; }
.nav-group-open > .nav-group-toggle .nav-group-arrow { transform: rotate(180deg); }
.nav-group-items { display: none; flex-direction: column; gap: 2px; padding-left: 10px; margin-top: 2px; }
.nav-group-open > .nav-group-items { display: flex; }
.nav-sub-item { text-decoration: none; color: #5f6b7b; font-size: 0.82em; font-weight: 600; padding: 8px 15px; border-radius: 6px; border-left: 2px solid var(--border); transition: all 0.2s; display: block; }
.nav-sub-item:hover { background: #f4f7f6; color: var(--accent); border-left-color: var(--accent); padding-left: 20px; }
.nav-sub-item.active { background: rgba(22,125,135,0.12); color: var(--accent); border-left-color: var(--accent); font-weight: 700; }

.search-container { position: relative; flex: 1; max-width: 400px; margin: 0 auto; }
#global-search { width: 100%; padding: 0 16px; height: 38px; border-radius: 8px; border: 1px solid #ddd; font-size: 0.9em; outline: none; background: #f9f9f9; transition: all 0.2s; }
#global-search:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(22, 125, 135, 0.1); }
.search-results { position: absolute; top: 42px; left: 0; width: 100%; background: white; box-shadow: 0 5px 20px rgba(0,0,0,0.15); display: none; z-index: 2000; border: 1px solid var(--border); max-height: 300px; overflow-y: auto; border-radius: 8px; margin-top: 5px;}
.result-item { padding: 12px 20px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.result-item:hover { background: #f4f7f6; }
.result-item strong { display: block; color: var(--text-main); font-size: 0.9em; }
.result-item span { font-size: 0.8em; color: #7f8c8d; font-family:'Inter',system-ui,sans-serif; font-variant-numeric:tabular-nums; font-feature-settings:"tnum" 1; }

.btn-header-nuovo { background: var(--accent); color: white; border: none; padding: 0 24px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: bold; font-size: 0.95em; cursor: pointer; white-space: nowrap; transition: filter 0.2s, transform 0.1s; }
.btn-header-nuovo:hover { filter: brightness(1.1); transform: translateY(-1px); }

.mini-calendar-wrapper { border: 1px solid var(--border); background: white; margin-top: 5px; padding: 10px; border-radius: 8px; z-index: 10;}
.mc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: bold; color: var(--text-main); text-transform: uppercase; font-size: 0.85em; }
.mc-btn { background: transparent; border: 1px solid transparent; cursor: pointer; color: #7f8c8d; font-size: 1.2em; padding: 0 5px; outline: none; border-radius: 3px; height: 28px; display: flex; align-items: center;}
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 0.8em; }
.mc-day-name { font-weight: bold; color: #bdc3c7; font-size: 0.8em; padding-bottom: 5px; }
.mc-day { padding: 5px 0; cursor: pointer; border: 1px solid transparent; transition: all 0.2s; color: var(--text-main); border-radius: 4px; }
.mc-day.today { background: var(--accent); color: white; font-weight: bold; border: 1px solid var(--accent); }

/* FORZA BRUTA CSS */
.menu-icon, .menu-toggle, .hamburger, .sidebar-toggle { display: none !important; opacity: 0 !important; width: 0 !important; height: 0 !important; pointer-events: none !important; position: absolute !important; left: -9999px !important; }

/* FIX CENTRATURA ASSOLUTA BARRA RICERCA */
header { position: relative !important; }
.search-container { position: absolute !important; left: 50% !important; transform: translateX(-50%) !important; width: 100% !important; max-width: 400px !important; margin: 0 !important; }

/* --- BLOCCO GEOMETRICO HEADER (Anti-Sbalzo) --- */
body > .main-container > header, header {
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 20px !important;
    padding: 0 20px !important;
    display: flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
    position: relative !important;
    overflow: visible !important;
    z-index: 500 !important;
}

.search-container {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    z-index: 600 !important;
    overflow: visible !important;
}

/* --- ESCLUSIONE HEADER PAGINE STATISTICHE --- */
/* Nasconde completamente l'header (ricerca + pulsante Nuova Prenotazione)
   su tutte le pagine del menù Statistiche, lasciandolo intatto sulle altre. */
body.page-statistiche > .main-container > header,
body.page-statistiche header {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    visibility: hidden !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    pointer-events: none !important;
}

/* --- FIX SCROLL #SALE --- */
#sale { overflow-y: auto !important; flex: 1 1 auto !important; min-height: 0 !important; max-height: calc(100vh - 120px) !important; padding-bottom: 100px !important; box-sizing: border-box !important; overscroll-behavior: contain !important; }

/* --- FIX SCROLL #SALE --- */
#sale { overflow-y: auto !important; flex: 1 1 auto !important; min-height: 0 !important; max-height: calc(100vh - 120px) !important; padding-bottom: 100px !important; box-sizing: border-box !important; overscroll-behavior: contain !important; }

/* --- AZIONI HEADER (Pulsanti Nuova...) --- */
.header-actions {
    margin-left: auto; /* Spinge il blocco chirurgicamente a destra */
    display: flex;
    align-items: center;
    position: relative;
    z-index: 700;
}

.btn-header-nuovo {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(22, 125, 135, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-header-nuovo:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(22, 125, 135, 0.3);
}


/* ========================================== */
/* MED-OS: STILE PULSANTI AZIONE HEADER       */
/* ========================================== */

/* Spinge l'ultimo blocco dell'header (il pulsante) tutto a destra */
header > div:last-child {
    margin-left: auto;
}

/* Design standardizzato del pulsante Nuova Prenotazione/Anagrafica/Documento */
.btn-header-nuovo {
    background-color: var(--accent);
    color: #ffffff;
    border: none;
    padding: 10px 20px; /*larghezza pulsante*/
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(22, 125, 135, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-header-nuovo:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(22, 125, 135, 0.3);
}


/* ========================================== */
/* MED-OS: GEOMETRIA E ALLINEAMENTO GLOBALE   */
/* ========================================== */
header, .content-area {
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.content-area {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

/* --- STATI AVANZAMENTO APPUNTAMENTO --- */
.card-progress { display: none !important; }

.appointment-card.stato-1 {
    border-bottom: 4px solid #f39c12 !important;
    background: linear-gradient(to bottom, #ffffff, #fffdf5) !important;
}
.appointment-card.stato-2 {
    border-bottom: 4px solid #f7dc6f !important;
    background: linear-gradient(to bottom, #ffffff, #fffef5) !important;
}
.appointment-card.stato-6 {
    border-bottom: 4px solid #3498db !important;
    background: linear-gradient(to bottom, #ffffff, #f5faff) !important;
}
.appointment-card.stato-3 {
    border-bottom: 4px solid #e74c3c !important;
    background: linear-gradient(to bottom, #ffffff, #fff5f5) !important;
}
.appointment-card.stato-4 {
    border-bottom: 4px solid #2ecc71 !important;
    background: linear-gradient(to bottom, #ffffff, #f5fdf7) !important;
    opacity: 0.75;
}
.appointment-card.stato-5 {
    border-bottom: 4px solid #7f8c8d !important;
    background: linear-gradient(to bottom, #f8f8f8, #f0f0f0) !important;
    opacity: 0.5;
    filter: grayscale(30%);
}

/* icone stato gestite inline nel DOM da _iconaStato() */

.btn-stato { display: flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s; }


/* --- MED-OS: TOPBAR STRUTTURALE AGENDA --- */
.medos-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 25px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 500;
    min-height: 65px;
    box-shadow: 0 4px 6px -4px rgba(0,0,0,0.05);
}
