/* Cantiere 3D — tablet e telefono: niente scroll orizzontale, barra inferiore stile app,
   tabelle trasformate in schede, comandi del 3D compattati. */
@media (max-width:1240px) and (min-width:821px){
  .topbar{gap:10px}
  .tb-name{display:none}
  .tb-code{white-space:nowrap}
  .tabs .tl{display:none}.tabs .ts{display:inline}
  .tabs button{padding:7px 10px;font-size:12.5px}
  .dbstatus{max-width:200px;flex:0 1 auto}
}
@media (max-width:980px) and (min-width:821px){
  .tb-txt{display:none}
  .tabs button{padding:7px 6px;font-size:11.5px}
  .tabs .tab-add{margin-left:2px}
  .dbstatus{max-width:150px}
}
@media (max-width:820px){
  html,body{height:auto}
  body{padding-bottom:calc(66px + env(safe-area-inset-bottom,0px));background-attachment:scroll}
  .shell{height:auto;display:block}
  .appviews,.view{height:auto}
  /* barra superiore compatta */
  .topbar{position:sticky;top:0;z-index:40;gap:8px;padding-block:8px;backdrop-filter:none;-webkit-backdrop-filter:none;background:#fff}
  .tb-brand{flex:none;gap:8px}
  .tb-name{display:none}
  .tb-code{font-size:10px}
  .dbstatus{margin-left:auto;min-width:0;max-width:52vw;font-size:11.5px;padding:5px 10px}
  .archbtn{padding:6px 10px;font-size:12px}
  .archpop{position:fixed;left:12px;right:12px;top:58px;width:auto}
  .selpop{left:12px;right:12px}
  /* navigazione in basso, stile app */
  .tabs{overflow:visible;position:fixed;left:0;right:0;bottom:0;z-index:45;display:grid;grid-template-columns:repeat(7,1fr);gap:0;margin:0;padding:6px 4px calc(6px + env(safe-area-inset-bottom,0px));background:rgba(255,255,255,.96);backdrop-filter:blur(16px) saturate(160%);-webkit-backdrop-filter:blur(16px) saturate(160%);border:none;border-top:1px solid rgba(13,43,82,.1);border-radius:0;box-shadow:0 -6px 20px -12px rgba(16,24,40,.25)}
  .tabs button{flex-direction:column;justify-content:center;gap:3px;padding:5px 2px;min-height:50px;border-radius:12px;font-size:10.5px;font-weight:600;color:#5d6b7c;background:none;box-shadow:none;margin:0;position:relative}
  .tabs button:hover{background:none}
  .tabs .ti{display:block;width:22px;height:22px}
  .tabs .tl{display:none}.tabs .ts{display:block;line-height:1}
  .tabs button[aria-current="page"]{color:#0d2b52;background:none;box-shadow:none}
  .tabs button[aria-current="page"] .ti{background:#e8eef8;border-radius:9px;box-shadow:0 0 0 5px #e8eef8}
  .tabs .tab-add,.tabs .tab-add:hover,.tabs .tab-add[aria-current="page"]{color:#c8102e;background:none;box-shadow:none;margin:0}
  .tabs .tab-add .ti{background:linear-gradient(135deg,#e2234a,#b10f2b);color:#fff;border-radius:50%;padding:3px;width:26px;height:26px;margin-top:-4px;box-shadow:0 6px 14px -6px rgba(209,25,58,.8)}
  .tabs .tab-add[aria-current="page"] .ti{box-shadow:0 6px 14px -6px rgba(209,25,58,.8)}
  .tabbadge{position:absolute;top:2px;left:calc(50% + 6px);margin:0;min-width:16px;height:16px;font-size:9.5px;padding:0 4px}
  body.senzacant{padding-bottom:0}
  body.senzacant .tabs{display:none}
  .toast{bottom:calc(78px + env(safe-area-inset-bottom,0px))}
  .updbar{top:auto;bottom:calc(76px + env(safe-area-inset-bottom,0px))}
  /* pagine */
  .pagewrap{padding-block:14px 28px;gap:14px}
  .pagehead{padding:20px 18px 18px;border-radius:16px;gap:12px}
  .pagehead h2{font-size:26px;margin:2px 0 6px}
  .pagehead .lede{font-size:13.5px;line-height:1.5}
  .pagehead .actions{width:100%}
  .pagehead .actions .btn{flex:1 1 auto}
  .rings{width:100%;display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
  .ring{min-width:0}.ring svg{width:76px;height:76px}.ring .rl{font-size:11px}.ring .rl b{font-size:12px}
  .kpis{grid-template-columns:1fr 1fr;gap:10px}
  .kpi{padding:12px 14px}.kpi.hero{grid-column:1/-1}
  .kpis:not(.mkpis) .kpi:last-child:nth-child(even){grid-column:1/-1}
  .kpi .v{font-size:26px}
  .card{padding:14px 14px 12px;border-radius:16px}
  .card header{align-items:flex-start}
  .cgrid,.sc-grid{grid-template-columns:1fr}
  .mini{min-height:34px;padding:6px 12px}
  input,select,textarea,.page input:not([type=checkbox]):not([type=file]):not([type=radio]),.page select,.page textarea{font-size:16px}
  .drawer{width:100%;top:auto;max-height:88vh;border-radius:20px 20px 0 0;animation:slideUp .3s cubic-bezier(.2,.8,.2,1)}
  .dr-h{border-radius:20px 20px 0 0}
  @keyframes slideUp{from{transform:translateY(100%)}to{transform:none}}

  /* cantiere 3D */
  #v-cantiere .app{display:block;height:auto}
  .stage{height:calc(100svh - 58px - 66px - env(safe-area-inset-bottom,0px));min-height:430px;max-height:760px}
  .cadbar{top:10px;left:10px;max-width:calc(100% - 20px);overflow-x:auto;overflow-y:visible;scrollbar-width:none;padding:3px}
  .cadbar::-webkit-scrollbar{display:none}
  .cadbar>button,.tbdrop>button{width:42px;min-width:42px;height:42px;padding:0;flex:none}
  .cadbar>button span,.tbdrop>button span,.tbdrop>button .dd{display:none}
  #panelBtn{display:none}
  .tbpop{left:10px!important;right:10px!important;min-width:0;max-height:62%;overflow:auto}
  .hud{top:60px;left:10px;right:10px;justify-content:flex-start}
  .hud .views{flex-wrap:nowrap;overflow-x:auto;max-width:calc(100% - 90px);scrollbar-width:none}
  .hud .views::-webkit-scrollbar{display:none}
  .hud .views .chipbtn{flex:none;padding:7px 10px}
  .stage.detail .hud .scalebtn{display:none}
  .vcube-wrap{top:96px;right:4px;transform:scale(.7);transform-origin:top right}
  .navhint{display:none}
  .timeline{left:10px;right:10px;bottom:10px;padding:8px 10px;gap:8px}
  .timeline .tl-mid{flex:1 1 calc(100% - 50px)}
  .tl-meter{flex:1 1 auto;flex-direction:row;align-items:center;gap:8px;min-width:0}
  .tl-meter .tm-v{font-size:16px;white-space:nowrap}.tl-meter .tm-bar{flex:1}.tl-meter .tm-s{display:none}
  .tlwhat{display:none}
  .kmread{left:10px;right:10px;max-width:none;bottom:calc(12px + env(safe-area-inset-bottom,0px))}
  .stage.showtl .kmread{bottom:calc(130px + env(safe-area-inset-bottom,0px))}
  .detailbar{left:10px;right:10px;bottom:10px;max-height:52%;overflow:auto;padding:10px 12px}
  .detailbar .db-head b{font-size:15px;line-height:1.25}
  .detailbar:not(.open) .db-facts{display:none}
  #dbMore{display:inline-flex}
  .stage.detail .kmread{bottom:calc(120px + env(safe-area-inset-bottom,0px))}
  .notepop{left:12px!important;right:12px;width:auto;max-width:none;top:110px!important}
  .lbl.sign{transform:translate(-50%,-100%) scale(.85)}
  .panelclose,.panelstrip{display:none!important}
  .app.panel-closed .panel>*{display:revert}
  .app.panel-closed .panel{padding-block:16px;overflow:visible}
  .panel{gap:16px;padding-top:16px;box-shadow:none;border-left:none;border-top:1px solid #e3e8f0;overflow:visible;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
}
@media (max-width:380px){
  .tabs button{font-size:9.5px}
  .kpis{grid-template-columns:1fr}
}
