/* Trium Service v0.1.81 - Android/PWA fullscreen and safe-area hardening */
:root {
  --app-vw: 100dvw;
  --app-vh: 100dvh;
  --app-vx: 0px;
  --app-vy: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html, body, #app {
  width: 100%;
  min-width: 0;
  min-height: 100%;
}

html {
  height: 100%;
  background: #101828;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
  overflow-x: hidden;
}

/* Installed PWA: use the dynamic visual viewport rather than legacy 100vh/100vw. */
@media (display-mode: standalone), (display-mode: fullscreen), (max-width: 900px) {
  body, #app {
    min-height: var(--app-vh, 100dvh) !important;
    max-width: var(--app-vw, 100dvw);
  }

  .shell {
    width: var(--app-vw, 100dvw) !important;
    min-width: 0 !important;
    min-height: var(--app-vh, 100dvh) !important;
    height: var(--app-vh, 100dvh) !important;
    max-height: var(--app-vh, 100dvh) !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .main {
    min-width: 0 !important;
    min-height: 0 !important;
    height: var(--app-vh, 100dvh) !important;
    max-height: var(--app-vh, 100dvh) !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    padding-right: var(--safe-right) !important;
    padding-bottom: var(--safe-bottom) !important;
  }

  .topbar {
    padding-top: max(10px, var(--safe-top)) !important;
    padding-right: max(12px, var(--safe-right)) !important;
  }

  .content {
    padding-bottom: max(20px, calc(var(--safe-bottom) + 12px)) !important;
  }

  .sidebar {
    top: var(--app-vy, 0px) !important;
    left: calc(var(--app-vx, 0px) + var(--safe-left)) !important;
    bottom: auto !important;
    height: var(--app-vh, 100dvh) !important;
    max-height: var(--app-vh, 100dvh) !important;
    box-sizing: border-box !important;
    padding-top: max(14px, var(--safe-top)) !important;
    padding-bottom: max(14px, calc(var(--safe-bottom) + 8px)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  .menu-backdrop {
    position: fixed !important;
    top: var(--app-vy, 0px) !important;
    left: var(--app-vx, 0px) !important;
    width: var(--app-vw, 100dvw) !important;
    height: var(--app-vh, 100dvh) !important;
  }

  .side-user {
    padding-bottom: max(8px, var(--safe-bottom)) !important;
  }
}

/* Android landscape: a 3-button/gesture navigation area can sit on either side. */
@media (max-width: 900px) and (orientation: landscape) {
  .sidebar {
    padding-left: max(0px, var(--safe-left)) !important;
  }
  .main {
    padding-right: max(0px, var(--safe-right)) !important;
  }
}

/* v0.1.89 - calendario giornate Nuove Installazioni */
.installation-calendar{border:1px solid #d0d5dd;border-radius:12px;padding:14px;background:#fff;max-width:760px}
.installation-calendar-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;text-transform:capitalize}
.installation-calendar-week,.installation-calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(34px,1fr));gap:6px}
.installation-calendar-week{margin-bottom:6px;color:#667085;font-size:12px;text-align:center;font-weight:600}
.installation-calendar-day{border:1px solid #d0d5dd;background:#fff;border-radius:8px;min-height:48px;display:flex;align-items:center;justify-content:center;gap:4px;cursor:pointer;font:inherit;color:#344054}
.installation-calendar-day:hover{border-color:#667085;background:#f9fafb}
.installation-calendar-day.selected{background:#ecfdf3;border-color:#12b76a;color:#067647;font-weight:700}
.installation-calendar-day small{font-size:11px}
.installation-calendar-empty{min-height:48px}
.installation-calendar-selected{margin-top:12px;display:flex;flex-direction:column;gap:4px;color:#475467;font-size:13px}
.installation-agenda{outline:1px solid rgba(15,118,110,.18)}
@media (max-width:600px){.installation-calendar{padding:10px}.installation-calendar-week,.installation-calendar-grid{gap:4px}.installation-calendar-day,.installation-calendar-empty{min-height:42px}.installation-calendar-day{padding:4px}}


/* v0.1.93 - Contratti di Manutenzione: form ordinato e responsive */
.maintenance-contract-form{display:flex;flex-direction:column;gap:14px;min-width:0}
.maintenance-form-section{border:1px solid #e4e7ec;border-radius:10px;background:#fff;padding:16px;min-width:0}
.maintenance-form-section--general{background:#f9fafb}
.maintenance-form-section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px;padding-bottom:12px;border-bottom:1px solid #eaecf0}
.maintenance-form-section-head h3{margin:0 0 3px;font-size:15px;color:#101828}
.maintenance-form-section-head small,.maintenance-form-section .field>small{display:block;color:#667085;font-size:11px;line-height:1.4;margin-top:5px}
.maintenance-form-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:14px 16px;align-items:start}
.maintenance-field-span{grid-column:1/-1}
.maintenance-switch,.maintenance-checkline{display:flex!important;align-items:center!important;gap:9px!important;margin:0!important;color:#344054;font-weight:600;cursor:pointer;line-height:1.3}
.maintenance-switch{flex:0 0 auto;border:1px solid #d0d5dd;border-radius:8px;padding:8px 10px;background:#fff}
.maintenance-switch input[type=checkbox],.maintenance-checkline input[type=checkbox]{width:17px!important;height:17px!important;min-width:17px!important;max-width:17px!important;margin:0!important;padding:0!important;flex:0 0 17px!important;appearance:auto!important}
.maintenance-checkline-box{min-height:44px;border:1px solid #d0d5dd;border-radius:8px;padding:0 12px!important;background:#fff}
.maintenance-input-prefix,.maintenance-input-suffix{display:flex;align-items:stretch;border:1px solid #d0d5dd;border-radius:8px;background:#fff;overflow:hidden;min-height:44px}
.maintenance-input-prefix:focus-within,.maintenance-input-suffix:focus-within{border-color:#667085;box-shadow:0 0 0 1px #667085}
.maintenance-input-prefix>span,.maintenance-input-suffix>span{display:flex;align-items:center;justify-content:center;min-width:42px;padding:0 10px;background:#f9fafb;color:#475467;font-weight:600;border-right:1px solid #eaecf0}
.maintenance-input-suffix>span{border-right:0;border-left:1px solid #eaecf0}
.maintenance-input-prefix input,.maintenance-input-suffix input{border:0!important;border-radius:0!important;box-shadow:none!important;min-width:0!important;width:100%!important;background:transparent!important}
.maintenance-contract-form input:disabled{background:#f2f4f7!important;color:#98a2b3!important;cursor:not-allowed}
.maintenance-field-error{color:#b42318!important;font-weight:600}
#modal .modal-card:has(.maintenance-contract-form){width:min(860px,calc(100vw - 32px));max-width:860px}
#modal .modal-card:has(.maintenance-contract-form) .modal-body{max-height:min(74vh,760px);overflow:auto}
@media(max-width:700px){.maintenance-form-grid{grid-template-columns:1fr}.maintenance-field-span{grid-column:auto}.maintenance-form-section-head{flex-direction:column}.maintenance-switch{width:100%;box-sizing:border-box}.maintenance-form-section{padding:13px}}


/* v0.1.98 - sidebar scrollabile con barra di scorrimento nascosta */
.sidebar{display:flex!important;flex-direction:column!important;min-height:0!important;height:100vh;height:100dvh;max-height:100vh;max-height:100dvh;overflow:hidden!important}
.sidebar>.brand,.sidebar>.side-user{flex:0 0 auto!important}
.sidebar>.nav{display:flex;flex-direction:column;flex:1 1 auto!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;scrollbar-gutter:auto;scrollbar-width:none;-ms-overflow-style:none;padding-bottom:8px}
.sidebar>.nav::-webkit-scrollbar{width:0!important;height:0!important;display:none!important}
.sidebar>.nav>a{flex:0 0 auto}
.side-user{margin-top:auto}
@media (max-width:900px), (display-mode:standalone), (display-mode:fullscreen){
  .sidebar{overflow:hidden!important}
  .sidebar>.nav{overflow-y:auto!important;-webkit-overflow-scrolling:touch}
}


/* v0.1.99 - selettore Cliente ricercabile */
.customer-search-combo{position:relative;width:100%;min-width:0}
.customer-search-input{width:100%!important;box-sizing:border-box!important}
.customer-search-source{position:absolute!important;left:0!important;bottom:0!important;width:1px!important;height:1px!important;min-width:1px!important;min-height:1px!important;opacity:0!important;pointer-events:none!important;padding:0!important;border:0!important}
.customer-search-results{display:none;position:absolute;z-index:2500;left:0;right:0;top:calc(100% + 4px);max-height:280px;overflow-y:auto;background:#fff;border:1px solid #d0d5dd;border-radius:9px;box-shadow:0 12px 28px rgba(16,24,40,.16);padding:4px}
.customer-search-results.open{display:block}
.customer-search-result{display:flex;width:100%;border:0;background:#fff;color:#101828;text-align:left;padding:9px 10px;border-radius:6px;cursor:pointer;font:inherit;font-size:13px}
.customer-search-result:hover,.customer-search-result.active{background:#f2f4f7}
.customer-search-empty{padding:10px;color:#667085;font-size:12px}
@media(max-width:700px){.customer-search-results{max-height:220px}}

/* v0.1.102 - Statistiche: sfondo celle coerente con lo stato */
#statisticsTable td.statistics-status-cell{transition:background-color .15s ease;vertical-align:top}
#statisticsTable td.statistics-status-green{background:#ECFDF3!important}
#statisticsTable td.statistics-status-yellow{background:#FFFAEB!important}
#statisticsTable td.statistics-status-blue{background:#EFF8FF!important}
#statisticsTable td.statistics-status-red{background:#FEF3F2!important}
#statisticsTable td.statistics-status-white{background:#FFFFFF!important}
#statisticsTable td.statistics-status-gray{background:#F2F4F7!important;color:#667085}
#statisticsTable .statistics-stack{display:flex;flex-direction:column;gap:8px;min-width:170px}
#statisticsTable .statistics-status-item{border:1px solid rgba(16,24,40,.10);border-radius:8px;padding:8px;background:rgba(255,255,255,.64)}
#statisticsTable .statistics-status-item.statistics-status-green{background:#D1FADF;border-color:#A6F4C5}
#statisticsTable .statistics-status-item.statistics-status-yellow{background:#FEF0C7;border-color:#FEDF89}
#statisticsTable .statistics-status-item.statistics-status-blue{background:#D1E9FF;border-color:#B2DDFF}
#statisticsTable .statistics-status-item.statistics-status-red{background:#FEE4E2;border-color:#FECDCA}
#statisticsTable .statistics-empty{min-width:150px;min-height:56px;display:flex;align-items:center;justify-content:center}
#statisticsTable .statistics-missing-label{display:inline-flex;align-items:center;border-radius:999px;padding:5px 9px;background:#E4E7EC;color:#475467;font-size:11px;font-weight:700}
#statisticsTable td.statistics-status-cell a{color:#101828}
