/* Gestionale Pro Next v6.2.27 - universal mobile/tablet responsive layer */
:root{--gp-safe-top:env(safe-area-inset-top,0px);--gp-safe-right:env(safe-area-inset-right,0px);--gp-safe-bottom:env(safe-area-inset-bottom,0px);--gp-safe-left:env(safe-area-inset-left,0px)}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;max-width:100%;overflow-x:hidden}
body{width:100%;max-width:100%;min-width:0;overflow-x:hidden}
*,*::before,*::after{box-sizing:border-box}
img,video,canvas,svg,iframe{max-width:100%}
img,video{height:auto}
input,select,textarea,button{max-width:100%}
button,a,input,select,textarea{-webkit-tap-highlight-color:transparent}
button,a,[role="button"]{touch-action:manipulation}
.tablewrap,.table-wrap,.tableWrap,.responsive-table,.overflow-table{width:100%;max-width:100%;overflow-x:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior-inline:contain}
table{max-width:100%}
dialog{max-width:min(96vw,1100px);max-height:min(94dvh,94vh);overflow:auto}
pre,code,.mono{max-width:100%;overflow-wrap:anywhere;word-break:break-word}

/* Tablet portrait / compact desktop */
@media (max-width:900px){
  body{padding-left:var(--gp-safe-left);padding-right:var(--gp-safe-right)}
  header,.topbar,.top,.unified-header{max-width:100%}
  .shell,.layout,.unified-shell{display:block!important;min-height:0!important}
  .shell>aside,.shell aside,.sidebar,.unified-sidebar{position:static!important;top:auto!important;height:auto!important;max-height:none!important;width:100%!important;overflow:visible!important;padding:8px!important}
  .shell aside nav,.shell>aside nav,.sidebar nav,.unified-sidebar nav{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:5px!important;width:100%!important}
  .shell nav .sep,.nav-sep,.sidebar-title{grid-column:1/-1!important;margin:8px 6px 3px!important}
  .shell nav button,.shell nav a,.sidebar nav button,.sidebar nav a,.unified-sidebar a,.unified-sidebar button{min-width:0!important;width:100%!important;min-height:42px!important;padding:8px 9px!important;overflow:hidden!important}
  .shell nav button b,.shell nav a b,.unified-sidebar b{min-width:0!important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  main{width:100%!important;max-width:100%!important;padding-left:14px!important;padding-right:14px!important}
  .pagehead,.page-head,.panelHead,.sectionHead,.sectionhead{min-width:0}
  .page-actions,.action-row,.toolbar,.headActions,.mobile-head-actions,.mobile-profile-actions,.employee-head-actions,.reviewActions{flex-wrap:wrap!important;min-width:0}
  .toolbar>*{min-width:0!important;max-width:100%!important}
  .cards,.kpis,.stats,.finance-home,.finance-kpis,.employee-summary,.payroll-summary{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .formgrid,.permgrid,.grid.two,.twocol,.company-settings-grid,.dispatch-grid,.split,.backup-grid{grid-template-columns:1fr!important}
  .span2,.wide{grid-column:auto!important}
  .scheduled-admin-row{grid-template-columns:1fr!important}
  .portal-permission-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .attendance-report-panel,.payroll-panel,.panel{max-width:100%;min-width:0}
  .attendance-table,.payroll-table,.customer-master-table{width:max-content;min-width:900px}
  .attendance-report-panel .tablewrap,.payroll-panel .tablewrap{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
  .notify-log-row{grid-template-columns:1fr 80px 1fr!important}
  .invoice-action-menu{grid-template-columns:1fr 1fr!important}
  .customer-email-row{max-width:100%}
  .support-flow-note,.broadcast-help{flex-wrap:wrap}
  .support-flow-note b,.broadcast-help b{white-space:normal!important}
  .profile-switch-mobile:not([hidden]){display:inline-flex!important}
}

/* Phones + small tablets */
@media (max-width:768px){
  html,body{min-height:100%;min-height:100dvh}
  body{padding-bottom:var(--gp-safe-bottom)}
  input:not([type="checkbox"]):not([type="radio"]),select,textarea{font-size:16px!important}
  header,.topbar,.top,.unified-header{padding-left:max(10px,var(--gp-safe-left))!important;padding-right:max(10px,var(--gp-safe-right))!important}
  main{padding:12px!important;padding-left:max(12px,var(--gp-safe-left))!important;padding-right:max(12px,var(--gp-safe-right))!important;padding-bottom:calc(24px + var(--gp-safe-bottom))!important}
  .shell aside nav,.shell>aside nav,.sidebar nav,.unified-sidebar nav{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .cards,.kpis,.stats,.finance-home,.finance-kpis,.employee-summary,.payroll-summary{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}
  .card,.panel,.teamcard{min-width:0!important;max-width:100%!important}
  .pagehead h1,.page-head h1{font-size:clamp(22px,6vw,28px)!important;line-height:1.12}
  .pagehead p,.page-head p{max-width:100%;overflow-wrap:anywhere}
  .page-navline{position:static!important;max-width:100%;flex-wrap:wrap!important}
  .page-breadcrumb{flex-basis:100%;order:3;min-width:0}
  dialog{width:calc(100vw - 16px)!important;max-width:calc(100vw - 16px)!important;margin:8px!important;border-radius:16px!important}
  dialog form{max-width:100%;overflow-x:hidden}
  .dlghead,.panel-head,.sectionhead,.sectionHead,.panelHead{flex-wrap:wrap}
  .toolbar{align-items:stretch!important}
  .toolbar input,.toolbar select,.toolbar button{width:100%!important;min-width:0!important;flex:1 1 100%!important}
  .row-actions,.page-actions,.action-row{width:100%}
  .row-actions>button,.row-actions>a{flex:1 1 auto}
  .scheduled-admin-row>div:last-child{display:flex;gap:8px;flex-wrap:wrap}
  .portal-permission-grid{grid-template-columns:1fr!important}
  .notify-log-row{grid-template-columns:1fr!important}
  .notify-log-row>*{min-width:0}
  .invoice-action-menu{grid-template-columns:1fr!important}
  .customer-email-row{grid-template-columns:1fr 42px!important}
  .inline-field{flex-wrap:wrap}.inline-field>*{flex:1 1 100%!important}
  .company-logo-editor{flex-direction:column;align-items:stretch!important}
  .company-logo-preview{width:100%!important;max-width:260px}

  /* Employee portal */
  .app header{padding:calc(12px + var(--gp-safe-top)) 12px 12px!important;align-items:flex-start!important;gap:10px;flex-wrap:wrap!important}
  .app header>div,.employee-head-actions{min-width:0}
  .employee-head-actions{width:100%;display:flex;justify-content:stretch!important}
  .employee-head-actions>*{flex:1 1 auto;min-width:0}
  .portal-version{text-align:left!important;width:100%}
  .portal-launcher{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important}
  .portal-module{min-height:112px!important;padding:14px!important;border-radius:15px!important;overflow:hidden}
  .portal-module .module-icon{font-size:27px!important;margin-bottom:8px!important}
  .portal-module b{font-size:14px;line-height:1.15;overflow-wrap:anywhere}
  .portal-module small{font-size:10px;line-height:1.25}
  .employee-card{display:block!important}.rulebox{min-width:0!important;margin-top:12px;grid-template-columns:1fr 1fr!important}
  .clock-card{padding:20px 14px!important}.live-clock{font-size:clamp(34px,12vw,48px)!important}
  .clock-actions{grid-template-columns:1fr 1fr!important;gap:8px!important}.start-btn,.stop-btn{padding:16px 8px!important;font-size:16px!important}
  .recent-item{grid-template-columns:1fr!important}.cost{text-align:left!important}

  /* Client portal */
  .topbar{height:auto!important;min-height:64px;grid-template-columns:1fr auto!important}
  .hero{padding:24px 18px!important;border-radius:18px!important}.hero h1{font-size:clamp(30px,9vw,42px)!important}
  .heroActions{flex-direction:column!important}.heroActions>*{width:100%}
  .kpis{grid-template-columns:repeat(2,minmax(0,1fr))!important}.split,.packageGrid,.supportWrap,.requestCard,.requestRow,.hoursHero{grid-template-columns:1fr!important}
  .itemCard{grid-template-columns:1fr!important}.itemMeta{flex-wrap:wrap!important;justify-content:flex-start!important}

  /* Technician */
  .employeePortalNav{grid-template-columns:repeat(2,minmax(0,1fr))!important;padding-left:max(8px,var(--gp-safe-left))!important;padding-right:max(8px,var(--gp-safe-right))!important}
  .employeePortalNav a,.employeePortalNav button{min-height:44px;font-size:11px!important;min-width:0}
  .jobWizardDialog{width:100vw!important;max-width:none!important;height:100dvh!important;max-height:100dvh!important;border-radius:0!important;margin:0!important}
  .wizardDock{padding-bottom:calc(9px + var(--gp-safe-bottom))!important}
}

/* Narrow phones: 320-430px */
@media (max-width:480px){
  main{padding-left:9px!important;padding-right:9px!important}
  .shell aside nav,.shell>aside nav,.sidebar nav,.unified-sidebar nav{grid-template-columns:1fr 1fr!important;gap:4px!important}
  .shell nav button,.shell nav a,.unified-sidebar a,.unified-sidebar button{padding:8px 7px!important;font-size:11px!important}
  .cards,.kpis,.stats,.finance-home,.finance-kpis,.employee-summary,.payroll-summary{grid-template-columns:1fr!important}
  .portal-launcher{grid-template-columns:1fr 1fr!important}
  .portal-module{min-height:104px!important;padding:12px!important}
  .clock-actions{grid-template-columns:1fr!important}.start-btn,.stop-btn{font-size:17px!important}
  .rulebox{grid-template-columns:1fr!important}
  .login-shell{padding:12px!important;padding-top:calc(12px + var(--gp-safe-top))!important;padding-bottom:calc(12px + var(--gp-safe-bottom))!important}
  .login-card{padding:20px 16px!important;border-radius:18px!important}
  .hero{padding:20px 15px!important}.hero h1{font-size:30px!important}
  .kpis,.hourStats{grid-template-columns:1fr!important}
  .top h1{font-size:18px!important}.eyebrow{font-size:9px!important}.badge{padding:6px 8px!important}
  .mobile-head-actions,.mobile-profile-actions{gap:5px!important;max-width:58%}.mobile-head-actions select{min-width:58px!important;padding:7px!important}
  .grid{grid-template-columns:1fr!important}.action{min-height:106px!important}
  .wizardDock{grid-template-columns:88px 1fr 88px!important;gap:6px!important}.wizardDock button{font-size:11px!important;padding-left:6px!important;padding-right:6px!important}
  .jobStepper{grid-template-columns:repeat(5,58px)!important}
  .photoGallery,.photo-gallery{grid-template-columns:1fr 1fr!important}
}

/* Very small phones */
@media (max-width:350px){
  .portal-launcher{grid-template-columns:1fr!important}
  .shell aside nav,.shell>aside nav,.sidebar nav,.unified-sidebar nav{grid-template-columns:1fr!important}
  .clock-actions{grid-template-columns:1fr!important}
  .mobile-profile-actions,.mobile-head-actions{max-width:62%}
}

/* Landscape phones / short-height tablets */
@media (orientation:landscape) and (max-height:560px) and (max-width:950px){
  .app header,.topbar,.top,header{position:static!important}
  .login-shell{place-items:start center!important;padding-top:10px!important}
  .login-card{margin:0 auto!important}
  .portal-launcher{grid-template-columns:repeat(4,minmax(0,1fr))!important}
  .portal-module{min-height:88px!important;padding:10px!important}.portal-module .module-icon{font-size:22px!important;margin-bottom:5px!important}
  .clock-card{padding:14px!important}.live-clock{margin:5px 0!important;font-size:34px!important}
  .employeePortalNav{position:static!important;grid-template-columns:repeat(4,minmax(0,1fr))!important}
}
@media (max-width:768px){
  .top-actions{display:flex!important;flex-wrap:wrap!important;gap:6px!important;max-width:100%!important;min-width:0!important}
  .top-actions>*{min-width:0!important;max-width:100%!important}
}
@media (max-width:480px){
  .top-actions{width:100%!important}
  .top-actions .btn,.top-actions button,.top-actions a{flex:1 1 auto!important;font-size:11px!important;padding-left:8px!important;padding-right:8px!important}
  .top-actions label{flex:1 1 100%!important}
}
/* v6.2.27 FIX23 - employee mobile cards + action accessibility */
@media(max-width:760px){
  .employee-tablewrap{overflow:visible!important;background:transparent!important;padding:0!important}
  .employee-master-table,.employee-master-table tbody,.employee-master-table tr,.employee-master-table td{display:block;width:100%!important;min-width:0!important}
  .employee-master-table thead{display:none}
  .employee-master-table tr{margin:0 0 12px;background:#fff;border:1px solid #dce3eb;border-radius:14px;padding:10px;box-shadow:0 2px 8px rgba(16,24,40,.04)}
  .employee-master-table td{border:0!important;padding:7px 8px!important;white-space:normal!important;position:static!important;box-shadow:none!important}
  .employee-master-table td:before{content:attr(data-label);display:block;color:#667085;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;margin-bottom:2px}
  .employee-master-table td:nth-child(4),.employee-master-table td:nth-child(5),.employee-master-table td:nth-child(6),.employee-master-table td:nth-child(7),.employee-master-table td:nth-child(8),.employee-master-table td:nth-child(9){display:none}
  .employee-desktop-actions{display:none!important}.employee-mobile-actions{display:block}.employee-mobile-actions summary{list-style:none;cursor:pointer;background:#172033;color:#fff;border-radius:10px;padding:11px 14px;text-align:center;font-weight:800}.employee-mobile-actions summary::-webkit-details-marker{display:none}
  .employee-toolbar{display:grid!important;grid-template-columns:1fr!important}.employee-toolbar>*{width:100%!important;min-width:0!important}
  .pdf-center-toolbar{display:grid!important;grid-template-columns:1fr!important}.pdf-center-toolbar>*{width:100%!important;min-width:0!important}.pdf-center-tablewrap{overflow-x:auto!important}.pdf-actions{min-width:0!important;display:grid!important;grid-template-columns:1fr 1fr!important}.pdf-actions button{min-width:0!important}
  .duplicate-customer-card{align-items:stretch;flex-direction:column}.duplicate-customer-card button{width:100%}
}

/* Planner R12: explicit edit/delete list, touch friendly */
.planner-period-panel{margin-top:16px}.planner-period-actions{display:grid;gap:8px}.planner-period-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:12px 14px;border:1px solid #dfe7ef;border-radius:12px;background:#fff}.planner-period-row>div:first-child{display:flex;flex-direction:column;gap:3px;min-width:0}.planner-period-row small{font-size:10px;color:#6b7b8f}.planner-period-row b{font-size:13px;white-space:normal}.planner-period-row span{font-size:11px;color:#6b7b8f}.planner-period-row .actions{display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end}.planner-event{cursor:pointer}.planner-event.ticket{outline:1px solid rgba(20,116,232,.18)}@media(max-width:760px){.planner-period-row{grid-template-columns:1fr}.planner-period-row .actions{justify-content:stretch}.planner-period-row .actions button{flex:1;min-height:44px}}
